Search in sources :

Example 1 with Interfaces

use of org.geotoolkit.sml.xml.v101.Interfaces in project netvirt by opendaylight.

the class NeutronPortChangeListener method handleRouterInterfaceRemoved.

private void handleRouterInterfaceRemoved(Port routerPort) {
    if (routerPort.getDeviceId() != null) {
        Uuid routerId = new Uuid(routerPort.getDeviceId());
        Uuid infNetworkId = routerPort.getNetworkId();
        elanService.removeKnownL3DmacAddress(routerPort.getMacAddress().getValue(), infNetworkId.getValue());
        Uuid vpnId = ObjectUtils.defaultIfNull(neutronvpnUtils.getVpnForRouter(routerId, true), routerId);
        Map<FixedIpsKey, FixedIps> keyFixedIpsMap = routerPort.nonnullFixedIps();
        boolean vpnInstanceInternetIpVersionRemoved = false;
        Uuid vpnInstanceInternetUuid = null;
        for (FixedIps portIP : keyFixedIpsMap.values()) {
            // Internet VPN : flush InternetVPN first
            Uuid subnetId = portIP.getSubnetId();
            Subnetmap sn = neutronvpnUtils.getSubnetmap(subnetId);
            if (sn != null && sn.getInternetVpnId() != null) {
                if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, sn.getInternetVpnId())) {
                    vpnInstanceInternetIpVersionRemoved = true;
                    vpnInstanceInternetUuid = sn.getInternetVpnId();
                }
                nvpnManager.updateVpnInternetForSubnet(sn, sn.getInternetVpnId(), false);
            }
        }
        /* Remove ping responder for router interfaces
             *  A router interface reference in a VPN will have to be removed before the host interface references
             * for that subnet in the VPN are removed. This is to ensure that the FIB Entry of the router interface
             *  is not the last entry to be removed for that subnet in the VPN.
             *  If router interface FIB entry is the last to be removed for a subnet in a VPN , then all the host
             *  interface references in the vpn will already have been cleared, which will cause failures in
             *  cleanup of router interface flows*/
        nvpnManager.deleteVpnInterface(routerPort.getUuid().getValue(), null, /* vpn-id */
        null);
        // update RouterInterfaces map
        LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
            IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
            for (FixedIps portIP : keyFixedIpsMap.values()) {
                Subnetmap sn = neutronvpnUtils.getSubnetmap(portIP.getSubnetId());
                if (null == sn) {
                    LOG.error("Subnetmap for subnet {} not found", portIP.getSubnetId().getValue());
                    continue;
                }
                // router Port have either IPv4 or IPv6, never both
                ipVersion = neutronvpnUtils.getIpVersionFromString(sn.getSubnetIp());
                String ipValue = portIP.getIpAddress().stringValue();
                neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipValue, confTx);
                // NOTE:  Please donot change the order of calls to removeSubnetFromVpn and
                // and updateSubnetNodeWithFixedIP
                nvpnManager.removeSubnetFromVpn(vpnId, sn, sn.getInternetVpnId());
                nvpnManager.updateSubnetNodeWithFixedIp(portIP.getSubnetId(), null, null, null, null, null);
            }
            nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, routerPort.getUuid().getValue());
            deleteElanInterface(routerPort.getUuid().getValue(), confTx);
            deleteOfPortInterface(routerPort, confTx);
            jobCoordinator.enqueueJob(routerId.toString(), () -> {
                nvpnNatManager.handleSubnetsForExternalRouter(routerId);
                return Collections.emptyList();
            });
            if (neutronvpnUtils.shouldVpnHandleIpVersionChoiceChange(ipVersion, routerId, false)) {
                LOG.debug("vpnInstanceOpDataEntry is getting update with ip address family {} for VPN {}", ipVersion, vpnId.getValue());
                neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, false);
            }
        }), LOG, "Error handling interface removal");
        if (vpnInstanceInternetIpVersionRemoved) {
            neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnInstanceInternetUuid.getValue(), IpVersionChoice.IPV6, false);
            neutronvpnUtils.updateVpnInstanceWithFallback(routerId, vpnInstanceInternetUuid, false);
        }
    }
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports) JsonObject(com.google.gson.JsonObject) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) LoggerFactory(org.slf4j.LoggerFactory) InterfaceAcl(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAcl) PortBindingExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RoutersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.RoutersBuilder) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) NeutronvpnConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.config.rev160806.NeutronvpnConfig) PreDestroy(javax.annotation.PreDestroy) NeutronConstants(org.opendaylight.netvirt.neutronvpn.api.utils.NeutronConstants) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) Nullable(org.eclipse.jdt.annotation.Nullable) Gson(com.google.gson.Gson) Locale(java.util.Locale) DataTreeEventCallbackRegistrar(org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) Hostconfig(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.Hostconfig) Duration(java.time.Duration) Map(java.util.Map) Datastore(org.opendaylight.mdsal.binding.util.Datastore) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) PortIdToSubport(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.port.id.subport.data.PortIdToSubport) NeutronUtils(org.opendaylight.netvirt.neutronvpn.api.utils.NeutronUtils) Set(java.util.Set) Collectors(java.util.stream.Collectors) FixedIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey) Objects(java.util.Objects) JsonArray(com.google.gson.JsonArray) List(java.util.List) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) TypedWriteTransaction(org.opendaylight.mdsal.binding.util.TypedWriteTransaction) Optional(java.util.Optional) Router(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SplitHorizon(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizon) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) HashMap(java.util.HashMap) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) Singleton(javax.inject.Singleton) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) ObjectUtils(org.apache.commons.lang3.ObjectUtils) SplitHorizonBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizonBuilder) ElanInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder) Logger(org.slf4j.Logger) ElanInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceKey) StaticMacEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries) InterfaceAclBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder) FloatingIpIdToPortMappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.port.info.FloatingIpIdToPortMappingBuilder) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) ExecutionException(java.util.concurrent.ExecutionException) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.L2vlan) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ElanInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInterfaces) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) FloatingIpIdToPortMappingKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.port.info.FloatingIpIdToPortMappingKey) Collections(java.util.Collections) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FixedIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Example 2 with Interfaces

use of org.geotoolkit.sml.xml.v101.Interfaces in project geotoolkit by Geomatys.

the class SmlXMLBindingTest method SystemUnmarshallMarshalingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws java.lang.Exception
 */
