Search in sources :

Example 16 with RecordType

use of org.geotoolkit.csw.xml.v202.RecordType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method getRecordByIdResponseUnMarshalingTest.

/**
 * Test getRecordById request Marshalling.
 */
@Test
public void getRecordByIdResponseUnMarshalingTest() throws JAXBException {
    Unmarshaller unmarshaller = pool.acquireUnmarshaller();
    /*
         * Test marshalling csw getRecordByIdResponse v2.0.2
         */
    SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
    SimpleLiteral title = new SimpleLiteral("(JASON-1)");
    SimpleLiteral type = new SimpleLiteral("clearinghouse");
    List<SimpleLiteral> subject = new ArrayList<>();
    subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
    subject.add(new SimpleLiteral("oceans elevation 2"));
    SimpleLiteral modified = new SimpleLiteral("2007-11-15 21:26:49");
    SimpleLiteral Abstract = new SimpleLiteral("Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.");
    SimpleLiteral references = new SimpleLiteral("http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml");
    SimpleLiteral spatial = new SimpleLiteral("northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;");
    List<BoundingBoxType> bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    RecordType record = new RecordType(id, title, type, subject, null, modified, null, Abstract, bbox, null, null, null, spatial, references);
    BriefRecordType briefRecord = new BriefRecordType(id, title, type, bbox);
    SummaryRecordType sumRecord = new SummaryRecordType(id, title, type, bbox, subject, null, modified, Abstract);
    List<AbstractRecordType> records = new ArrayList<>();
    records.add(record);
    records.add(briefRecord);
    records.add(sumRecord);
    GetRecordByIdResponse expResult = new GetRecordByIdResponseType(records);
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:GetRecordByIdResponse xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dct=\"http://purl.org/dc/terms/\">\n" + "  <csw:Record>\n" + "    <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "    <dc:title>(JASON-1)</dc:title>\n" + "    <dc:type>clearinghouse</dc:type>\n" + "    <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + "    <dc:subject>oceans elevation 2</dc:subject>\n" + "    <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + "    <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + "    <dct:references>http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml</dct:references>\n" + "    <dct:spatial>northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;</dct:spatial>\n" + "    <ows:WGS84BoundingBox dimensions=\"2\">\n" + "      <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "      <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "    </ows:WGS84BoundingBox>\n" + "  </csw:Record>\n" + "  <csw:BriefRecord>\n" + "    <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "    <dc:title>(JASON-1)</dc:title>\n" + "    <dc:type>clearinghouse</dc:type>\n" + "    <ows:WGS84BoundingBox dimensions=\"2\">\n" + "      <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "      <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "    </ows:WGS84BoundingBox>\n" + "  </csw:BriefRecord>\n" + "  <csw:SummaryRecord>\n" + "    <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "    <dc:title>(JASON-1)</dc:title>\n" + "    <dc:type>clearinghouse</dc:type>\n" + "    <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + "    <dc:subject>oceans elevation 2</dc:subject>\n" + "    <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + "    <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + "    <ows:WGS84BoundingBox dimensions=\"2\">\n" + "      <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "      <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "    </ows:WGS84BoundingBox>\n" + "  </csw:SummaryRecord>\n" + "</csw:GetRecordByIdResponse>\n";
    GetRecordByIdResponse result = ((JAXBElement<GetRecordByIdResponse>) unmarshaller.unmarshal(new StringReader(xml))).getValue();
    assertTrue(result.getAny() instanceof List);
    List<Object> resultList = result.getAny();
    List<Object> expResultList = expResult.getAny();
    assertEquals(resultList.get(0), expResultList.get(0));
    assertEquals(resultList.get(1), expResultList.get(1));
    assertEquals(resultList.get(2), expResultList.get(2));
    assertEquals(resultList, expResultList);
    assertEquals(expResult.getAny(), result.getAny());
    assertEquals(expResult, result);
    pool.recycle(unmarshaller);
}
Also used : SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) AbstractRecordType(org.geotoolkit.csw.xml.v202.AbstractRecordType) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) GetRecordByIdResponseType(org.geotoolkit.csw.xml.v202.GetRecordByIdResponseType) AbstractRecordType(org.geotoolkit.csw.xml.v202.AbstractRecordType) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) RecordType(org.geotoolkit.csw.xml.v202.RecordType) StringReader(java.io.StringReader) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) List(java.util.List) ArrayList(java.util.ArrayList) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 17 with RecordType

