Search in sources :

Example 26 with SystemType

use of org.geotoolkit.sml.xml.v101.SystemType in project arctic-sea by 52North.

the class SensorMLDecoderV101Test method should_decode_io_from_sml.

@Test
public void should_decode_io_from_sml() throws DecodingException {
    SensorMLDocument xbSmlDoc = getSensorMLDoc();
    SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
    InputList xbInputList = xbSystem.addNewInputs().addNewInputList();
    OutputList xbOutputList = xbSystem.addNewOutputs().addNewOutputList();
    IoComponentPropertyType input1 = xbInputList.addNewInput();
    input1.setName("input1");
    input1.addNewBoolean();
    IoComponentPropertyType input2 = xbInputList.addNewInput();
    input2.setName("input2");
    input2.addNewCount();
    IoComponentPropertyType output1 = xbOutputList.addNewOutput();
    output1.setName("output1");
    output1.addNewQuantity();
    IoComponentPropertyType output2 = xbOutputList.addNewOutput();
    output2.setName("output2");
    DataArrayType dataArray = getDataArray();
    output2.setAbstractDataArray1(dataArray);
    XmlHelper.substituteElement(output2.getAbstractDataArray1(), dataArray);
    IoComponentPropertyType output3 = xbOutputList.addNewOutput();
    output3.setName("output3");
    DataRecordType dataRecord = DataRecordType.Factory.newInstance();
    output3.setAbstractDataRecord(dataRecord);
    XmlHelper.substituteElement(output3.getAbstractDataRecord(), dataRecord);
    AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
    assertThat(absProcess.getInputs().get(0).getIoValue().getDataComponentType(), is(SweDataComponentType.Boolean));
    // assertThat(
    // ((SweAbstractSimpleType)absProcess.getInputs().get(0).getIoValue()).getDataComponentType(),
    // is (SweDataComponentType.Boolean));
    assertThat(absProcess.getInputs().get(1).getIoValue().getDataComponentType(), is(SweDataComponentType.Count));
    // assertThat(
    // ((SweAbstractSimpleType)absProcess.getInputs().get(1).getIoValue()).getDataComponentType(),
    // is (SweDataComponentType.Count));
    assertThat(absProcess.getOutputs().get(0).getIoValue().getDataComponentType(), is(SweDataComponentType.Quantity));
    // assertThat(
    // ((SweAbstractSimpleType)absProcess.getOutputs().get(0).getIoValue()).getDataComponentType(),
    // is (SweDataComponentType.Quantity));
    assertThat(absProcess.getOutputs().get(1).getIoValue().getDataComponentType(), is(SweDataComponentType.DataArray));
    assertThat(absProcess.getOutputs().get(2).getIoValue().getDataComponentType(), is(SweDataComponentType.DataRecord));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) InputList(net.opengis.sensorML.x101.InputsDocument.Inputs.InputList) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SystemType(net.opengis.sensorML.x101.SystemType) IoComponentPropertyType(net.opengis.sensorML.x101.IoComponentPropertyType) OutputList(net.opengis.sensorML.x101.OutputsDocument.Outputs.OutputList) DataArrayType(net.opengis.swe.x101.DataArrayType) Test(org.junit.jupiter.api.Test)

Example 27 with SystemType

use of org.geotoolkit.sml.xml.v101.SystemType in project arctic-sea by 52North.

the class SensorMLEncoderV101Test method should_merge_and_encode_two_same_contact_person_only_once.

@Test
public void should_merge_and_encode_two_same_contact_person_only_once() throws EncodingException {
    final SensorML sensorML = new SensorML();
    final System system = new System();
    sensorML.addMember(system);
    final SmlPerson p1 = createPerson("1");
    system.addContact(p1);
    final SensorMLDocument xbSensorML = SensorMLDocument.Factory.newInstance();
    final SystemType xbSystem = SystemType.Factory.newInstance();
    final Person xbP1 = xbSystem.addNewContact().addNewPerson();
    setPersonValues(p1, xbP1);
    final XmlObject xbProcess = xbSensorML.addNewSensorML().addNewMember().addNewProcess().set(xbSystem);
    XmlHelper.substituteElement(xbProcess, xbSystem);
    xbSensorML.getSensorML().setVersion("1.0.1");
    sensorML.setXml(xbSensorML.xmlText());
    final SystemType xbEncodedSystem = encodeSystem(sensorML);
    assertThat(xbEncodedSystem.sizeOfContactArray(), is(1));
    assertThat(xbEncodedSystem.getContactArray(0).isSetPerson(), is(true));
    checkPerson(p1, xbEncodedSystem.getContactArray(0).getPerson());
}
Also used : SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) SystemType(net.opengis.sensorML.x101.SystemType) XmlObject(org.apache.xmlbeans.XmlObject) SensorML(org.n52.shetland.ogc.sensorML.SensorML) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Person(net.opengis.sensorML.x101.PersonDocument.Person) System(org.n52.shetland.ogc.sensorML.System) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Test(org.junit.jupiter.api.Test)