@Test
public void SystemUnmarshallMarshalingTest() throws Exception {
    Unmarshaller unmarshaller = SensorMLMarshallerPool.getInstance().acquireUnmarshaller();
    InputStream is = SmlXMLBindingTest.class.getResourceAsStream("/org/geotoolkit/sml/system.xml");
    Object unmarshalled = unmarshaller.unmarshal(is);
    if (unmarshalled instanceof JAXBElement) {
        unmarshalled = ((JAXBElement) unmarshalled).getValue();
    }
    assertTrue(unmarshalled instanceof SensorML);
    SensorML result = (SensorML) unmarshalled;
    Member member = new Member();
    member.setRole("urn:x-ogx:def:sensor:OGC:detector");
    SystemType system = new SystemType();
    List<JAXBElement<String>> kw = new ArrayList<JAXBElement<String>>();
    kw.add(sml100Factory.createKeywordsKeywordListKeyword("piezometer"));
    kw.add(sml100Factory.createKeywordsKeywordListKeyword("geosciences"));
    kw.add(sml100Factory.createKeywordsKeywordListKeyword("point d'eau"));
    Keywords keywords = new Keywords(new KeywordList(URI.create("urn:x-brgm:def:gcmd:keywords"), kw));
    system.setKeywords(keywords);
    Classifier cl1 = new Classifier("intendedApplication", new Term("eaux souterraines", URI.create("urn:x-ogc:def:classifier:OGC:application")));
    CodeSpacePropertyType cs = new CodeSpacePropertyType("urn:x-brgm:def:GeoPoint:bss");
    Classifier cl2 = new Classifier("sensorType", new Term(cs, "piezometer", URI.create("urn:sensor:classifier:sensorType")));
    CodeSpacePropertyType cs3 = new CodeSpacePropertyType("urn:x-sandre:def:mdo:identifier");
    Classifier cl3 = new Classifier("waterBody", new Term(cs3, "FR6221", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs4 = new CodeSpacePropertyType("urn:x-sandre:def:mdo:name");
    Classifier cl4 = new Classifier("waterBody", new Term(cs4, "Multicouche pliocene et alluvions quaternaires du Roussillon", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs5 = new CodeSpacePropertyType("urn:x-sandre:def:bdhrf:identifier");
    Classifier cl5 = new Classifier("hydrologicalEntity", new Term(cs5, "225", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs6 = new CodeSpacePropertyType("urn:x-sandre:def:bdhrf:name");
    Classifier cl6 = new Classifier("hydrologicalEntity", new Term(cs6, "Pliocene du Roussillon", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs7 = new CodeSpacePropertyType("urn:x-insee:def:commune:identifier");
    Classifier cl7 = new Classifier("commune", new Term(cs7, "66008", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs8 = new CodeSpacePropertyType("urn:x-insee:def:commune:name");
    Classifier cl8 = new Classifier("commune", new Term(cs8, "ARGELES SUR MER", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs9 = new CodeSpacePropertyType("urn:x-sandre:def:network:identifier");
    Classifier cl9 = new Classifier("network", new Term(cs9, "600000221", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs10 = new CodeSpacePropertyType("urn:x-sandre:def:network:identifier");
    Classifier cl10 = new Classifier("network", new Term(cs10, "600000025", URI.create("urn:sensor:classifier:references")));
    List<Classifier> cls = new ArrayList<Classifier>();
    cls.add(cl1);
    cls.add(cl2);
    cls.add(cl3);
    cls.add(cl4);
    cls.add(cl5);
    cls.add(cl6);
    cls.add(cl7);
    cls.add(cl8);
    cls.add(cl9);
    cls.add(cl10);
    ClassifierList claList = new ClassifierList(null, cls);
    Classification classification = new Classification(claList);
    system.setClassification(classification);
    List<Identifier> identifiers = new ArrayList<Identifier>();
    cs = new CodeSpacePropertyType("urn:x-brgm:def:samplingStation:bss");
    Identifier id1 = new Identifier("bssCode", new Term(cs, "10972X0137/PONT", URI.create("urn:x-ogc:def:identifier:OGC:modelNumber")));
    cs = new CodeSpacePropertyType("urn:x-brgm:def:sensorSystem:hydras");
    Identifier id2 = new Identifier("supervisorCode", new Term(cs, "00ARGLELES", URI.create("urn:x-ogc:def:identifier:OGC:modelNumber")));
    Identifier id3 = new Identifier("longName", new Term("ARGELES", URI.create("urn:x-ogc:def:identifier:OGC:longname")));
    identifiers.add(id1);
    identifiers.add(id2);
    identifiers.add(id3);
    IdentifierList identifierList = new IdentifierList(null, identifiers);
    Identification identification = new Identification(identifierList);
    system.setIdentification(identification);
    Capabilities capabilities = new Capabilities();
    List<DataComponentPropertyType> fields = new ArrayList<DataComponentPropertyType>();
    QuantityType quantity = new QuantityType("urn:x-ogc:def:property:temperature", new UomPropertyType(null, "urn:ogc:unit:degree:celsius"), 0.1);
    DataComponentPropertyType field1 = new DataComponentPropertyType("resolution", "urn:x-ogc:def:property:resolution", quantity);
    fields.add(field1);
    QuantityRange quantityR = new QuantityRange(new UomPropertyType(null, "urn:ogc:unit:percent"), Arrays.asList(-0.5, 0.5));
    quantityR.setDefinition("urn:x-ogc:def:property:absoluteAccuracy");
    DataComponentPropertyType field2 = new DataComponentPropertyType("accuracy", "urn:x-ogc:def:property:accuracy", quantityR);
    fields.add(field2);
    DataRecordType record = new DataRecordType("urn:x-ogc:def:property:measurementProperties", fields);
    record.setDescription("Toutes les informations sur les  contraintes sur les donnees");
    JAXBElement<? extends AbstractDataRecordType> jbRecord = swe100Factory.createDataRecord(record);
    capabilities.setAbstractDataRecord(jbRecord);
    system.setCapabilities(capabilities);
    AddressType address1 = new AddressType("SGR LRO-1039 Rue de Pinville-34000 Montpellier", "MONTPELLIER", null, null, null, "m.blaise@brgm.fr");
    ContactInfo contactInfo1 = new ContactInfo(null, address1);
    ResponsibleParty resp1 = new ResponsibleParty("BLAISE Marion (BRGM)", "BRGM", null, contactInfo1);
    Contact contact1 = new Contact("urn:x-ogc:def:role:producer", resp1);
    AddressType address2 = new AddressType("Hotel du Departement, B.P. 906, 66 906 Perpignan Cedex", "PERPIGNAN", null, null, null, null);
    ContactInfo contactInfo2 = new ContactInfo(null, address2);
    ResponsibleParty resp2 = new ResponsibleParty("ASSENS Martine (CG66)", "CONSEIL GENERAL DES PYRENEES ORIENTALES", null, contactInfo2);
    Contact contact2 = new Contact("urn:x-ogc:def:role:owner", resp2);
    system.setContact(Arrays.asList(contact1, contact2));
    IoComponentPropertyType io = new IoComponentPropertyType("level", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:level"));
    InputList inputList = new InputList(Arrays.asList(io));
    Inputs inputs = new Inputs(inputList);
    system.setInputs(inputs);
    fields = new ArrayList<DataComponentPropertyType>();
    TimeType time = new TimeType("urn:x-ogc:def:phenomenon:observationTime", new UomPropertyType(null, "urn:x-ogc:def:unit:ISO8601"));
    fields.add(new DataComponentPropertyType("time", null, time));
    QuantityType q = new QuantityType("urn:x-ogc:def:phenomenon:OGC:depth", new UomPropertyType("m", null), null);
    fields.add(new DataComponentPropertyType("depth", null, q));
    BooleanType b = new BooleanType("urn:x-ogc:def:phenomenon:BRGM:validity", null);
    fields.add(new DataComponentPropertyType("validity", null, b));
    DataRecordType outRecord = new DataRecordType(null, fields);
    outRecord.setId("outputGroup");
    IoComponentPropertyType io2 = new IoComponentPropertyType("piezoMeasurements", swe100Factory.createDataRecord(outRecord));
    OutputList outputList = new OutputList(Arrays.asList(io2));
    Outputs outputs = new Outputs(outputList);
    system.setOutputs(outputs);
    fields = new ArrayList<DataComponentPropertyType>();
    q = new QuantityType("urn:x-ogc:def:property:depth", new UomPropertyType(null, "urn:ogc:unit:m"), 166.0);
    fields.add(new DataComponentPropertyType("MaxDepth", null, q));
    DataRecordType charRecord = new DataRecordType(null, fields);
    List<DataComponentPropertyType> fields2 = new ArrayList<DataComponentPropertyType>();
    fields2.add(new DataComponentPropertyType("physicalProperties", null, swe100Factory.createDataRecord(charRecord)));
    DataRecordType ccharRecord = new DataRecordType("urn:x-ogc:def:property:physicalProperties", fields2);
    Characteristics characteristics = new Characteristics();
    characteristics.setAbstractDataRecord(swe100Factory.createDataRecord(ccharRecord));
    system.setCharacteristics(characteristics);
    DirectPositionType pos = new DirectPositionType("urn:ogc:crs:EPSG:27582", 2, Arrays.asList(65400.0, 1731368.0));
    PointType point = new PointType("STATION_LOCALISATION", pos);
    Location location = new Location(point);
    system.setSMLLocation(location);
    EngineeringDatumType engineeringDatum = new EngineeringDatumType("datum", "Sensor Datum", new CodeType("X, Y et Z sont orthogonal au regard d'un point de reference."));
    EngineeringDatumRefType usesEngineeringDatum = new EngineeringDatumRefType(engineeringDatum);
    EngineeringCRSType engineeringCRS = new EngineeringCRSType("STATION_FRAME", "Position absolue du capteur", new CoordinateSystemRefType("urn:ogc:def:crs:ogc:1.0:xyzFrame"), usesEngineeringDatum);
    SpatialReferenceFrame spatialReferenceFrame = new SpatialReferenceFrame(engineeringCRS);
    system.setSpatialReferenceFrame(spatialReferenceFrame);
    Document doc = new Document("Fiche descriptive de la station", "text/html", Arrays.asList(new OnlineResource("http://ades.eaufrance.fr/FichePtEau.aspx?code=10972X0137/PONT")));
    Documentation documentation = new Documentation(doc);
    documentation.setRole("urn:ogc:role:description");
    system.setDocumentation(Arrays.asList(documentation));
    List<ComponentPropertyType> compos = new ArrayList<ComponentPropertyType>();
    compos.add(new ComponentPropertyType("Profondeur", "urn:x-ogc:def:sensor:detector", "capteur_"));
    ComponentList componentList = new ComponentList(compos);
    Components components = new Components(componentList);
    system.setComponents(components);
    List<CoordinateType> coordinates = new ArrayList<CoordinateType>();
    QuantityType xQuant = new QuantityType("urn:ogc:def:phenomenon:distance", new UomPropertyType("m", null), 0.0);
    xQuant.setAxisID("X");
    CoordinateType xcoord = new CoordinateType("x", xQuant);
    QuantityType yQuant = new QuantityType("urn:ogc:def:phenomenon:distance", new UomPropertyType("m", null), 0.0);
    yQuant.setAxisID("Y");
    CoordinateType ycoord = new CoordinateType("y", yQuant);
    QuantityType zQuant = new QuantityType("urn:ogc:def:phenomenon:distance", new UomPropertyType("m", null), 0.0);
    zQuant.setAxisID("Z");
    CoordinateType zcoord = new CoordinateType("z", zQuant);
    coordinates.add(xcoord);
    coordinates.add(ycoord);
    coordinates.add(zcoord);
    VectorType vect = new VectorType("urn:ogc:def:phenomenon:location", coordinates);
    VectorPropertyType vectP = new VectorPropertyType(vect);
    PositionType Sposition = new PositionType(URI.create("#REFERENCE_POINT"), URI.create("#PIEZOMETER_FRAME"), vectP, null);
    Position position = new Position("piezoPosition", Sposition);
    PositionList positionList = new PositionList(null, Arrays.asList(position));
    Positions positions = new Positions(positionList);
    system.setPositions(positions);
    TemporalReferenceFrame temporalReferenceFrame = new TemporalReferenceFrame(new TemporalCRSType("temporalReference", null, null, "calendrier gregorien en heure d'ete", new TemporalCSRefType("urn:x-brgm:temporalCS:gregorian"), new TemporalDatumRefType("urn:x-brgm:temporalDatum:UniversalTime")));
    system.setTemporalReferenceFrame(temporalReferenceFrame);
    List<Connection> connecL = new ArrayList<Connection>();
    connecL.add(new Connection("inputTolevel", new Link(null, new LinkRef("this/inputs/level"), new LinkRef("piezometer/inputs/level"))));
    Connection c2 = new Connection("depthToOutput", new Link(null, new LinkRef("piezometer/outputs/depth"), new LinkRef("this/outputs/piezoMeasurements/depth")));
    ArrayLink alink = new ArrayLink();
    LinkRef sa = new LinkRef("piezometer/outputs/depth");
    alink.setSourceArray(sa);
    LinkRef si = new LinkRef("this/outputs/piezoMeasurements/depth");
    alink.setSourceIndex(si);
    LinkRef da = new LinkRef("this/outputs/piezoMeasurements/depth");
    alink.setDestinationArray(da);
    LinkRef di = new LinkRef("this/outputs/piezoMeasurements/depth");
    alink.getDestinationIndex().add(di);
    c2.setArrayLink(alink);
    connecL.add(c2);
    ConnectionList connectionList = new ConnectionList(connecL);
    Connections connections = new Connections(connectionList);
    system.setConnections(connections);
    LayerPropertyType applicationLayer = new LayerPropertyType(new Category("urn:ogc:def:protocol:applicationLink", "urn:x-brgm:def:protocol:hydrasIRIS"));
    LayerPropertyType dataLinkLayer = new LayerPropertyType(new Category("urn:ogc:def:protocol:dataLink", "urn:x-brgm:def:dataLink:RTC"));
    InterfaceDefinition definition = new InterfaceDefinition(null, applicationLayer, dataLinkLayer);
    Interface i1 = new Interface("RS-232", definition);
    List<Interface> interfaceL = new ArrayList<Interface>();
    interfaceL.add(i1);
    InterfaceList interfaceList = new InterfaceList(null, interfaceL);
    Interfaces interfaces = new Interfaces(interfaceList);
    system.setInterfaces(interfaces);
    Rights rights = new Rights(true, true, new Documentation(new Document("Donnees sous copyright du BRGM")));
    LegalConstraint legalConstraint = new LegalConstraint(rights);
    system.setLegalConstraint(legalConstraint);
    system.setDescription("information about the piezometer");
    system.setName(new DefaultIdentifier("Piezometer Test"));
    member.setProcess(sml100Factory.createSystem(system));
    SensorML expectedResult = new SensorML("1.0", Arrays.asList(member));
    assertEquals(result.getMember().size(), 1);
    assertTrue(result.getMember().get(0).getProcess() != null);
    assertTrue(result.getMember().get(0).getProcess().getValue() instanceof SystemType);
    SystemType resultProcess = (SystemType) result.getMember().get(0).getProcess().getValue();
    assertEquals(resultProcess.getCapabilities().size(), system.getCapabilities().size());
    assertTrue(resultProcess.getCapabilities().get(0).getAbstractDataRecord().getValue() instanceof DataRecordType);
    DataRecordType resultRecord = (DataRecordType) resultProcess.getCapabilities().get(0).getAbstractDataRecord().getValue();
    DataRecordType expRecord = (DataRecordType) system.getCapabilities().get(0).getAbstractDataRecord().getValue();
    assertEquals(resultRecord.getField().get(0), expRecord.getField().get(0));
    assertEquals(resultRecord.getField().get(1), expRecord.getField().get(1));
    assertEquals(resultRecord.getField(), expRecord.getField());
    assertEquals(resultProcess.getCapabilities().get(0).getAbstractDataRecord().getValue(), system.getCapabilities().get(0).getAbstractDataRecord().getValue());
    assertEquals(resultProcess.getCapabilities().get(0), system.getCapabilities().get(0));
    assertEquals(resultProcess.getCapabilities(), system.getCapabilities());
    assertTrue(resultProcess.getContact().size() == 2);
    assertEquals(resultProcess.getContact().get(0).getContactList(), system.getContact().get(0).getContactList());
    assertEquals(resultProcess.getContact().get(0).getResponsibleParty().getContactInfo(), system.getContact().get(0).getResponsibleParty().getContactInfo());
    assertEquals(resultProcess.getContact().get(0).getResponsibleParty().getOrganizationName(), system.getContact().get(0).getResponsibleParty().getOrganizationName());
    assertEquals(resultProcess.getContact().get(0).getResponsibleParty(), system.getContact().get(0).getResponsibleParty());
    assertEquals(resultProcess.getContact().get(0), system.getContact().get(0));
    assertEquals(resultProcess.getContact(), system.getContact());
    assertTrue(resultProcess.getClassification().size() == 1);
    assertTrue(resultProcess.getClassification().get(0).getClassifierList().getClassifier().size() == 10);
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm(), system.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm());
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0), system.getClassification().get(0).getClassifierList().getClassifier().get(0));
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier(), system.getClassification().get(0).getClassifierList().getClassifier());
    assertEquals(resultProcess.getClassification().get(0).getClassifierList(), system.getClassification().get(0).getClassifierList());
    assertEquals(resultProcess.getClassification().get(0), system.getClassification().get(0));
    assertEquals(resultProcess.getClassification(), system.getClassification());
    assertEquals(resultProcess.getIdentification(), system.getIdentification());
    assertEquals(resultProcess.getValidTime(), system.getValidTime());
    assertEquals(resultProcess.getParameters(), system.getParameters());
    assertEquals(resultProcess.getInputs().getInputList().getInput(), system.getInputs().getInputList().getInput());
    assertEquals(resultProcess.getInputs().getInputList(), system.getInputs().getInputList());
    assertEquals(resultProcess.getInputs(), system.getInputs());
    assertEquals(resultProcess.getOutputs(), system.getOutputs());
    assertEquals(resultProcess.getSMLLocation(), system.getSMLLocation());
    assertEquals(resultProcess.getPosition(), system.getPosition());
    assertEquals(resultProcess.getSpatialReferenceFrame(), system.getSpatialReferenceFrame());
    assertEquals(resultProcess.getDocumentation(), system.getDocumentation());
    assertEquals(resultProcess.getCharacteristics(), system.getCharacteristics());
    assertEquals(resultProcess.getComponents(), system.getComponents());
    assertEquals(resultProcess.getPositions(), system.getPositions());
    assertEquals(resultProcess.getTemporalReferenceFrame(), system.getTemporalReferenceFrame());
    assertEquals(resultProcess.getConnections().getConnectionList().getConnection().get(0), system.getConnections().getConnectionList().getConnection().get(0));
    assertEquals(resultProcess.getConnections().getConnectionList().getConnection().get(1), system.getConnections().getConnectionList().getConnection().get(1));
    assertEquals(resultProcess.getConnections().getConnectionList().getConnection(), system.getConnections().getConnectionList().getConnection());
    assertEquals(resultProcess.getConnections().getConnectionList(), system.getConnections().getConnectionList());
    assertEquals(resultProcess.getConnections(), system.getConnections());
    assertEquals(resultProcess.getInterfaces(), system.getInterfaces());
    assertEquals(resultProcess.getLegalConstraint(), system.getLegalConstraint());
    assertEquals(resultProcess.getKeywords(), system.getKeywords());
    assertEquals(resultProcess.getId(), system.getId());
    assertEquals(resultProcess.getName(), system.getName());
    assertEquals(resultProcess, system);
    assertEquals(expectedResult.getMember().get(0), result.getMember().get(0));
    assertEquals(expectedResult.getMember(), result.getMember());
    assertEquals(expectedResult, result);
    SensorMLMarshallerPool.getInstance().recycle(unmarshaller);
}
Also used : Connections(org.geotoolkit.sml.xml.v100.Connections) LayerPropertyType(org.geotoolkit.sml.xml.v100.LayerPropertyType) InterfaceDefinition(org.geotoolkit.sml.xml.v100.InterfaceDefinition) ArrayList(java.util.ArrayList) SystemType(org.geotoolkit.sml.xml.v100.SystemType) InterfaceList(org.geotoolkit.sml.xml.v100.InterfaceList) IdentifierList(org.geotoolkit.sml.xml.v100.IdentifierList) EngineeringDatumType(org.geotoolkit.gml.xml.v311.EngineeringDatumType) Document(org.geotoolkit.sml.xml.v100.Document) Components(org.geotoolkit.sml.xml.v100.Components) VectorPropertyType(org.geotoolkit.swe.xml.v100.VectorPropertyType) Rights(org.geotoolkit.sml.xml.v100.Rights) Identifier(org.geotoolkit.sml.xml.v100.Identifier) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) ObservableProperty(org.geotoolkit.swe.xml.v100.ObservableProperty) Classification(org.geotoolkit.sml.xml.v100.Classification) ContactInfo(org.geotoolkit.sml.xml.v100.ContactInfo) Unmarshaller(javax.xml.bind.Unmarshaller) Member(org.geotoolkit.sml.xml.v100.Member) Position(org.geotoolkit.sml.xml.v100.Position) ClassifierList(org.geotoolkit.sml.xml.v100.ClassifierList) CoordinateSystemRefType(org.geotoolkit.gml.xml.v311.CoordinateSystemRefType) Documentation(org.geotoolkit.sml.xml.v100.Documentation) TemporalCRSType(org.geotoolkit.gml.xml.v311.TemporalCRSType) JAXBElement(javax.xml.bind.JAXBElement) Term(org.geotoolkit.sml.xml.v100.Term) ArrayLink(org.geotoolkit.sml.xml.v100.ArrayLink) IoComponentPropertyType(org.geotoolkit.sml.xml.v100.IoComponentPropertyType) OnlineResource(org.geotoolkit.sml.xml.v100.OnlineResource) QuantityType(org.geotoolkit.swe.xml.v100.QuantityType) EngineeringDatumRefType(org.geotoolkit.gml.xml.v311.EngineeringDatumRefType) Outputs(org.geotoolkit.sml.xml.v100.Outputs) EngineeringCRSType(org.geotoolkit.gml.xml.v311.EngineeringCRSType) Link(org.geotoolkit.sml.xml.v100.Link) ArrayLink(org.geotoolkit.sml.xml.v100.ArrayLink) OutputList(org.geotoolkit.sml.xml.v100.OutputList) DataRecordType(org.geotoolkit.swe.xml.v100.DataRecordType) AbstractDataRecordType(org.geotoolkit.swe.xml.v100.AbstractDataRecordType) Keywords(org.geotoolkit.sml.xml.v100.Keywords) Category(org.geotoolkit.swe.xml.v100.Category) InputList(org.geotoolkit.sml.xml.v100.InputList) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) IoComponentPropertyType(org.geotoolkit.sml.xml.v100.IoComponentPropertyType) DataComponentPropertyType(org.geotoolkit.swe.xml.v100.DataComponentPropertyType) ComponentPropertyType(org.geotoolkit.sml.xml.v100.ComponentPropertyType) ConnectionList(org.geotoolkit.sml.xml.v100.ConnectionList) PositionList(org.geotoolkit.sml.xml.v100.PositionList) TemporalDatumRefType(org.geotoolkit.gml.xml.v311.TemporalDatumRefType) LegalConstraint(org.geotoolkit.sml.xml.v100.LegalConstraint) Identification(org.geotoolkit.sml.xml.v100.Identification) ComponentList(org.geotoolkit.sml.xml.v100.ComponentList) Classifier(org.geotoolkit.sml.xml.v100.Classifier) TemporalReferenceFrame(org.geotoolkit.sml.xml.v100.TemporalReferenceFrame) TemporalCSRefType(org.geotoolkit.gml.xml.v311.TemporalCSRefType) TimeType(org.geotoolkit.swe.xml.v100.TimeType) UomPropertyType(org.geotoolkit.swe.xml.v100.UomPropertyType) SpatialReferenceFrame(org.geotoolkit.sml.xml.v100.SpatialReferenceFrame) CoordinateType(org.geotoolkit.swe.xml.v100.CoordinateType) VectorType(org.geotoolkit.swe.xml.v100.VectorType) CodeSpacePropertyType(org.geotoolkit.swe.xml.v100.CodeSpacePropertyType) DataComponentPropertyType(org.geotoolkit.swe.xml.v100.DataComponentPropertyType) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) Inputs(org.geotoolkit.sml.xml.v100.Inputs) LinkRef(org.geotoolkit.sml.xml.v100.LinkRef) InputStream(java.io.InputStream) BooleanType(org.geotoolkit.swe.xml.v100.BooleanType) Connection(org.geotoolkit.sml.xml.v100.Connection) QuantityRange(org.geotoolkit.swe.xml.v100.QuantityRange) ResponsibleParty(org.geotoolkit.sml.xml.v100.ResponsibleParty) SensorML(org.geotoolkit.sml.xml.v100.SensorML) Contact(org.geotoolkit.sml.xml.v100.Contact) TimePositionType(org.geotoolkit.gml.xml.v311.TimePositionType) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) PositionType(org.geotoolkit.swe.xml.v100.PositionType) Interfaces(org.geotoolkit.sml.xml.v100.Interfaces) Characteristics(org.geotoolkit.sml.xml.v100.Characteristics) Capabilities(org.geotoolkit.sml.xml.v100.Capabilities) KeywordList(org.geotoolkit.sml.xml.v100.KeywordList) Positions(org.geotoolkit.sml.xml.v100.Positions) PointType(org.geotoolkit.gml.xml.v311.PointType) CodeType(org.geotoolkit.gml.xml.v311.CodeType) AddressType(org.geotoolkit.sml.xml.v100.AddressType) Interface(org.geotoolkit.sml.xml.v100.Interface) Location(org.geotoolkit.sml.xml.v100.Location)

Example 3 with Interfaces

use of org.geotoolkit.sml.xml.v101.Interfaces in project genius by opendaylight.

the class TepDeleteDatastore method doExecute.

@Override
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
protected Object doExecute() {
    InstanceIdentifier<TransportZones> itmConfigPath = InstanceIdentifier.builder(TransportZones.class).build();
    InstanceIdentifier<Interfaces> interfacesConfigPath = InstanceIdentifier.builder(Interfaces.class).build();
    final InstanceIdentifier<InterfacesState> ifStateOpPath = InstanceIdentifier.builder(InterfacesState.class).build();
    InstanceIdentifier<Nodes> frmConfigPath = InstanceIdentifier.builder(Nodes.class).build();
    List<InstanceIdentifier<T>> allConfigPaths = new ArrayList<>();
    allConfigPaths.add((InstanceIdentifier<T>) itmConfigPath);
    allConfigPaths.add((InstanceIdentifier<T>) interfacesConfigPath);
    allConfigPaths.add((InstanceIdentifier<T>) frmConfigPath);
    // allConfigPaths.add((InstanceIdentifier<T>) tunnelsConfigPath);
    final ManagedNewTransactionRunner txrunner = new ManagedNewTransactionRunnerImpl(itmProvider.getDataBroker());
    Futures.addCallback(txrunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> allConfigPaths.forEach(tx::delete)), ItmUtils.DEFAULT_WRITE_CALLBACK, MoreExecutors.directExecutor());
    List<InstanceIdentifier<T>> allOperationalPaths = new ArrayList<>();
    // allOperationalPaths.add((InstanceIdentifier<T>) tnStateOpPath);
    allOperationalPaths.add((InstanceIdentifier<T>) ifStateOpPath);
    Futures.addCallback(txrunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.OPERATIONAL, tx -> allOperationalPaths.forEach(tx::delete)), ItmUtils.DEFAULT_WRITE_CALLBACK, MoreExecutors.directExecutor());
    return null;
}
Also used : MoreExecutors(com.google.common.util.concurrent.MoreExecutors) InterfacesState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState) OsgiCommandSupport(org.apache.karaf.shell.console.OsgiCommandSupport) Command(org.apache.karaf.shell.commands.Command) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) ArrayList(java.util.ArrayList) Interfaces(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Datastore(org.opendaylight.mdsal.binding.util.Datastore) IITMProvider(org.opendaylight.genius.itm.api.IITMProvider) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) ItmUtils(org.opendaylight.genius.itm.impl.ItmUtils) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) ArrayList(java.util.ArrayList) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Interfaces(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) InterfacesState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 4 with Interfaces

use of org.geotoolkit.sml.xml.v101.Interfaces in project geotoolkit by Geomatys.

the class SmlXMLBindingTest method SystemMarshalingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws java.lang.Exception
 */
@Test
public void SystemMarshalingTest() throws Exception {
    SensorML.Member member = new SensorML.Member();
    SystemType system = new SystemType();
    system.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-09-CTD-1");
    List<String> kw = new ArrayList<String>();
    kw.add("OCEANS");
    kw.add("OCEANS:OCEAN TEMPERATURE");
    kw.add("OCEANS:OCEAN PRESSURE");
    kw.add("OCEANS:SALINITY/DENSITY");
    kw.add("Instruments/Sensors:In Situ/Laboratory Instruments:Conductivity Sensors");
    Keywords keywords = new Keywords(new KeywordList(URI.create("urn:x-nasa:def:gcmd:keywords"), kw));
    system.setKeywords(keywords);
    CodeSpacePropertyType cs = new CodeSpacePropertyType("urn:x-ogc:dictionary::sensorTypes");
    Classifier cl2 = new Classifier("sensorType", new Term(cs, "CTD", "urn:x-ogc:def:classifier:OGC:sensorType"));
    List<Classifier> cls = new ArrayList<Classifier>();
    cls.add(cl2);
    ClassifierList claList = new ClassifierList(null, cls);
    Classification classification = new Classification(claList);
    system.setClassification(classification);
    List<Identifier> identifiers = new ArrayList<Identifier>();
    Identifier id1 = new Identifier("uniqueID", new Term("urn:ogc:object:feature:Sensor:IFREMER:13471-09-CTD-1", "urn:ogc:def:identifierType:OGC:uniqueID"));
    Identifier id2 = new Identifier("shortName", new Term("Microcat_CT_SBE37", "urn:x-ogc:def:identifier:OGC:shortName"));
    cs = new CodeSpacePropertyType("urn:x-ogc:def:identifier:SBE:modelNumber");
    Identifier id3 = new Identifier("modelNumber", new Term(cs, "", "urn:x-ogc:def:identifier:OGC:modelNumber"));
    cs = new CodeSpacePropertyType("urn:x-ogc:def:identifier:SBE:serialNumber");
    Identifier id4 = new Identifier("serialNumber", new Term(cs, "", "urn:x-ogc:def:identifier:OGC:serialNumber"));
    identifiers.add(id1);
    identifiers.add(id2);
    identifiers.add(id3);
    identifiers.add(id4);
    IdentifierList identifierList = new IdentifierList(null, identifiers);
    Identification identification = new Identification(identifierList);
    system.setIdentification(identification);
    Address address1 = new Address("1808 136th Place NE", "Bellevue", "Washington", "98005", "USA", null);
    Phone phone1 = new Phone("+1 (425) 643-9866", "+1 (425) 643-9954");
    ContactInfo contactInfo1 = new ContactInfo(phone1, address1);
    contactInfo1.setOnlineResource(new OnlineResource("http://www.seabird.com"));
    ResponsibleParty resp1 = new ResponsibleParty(null, "Sea-Bird Electronics, Inc.", null, contactInfo1);
    Contact contact1 = new Contact(null, resp1);
    contact1.setArcrole("urn:x-ogc:def:classifiers:OGC:contactType:manufacturer");
    system.setContact(Arrays.asList(contact1));
    List<ComponentPropertyType> compos = new ArrayList<ComponentPropertyType>();
    ComponentType compo1 = new ComponentType();
    compo1.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-1017-PSAL-2.0");
    List<IoComponentPropertyType> ios1 = new ArrayList<IoComponentPropertyType>();
    ios1.add(new IoComponentPropertyType("CNDC", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:CNDC")));
    ios1.add(new IoComponentPropertyType("TEMP", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:TEMP")));
    ios1.add(new IoComponentPropertyType("PRES", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:PRES")));
    Inputs inputs1 = new Inputs(ios1);
    compo1.setInputs(inputs1);
    QuantityType q = new QuantityType("urn:x-ogc:def:phenomenon:OGC:PSAL", new UomPropertyType("P.S.U", null), null);
    q.setParameterName(new CodeType("#sea_water_electrical_conductivity", "http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/11/standard-name-table"));
    IoComponentPropertyType io1 = new IoComponentPropertyType("computedPSAL", q);
    Outputs outputs1 = new Outputs(Arrays.asList(io1));
    compo1.setOutputs(outputs1);
    compos.add(new ComponentPropertyType("IFREMER-13471-1017-PSAL-2.0", sml101Factory.createComponent(compo1)));
    ComponentType compo2 = new ComponentType();
    compo2.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-1017-CNDC-2.0");
    List<IoComponentPropertyType> ios2 = new ArrayList<IoComponentPropertyType>();
    ios2.add(new IoComponentPropertyType("CNDC", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:CNDC")));
    Inputs inputs2 = new Inputs(ios2);
    compo2.setInputs(inputs2);
    QuantityType q2 = new QuantityType("urn:x-ogc:def:phenomenon:OGC:CNDC", new UomPropertyType("mhos/m", null), null);
    q2.setParameterName(new CodeType("#sea_water_electrical_conductivity", "http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/11/standard-name-table"));
    IoComponentPropertyType io2 = new IoComponentPropertyType("measuredCNDC", q2);
    Outputs outputs2 = new Outputs(Arrays.asList(io2));
    compo2.setOutputs(outputs2);
    compos.add(new ComponentPropertyType("IFREMER-13471-1017-CNDC-2.0", sml101Factory.createComponent(compo2)));
    ComponentType compo3 = new ComponentType();
    compo3.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-1017-PRES-2.0");
    compo3.setDescription("Conductivity detector connected to the SBE37SMP Recorder");
    List<IoComponentPropertyType> ios3 = new ArrayList<IoComponentPropertyType>();
    ios3.add(new IoComponentPropertyType("PRES", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:PRES")));
    Inputs inputs3 = new Inputs(ios3);
    compo3.setInputs(inputs3);
    UomPropertyType uom3 = new UomPropertyType("dBar", null);
    uom3.setTitle("decibar=10000 pascals");
    QuantityType q3 = new QuantityType("urn:x-ogc:def:phenomenon:OGC:PRES", uom3, null);
    q3.setParameterName(new CodeType("#sea_water_pressure", "http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/11/standard-name-table"));
    IoComponentPropertyType io3 = new IoComponentPropertyType("measuredPRES", q3);
    Outputs outputs3 = new Outputs(Arrays.asList(io3));
    compo3.setOutputs(outputs3);
    compos.add(new ComponentPropertyType("IFREMER-13471-1017-PRES-2.0", sml101Factory.createComponent(compo3)));
    ComponentType compo4 = new ComponentType();
    compo4.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-1017-TEMP-2.0");
    compo4.setDescription(" Temperature detector connected to the SBE37SMP Recorder");
    List<IoComponentPropertyType> ios4 = new ArrayList<IoComponentPropertyType>();
    ios4.add(new IoComponentPropertyType("TEMP", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:TEMP")));
    Inputs inputs4 = new Inputs(ios4);
    compo4.setInputs(inputs4);
    UomPropertyType uom4 = new UomPropertyType("Cel", null);
    uom4.setTitle("Celsius degree");
    QuantityType q4 = new QuantityType("urn:x-ogc:def:phenomenon:OGC:TEMP", uom4, null);
    q4.setParameterName(new CodeType("#sea_water_temperature", "http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/11/standard-name-table"));
    IoComponentPropertyType io4 = new IoComponentPropertyType("measuredTEMP", q4);
    Outputs outputs4 = new Outputs(Arrays.asList(io4));
    compo4.setOutputs(outputs4);
    List<DataComponentPropertyType> params4 = new ArrayList<DataComponentPropertyType>();
    List<DataComponentPropertyType> fields4 = new ArrayList<DataComponentPropertyType>();
    QuantityRange qr = new QuantityRange(new UomPropertyType("Cel", null), Arrays.asList(-5.0, 35.0));
    qr.setDefinition("urn:x-ogc:def:sensor:dynamicRange");
    fields4.add(new DataComponentPropertyType("dynamicRange", null, qr));
    QuantityType qr2 = new QuantityType("urn:x-ogc:def:sensor:gain", null, 1.0);
    fields4.add(new DataComponentPropertyType("gain", null, qr2));
    QuantityType qr3 = new QuantityType("urn:x-ogc:def:sensor:offset", null, 0.0);
    fields4.add(new DataComponentPropertyType("offset", null, qr3));
    DataRecordType record = new DataRecordType("urn:x-ogc:def:sensor:linearCalibration", fields4);
    DataComponentPropertyType recordProp = new DataComponentPropertyType(record, "calibration");
    recordProp.setRole("urn:x-ogc:def:sensor:steadyState");
    params4.add(recordProp);
    params4.add(new DataComponentPropertyType("accuracy", "urn:x-ogc:def:sensor:OGC:accuracy", new QuantityType("urn:x-ogc:def:sensor:OGC:absoluteAccuracy", new UomPropertyType("Cel", null), 0.0020)));
    ParameterList parameterList4 = new ParameterList(params4);
    Parameters parameters4 = new Parameters(parameterList4);
    compo4.setParameters(parameters4);
    compo4.setMethod(new MethodPropertyType("urn:x-ogc:def:process:1.0:detector"));
    compos.add(new ComponentPropertyType("IFREMER-13471-1017-TEMP-2.0", sml101Factory.createComponent(compo4)));
    ComponentList componentList = new ComponentList(compos);
    Components components = new Components(componentList);
    system.setComponents(components);
    Interface i1 = new Interface("RS232", null);
    List<Interface> interfaceL = new ArrayList<Interface>();
    interfaceL.add(i1);
    InterfaceList interfaceList = new InterfaceList(null, interfaceL);
    Interfaces interfaces = new Interfaces(interfaceList);
    system.setInterfaces(interfaces);
    system.setDescription("The SBE 37-SMP MicroCAT is a high-accuracy conductivity and temperature (pressure optional) recorder with internal battery and memory, serial communication or Inductive Modem and pump (optional). Designed for moorings or other long duration, fixed-site deployments, the MicroCAT includes a standard serial interface and nonvolatile FLASH memory. Construction is of titanium and other non-corroding materials to ensure long life with minimum maintenance, and depth capability is 7000 meters (23,000 feet).");
    member.setProcess(sml101Factory.createSystem(system));
    SensorML sensor = new SensorML("1.0.1", Arrays.asList(member));
    Marshaller m = SensorMLMarshallerPool.getInstance().acquireMarshaller();
    StringWriter sw = new StringWriter();
    m.marshal(sensor, sw);
    String result = sw.toString();
    InputStream in = SmlXMLBindingTest.class.getResourceAsStream("/org/geotoolkit/sml/system101.xml");
    StringWriter out = new StringWriter();
    byte[] buffer = new byte[1024];
    int size;
    while ((size = in.read(buffer, 0, 1024)) > 0) {
        out.write(new String(buffer, 0, size));
    }
    String expResult = out.toString();
    final DocumentComparator comparator = new DocumentComparator(expResult, result) {

        @Override
        protected strictfp void compareAttributeNode(Attr expected, Node actual) {
            super.compareAttributeNode(expected, actual);
        }
    };
    comparator.ignoredAttributes.add("http://www.w3.org/2000/xmlns:*");
    comparator.ignoredAttributes.add("http://www.w3.org/2001/XMLSchema-instance:schemaLocation");
    comparator.compare();
    SensorMLMarshallerPool.getInstance().recycle(m);
}
Also used : Address(org.geotoolkit.sml.xml.v101.Address) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) SystemType(org.geotoolkit.sml.xml.v101.SystemType) InterfaceList(org.geotoolkit.sml.xml.v101.InterfaceList) IdentifierList(org.geotoolkit.sml.xml.v101.IdentifierList) Attr(org.w3c.dom.Attr) Components(org.geotoolkit.sml.xml.v101.Components) Identifier(org.geotoolkit.sml.xml.v101.Identifier) ObservableProperty(org.geotoolkit.swe.xml.v101.ObservableProperty) Classification(org.geotoolkit.sml.xml.v101.Classification) ContactInfo(org.geotoolkit.sml.xml.v101.ContactInfo) Parameters(org.geotoolkit.sml.xml.v101.Parameters) ClassifierList(org.geotoolkit.sml.xml.v101.ClassifierList) Term(org.geotoolkit.sml.xml.v101.Term) IoComponentPropertyType(org.geotoolkit.sml.xml.v101.IoComponentPropertyType) OnlineResource(org.geotoolkit.sml.xml.v101.OnlineResource) QuantityType(org.geotoolkit.swe.xml.v101.QuantityType) Outputs(org.geotoolkit.sml.xml.v101.Outputs) ParameterList(org.geotoolkit.sml.xml.v101.ParameterList) DataRecordType(org.geotoolkit.swe.xml.v101.DataRecordType) Keywords(org.geotoolkit.sml.xml.v101.Keywords) DataComponentPropertyType(org.geotoolkit.swe.xml.v101.DataComponentPropertyType) ComponentPropertyType(org.geotoolkit.sml.xml.v101.ComponentPropertyType) IoComponentPropertyType(org.geotoolkit.sml.xml.v101.IoComponentPropertyType) Identification(org.geotoolkit.sml.xml.v101.Identification) ComponentList(org.geotoolkit.sml.xml.v101.ComponentList) Classifier(org.geotoolkit.sml.xml.v101.Classifier) UomPropertyType(org.geotoolkit.swe.xml.v101.UomPropertyType) StringWriter(java.io.StringWriter) Phone(org.geotoolkit.sml.xml.v101.Phone) DocumentComparator(org.apache.sis.test.xml.DocumentComparator) CodeSpacePropertyType(org.geotoolkit.swe.xml.v101.CodeSpacePropertyType) DataComponentPropertyType(org.geotoolkit.swe.xml.v101.DataComponentPropertyType) Inputs(org.geotoolkit.sml.xml.v101.Inputs) ComponentType(org.geotoolkit.sml.xml.v101.ComponentType) Marshaller(javax.xml.bind.Marshaller) InputStream(java.io.InputStream) QuantityRange(org.geotoolkit.swe.xml.v101.QuantityRange) ResponsibleParty(org.geotoolkit.sml.xml.v101.ResponsibleParty) SensorML(org.geotoolkit.sml.xml.v101.SensorML) MethodPropertyType(org.geotoolkit.sml.xml.v101.MethodPropertyType) Contact(org.geotoolkit.sml.xml.v101.Contact) Interfaces(org.geotoolkit.sml.xml.v101.Interfaces) KeywordList(org.geotoolkit.sml.xml.v101.KeywordList) CodeType(org.geotoolkit.gml.xml.v311.CodeType) Interface(org.geotoolkit.sml.xml.v101.Interface)

Example 5 with Interfaces

use of org.geotoolkit.sml.xml.v101.Interfaces in project geotoolkit by Geomatys.

the class SmlXMLBindingTest method SystemUnmarshallMarshalingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws java.lang.Exception
 */
@Test
public void SystemUnmarshallMarshalingTest() throws Exception {
    Unmarshaller unmarshaller = SensorMLMarshallerPool.getInstance().acquireUnmarshaller();
    InputStream is = SmlXMLBindingTest.class.getResourceAsStream("/org/geotoolkit/sml/system101.xml");
    Object unmarshalled = unmarshaller.unmarshal(is);
    if (unmarshalled instanceof JAXBElement) {
        unmarshalled = ((JAXBElement) unmarshalled).getValue();
    }
    assertTrue(unmarshalled instanceof SensorML);
    SensorML result = (SensorML) unmarshalled;
    SensorML.Member member = new SensorML.Member();
    SystemType system = new SystemType();
    system.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-09-CTD-1");
    List<String> kw = new ArrayList<String>();
    kw.add("OCEANS");
    kw.add("OCEANS:OCEAN TEMPERATURE");
    kw.add("OCEANS:OCEAN PRESSURE");
    kw.add("OCEANS:SALINITY/DENSITY");
    kw.add("Instruments/Sensors:In Situ/Laboratory Instruments:Conductivity Sensors");
    Keywords keywords = new Keywords(new KeywordList(URI.create("urn:x-nasa:def:gcmd:keywords"), kw));
    system.setKeywords(keywords);
    CodeSpacePropertyType cs = new CodeSpacePropertyType("urn:x-ogc:dictionary::sensorTypes");
    Classifier cl2 = new Classifier("sensorType", new Term(cs, "CTD", "urn:x-ogc:def:classifier:OGC:sensorType"));
    List<Classifier> cls = new ArrayList<Classifier>();
    cls.add(cl2);
    ClassifierList claList = new ClassifierList(null, cls);
    Classification classification = new Classification(claList);
    system.setClassification(classification);
    List<Identifier> identifiers = new ArrayList<Identifier>();
    Identifier id1 = new Identifier("uniqueID", new Term("urn:ogc:object:feature:Sensor:IFREMER:13471-09-CTD-1", "urn:ogc:def:identifierType:OGC:uniqueID"));
    Identifier id2 = new Identifier("shortName", new Term("Microcat_CT_SBE37", "urn:x-ogc:def:identifier:OGC:shortName"));
    cs = new CodeSpacePropertyType("urn:x-ogc:def:identifier:SBE:modelNumber");
    Identifier id3 = new Identifier("modelNumber", new Term(cs, "", "urn:x-ogc:def:identifier:OGC:modelNumber"));
    cs = new CodeSpacePropertyType("urn:x-ogc:def:identifier:SBE:serialNumber");
    Identifier id4 = new Identifier("serialNumber", new Term(cs, "", "urn:x-ogc:def:identifier:OGC:serialNumber"));
    identifiers.add(id1);
    identifiers.add(id2);
    identifiers.add(id3);
    identifiers.add(id4);
    IdentifierList identifierList = new IdentifierList(null, identifiers);
    Identification identification = new Identification(identifierList);
    system.setIdentification(identification);
    Address address1 = new Address("1808 136th Place NE", "Bellevue", "Washington", "98005", "USA", null);
    Phone phone1 = new Phone("+1 (425) 643-9866", "+1 (425) 643-9954");
    ContactInfo contactInfo1 = new ContactInfo(phone1, address1);
    contactInfo1.setOnlineResource(new OnlineResource("http://www.seabird.com"));
    ResponsibleParty resp1 = new ResponsibleParty(null, "Sea-Bird Electronics, Inc.", null, contactInfo1);
    Contact contact1 = new Contact(null, resp1);
    contact1.setArcrole("urn:x-ogc:def:classifiers:OGC:contactType:manufacturer");
    system.setContact(Arrays.asList(contact1));
    List<ComponentPropertyType> compos = new ArrayList<ComponentPropertyType>();
    ComponentType compo1 = new ComponentType();
    compo1.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-1017-PSAL-2.0");
    List<IoComponentPropertyType> ios1 = new ArrayList<IoComponentPropertyType>();
    ios1.add(new IoComponentPropertyType("CNDC", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:CNDC")));
    ios1.add(new IoComponentPropertyType("TEMP", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:TEMP")));
    ios1.add(new IoComponentPropertyType("PRES", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:PRES")));
    Inputs inputs1 = new Inputs(ios1);
    compo1.setInputs(inputs1);
    QuantityType q = new QuantityType("urn:x-ogc:def:phenomenon:OGC:PSAL", new UomPropertyType("P.S.U", null), null);
    q.setParameterName(new CodeType("#sea_water_electrical_conductivity", "http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/11/standard-name-table"));
    IoComponentPropertyType io1 = new IoComponentPropertyType("computedPSAL", q);
    Outputs outputs1 = new Outputs(Arrays.asList(io1));
    compo1.setOutputs(outputs1);
    compos.add(new ComponentPropertyType("IFREMER-13471-1017-PSAL-2.0", sml101Factory.createComponent(compo1)));
    ComponentType compo2 = new ComponentType();
    compo2.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-1017-CNDC-2.0");
    List<IoComponentPropertyType> ios2 = new ArrayList<IoComponentPropertyType>();
    ios2.add(new IoComponentPropertyType("CNDC", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:CNDC")));
    Inputs inputs2 = new Inputs(ios2);
    compo2.setInputs(inputs2);
    QuantityType q2 = new QuantityType("urn:x-ogc:def:phenomenon:OGC:CNDC", new UomPropertyType("mhos/m", null), null);
    q2.setParameterName(new CodeType("#sea_water_electrical_conductivity", "http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/11/standard-name-table"));
    IoComponentPropertyType io2 = new IoComponentPropertyType("measuredCNDC", q2);
    Outputs outputs2 = new Outputs(Arrays.asList(io2));
    compo2.setOutputs(outputs2);
    compos.add(new ComponentPropertyType("IFREMER-13471-1017-CNDC-2.0", sml101Factory.createComponent(compo2)));
    ComponentType compo3 = new ComponentType();
    compo3.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-1017-PRES-2.0");
    compo3.setDescription("Conductivity detector connected to the SBE37SMP Recorder");
    List<IoComponentPropertyType> ios3 = new ArrayList<IoComponentPropertyType>();
    ios3.add(new IoComponentPropertyType("PRES", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:PRES")));
    Inputs inputs3 = new Inputs(ios3);
    compo3.setInputs(inputs3);
    UomPropertyType uom3 = new UomPropertyType("dBar", null);
    uom3.setTitle("decibar=10000 pascals");
    QuantityType q3 = new QuantityType("urn:x-ogc:def:phenomenon:OGC:PRES", uom3, null);
    q3.setParameterName(new CodeType("#sea_water_pressure", "http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/11/standard-name-table"));
    IoComponentPropertyType io3 = new IoComponentPropertyType("measuredPRES", q3);
    Outputs outputs3 = new Outputs(Arrays.asList(io3));
    compo3.setOutputs(outputs3);
    compos.add(new ComponentPropertyType("IFREMER-13471-1017-PRES-2.0", sml101Factory.createComponent(compo3)));
    ComponentType compo4 = new ComponentType();
    compo4.setId("urn-ogc-object-feature-Sensor-IFREMER-13471-1017-TEMP-2.0");
    compo4.setDescription(" Temperature detector connected to the SBE37SMP Recorder");
    List<IoComponentPropertyType> ios4 = new ArrayList<IoComponentPropertyType>();
    ios4.add(new IoComponentPropertyType("TEMP", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:TEMP")));
    Inputs inputs4 = new Inputs(ios4);
    compo4.setInputs(inputs4);
    UomPropertyType uom4 = new UomPropertyType("Cel", null);
    uom4.setTitle("Celsius degree");
    QuantityType q4 = new QuantityType("urn:x-ogc:def:phenomenon:OGC:TEMP", uom4, null);
    q4.setParameterName(new CodeType("#sea_water_temperature", "http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/11/standard-name-table"));
    IoComponentPropertyType io4 = new IoComponentPropertyType("measuredTEMP", q4);
    Outputs outputs4 = new Outputs(Arrays.asList(io4));
    compo4.setOutputs(outputs4);
    List<DataComponentPropertyType> params4 = new ArrayList<DataComponentPropertyType>();
    List<DataComponentPropertyType> fields4 = new ArrayList<DataComponentPropertyType>();
    QuantityRange qr = new QuantityRange(new UomPropertyType("Cel", null), Arrays.asList(-5.0, 35.0));
    qr.setDefinition("urn:x-ogc:def:sensor:dynamicRange");
    fields4.add(new DataComponentPropertyType("dynamicRange", null, qr));
    QuantityType qr2 = new QuantityType("urn:x-ogc:def:sensor:gain", null, 1.0);
    fields4.add(new DataComponentPropertyType("gain", null, qr2));
    QuantityType qr3 = new QuantityType("urn:x-ogc:def:sensor:offset", null, 0.0);
    fields4.add(new DataComponentPropertyType("offset", null, qr3));
    DataRecordType record = new DataRecordType("urn:x-ogc:def:sensor:linearCalibration", fields4);
    DataComponentPropertyType recordProp = new DataComponentPropertyType(record, "calibration");
    recordProp.setRole("urn:x-ogc:def:sensor:steadyState");
    params4.add(recordProp);
    params4.add(new DataComponentPropertyType("accuracy", "urn:x-ogc:def:sensor:OGC:accuracy", new QuantityType("urn:x-ogc:def:sensor:OGC:absoluteAccuracy", new UomPropertyType("Cel", null), 0.0020)));
    ParameterList parameterList4 = new ParameterList(params4);
    Parameters parameters4 = new Parameters(parameterList4);
    compo4.setParameters(parameters4);
    compo4.setMethod(new MethodPropertyType("urn:x-ogc:def:process:1.0:detector"));
    compos.add(new ComponentPropertyType("IFREMER-13471-1017-TEMP-2.0", sml101Factory.createComponent(compo4)));
    ComponentList componentList = new ComponentList(compos);
    Components components = new Components(componentList);
    system.setComponents(components);
    Interface i1 = new Interface("RS232", null);
    List<Interface> interfaceL = new ArrayList<Interface>();
    interfaceL.add(i1);
    InterfaceList interfaceList = new InterfaceList(null, interfaceL);
    Interfaces interfaces = new Interfaces(interfaceList);
    system.setInterfaces(interfaces);
    system.setDescription("The SBE 37-SMP MicroCAT is a high-accuracy conductivity and temperature (pressure optional) recorder with internal battery and memory, serial communication or Inductive Modem and pump (optional). Designed for moorings or other long duration, fixed-site deployments, the MicroCAT includes a standard serial interface and nonvolatile FLASH memory. Construction is of titanium and other non-corroding materials to ensure long life with minimum maintenance, and depth capability is 7000 meters (23,000 feet).");
    member.setProcess(sml101Factory.createSystem(system));
    SensorML expectedResult = new SensorML("1.0.1", Arrays.asList(member));
    assertEquals(result.getMember().size(), 1);
    assertTrue(result.getMember().get(0).getProcess() != null);
    assertTrue(result.getMember().get(0).getProcess().getValue() instanceof SystemType);
    SystemType resultProcess = (SystemType) result.getMember().get(0).getProcess().getValue();
    assertTrue(resultProcess.getContact().size() == 1);
    assertEquals(resultProcess.getContact().get(0).getContactList(), system.getContact().get(0).getContactList());
    assertEquals(resultProcess.getContact().get(0).getResponsibleParty().getContactInfo(), system.getContact().get(0).getResponsibleParty().getContactInfo());
    assertEquals(resultProcess.getContact().get(0).getResponsibleParty().getOrganizationName(), system.getContact().get(0).getResponsibleParty().getOrganizationName());
    assertEquals(resultProcess.getContact().get(0).getResponsibleParty(), system.getContact().get(0).getResponsibleParty());
    assertEquals(resultProcess.getContact().get(0), system.getContact().get(0));
    assertEquals(resultProcess.getContact(), system.getContact());
    assertTrue(resultProcess.getClassification().size() == 1);
    assertTrue(resultProcess.getClassification().get(0).getClassifierList().getClassifier().size() == 1);
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm().getCodeSpace(), system.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm().getCodeSpace());
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm().getDefinition(), system.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm().getDefinition());
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm().getValue(), system.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm().getValue());
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm(), system.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm());
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0), system.getClassification().get(0).getClassifierList().getClassifier().get(0));
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier(), system.getClassification().get(0).getClassifierList().getClassifier());
    assertEquals(resultProcess.getClassification().get(0).getClassifierList(), system.getClassification().get(0).getClassifierList());
    assertEquals(resultProcess.getClassification().get(0), system.getClassification().get(0));
    assertEquals(resultProcess.getClassification(), system.getClassification());
    assertEquals(resultProcess.getIdentification().size(), system.getIdentification().size());
    assertEquals(resultProcess.getIdentification().get(0).getIdentifierList().getIdentifier().size(), system.getIdentification().get(0).getIdentifierList().getIdentifier().size());
    assertEquals(resultProcess.getIdentification().get(0).getIdentifierList().getIdentifier(), system.getIdentification().get(0).getIdentifierList().getIdentifier());
    assertEquals(resultProcess.getIdentification().get(0).getIdentifierList(), system.getIdentification().get(0).getIdentifierList());
    assertEquals(resultProcess.getIdentification().get(0), system.getIdentification().get(0));
    assertEquals(resultProcess.getIdentification(), system.getIdentification());
    assertEquals(resultProcess.getValidTime(), system.getValidTime());
    assertEquals(resultProcess.getParameters(), system.getParameters());
    // assertEquals(resultProcess.getInputs().getInputList().getInput(), system.getInputs().getInputList().getInput());
    // assertEquals(resultProcess.getInputs().getInputList(), system.getInputs().getInputList());
    // assertEquals(resultProcess.getInputs(), system.getInputs());
    assertEquals(resultProcess.getOutputs(), system.getOutputs());
    assertEquals(resultProcess.getSMLLocation(), system.getSMLLocation());
    assertEquals(resultProcess.getPosition(), system.getPosition());
    assertEquals(resultProcess.getSpatialReferenceFrame(), system.getSpatialReferenceFrame());
    assertEquals(resultProcess.getDocumentation(), system.getDocumentation());
    assertEquals(resultProcess.getCharacteristics(), system.getCharacteristics());
    assertEquals(resultProcess.getComponents().getComponentList().getComponent().size(), system.getComponents().getComponentList().getComponent().size());
    for (int i = 0; i < system.getComponents().getComponentList().getComponent().size(); i++) {
        ComponentPropertyType expCP = system.getComponents().getComponentList().getComponent().get(i);
        ComponentPropertyType resCP = resultProcess.getComponents().getComponentList().getComponent().get(i);
        ComponentType expCPprocess = (ComponentType) expCP.getAbstractProcess();
        ComponentType resCPprocess = (ComponentType) resCP.getAbstractProcess();
        assertEquals(expCPprocess.getBoundedBy(), resCPprocess.getBoundedBy());
        assertEquals(expCPprocess.getCapabilities(), resCPprocess.getCapabilities());
        assertEquals(expCPprocess.getCharacteristics(), resCPprocess.getCharacteristics());
        assertEquals(expCPprocess.getClassification(), resCPprocess.getClassification());
        assertEquals(expCPprocess.getContact(), resCPprocess.getContact());
        assertEquals(expCPprocess.getDescription(), resCPprocess.getDescription());
        assertEquals(expCPprocess.getDescriptionReference(), resCPprocess.getDescriptionReference());
        assertEquals(expCPprocess.getDocumentation(), resCPprocess.getDocumentation());
        assertEquals(expCPprocess.getHistory(), resCPprocess.getHistory());
        assertEquals(expCPprocess.getId(), resCPprocess.getId());
        assertEquals(expCPprocess.getIdentification(), resCPprocess.getIdentification());
        assertEquals(expCPprocess.getIdentifier(), resCPprocess.getIdentifier());
        assertEquals(expCPprocess.getInputs(), resCPprocess.getInputs());
        assertEquals(expCPprocess.getInterfaces(), resCPprocess.getInterfaces());
        assertEquals(expCPprocess.getKeywords(), resCPprocess.getKeywords());
        assertEquals(expCPprocess.getLegalConstraint(), resCPprocess.getLegalConstraint());
        assertEquals(expCPprocess.getLocation(), resCPprocess.getLocation());
        assertEquals(expCPprocess.getName(), resCPprocess.getName());
        assertEquals(expCPprocess.getOutputs(), resCPprocess.getOutputs());
        if (expCPprocess.getParameters() != null) {
            for (int j = 0; j < expCPprocess.getParameters().getParameterList().getParameter().size(); j++) {
                final DataComponentPropertyType expParam = expCPprocess.getParameters().getParameterList().getParameter().get(j);
                final DataComponentPropertyType resParam = resCPprocess.getParameters().getParameterList().getParameter().get(j);
                if (expParam.getAbstractRecord() instanceof DataRecordType) {
                    DataRecordType expRecord = (DataRecordType) expParam.getAbstractRecord();
                    DataRecordType resRecord = (DataRecordType) resParam.getAbstractRecord();
                    for (int k = 0; k < expRecord.getField().size(); k++) {
                        DataComponentPropertyType expField = expRecord.getField().get(k);
                        DataComponentPropertyType resField = resRecord.getField().get(k);
                        assertEquals(expField.getQuantityRange(), resField.getQuantityRange());
                        assertEquals(expField, resField);
                    }
                    assertEquals(expRecord.getField(), resRecord.getField());
                    assertEquals(expRecord, resRecord);
                }
                assertEquals(expParam.getAbstractRecord(), resParam.getAbstractRecord());
                assertEquals(expParam, resParam);
            }
            assertEquals(expCPprocess.getParameters().getParameterList().getParameter(), resCPprocess.getParameters().getParameterList().getParameter());
            assertEquals(expCPprocess.getParameters().getParameterList(), resCPprocess.getParameters().getParameterList());
        }
        assertEquals(expCPprocess.getParameters(), resCPprocess.getParameters());
        assertEquals(expCPprocess.getParameterName(), resCPprocess.getParameterName());
        assertEquals(expCPprocess.getPosition(), resCPprocess.getPosition());
        assertEquals(expCPprocess.getSMLLocation(), resCPprocess.getSMLLocation());
        assertEquals(expCPprocess.getSecurityConstraint(), resCPprocess.getSecurityConstraint());
        assertEquals(expCPprocess.getSrsName(), resCPprocess.getSrsName());
        assertEquals(expCPprocess.getValidTime(), resCPprocess.getValidTime());
        assertEquals(expCPprocess.getMethod(), resCPprocess.getMethod());
        assertEquals(expCPprocess.getTemporalReferenceFrame(), resCPprocess.getTemporalReferenceFrame());
        assertEquals(expCPprocess.getTimePosition(), resCPprocess.getTimePosition());
        assertEquals(expCPprocess, resCPprocess);
        assertEquals(expCP, resCP);
    }
    assertEquals(resultProcess.getComponents().getComponentList().getComponent(), system.getComponents().getComponentList().getComponent());
    assertEquals(resultProcess.getComponents().getComponentList(), system.getComponents().getComponentList());
    assertEquals(resultProcess.getComponents(), system.getComponents());
    assertEquals(resultProcess.getPositions(), system.getPositions());
    assertEquals(resultProcess.getTemporalReferenceFrame(), system.getTemporalReferenceFrame());
    assertEquals(resultProcess.getConnections(), system.getConnections());
    assertEquals(resultProcess.getInterfaces(), system.getInterfaces());
    assertEquals(resultProcess.getLegalConstraint(), system.getLegalConstraint());
    assertEquals(resultProcess, system);
    assertEquals(expectedResult.getMember().get(0), result.getMember().get(0));
    assertEquals(expectedResult.getMember(), result.getMember());
    assertEquals(expectedResult, result);
    SensorMLMarshallerPool.getInstance().recycle(unmarshaller);
}
Also used : Address(org.geotoolkit.sml.xml.v101.Address) ArrayList(java.util.ArrayList) SystemType(org.geotoolkit.sml.xml.v101.SystemType) InterfaceList(org.geotoolkit.sml.xml.v101.InterfaceList) IdentifierList(org.geotoolkit.sml.xml.v101.IdentifierList) Components(org.geotoolkit.sml.xml.v101.Components) Identifier(org.geotoolkit.sml.xml.v101.Identifier) ObservableProperty(org.geotoolkit.swe.xml.v101.ObservableProperty) Classification(org.geotoolkit.sml.xml.v101.Classification) ContactInfo(org.geotoolkit.sml.xml.v101.ContactInfo) Unmarshaller(javax.xml.bind.Unmarshaller) Parameters(org.geotoolkit.sml.xml.v101.Parameters) ClassifierList(org.geotoolkit.sml.xml.v101.ClassifierList) JAXBElement(javax.xml.bind.JAXBElement) Term(org.geotoolkit.sml.xml.v101.Term) IoComponentPropertyType(org.geotoolkit.sml.xml.v101.IoComponentPropertyType) OnlineResource(org.geotoolkit.sml.xml.v101.OnlineResource) QuantityType(org.geotoolkit.swe.xml.v101.QuantityType) Outputs(org.geotoolkit.sml.xml.v101.Outputs) ParameterList(org.geotoolkit.sml.xml.v101.ParameterList) DataRecordType(org.geotoolkit.swe.xml.v101.DataRecordType) Keywords(org.geotoolkit.sml.xml.v101.Keywords) DataComponentPropertyType(org.geotoolkit.swe.xml.v101.DataComponentPropertyType) ComponentPropertyType(org.geotoolkit.sml.xml.v101.ComponentPropertyType) IoComponentPropertyType(org.geotoolkit.sml.xml.v101.IoComponentPropertyType) Identification(org.geotoolkit.sml.xml.v101.Identification) ComponentList(org.geotoolkit.sml.xml.v101.ComponentList) Classifier(org.geotoolkit.sml.xml.v101.Classifier) UomPropertyType(org.geotoolkit.swe.xml.v101.UomPropertyType) Phone(org.geotoolkit.sml.xml.v101.Phone) CodeSpacePropertyType(org.geotoolkit.swe.xml.v101.CodeSpacePropertyType) DataComponentPropertyType(org.geotoolkit.swe.xml.v101.DataComponentPropertyType) Inputs(org.geotoolkit.sml.xml.v101.Inputs) ComponentType(org.geotoolkit.sml.xml.v101.ComponentType) InputStream(java.io.InputStream) QuantityRange(org.geotoolkit.swe.xml.v101.QuantityRange) ResponsibleParty(org.geotoolkit.sml.xml.v101.ResponsibleParty) SensorML(org.geotoolkit.sml.xml.v101.SensorML) MethodPropertyType(org.geotoolkit.sml.xml.v101.MethodPropertyType) Contact(org.geotoolkit.sml.xml.v101.Contact) Interfaces(org.geotoolkit.sml.xml.v101.Interfaces) KeywordList(org.geotoolkit.sml.xml.v101.KeywordList) CodeType(org.geotoolkit.gml.xml.v311.CodeType) Interface(org.geotoolkit.sml.xml.v101.Interface)

Aggregations

ArrayList (java.util.ArrayList)5 InputStream (java.io.InputStream)3 CodeType (org.geotoolkit.gml.xml.v311.CodeType)3 Address (org.geotoolkit.sml.xml.v101.Address)2 Classification (org.geotoolkit.sml.xml.v101.Classification)2 Classifier (org.geotoolkit.sml.xml.v101.Classifier)2 ClassifierList (org.geotoolkit.sml.xml.v101.ClassifierList)2 ComponentList (org.geotoolkit.sml.xml.v101.ComponentList)2 ComponentPropertyType (org.geotoolkit.sml.xml.v101.ComponentPropertyType)2 ComponentType (org.geotoolkit.sml.xml.v101.ComponentType)2 Components (org.geotoolkit.sml.xml.v101.Components)2 Contact (org.geotoolkit.sml.xml.v101.Contact)2 ContactInfo (org.geotoolkit.sml.xml.v101.ContactInfo)2 Identification (org.geotoolkit.sml.xml.v101.Identification)2 Identifier (org.geotoolkit.sml.xml.v101.Identifier)2 IdentifierList (org.geotoolkit.sml.xml.v101.IdentifierList)2 Inputs (org.geotoolkit.sml.xml.v101.Inputs)2 Interface (org.geotoolkit.sml.xml.v101.Interface)2 InterfaceList (org.geotoolkit.sml.xml.v101.InterfaceList)2 Interfaces (org.geotoolkit.sml.xml.v101.Interfaces)2