use of org.geotoolkit.csw.xml.v202.RecordType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method updateMarshalingTest.

/**
 * Test simple Record Marshalling.
 */
@Test
public void updateMarshalingTest() throws JAXBException, IOException, ParserConfigurationException, SAXException {
    Marshaller marshaller = pool.acquireMarshaller();
    // <TODO
    SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
    SimpleLiteral title = new SimpleLiteral("(JASON-1)");
    SimpleLiteral type = new SimpleLiteral("clearinghouse");
    List<SimpleLiteral> subject = new ArrayList<>();
    subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
    subject.add(new SimpleLiteral("oceans elevation 2"));
    SimpleLiteral modified = new SimpleLiteral("2007-11-15 21:26:49");
    SimpleLiteral Abstract = new SimpleLiteral("Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.");
    SimpleLiteral references = new SimpleLiteral("http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml");
    SimpleLiteral spatial = new SimpleLiteral("northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;");
    List<BoundingBoxType> bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    RecordType record = new RecordType(id, title, type, subject, null, modified, null, Abstract, bbox, null, null, null, spatial, references);
    QueryConstraintType query = new QueryConstraintType("identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'", "1.1.0");
    UpdateType update = new UpdateType(record, query);
    TransactionType request = new TransactionType("CSW", "2.0.2", update);
    // marshaller.marshal(request, System.out);
    // TODO/>
    /*
         * Test 2 : Simple recordProperty (String)
         */
    RecordPropertyType recordProperty = new RecordPropertyType("/csw:Record/dc:contributor", "Jane");
    query = new QueryConstraintType("identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'", "1.1.0");
    update = new UpdateType(Arrays.asList(recordProperty), query);
    request = new TransactionType("CSW", "2.0.2", update);
    String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Transaction verboseResponse=\"false\" version=\"2.0.2\" service=\"CSW\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + "  <csw:Update>\n" + "    <csw:RecordProperty>\n" + "      <csw:Name>/csw:Record/dc:contributor</csw:Name>\n" + "      <csw:Value>Jane</csw:Value>\n" + "    </csw:RecordProperty>\n" + "    <csw:Constraint version=\"1.1.0\">\n" + "      <csw:CqlText>identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'</csw:CqlText>\n" + "    </csw:Constraint>\n" + "  </csw:Update>\n" + "</csw:Transaction>\n";
    StringWriter sw = new StringWriter();
    marshaller.marshal(request, sw);
    String result = sw.toString();
    assertXmlEquals(expResult, result, "xmlns:*");
    /*
         * Test 3 : Complex recordProperty (GeographicBoundingBox)
         */
    DefaultGeographicBoundingBox geographicElement = new DefaultGeographicBoundingBox(1.1, 1.1, 1.1, 1.1);
    recordProperty = new RecordPropertyType("/gmd:MD_Metadata/identificationInfo/extent/geographicElement", geographicElement);
    query = new QueryConstraintType("identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'", "1.1.0");
    update = new UpdateType(Arrays.asList(recordProperty), query);
    request = new TransactionType("CSW", "2.0.2", update);
    expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Transaction verboseResponse=\"false\" version=\"2.0.2\" service=\"CSW\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:gmd=\"http://www.isotc211.org/2005/gmd\" xmlns:gco=\"http://www.isotc211.org/2005/gco\">\n" + "  <csw:Update>\n" + "    <csw:RecordProperty>\n" + "      <csw:Name>/gmd:MD_Metadata/identificationInfo/extent/geographicElement</csw:Name>\n" + "      <csw:Value>\n" + "       <gmd:EX_GeographicBoundingBox>" + '\n' + "        <gmd:extentTypeCode>\n" + "          <gco:Boolean>true</gco:Boolean>\n" + "        </gmd:extentTypeCode>\n" + "        <gmd:westBoundLongitude>\n" + "          <gco:Decimal>1.1</gco:Decimal>\n" + "        </gmd:westBoundLongitude>\n" + "        <gmd:eastBoundLongitude>\n" + "          <gco:Decimal>1.1</gco:Decimal>\n" + "        </gmd:eastBoundLongitude>\n" + "        <gmd:southBoundLatitude>\n" + "          <gco:Decimal>1.1</gco:Decimal>\n" + "        </gmd:southBoundLatitude>\n" + "        <gmd:northBoundLatitude>\n" + "          <gco:Decimal>1.1</gco:Decimal>\n" + "        </gmd:northBoundLatitude>\n" + "       </gmd:EX_GeographicBoundingBox>" + '\n' + "      </csw:Value>\n" + "    </csw:RecordProperty>\n" + "    <csw:Constraint version=\"1.1.0\">\n" + "      <csw:CqlText>identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'</csw:CqlText>\n" + "    </csw:Constraint>\n" + "  </csw:Update>\n" + "</csw:Transaction>\n";
    sw = new StringWriter();
    marshaller.marshal(request, sw);
    result = sw.toString();
    assertXmlEquals(expResult, result, "xmlns:*");
    pool.recycle(marshaller);
}
Also used : RecordPropertyType(org.geotoolkit.csw.xml.v202.RecordPropertyType) Marshaller(javax.xml.bind.Marshaller) TransactionType(org.geotoolkit.csw.xml.v202.TransactionType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) ArrayList(java.util.ArrayList) UpdateType(org.geotoolkit.csw.xml.v202.UpdateType) QueryConstraintType(org.geotoolkit.csw.xml.v202.QueryConstraintType) BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox) AbstractRecordType(org.geotoolkit.csw.xml.v202.AbstractRecordType) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) RecordType(org.geotoolkit.csw.xml.v202.RecordType) StringWriter(java.io.StringWriter) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) Test(org.junit.Test)