Example 28 with SystemType

use of org.geotoolkit.sml.xml.v101.SystemType in project arctic-sea by 52North.

the class SensorMLEncoderV101Test method should_set_gml_id.

@Test
public void should_set_gml_id() throws EncodingException {
    final SensorML sensorMl = new SensorML();
    final System system = new System();
    sensorMl.addMember(system);
    system.setGmlId(TEST_ID_1);
    final SystemType xbSystem = encodeSystem(sensorMl);
    assertThat(xbSystem.getId(), is(TEST_ID_1));
}
Also used : SystemType(net.opengis.sensorML.x101.SystemType) SensorML(org.n52.shetland.ogc.sensorML.SensorML) System(org.n52.shetland.ogc.sensorML.System) Test(org.junit.jupiter.api.Test)

Example 29 with SystemType

use of org.geotoolkit.sml.xml.v101.SystemType in project arctic-sea by 52North.

the class SensorMLEncoderV101Test method should_merge_and_encode_multiple_contacts.

@Test
public void should_merge_and_encode_multiple_contacts() throws EncodingException {
    final SensorML sensorML = new SensorML();
    final System system = new System();
    sensorML.addMember(system);
    final SmlPerson p1 = createPerson("1");
    final SmlResponsibleParty rp1 = createResponsibleParty("1");
    system.addContact(p1);
    system.addContact(rp1);
    final SensorMLDocument xbSensorML = SensorMLDocument.Factory.newInstance();
    final SystemType xbSystem = SystemType.Factory.newInstance();
    final ContactList xbContactList = xbSystem.addNewContact().addNewContactList();
    final Person xbP1 = xbContactList.addNewMember().addNewPerson();
    setPersonValues(p1, xbP1);
    final ResponsibleParty xbRP1 = xbContactList.addNewMember().addNewResponsibleParty();
    setResponsiblePartyValues(rp1, xbRP1);
    final XmlObject xbProcess = xbSensorML.addNewSensorML().addNewMember().addNewProcess().set(xbSystem);
    XmlHelper.substituteElement(xbProcess, xbSystem);
    xbSensorML.getSensorML().setVersion("1.0.1");
    sensorML.setXml(xbSensorML.xmlText());
    final SystemType xbEncodedSystem = encodeSystem(sensorML);
    assertThat(xbEncodedSystem.sizeOfContactArray(), is(1));
    assertThat(xbEncodedSystem.getContactArray(0).isSetContactList(), is(true));
    assertThat(xbEncodedSystem.getContactArray(0).getContactList().sizeOfMemberArray(), is(2));
    boolean personChecked = false, responsiblePartyChecked = false;
    for (final Member member : xbEncodedSystem.getContactArray(0).getContactList().getMemberArray()) {
        if (member.isSetPerson()) {
            checkPerson(p1, member.getPerson());
            personChecked = true;
        } else if (member.isSetResponsibleParty()) {
            checkResponsibleParty(rp1, member.getResponsibleParty());
            responsiblePartyChecked = true;
        }
    }
    if (!personChecked) {
        fail("sml:Person not found in contact/contactList");
    }
    if (!responsiblePartyChecked) {
        fail("sml:ResponsibleParty not found in contact/ContactList");
    }
}
Also used : SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) SystemType(net.opengis.sensorML.x101.SystemType) XmlObject(org.apache.xmlbeans.XmlObject) ContactList(net.opengis.sensorML.x101.ContactListDocument.ContactList) SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) ResponsibleParty(net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty) SensorML(org.n52.shetland.ogc.sensorML.SensorML) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Person(net.opengis.sensorML.x101.PersonDocument.Person) Member(net.opengis.sensorML.x101.ContactListDocument.ContactList.Member) System(org.n52.shetland.ogc.sensorML.System) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Test(org.junit.jupiter.api.Test)

