You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2014/07/30 01:09:18 UTC
svn commit: r1614509 - in /sis/branches/JDK7: ./
core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/
core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/
core/sis-metadata/src/test/java/org/apache/sis/metadata/...
Author: desruisseaux
Date: Tue Jul 29 23:09:18 2014
New Revision: 1614509
URL: http://svn.apache.org/r1614509
Log:
Merge from the JDK8 branch.
Added:
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java
- copied unchanged from r1614508, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java
- copied unchanged from r1614508, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/Name.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/OperationName.java
- copied unchanged from r1614508, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/OperationName.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java
- copied, changed from r1614508, sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java
Modified:
sis/branches/JDK7/ (props changed)
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/package-info.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultCoupledResource.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationChainMetadata.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationMetadata.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultParameter.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentification.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultParameterTest.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/service/ServiceIdentification.xml
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java
Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
Merged /sis/branches/JDK8:r1614194-1614508
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/package-info.java?rev=1614509&r1=1614508&r2=1614509&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/package-info.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/package-info.java [UTF-8] Tue Jul 29 23:09:18 2014
@@ -46,7 +46,16 @@
*
* @author Guilhem Legal (Geomatys)
* @since 0.3 (derived from geotk-3.15)
- * @version 0.3
+ * @version 0.5
* @module
*/
+@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GMD, xmlns = {
+ @XmlNs(prefix = "gmd", namespaceURI = Namespaces.GMD),
+ @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO)
+})
package org.apache.sis.internal.jaxb.metadata.direct;
+
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlSchema;
+import org.apache.sis.xml.Namespaces;
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultCoupledResource.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultCoupledResource.java?rev=1614509&r1=1614508&r2=1614509&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultCoupledResource.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultCoupledResource.java [UTF-8] Tue Jul 29 23:09:18 2014
@@ -19,13 +19,19 @@ package org.apache.sis.metadata.iso.serv
import java.util.Collection;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.opengis.util.ScopedName;
+import org.opengis.util.InternationalString;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.identification.DataIdentification;
import org.opengis.metadata.service.CoupledResource;
import org.opengis.metadata.service.OperationMetadata;
import org.apache.sis.metadata.iso.ISOMetadata;
+import org.apache.sis.internal.jaxb.metadata.direct.GO_ScopedName;
+
+import static org.apache.sis.internal.jaxb.gco.PropertyType.LEGACY_XML;
/**
@@ -38,10 +44,12 @@ import org.apache.sis.metadata.iso.ISOMe
* @module
*/
@XmlType(name = "SV_CoupledResource_Type", propOrder = {
- "scopedName",
+ "operationName",
+ "identifier",
+ "scopedName" /*,
"resourceReferences",
"resources",
- "operation"
+ "operation" */
})
@XmlRootElement(name = "SV_CoupledResource")
public class DefaultCoupledResource extends ISOMetadata implements CoupledResource {
@@ -145,7 +153,8 @@ public class DefaultCoupledResource exte
* @return identifier of the resource, or {@code null} if none.
*/
@Override
- @XmlElement(name = "scopedName")
+ @XmlElementRef
+ @XmlJavaTypeAdapter(GO_ScopedName.class)
public ScopedName getScopedName() {
return scopedName;
}
@@ -166,7 +175,7 @@ public class DefaultCoupledResource exte
* @return References to the resource on which the services operates.
*/
@Override
- @XmlElement(name = "resourceReference")
+/// @XmlElement(name = "resourceReference")
public Collection<Citation> getResourceReferences() {
return resourceReferences = nonNullCollection(resourceReferences, Citation.class);
}
@@ -186,7 +195,7 @@ public class DefaultCoupledResource exte
* @return tightly coupled resources.
*/
@Override
- @XmlElement(name = "resource")
+/// @XmlElement(name = "resource")
public Collection<DataIdentification> getResources() {
return resources = nonNullCollection(resources, DataIdentification.class);
}
@@ -206,7 +215,7 @@ public class DefaultCoupledResource exte
* @return The service operation, or {@code null} if none.
*/
@Override
- @XmlElement(name = "operation")
+/// @XmlElement(name = "operation")
public OperationMetadata getOperation() {
return operation;
}
@@ -220,4 +229,47 @@ public class DefaultCoupledResource exte
checkWritePermission();
this.operation = newValue;
}
+
+
+
+ // Bridges for elements from legacy ISO 19119
+
+ /**
+ * For JAXB marhalling of ISO 19119 document only.
+ */
+ @XmlElement(name = "operationName")
+ final InternationalString getOperationName() {
+ if (LEGACY_XML) {
+ final OperationMetadata operation = getOperation();
+ if (operation != null) {
+ return operation.getOperationName();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * For JAXB unmarhalling of ISO 19119 document only. Sets {@link #operation} to a temporary
+ * {@link OperationName} placeholder. That temporary instance will be replaced by the real
+ * one when the enclosing {@link DefaultServiceIdentification} is unmarshalled.
+ */
+ final void setOperationName(final InternationalString name) {
+ if (operation == null) {
+ operation = new OperationName(name);
+ }
+ }
+
+ /**
+ * Returns the resource identifier, which is assumed to be the name as a string.
+ */
+ @XmlElement(name = "identifier")
+ final String getIdentifier() {
+ if (LEGACY_XML) {
+ final ScopedName name = getScopedName();
+ if (name != null) {
+ return name.tip().toString();
+ }
+ }
+ return null;
+ }
}
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationChainMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationChainMetadata.java?rev=1614509&r1=1614508&r2=1614509&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationChainMetadata.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationChainMetadata.java [UTF-8] Tue Jul 29 23:09:18 2014
@@ -24,6 +24,7 @@ import org.opengis.metadata.service.Oper
import org.opengis.metadata.service.OperationMetadata;
import org.opengis.util.InternationalString;
import org.apache.sis.metadata.iso.ISOMetadata;
+import org.apache.sis.util.iso.Types;
/**
@@ -74,10 +75,10 @@ public class DefaultOperationChainMetada
* @param name The name as used by the service for this chain.
* @param operation Information about the operations applied by the chain.
*/
- public DefaultOperationChainMetadata(final InternationalString name,
+ public DefaultOperationChainMetadata(final CharSequence name,
final OperationMetadata operation)
{
- this.name = name;
+ this.name = Types.toInternationalString(name);
this.operations = singleton(operation, OperationMetadata.class);
}
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationMetadata.java?rev=1614509&r1=1614508&r2=1614509&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationMetadata.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultOperationMetadata.java [UTF-8] Tue Jul 29 23:09:18 2014
@@ -16,7 +16,6 @@
*/
package org.apache.sis.metadata.iso.service;
-import java.util.Set;
import java.util.List;
import java.util.Collection;
import javax.xml.bind.annotation.XmlType;
@@ -84,7 +83,7 @@ public class DefaultOperationMetadata ex
/**
* The parameters that are required for this interface.
*/
- private Set<Parameter> parameters;
+ private Collection<Parameter> parameters;
/**
* List of operation that must be completed immediately.
@@ -271,8 +270,8 @@ public class DefaultOperationMetadata ex
*/
@Override
@XmlElement(name = "parameters")
- public Set<Parameter> getParameters() {
- return parameters = nonNullSet(parameters, Parameter.class);
+ public Collection<Parameter> getParameters() {
+ return parameters = nonNullCollection(parameters, Parameter.class);
}
/**
@@ -280,8 +279,8 @@ public class DefaultOperationMetadata ex
*
* @param newValues The new set of parameters that are required for this interface.
*/
- public void setParameters(final Set<? extends Parameter> newValues) {
- parameters = writeSet(newValues, parameters, Parameter.class);
+ public void setParameters(final Collection<? extends Parameter> newValues) {
+ parameters = writeCollection(newValues, parameters, Parameter.class);
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultParameter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultParameter.java?rev=1614509&r1=1614508&r2=1614509&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultParameter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultParameter.java [UTF-8] Tue Jul 29 23:09:18 2014
@@ -27,7 +27,6 @@ import org.opengis.metadata.service.Para
import org.opengis.metadata.service.ParameterDirection;
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.internal.jaxb.metadata.direct.GO_MemberName;
-import org.apache.sis.util.iso.Types;
import static org.apache.sis.internal.jaxb.gco.PropertyType.LEGACY_XML;
@@ -47,7 +46,7 @@ import static org.apache.sis.internal.ja
"name",
"direction",
"description",
- "optionality",
+ "optionalityLabel",
"repeatability",
"valueType"
})
@@ -76,12 +75,12 @@ public class DefaultParameter extends IS
/**
* Indication if the parameter is required.
*/
- private InternationalString optionality;
+ private Boolean optionality;
/**
* Indication if more than one value of the parameter may be provided.
*/
- private boolean repeatability;
+ private Boolean repeatability;
/**
* Constructs an initially empty parameter.
@@ -97,11 +96,11 @@ public class DefaultParameter extends IS
* @param repeatability Indication if more than one value of the parameter may be provided.
*/
public DefaultParameter(final MemberName name,
- final CharSequence optionality,
+ final boolean optionality,
final boolean repeatability)
{
this.name = name;
- this.optionality = Types.toInternationalString(optionality);
+ this.optionality = optionality;
this.repeatability = repeatability;
}
@@ -220,8 +219,8 @@ public class DefaultParameter extends IS
* @return Whether the parameter is required.
*/
@Override
- @XmlElement(name = "optionality", required = true)
- public InternationalString getOptionality() {
+/// @XmlElement(name = "optionality", required = true)
+ public Boolean getOptionality() {
return optionality;
}
@@ -230,7 +229,7 @@ public class DefaultParameter extends IS
*
* @param newValue Whether the parameter is required.
*/
- public void setOptionality(final InternationalString newValue) {
+ public void setOptionality(final Boolean newValue) {
checkWritePermission();
this.optionality = newValue;
}
@@ -242,7 +241,7 @@ public class DefaultParameter extends IS
*/
@Override
@XmlElement(name = "repeatability", required = true)
- public boolean getRepeatability() {
+ public Boolean getRepeatability() {
return repeatability;
}
@@ -251,7 +250,7 @@ public class DefaultParameter extends IS
*
* @param newValue Whether more than one value of the parameter may be provided.
*/
- public void setRepeatability(final boolean newValue) {
+ public void setRepeatability(final Boolean newValue) {
checkWritePermission();
this.repeatability = newValue;
}
@@ -261,6 +260,21 @@ public class DefaultParameter extends IS
// Bridges for elements from legacy ISO 19119
/**
+ * Returns the optionality as a "Optional" or "Mandatory" string.
+ */
+ @XmlElement(name = "optionality", required = true)
+ final String getOptionalityLabel() {
+ return (optionality == null) ? null : (optionality) ? "Optional" : "Mandatory";
+ }
+
+ /**
+ * Sets optionality to {@code true} if the given string is equals, ignoring case, to {@code "Optional"}.
+ */
+ final void setOptionalityLabel(final String label) {
+ optionality = (label == null) ? null : label.equalsIgnoreCase("Optional");
+ }
+
+ /**
* For JAXB marhalling of ISO 19119 document only.
* Note that there is not setter method, since we expect the same information
* to be provided in the {@link #name} attribute type.
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentification.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentification.java?rev=1614509&r1=1614508&r2=1614509&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentification.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentification.java [UTF-8] Tue Jul 29 23:09:18 2014
@@ -17,8 +17,9 @@
package org.apache.sis.metadata.iso.service;
import java.util.Collection;
-import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.util.GenericName;
import org.opengis.metadata.citation.Citation;
@@ -47,15 +48,15 @@ import org.apache.sis.metadata.iso.ident
@XmlType(name = "MD_ServiceIdentification_Type", propOrder = { // ISO 19139 still use the old prefix.
"serviceType",
"serviceTypeVersions",
- "accessProperties",
- "couplingType",
+/// "accessProperties",
"coupledResources",
- "operatedDatasets",
- "profiles",
- "serviceStandards",
+ "couplingType",
+/// "operatedDatasets",
+/// "profiles",
+/// "serviceStandards",
"containsOperations",
"operatesOn",
- "containsChain"
+/// "containsChain"
})
@XmlRootElement(name = "SV_ServiceIdentification")
public class DefaultServiceIdentification extends AbstractIdentification implements ServiceIdentification {
@@ -240,7 +241,7 @@ public class DefaultServiceIdentificatio
* @return Information about the availability of the service, or {@code null} if none.
*/
@Override
- @XmlElement(name = "accessProperties")
+/// @XmlElement(name = "accessProperties")
public StandardOrderProcess getAccessProperties() {
return accessProperties;
@@ -303,7 +304,7 @@ public class DefaultServiceIdentificatio
* @return Reference(s) to the resource on which the service operates.
*/
@Override
- @XmlElement(name = "operatedDataset")
+/// @XmlElement(name = "operatedDataset")
public Collection<Citation> getOperatedDatasets() {
return operatedDatasets = nonNullCollection(operatedDatasets, Citation.class);
}
@@ -323,7 +324,7 @@ public class DefaultServiceIdentificatio
* @return Profile(s) to which the service adheres.
*/
@Override
- @XmlElement(name = "profile")
+/// @XmlElement(name = "profile")
public Collection<Citation> getProfiles() {
return profiles = nonNullCollection(profiles, Citation.class);
}
@@ -343,7 +344,7 @@ public class DefaultServiceIdentificatio
* @return Standard(s) to which the service adheres.
*/
@Override
- @XmlElement(name = "serviceStandard")
+/// @XmlElement(name = "serviceStandard")
public Collection<Citation> getServiceStandards() {
return serviceStandards = nonNullCollection(serviceStandards, Citation.class);
}
@@ -403,7 +404,7 @@ public class DefaultServiceIdentificatio
* @return Information about the chain applied by the service.
*/
@Override
- @XmlElement(name = "containsChain")
+/// @XmlElement(name = "containsChain")
public Collection<OperationChainMetadata> getContainsChain() {
return containsChain = nonNullCollection(containsChain, OperationChainMetadata.class);
}
@@ -416,4 +417,13 @@ public class DefaultServiceIdentificatio
public void setContainsChain(final Collection<? extends OperationChainMetadata> newValues) {
containsChain = writeCollection(newValues, containsChain, OperationChainMetadata.class);
}
+
+ /**
+ * Invoked after JAXB has unmarshalled this object.
+ */
+ private void afterUnmarshal(final Unmarshaller u, final Object parent) {
+ if (containsOperations != null && coupledResources != null) {
+ OperationName.resolve(containsOperations, coupledResources);
+ }
+ }
}
Copied: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java (from r1614508, sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java?p2=sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java&p1=sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java&r1=1614508&r2=1614509&rev=1614509&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultCoupledResourceTest.java [UTF-8] Tue Jul 29 23:09:18 2014
@@ -18,6 +18,7 @@ package org.apache.sis.metadata.iso.serv
import org.opengis.util.ScopedName;
import org.opengis.metadata.citation.OnlineResource;
+import org.opengis.metadata.service.CoupledResource;
import org.opengis.metadata.service.DistributedComputingPlatform;
import org.opengis.metadata.service.OperationMetadata;
import org.apache.sis.util.iso.SimpleInternationalString;
@@ -68,7 +69,7 @@ public final strictfp class DefaultCoupl
*/
resource.setOperation(new OperationName(operation.getOperationName()));
assertNotSame("Before resolve", operation, resource.getOperation());
- OperationName.resolve(singleton(operation), singleton(resource));
+ OperationName.resolve(singleton(operation), singleton((CoupledResource) resource));
assertSame("After resolve", operation, resource.getOperation());
/*
* If the name doesn't match, no replacement shall be done.
@@ -76,7 +77,7 @@ public final strictfp class DefaultCoupl
final OperationName other = new OperationName(new SimpleInternationalString("Other"));
resource.setOperation(other);
assertSame("Before resolve", other, resource.getOperation());
- OperationName.resolve(singleton(operation), singleton(resource));
+ OperationName.resolve(singleton(operation), singleton((CoupledResource) resource));
assertSame("After resolve", other, resource.getOperation());
}
}
Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultParameterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultParameterTest.java?rev=1614509&r1=1614508&r2=1614509&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultParameterTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultParameterTest.java [UTF-8] Tue Jul 29 23:09:18 2014
@@ -17,10 +17,14 @@
package org.apache.sis.metadata.iso.service;
import javax.xml.bind.JAXBException;
+import org.opengis.util.TypeName;
+import org.opengis.util.MemberName;
+import org.opengis.metadata.service.ParameterDirection;
import org.apache.sis.test.XMLTestCase;
import org.apache.sis.xml.Namespaces;
import org.junit.Test;
+import static org.apache.sis.internal.system.DefaultFactories.SIS_NAMES;
import static org.apache.sis.test.Assert.*;
@@ -34,6 +38,39 @@ import static org.apache.sis.test.Assert
*/
public final strictfp class DefaultParameterTest extends XMLTestCase {
/**
+ * Creates the parameter to use for testing purpose.
+ */
+ static DefaultParameter create() {
+ final TypeName valueType = SIS_NAMES.createTypeName(null, "CharacterString");
+ final MemberName paramName = SIS_NAMES.createMemberName(null, "Version", valueType);
+ final DefaultParameter param = new DefaultParameter(paramName, true, false);
+ assertSame("valueType", valueType, param.getValueType());
+ param.setDirection(ParameterDirection.IN);
+ return param;
+ }
+
+ /**
+ * Tests {@link DefaultParameter#getOptionalityLabel()} and {@link DefaultParameter#setOptionalityLabel(String)}.
+ */
+ @Test
+ public void testOptionalityLabel() {
+ final DefaultParameter param = create();
+ assertEquals("Optional", param.getOptionalityLabel());
+
+ param.setOptionality(false);
+ assertEquals("Mandatory", param.getOptionalityLabel());
+
+ param.setOptionality(null);
+ assertNull(param.getOptionalityLabel());
+
+ param.setOptionalityLabel("Optional");
+ assertTrue(param.getOptionality());
+
+ param.setOptionalityLabel("Mandatory");
+ assertFalse(param.getOptionality());
+ }
+
+ /**
* Tests marshalling of an empty parameter. The main purpose is to ensure that
* the XML does not contains spurious elements like empty enumeration wrapper.
*
@@ -42,13 +79,6 @@ public final strictfp class DefaultParam
@Test
public void testMarshalEmpty() throws JAXBException {
final String xml = marshal(new DefaultParameter());
- assertXmlEquals(
- "<srv:SV_Parameter xmlns:srv=\"" + Namespaces.SRV + '"' +
- " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
- " <srv:repeatability>\n" +
- " <gco:Boolean>false</gco:Boolean>\n" +
- " </srv:repeatability>\n" +
- "</srv:SV_Parameter>\n",
- xml, "xlmns:*");
+ assertXmlEquals("<srv:SV_Parameter xmlns:srv=\"" + Namespaces.SRV + "\"/>", xml, "xlmns:*");
}
}
Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java?rev=1614509&r1=1614508&r2=1614509&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java [UTF-8] Tue Jul 29 23:09:18 2014
@@ -17,13 +17,8 @@
package org.apache.sis.metadata.iso.service;
import javax.xml.bind.JAXBException;
-import org.opengis.util.TypeName;
-import org.opengis.util.MemberName;
import org.opengis.metadata.citation.Citation;
-import org.opengis.metadata.citation.OnlineResource;
import org.opengis.metadata.service.CouplingType;
-import org.opengis.metadata.service.DistributedComputingPlatform;
-import org.opengis.metadata.service.ParameterDirection;
import org.apache.sis.xml.NilReason;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.XMLTestCase;
@@ -43,8 +38,9 @@ import static org.apache.sis.internal.sy
* @module
*/
@DependsOn({
- org.apache.sis.metadata.iso.identification.DefaultDataIdentificationTest.class,
- DefaultParameterTest.class
+ DefaultParameterTest.class,
+ DefaultCoupledResourceTest.class,
+ org.apache.sis.metadata.iso.identification.DefaultDataIdentificationTest.class
})
public final strictfp class DefaultServiceIdentificationTest extends XMLTestCase {
/**
@@ -56,24 +52,15 @@ public final strictfp class DefaultServi
* Creates the service identification to use for testing purpose.
*/
private static DefaultServiceIdentification create() {
- final TypeName valueType = SIS_NAMES.createTypeName(null, "CharacterString");
- final MemberName paramName = SIS_NAMES.createMemberName(null, "Version", valueType);
- final DefaultParameter param = new DefaultParameter(paramName, "Optional", false);
- assertSame("valueType", valueType, param.getValueType());
- param.setDirection(ParameterDirection.IN);
-
- final DefaultOperationMetadata md = new DefaultOperationMetadata("Get Map",
- DistributedComputingPlatform.WEB_SERVICES, null);
- md.setParameters(singleton(param));
- md.setConnectPoints(singleton(NilReason.MISSING.createNilObject(OnlineResource.class)));
-
+ final DefaultCoupledResource resource = DefaultCoupledResourceTest.create();
final DefaultServiceIdentification id = new DefaultServiceIdentification(
SIS_NAMES.createGenericName(null, "Web Map Server"), // serviceType
NilReason.MISSING.createNilObject(Citation.class), // citation
"A dummy service for testing purpose."); // abstract
id.setServiceTypeVersions(singleton("1.0"));
+ id.setCoupledResources(singleton(resource));
id.setCouplingType(CouplingType.LOOSE);
- id.setContainsOperations(singleton(md));
+ id.setContainsOperations(singleton(resource.getOperation()));
return id;
}
Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1614509&r1=1614508&r2=1614509&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Tue Jul 29 23:09:18 2014
@@ -74,6 +74,7 @@ import org.junit.BeforeClass;
org.apache.sis.metadata.iso.identification.DefaultBrowseGraphicTest.class,
org.apache.sis.metadata.iso.identification.DefaultDataIdentificationTest.class,
org.apache.sis.metadata.iso.service.DefaultParameterTest.class,
+ org.apache.sis.metadata.iso.service.DefaultCoupledResourceTest.class,
org.apache.sis.metadata.iso.service.DefaultServiceIdentificationTest.class,
org.apache.sis.metadata.iso.quality.AbstractElementTest.class,
org.apache.sis.metadata.iso.quality.AbstractPositionalAccuracyTest.class,
Modified: sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/service/ServiceIdentification.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/service/ServiceIdentification.xml?rev=1614509&r1=1614508&r2=1614509&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/service/ServiceIdentification.xml (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/service/ServiceIdentification.xml Tue Jul 29 23:09:18 2014
@@ -33,12 +33,27 @@
<srv:serviceType>
<gco:LocalName>Web Map Server</gco:LocalName>
</srv:serviceType>
+
<srv:serviceTypeVersion>
<gco:CharacterString>1.0</gco:CharacterString>
</srv:serviceTypeVersion>
+
+ <srv:coupledResource>
+ <srv:SV_CoupledResource>
+ <srv:operationName>
+ <gco:CharacterString>Get Map</gco:CharacterString>
+ </srv:operationName>
+ <srv:identifier>
+ <gco:CharacterString>ABC-123</gco:CharacterString>
+ </srv:identifier>
+ <gco:ScopedName>mySpace:ABC-123</gco:ScopedName>
+ </srv:SV_CoupledResource>
+ </srv:coupledResource>
+
<srv:couplingType>
<srv:SV_CouplingType codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#SV_CouplingType" codeListValue="loose">Loose</srv:SV_CouplingType>
</srv:couplingType>
+
<srv:containsOperations>
<srv:SV_OperationMetadata>
<srv:operationName>
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java?rev=1614509&r1=1614508&r2=1614509&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java [UTF-8] Tue Jul 29 23:09:18 2014
@@ -19,8 +19,6 @@ package org.apache.sis.util.iso;
import java.util.List;
import java.util.Iterator;
import java.util.ConcurrentModificationException;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import org.opengis.util.NameSpace;
import org.opengis.util.LocalName;
import org.opengis.util.ScopedName;
@@ -56,8 +54,7 @@ import org.apache.sis.internal.util.Unmo
* @see DefaultNameSpace
* @see DefaultLocalName
*/
-@XmlType(name = "ScopedName") // Actually 'gml:CodeType', but the later is used elsewhere.
-@XmlRootElement(name = "ScopedName")
+// No JAXB annotation, because we can't use @XmlValue in this class.
public class DefaultScopedName extends AbstractName implements ScopedName {
/**
* Serial number for inter-operability with different versions.
@@ -90,14 +87,6 @@ public class DefaultScopedName extends A
}
/**
- * Empty constructor to be used by JAXB only. Despite its "final" declaration,
- * the {@link #parsedNames} field will be set by JAXB during unmarshalling.
- */
- private DefaultScopedName() {
- parsedNames = null;
- }
-
- /**
* Creates a new scoped names from the given list of local names. This constructor is
* not public because it does not check if the given local names have the proper scope.
*
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java?rev=1614509&r1=1614508&r2=1614509&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java [UTF-8] Tue Jul 29 23:09:18 2014
@@ -94,7 +94,7 @@ public final class Names extends Static
* @return The namespace object.
*/
private static NameSpace createNameSpace(final CharSequence namespace, final String separator) {
- if (namespace == null) {
+ if (namespace == null || namespace.length() == 0) {
return null;
}
return DefaultFactories.NAMES.createNameSpace(
@@ -103,6 +103,23 @@ public final class Names extends Static
}
/**
+ * Creates a local or scoped name in the given namespace.
+ * The character sequences can be either {@link String} or {@link InternationalString} instances.
+ * The {@code namespace} character sequences is taken verbatim, while {@code scopedName} is parsed
+ * as described in {@linkplain DefaultNameFactory#createGenericName(NameSpace, CharSequence...) name factory}.
+ *
+ * @param namespace The namespace, or {@code null} for the global namespace.
+ * @param separator The separator between the namespace and the scoped name.
+ * @param scopedName The name to parse.
+ * @return A local or scoped name in the given namespace.
+ */
+ public static GenericName parseGenericName(final CharSequence namespace, final String separator, final CharSequence scopedName) {
+ ensureNonNull("localPart", scopedName);
+ ensureNonNull("separator", separator);
+ return DefaultFactories.NAMES.parseGenericName(createNameSpace(namespace, separator), scopedName);
+ }
+
+ /**
* Creates a name which is local in the given namespace.
* The character sequences can be either {@link String} or {@link InternationalString} instances.
* Those character sequences are taken verbatim; they are <em>not</em> parsed into their components.