Example 18 with RecordType

use of org.geotoolkit.csw.xml.v202.RecordType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method recordMarshalingTest.

/**
 * Test simple Record Marshalling.
 */
@Test
public void recordMarshalingTest() throws JAXBException {
    Marshaller marshaller = pool.acquireMarshaller();
    /*
         * Test marshalling csw Record v2.0.2
         */
    SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
    SimpleLiteral title = new SimpleLiteral("(JASON-1)");
    SimpleLiteral type = new SimpleLiteral("clearinghouse");
    List<SimpleLiteral> subject = new ArrayList<>();
    subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
    subject.add(new SimpleLiteral("oceans elevation 2"));
    SimpleLiteral modified = new SimpleLiteral("2007-11-15 21:26:49");
    SimpleLiteral Abstract = new SimpleLiteral("Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.");
    SimpleLiteral references = new SimpleLiteral("http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml");
    SimpleLiteral spatial = new SimpleLiteral("northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;");
    List<BoundingBoxType> bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    RecordType record = new RecordType(id, title, type, subject, null, modified, null, Abstract, bbox, null, null, null, spatial, references);
    StringWriter sw = new StringWriter();
    marshaller.marshal(record, sw);
    String result = sw.toString();
    String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Record xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dct=\"http://purl.org/dc/terms/\">\n" + "  <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "  <dc:title>(JASON-1)</dc:title>\n" + "  <dc:type>clearinghouse</dc:type>\n" + "  <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + "  <dc:subject>oceans elevation 2</dc:subject>\n" + "  <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + "  <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + "  <dct:references>http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml</dct:references>\n" + "  <dct:spatial>northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;</dct:spatial>\n" + "  <ows:WGS84BoundingBox dimensions=\"2\">\n" + "    <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "    <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "  </ows:WGS84BoundingBox>\n" + "</csw:Record>\n";
    assertXmlEquals(expResult, result, "xmlns:*");
    pool.recycle(marshaller);
}
Also used : BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) Marshaller(javax.xml.bind.Marshaller) AbstractRecordType(org.geotoolkit.csw.xml.v202.AbstractRecordType) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) RecordType(org.geotoolkit.csw.xml.v202.RecordType) StringWriter(java.io.StringWriter) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) ArrayList(java.util.ArrayList) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) Test(org.junit.Test)