Example 30 with SystemType

use of org.geotoolkit.sml.xml.v101.SystemType in project arctic-sea by 52North.

the class SensorMLEncoderV101Test method should_encode_single_contact_person.

// @Test
// public void should_encode_features_of_interest() throws EncodingException {
// final SensorML sensorMl = new SensorML();
// final System system = new System();
// sensorMl.addMember(system);
// system.addFeatureOfInterest(TEST_ID_1);
// system.addFeatureOfInterest(TEST_ID_2);
// final SimpleDataRecordType xbSimpleDataRecord =
// encodeSimpleDataRecord(sensorMl, SensorMLConstants.ELEMENT_NAME_FEATURES_OF_INTEREST, 2);
// validateField(xbSimpleDataRecord.getFieldArray()[0], SensorMLConstants.FEATURE_OF_INTEREST_FIELD_NAME + 1,
// SensorMLConstants.FEATURE_OF_INTEREST_FIELD_DEFINITION, TEST_ID_1);
// validateField(xbSimpleDataRecord.getFieldArray()[1], SensorMLConstants.FEATURE_OF_INTEREST_FIELD_NAME + 2,
// SensorMLConstants.FEATURE_OF_INTEREST_FIELD_DEFINITION, TEST_ID_2);
// }
// 
// @Test
// public void should_encode_offerings() throws EncodingException {
// final SensorML sensorMl = new SensorML();
// final System system = new System();
// sensorMl.addMember(system);
// system.addOffering(new SosOffering(TEST_ID_1, TEST_NAME_1));
// system.addOffering(new SosOffering(TEST_ID_2, TEST_NAME_2));
// final SimpleDataRecordType xbSimpleDataRecord =
// encodeSimpleDataRecord(sensorMl, SensorMLConstants.ELEMENT_NAME_OFFERINGS, 2);
// validateField(xbSimpleDataRecord.getFieldArray()[0], TEST_NAME_1, SensorMLConstants.OFFERING_FIELD_DEFINITION,
// TEST_ID_1);
// validateField(xbSimpleDataRecord.getFieldArray()[1], TEST_NAME_2, SensorMLConstants.OFFERING_FIELD_DEFINITION,
// TEST_ID_2);
// }
// 
// @Test
// public void should_encode_parent_procedures() throws EncodingException {
// final SensorML sensorMl = new SensorML();
// final System system = new System();
// sensorMl.addMember(system);
// system.addParentProcedure(TEST_ID_1);
// system.addParentProcedure(TEST_ID_2);
// final SimpleDataRecordType xbSimpleDataRecord =
// encodeSimpleDataRecord(sensorMl, SensorMLConstants.ELEMENT_NAME_PARENT_PROCEDURES, 2);
// validateField(xbSimpleDataRecord.getFieldArray()[0], SensorMLConstants.PARENT_PROCEDURE_FIELD_NAME + 1,
// SensorMLConstants.PARENT_PROCEDURE_FIELD_DEFINITION, TEST_ID_1);
// validateField(xbSimpleDataRecord.getFieldArray()[1], SensorMLConstants.PARENT_PROCEDURE_FIELD_NAME + 2,
// SensorMLConstants.PARENT_PROCEDURE_FIELD_DEFINITION, TEST_ID_2);
// }
// 
// @Test
// public void should_encode_child_procedures() throws EncodingException {
// final SensorML sensorMl = new SensorML();
// final System system = new System();
// sensorMl.addMember(system);
// final System childProcedure = new System();
// childProcedure.setIdentifier(TEST_CHILD_1);
// system.addChildProcedure(childProcedure);
// childProcedure.addFeatureOfInterest(TEST_ID_1);
// final SystemType xbSystemType = encodeSystem(sensorMl);
// assertThat(xbSystemType.getComponents().getComponentList().sizeOfComponentArray(), is(1));
// final Component xbComponent = xbSystemType.getComponents().getComponentList().getComponentArray(0);
// assertThat(xbComponent.getProcess(), instanceOf(SystemType.class));
// final SystemType xbComponentSystem = (SystemType) xbComponent.getProcess();
// final SimpleDataRecordType xbSimpleDataRecord =
// encodeSimpleDataRecord(xbComponentSystem, SensorMLConstants.ELEMENT_NAME_FEATURES_OF_INTEREST, 1);
// validateField(xbSimpleDataRecord.getFieldArray(0), SensorMLConstants.FEATURE_OF_INTEREST_FIELD_NAME,
// SensorMLConstants.FEATURE_OF_INTEREST_FIELD_DEFINITION, TEST_ID_1);
// }
// 
// @Test
// @SuppressWarnings("unchecked")
// public void should_aggregate_child_outputs() throws EncodingException {
// final SweQuantity q1 = new SweQuantity();
// q1.setDefinition("def1");
// q1.setUom("uom1");
// final SmlIo<?> output1 = new SmlIo<SweQuantity>(q1);
// 
// final SweQuantity q2 = new SweQuantity();
// q2.setDefinition("def2");
// q2.setUom("uom2");
// final SmlIo<?> output2 = new SmlIo<SweQuantity>(q2);
// 
// final SweQuantity q3 = new SweQuantity();
// q3.setDefinition("def3");
// q3.setUom("uom3");
// final SmlIo<?> output3 = new SmlIo<SweQuantity>(q3);
// 
// final SensorML sensorMl = new SensorML();
// sensorMl.setIdentifier("sensorMl");
// final System system = new System();
// system.setIdentifier("system");
// sensorMl.addMember(system);
// system.getOutputs().add(output1);
// 
// final SensorML childSml = new SensorML();
// childSml.setIdentifier("childSml");
// final System childSystem = new System();
// childSystem.setIdentifier("childSystem");
// childSml.addMember(childSystem);
// system.addChildProcedure(childSml);
// childSystem.getOutputs().add(output2);
// 
// final SensorML grandchildSml = new SensorML();
// grandchildSml.setIdentifier("grandchildSml");
// final System grandchildSystem = new System();
// grandchildSystem.setIdentifier("grandchildSystem");
// grandchildSml.addMember(grandchildSystem);
// childSystem.addChildProcedure(grandchildSml);
// grandchildSystem.getOutputs().add(output3);
// 
// encodeSystem(sensorMl);
// 
// assertThat(system.getOutputs(), hasItems(output1, output2, output3));
// assertThat(childSystem.getOutputs(), hasItems(output2, output3));
// assertThat(grandchildSystem.getOutputs(), hasItem(output3));
// }
@Test
public void should_encode_single_contact_person() throws EncodingException {
    final SensorML sensorML = new SensorML();
    final System system = new System();
    sensorML.addMember(system);
    final SmlPerson contact = createPerson("");
    system.addContact(contact);
    final SystemType xbSystem = encodeSystem(sensorML);
    assertThat(xbSystem.sizeOfContactArray(), is(1));
    assertThat(xbSystem.getContactArray(0).getContactList().getMemberArray(0).isSetPerson(), is(true));
    checkPerson(contact, xbSystem.getContactArray(0).getContactList().getMemberArray(0).getPerson());
}
Also used : SystemType(net.opengis.sensorML.x101.SystemType) SensorML(org.n52.shetland.ogc.sensorML.SensorML) System(org.n52.shetland.ogc.sensorML.System) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Test(org.junit.jupiter.api.Test)

Aggregations

SystemType (net.opengis.sensorML.x101.SystemType)24 Test (org.junit.jupiter.api.Test)18 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)15 SystemType (org.osate.aadl2.SystemType)14 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)13 ArrayList (java.util.ArrayList)12 System (org.n52.shetland.ogc.sensorML.System)11 EObject (org.eclipse.emf.ecore.EObject)9 SensorML (org.n52.shetland.ogc.sensorML.SensorML)9 AnnexSubclause (org.osate.aadl2.AnnexSubclause)8 IdentifierList (net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)6 PublicPackageSection (org.osate.aadl2.PublicPackageSection)6 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)5 HashSet (java.util.HashSet)5 SystemImplementation (org.osate.aadl2.SystemImplementation)5 SafetyReq (com.ge.research.osate.verdict.dsl.verdict.SafetyReq)4 Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)4 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)4 Component (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component)4 SmlPerson (org.n52.shetland.ogc.sensorML.SmlPerson)4