Example 19 with RecordType

use of org.geotoolkit.csw.xml.v202.RecordType in project osate2 by osate.

the class PropertiesLinkingService method getLinkedObjects.

/**
 * returns the first linked object
 */
@Override
public List<EObject> getLinkedObjects(EObject context, EReference reference, INode node) throws IllegalNodeException {
    final EClass requiredType = reference.getEReferenceType();
    if (requiredType == null) {
        return Collections.<EObject>emptyList();
    }
    EObject searchResult = null;
    final EClass cl = Aadl2Package.eINSTANCE.getClassifier();
    final EClass sct = Aadl2Package.eINSTANCE.getSubcomponentType();
    final EClass pt = Aadl2Package.eINSTANCE.getPropertyType();
    final String name = getCrossRefNodeAsString(node);
    if (sct.isSuperTypeOf(requiredType) || cl.isSuperTypeOf(requiredType)) {
        // XXX: this code can be replicated in Aadl2LinkingService as it is called often in the core
        // resolve classifier reference
        EObject e = findClassifier(context, reference, name);
        if (e != null) {
            // the result satisfied the expected class
            return Collections.singletonList(e);
        }
        if (!(context instanceof Generalization) && sct.isSuperTypeOf(requiredType)) {
            // need to resolve prototype
            EObject res = AadlUtil.getContainingClassifier(context).findNamedElement(name);
            if (Aadl2Package.eINSTANCE.getDataPrototype() == reference) {
                if (res instanceof DataPrototype) {
                    searchResult = res;
                }
            } else if (res instanceof ComponentPrototype) {
                searchResult = res;
            }
        }
    } else if (Aadl2Package.eINSTANCE.getModelUnit() == requiredType) {
        AadlPackage pack = findAadlPackage(context, name, reference);
        if (pack != null) {
            searchResult = pack;
        } else {
            PropertySet ps = findPropertySet(context, name, reference);
            if (ps != null) {
                searchResult = ps;
            }
        }
    } else if (Aadl2Package.eINSTANCE.getAadlPackage() == requiredType) {
        AadlPackage pack = findAadlPackage(context, name, reference);
        if (pack != null) {
            searchResult = pack;
        }
    } else if (Aadl2Package.eINSTANCE.getPropertySet() == requiredType) {
        PropertySet ps = findPropertySet(context, name, reference);
        if (ps != null) {
            searchResult = ps;
        }
    } else if (Aadl2Package.eINSTANCE.getFeature().isSuperTypeOf(requiredType)) {
        if (context instanceof Feature) {
            // Feature referenced in feature refinement
            Classifier ns = AadlUtil.getContainingClassifier(context);
            // we need to resolve a refinement
            if (ns.getExtended() != null) {
                EObject res = ns.getExtended().findNamedElement(name);
                if (res != null && res instanceof Feature) {
                    searchResult = res;
                }
            } else {
                return Collections.emptyList();
            }
        } else if (context instanceof FlowEnd) {
            FlowEnd flowEnd = (FlowEnd) context;
            searchResult = findElementInContext(flowEnd, flowEnd.getContext(), name, Feature.class);
        }
    } else if (Aadl2Package.eINSTANCE.getSubcomponent().isSuperTypeOf(requiredType)) {
        // if context Subcomponent then find in extension source (refined
        // to)
        // prototype binding as context
        Classifier ns = AadlUtil.getContainingClassifier(context);
        if (context instanceof Subcomponent) {
            // we need to resolve a refinement
            if (ns.getExtended() != null) {
                ns = ns.getExtended();
            } else {
                return Collections.emptyList();
            }
        }
        EObject res = ns.findNamedElement(name);
        if (res instanceof Subcomponent) {
            searchResult = res;
        }
    } else if (Aadl2Package.eINSTANCE.getProperty() == requiredType) {
        // look for property definition in property set
        return findPropertyDefinitionAsList(context, reference, name);
    } else if (Aadl2Package.eINSTANCE.getAbstractNamedValue() == requiredType) {
        // AbstractNamedValue: constant reference, property definition reference, unit literal, enumeration literal
        if (context instanceof NamedValue) {
            List<EObject> res = Collections.EMPTY_LIST;
            if (name.indexOf("::") == -1) {
                // names without qualifier. Must be enum/unit literal
                res = findEnumLiteralAsList(context, reference, name);
                if (res.isEmpty()) {
                    res = findUnitLiteralAsList(context, reference, name);
                }
            }
            if (res.isEmpty()) {
                res = findPropertyConstant(context, reference, name);
            }
            if (res.isEmpty()) {
                res = findPropertyDefinitionAsList(context, reference, name);
            }
            return res;
        }
    } else if (Aadl2Package.eINSTANCE.getBasicProperty() == requiredType) {
        // look for record field definition
        if (context instanceof BasicPropertyAssociation) {
            BasicPropertyAssociation bpa = (BasicPropertyAssociation) context;
            // TODO: Need to check that the type of the record field is
            // correct for the value.
            Element parent = bpa.getOwner();
            while (parent != null && !(parent instanceof BasicPropertyAssociation || parent instanceof PropertyAssociation || parent instanceof Property || parent instanceof PropertyConstant)) {
                parent = parent.getOwner();
            }
            PropertyType propertyType = null;
            if (parent instanceof BasicPropertyAssociation) {
                BasicProperty bp = ((BasicPropertyAssociation) parent).getProperty();
                if (bp != null) {
                    propertyType = bp.getPropertyType();
                }
            } else if (parent instanceof PropertyAssociation) {
                Property pd = ((PropertyAssociation) parent).getProperty();
                if (pd != null) {
                    propertyType = pd.getPropertyType();
                }
            } else if (parent instanceof Property) {
                propertyType = ((Property) parent).getPropertyType();
            } else if (parent instanceof PropertyConstant) {
                propertyType = ((PropertyConstant) parent).getPropertyType();
            }
            propertyType = AadlUtil.getBasePropertyType(propertyType);
            if (propertyType != null && propertyType instanceof RecordType) {
                BasicProperty rf = (BasicProperty) ((RecordType) propertyType).findNamedElement(name);
                if (rf != null) {
                    searchResult = rf;
                }
            }
        }
    } else if (pt.isSuperTypeOf(requiredType)) {
        // look for property type in property set
        return findPropertyType(context, reference, name);
    } else if (Aadl2Package.eINSTANCE.getPropertyConstant() == requiredType) {
        // look for property constant in property set
        return findPropertyConstant(context, reference, name);
    } else if (Aadl2Package.eINSTANCE.getUnitLiteral() == requiredType) {
        // look for unit literal pointed to by baseUnit
        return findUnitLiteralAsList(context, reference, name);
    } else if (Aadl2Package.eINSTANCE.getEnumerationLiteral() == requiredType) {
        // look for enumeration literal
        return findEnumLiteralAsList(context, reference, name);
    } else if (Aadl2Package.eINSTANCE.getMode() == requiredType) {
        // referenced by mode transition, inmodes, ModeBinding
        EObject res = null;
        if (context instanceof ModeBinding) {
            if (reference == Aadl2Package.eINSTANCE.getModeBinding_ParentMode()) {
                res = AadlUtil.getContainingClassifier(context).findNamedElement(name);
            } else if (reference == Aadl2Package.eINSTANCE.getModeBinding_DerivedMode()) {
                Subcomponent subcomponent = AadlUtil.getContainingSubcomponent(context);
                while (subcomponent.getSubcomponentType() == null && subcomponent.getRefined() != null) {
                    subcomponent = subcomponent.getRefined();
                }
                ComponentClassifier subcomponentClassifier = null;
                if (subcomponent.getSubcomponentType() instanceof ComponentClassifier) {
                    subcomponentClassifier = ((ComponentClassifier) subcomponent.getSubcomponentType());
                } else if (subcomponent.getSubcomponentType() instanceof ComponentPrototype) {
                    subcomponentClassifier = findClassifierForComponentPrototype(AadlUtil.getContainingClassifier(context), ((ComponentPrototype) subcomponent.getSubcomponentType()));
                }
                if (subcomponentClassifier != null) {
                    res = subcomponentClassifier.findNamedElement(name);
                }
            }
        } else {
            // check about in modes in a contained property association
            PropertyAssociation pa = AadlUtil.getContainingPropertyAssociation(context);
            if (pa != null && !pa.getAppliesTos().isEmpty()) {
                ContainedNamedElement path = pa.getAppliesTos().get(0);
                EList<ContainmentPathElement> cpelist = path.getContainmentPathElements();
                Subcomponent cpesub = null;
                for (ContainmentPathElement containmentPathElement : cpelist) {
                    if (containmentPathElement.getNamedElement() instanceof Subcomponent) {
                        cpesub = (Subcomponent) containmentPathElement.getNamedElement();
                    } else {
                        break;
                    }
                }
                if (cpesub != null) {
                    if (cpesub.getAllClassifier() != null) {
                        res = cpesub.getAllClassifier().findNamedElement(name);
                    }
                } else {
                    res = AadlUtil.getContainingClassifier(context).findNamedElement(name);
                }
            } else {
                if ((pa != null) && (pa.getOwner() instanceof Subcomponent)) {
                    Subcomponent subco = (Subcomponent) pa.getOwner();
                    if (subco.getAllClassifier() != null) {
                        res = subco.getAllClassifier().findNamedElement(name);
                    }
                } else {
                    res = AadlUtil.getContainingClassifier(context).findNamedElement(name);
                }
            }
        }
        if (res != null && res instanceof Mode) {
            searchResult = res;
        }
    } else if (Aadl2Package.eINSTANCE.getNamedElement() == requiredType) {
        // containment path element
        if (context instanceof ContainmentPathElement) {
            EObject res = null;
            if (((ContainmentPathElement) context).getOwner() instanceof ContainmentPathElement) {
                // find next element in namespace of previous element
                ContainmentPathElement el = (ContainmentPathElement) ((ContainmentPathElement) context).getOwner();
                NamedElement ne = el.getNamedElement();
                if (ne instanceof Subcomponent) {
                    Subcomponent subcomponent = (Subcomponent) ne;
                    while (subcomponent.getSubcomponentType() == null && subcomponent.getRefined() != null) {
                        subcomponent = subcomponent.getRefined();
                    }
                    ComponentClassifier ns = null;
                    if (subcomponent.getSubcomponentType() instanceof ComponentClassifier) {
                        ns = (ComponentClassifier) subcomponent.getSubcomponentType();
                    } else if (subcomponent.getSubcomponentType() instanceof ComponentPrototype) {
                        ns = ResolvePrototypeUtil.resolveComponentPrototype((ComponentPrototype) subcomponent.getSubcomponentType(), el);
                    }
                    if (ns != null) {
                        res = ns.findNamedElement(name);
                        if (res == null && (ne instanceof ThreadSubcomponent || ne instanceof SubprogramSubcomponent || ne instanceof AbstractSubcomponent) && ns instanceof BehavioredImplementation) {
                            res = AadlUtil.findNamedElementInList(((BehavioredImplementation) ns).subprogramCalls(), name);
                        }
                    }
                } else if (ne instanceof FeatureGroup) {
                    FeatureGroup featureGroup = (FeatureGroup) ne;
                    while (featureGroup.getFeatureType() == null && featureGroup.getRefined() instanceof FeatureGroup) {
                        featureGroup = (FeatureGroup) featureGroup.getRefined();
                    }
                    FeatureGroupType ns = null;
                    if (featureGroup.getFeatureType() instanceof FeatureGroupType) {
                        ns = (FeatureGroupType) featureGroup.getFeatureType();
                    } else if (featureGroup.getFeatureType() instanceof FeatureGroupPrototype) {
                        ns = ResolvePrototypeUtil.resolveFeatureGroupPrototype((FeatureGroupPrototype) featureGroup.getFeatureType(), el);
                    }
                    if (ns != null) {
                        res = ns.findNamedElement(name);
                    }
                }
            } else {
                // the first containment path element
                Classifier ns = null;
                PropertyAssociation containingPropertyAssociation = AadlUtil.getContainingPropertyAssociation(context);
                if (containingPropertyAssociation != null) {
                    // need to make sure we look in the correct name space
                    if (containingPropertyAssociation.getOwner() instanceof Subcomponent) {
                        Subcomponent subcomponent = (Subcomponent) containingPropertyAssociation.getOwner();
                        while (subcomponent.getSubcomponentType() == null && subcomponent.getRefined() != null) {
                            subcomponent = subcomponent.getRefined();
                        }
                        if (subcomponent.getSubcomponentType() instanceof ComponentClassifier) {
                            ns = (ComponentClassifier) subcomponent.getSubcomponentType();
                        } else if (subcomponent.getSubcomponentType() instanceof ComponentPrototype) {
                            ns = ResolvePrototypeUtil.resolveComponentPrototype((ComponentPrototype) subcomponent.getSubcomponentType(), AadlUtil.getContainingClassifier(context));
                        }
                    } else if (containingPropertyAssociation.getOwner() instanceof FeatureGroup) {
                        FeatureGroup fg = (FeatureGroup) containingPropertyAssociation.getOwner();
                        while (fg.getFeatureType() == null && fg.getRefined() instanceof FeatureGroup) {
                            fg = (FeatureGroup) fg.getRefined();
                        }
                        if (fg.getFeatureType() instanceof FeatureGroupType) {
                            ns = (FeatureGroupType) fg.getFeatureType();
                        } else if (fg.getFeatureType() instanceof FeatureGroupPrototype) {
                            ns = ResolvePrototypeUtil.resolveFeatureGroupPrototype((FeatureGroupPrototype) fg.getFeatureType(), AadlUtil.getContainingClassifier(context));
                        }
                    } else {
                        ns = containingPropertyAssociation.getContainingClassifier();
                    }
                }
                if (ns != null) {
                    res = ns.findNamedElement(name);
                }
            }
            if (res != null && res instanceof NamedElement) {
                searchResult = res;
            }
        }
    } else {
        List<EObject> superes = super.getLinkedObjects(context, reference, node);
        return superes;
    }
    if (searchResult != null) {
        return Collections.singletonList(searchResult);
    }
    return Collections.<EObject>emptyList();
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) FeatureGroup(org.osate.aadl2.FeatureGroup) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Element(org.osate.aadl2.Element) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) AbstractSubcomponent(org.osate.aadl2.AbstractSubcomponent) FeatureGroupType(org.osate.aadl2.FeatureGroupType) NamedValue(org.osate.aadl2.NamedValue) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) PropertyType(org.osate.aadl2.PropertyType) Generalization(org.osate.aadl2.Generalization) Feature(org.osate.aadl2.Feature) ComponentPrototype(org.osate.aadl2.ComponentPrototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) BasicProperty(org.osate.aadl2.BasicProperty) EClass(org.eclipse.emf.ecore.EClass) RecordType(org.osate.aadl2.RecordType) EObject(org.eclipse.emf.ecore.EObject) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) ThreadSubcomponent(org.osate.aadl2.ThreadSubcomponent) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) AbstractSubcomponent(org.osate.aadl2.AbstractSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) List(java.util.List) EList(org.eclipse.emf.common.util.EList) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) AadlPackage(org.osate.aadl2.AadlPackage) BehavioredImplementation(org.osate.aadl2.BehavioredImplementation) Mode(org.osate.aadl2.Mode) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) DataPrototype(org.osate.aadl2.DataPrototype) PropertyConstant(org.osate.aadl2.PropertyConstant) ThreadSubcomponent(org.osate.aadl2.ThreadSubcomponent) EList(org.eclipse.emf.common.util.EList) PropertySet(org.osate.aadl2.PropertySet) ModeBinding(org.osate.aadl2.ModeBinding) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) FlowEnd(org.osate.aadl2.FlowEnd)

Example 20 with RecordType

use of org.geotoolkit.csw.xml.v202.RecordType in project openaire-cris-validator by EuroCRIS.

the class FileLoggingConnectionStreamFactory method wrapCheckOAIIdentifier.

private CheckingIterable<RecordType> wrapCheckOAIIdentifier(final CheckingIterable<RecordType> checker) {
    final Optional<String> repoIdentifier = endpoint.getRepositoryIdentifer();
    if (repoIdentifier.isPresent()) {
        final Function<RecordType, Set<String>> expectedFunction = new Function<RecordType, Set<String>>() {

            @Override
            public Set<String> apply(final RecordType x) {
                final MetadataType metadata = x.getMetadata();
                final Set<String> results = new HashSet<>();
                if (metadata != null) {
                    final Element el = (Element) metadata.getAny();
                    final String id = el.getAttribute("id");
                    results.add("oai:" + repoIdentifier.get() + ":" + el.getLocalName() + "s/" + id);
                    results.add("oai:" + repoIdentifier.get() + ":" + id);
                } else {
                    // make the test trivially satisfied for records with no metadata
                    results.add(x.getHeader().getIdentifier());
                }
                return results;
            }
        };
        return checker.checkForAllValueInSet(expectedFunction, ((final RecordType record) -> record.getHeader().getIdentifier()), "OAI identifier other than expected");
    } else {
        return checker;
    }
}
Also used : Function(java.util.function.Function) Set(java.util.Set) HashSet(java.util.HashSet) RecordType(org.openarchives.oai._2.RecordType) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) MetadataType(org.openarchives.oai._2.MetadataType) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)8 AbstractRecordType (org.geotoolkit.csw.xml.v202.AbstractRecordType)7 BriefRecordType (org.geotoolkit.csw.xml.v202.BriefRecordType)7 RecordType (org.geotoolkit.csw.xml.v202.RecordType)7 SummaryRecordType (org.geotoolkit.csw.xml.v202.SummaryRecordType)7 SimpleLiteral (org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral)7 BoundingBoxType (org.geotoolkit.ows.xml.v100.BoundingBoxType)7 WGS84BoundingBoxType (org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType)7 Test (org.junit.Test)7 List (java.util.List)6 RecordType (org.openarchives.oai._2.RecordType)6 OAIPMH (org.openarchives.oai._2.OAIPMH)5 ResumptionTokenType (org.openarchives.oai._2.ResumptionTokenType)5 StringWriter (java.io.StringWriter)4 Marshaller (javax.xml.bind.Marshaller)4 Property (org.osate.aadl2.Property)4 RecordType (org.osate.aadl2.RecordType)4 JAXBElement (javax.xml.bind.JAXBElement)3 BasicProperty (org.osate.aadl2.BasicProperty)3 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)3