Search in sources :

Example 11 with If

use of org.w3._2007.rif.If in project hale by halestudio.

the class TestModelRifToRifTranslator method testTranslateExample3CP.

/**
 * Tests that it is possible to translate the example 3 CP source dataset.
 *
 * @throws TranslationException
 *             if any errors occurred during the translation
 */
@Test
public void testTranslateExample3CP() throws TranslationException {
    URL url = getClass().getClassLoader().getResource(// $NON-NLS-1$
    "com/onespatial/jrc/tnstg/oml_to_rif/alignments/example3_cp.goml");
    org.w3._2007.rif.Document doc = translator.translate(url);
    assertNotNull(doc);
    assertNotNull(doc.getPayload());
    assertNotNull(doc.getPayload().getGroup());
    assertNotNull(doc.getPayload().getGroup().getSentence());
    assertThat(doc.getPayload().getGroup().getSentence().size(), is(1));
    assertNotNull(doc.getPayload().getGroup().getSentence().get(0));
    checkJavaBindings(doc);
}
Also used : URL(java.net.URL) Document(org.w3._2007.rif.Document) DomBasedUnitTest(com.onespatial.jrc.tns.oml_to_rif.fixture.DomBasedUnitTest) Test(org.junit.Test)

Example 12 with If

use of org.w3._2007.rif.If in project hale by halestudio.

the class TestModelRifToRifTranslator method testTranslateExample3CPSimpleFilter.

/**
 * Tests that it is possible to translate the example 3 CP source dataset,
 * including a simple predicate filter.
 *
 * @throws TranslationException
 *             if any errors occurred during the translation
 * @throws JAXBException
 *             if unable to write out a DOM document containing the RIF-PRD
 */
@Test
public void testTranslateExample3CPSimpleFilter() throws TranslationException, JAXBException {
    URL url = getClass().getClassLoader().getResource(// $NON-NLS-1$
    "com/onespatial/jrc/tnstg/proto/oml_to_rif/alignments/example3_cp_filter.goml");
    org.w3._2007.rif.Document doc = translator.translate(url);
    assertNotNull(doc);
    assertNotNull(doc.getPayload());
    assertNotNull(doc.getPayload().getGroup());
    assertNotNull(doc.getPayload().getGroup().getSentence());
    assertThat(doc.getPayload().getGroup().getSentence().size(), is(1));
    assertNotNull(doc.getPayload().getGroup().getSentence().get(0));
    checkJavaBindings(doc);
    writeDom(getDomFromRif(doc), System.out);
}
Also used : URL(java.net.URL) Document(org.w3._2007.rif.Document) DomBasedUnitTest(com.onespatial.jrc.tns.oml_to_rif.fixture.DomBasedUnitTest) Test(org.junit.Test)

Example 13 with If

use of org.w3._2007.rif.If in project hale by halestudio.

the class TestModelRifToRifTranslator method testTranslateExample3CPComplexFilter.

/**
 * Tests that it is possible to translate the example 3 CP source dataset,
 * including a slightly more complex predicate filter.
 *
 * @throws TranslationException
 *             if any errors occurred during the translation
 * @throws JAXBException
 *             if unable to write out a DOM document containing the RIF-PRD
 */
@Test
public void testTranslateExample3CPComplexFilter() throws TranslationException, JAXBException {
    URL url = getClass().getClassLoader().getResource(// $NON-NLS-1$
    "com/onespatial/jrc/tnstg/proto/oml_to_rif/alignments/example3_complex_logical_filter.goml");
    org.w3._2007.rif.Document doc = translator.translate(url);
    assertNotNull(doc);
    assertNotNull(doc.getPayload());
    assertNotNull(doc.getPayload().getGroup());
    assertNotNull(doc.getPayload().getGroup().getSentence());
    assertThat(doc.getPayload().getGroup().getSentence().size(), is(1));
    assertNotNull(doc.getPayload().getGroup().getSentence().get(0));
    checkJavaBindings(doc);
    writeDom(getDomFromRif(doc), System.out);
}
Also used : URL(java.net.URL) Document(org.w3._2007.rif.Document) DomBasedUnitTest(com.onespatial.jrc.tns.oml_to_rif.fixture.DomBasedUnitTest) Test(org.junit.Test)

Example 14 with If

use of org.w3._2007.rif.If in project hale by halestudio.

the class TestModelRifToRifTranslator method checkDoElements.

private void checkDoElements(Do do1) {
    assertNotNull(do1.getActionVar());
    assertTrue(do1.getActionVar().size() >= 1);
    // count number of news and frames in the collection
    int numNews = 0;
    int numFrames = 0;
    for (ActionVar v : do1.getActionVar()) {
        assertNotNull(v);
        if (v.getNew() != null) {
            numNews++;
            checkActionVarTypeNew(v);
        }
        if (v.getFrame() != null) {
            numFrames++;
            checkActionVarTypeFrame(v);
        }
    }
    assertThat(numNews, is(equalTo(1)));
    int numAsserts = 0;
    for (Object action : do1.getActions().getACTION()) {
        assertTrue(action instanceof org.w3._2007.rif.Assert);
        numAsserts++;
        org.w3._2007.rif.Assert a = (org.w3._2007.rif.Assert) action;
        assertNotNull(a);
        checkAssertTarget(a);
    }
    // CHECKSTYLE:OFF
    assertThat(numAsserts, is(equalTo(3)));
// CHECKSTYLE:ON
}
Also used : ActionVar(org.w3._2007.rif.Do.ActionVar) Assert(org.w3._2007.rif.Assert) Assert(org.w3._2007.rif.Assert)

Example 15 with If

use of org.w3._2007.rif.If in project hale by halestudio.

the class ModelRifToRifTranslator method createLogicalFilter.

private void createLogicalFilter(List<Formula> list, ModelRifMappingCondition mappingCondition) {
    // $NON-NLS-1$
    log.fine("Creating logical filter");
    Formula logicFilterFormula = factory.createFormula();
    if (mappingCondition.getLogicalType().equals(NOT)) {
        INeg negation = factory.createINeg();
        logicFilterFormula.setINeg(negation);
        // Formula subNegationFormula = factory.createFormula();
        List<Formula> notList = new ArrayList<Formula>();
        // notList.add(subNegationFormula);
        createChildFilters(mappingCondition, notList);
        negation.setFormula(notList.get(0));
        // $NON-NLS-1$
        log.fine("Filter is a NOT filter");
    } else {
        if (mappingCondition.getLogicalType().equals(AND)) {
            And and1 = factory.createAnd();
            logicFilterFormula.setAnd(and1);
            createChildFilters(mappingCondition, and1.getFormula());
            // $NON-NLS-1$
            log.fine("Filter is an AND filter");
        } else if (mappingCondition.getLogicalType().equals(OR)) {
            Or or = factory.createOr();
            logicFilterFormula.setOr(or);
            createChildFilters(mappingCondition, or.getFormula());
            // $NON-NLS-1$
            log.fine("Filter is an OR filter");
        }
    }
    list.add(logicFilterFormula);
}
Also used : Formula(org.w3._2007.rif.Formula) Or(org.w3._2007.rif.Or) INeg(org.w3._2007.rif.INeg) And(org.w3._2007.rif.And) ArrayList(java.util.ArrayList)

Aggregations

Actuate (org.n52.shetland.w3c.xlink.Actuate)15 Show (org.n52.shetland.w3c.xlink.Show)15 ActuateType (org.w3.x1999.xlink.ActuateType)15 ShowType (org.w3.x1999.xlink.ShowType)15 Reference (org.n52.shetland.w3c.xlink.Reference)14 Type (org.n52.shetland.w3c.xlink.Type)14 TypeType (org.w3.x1999.xlink.TypeType)14 IOException (java.io.IOException)13 XmlObject (org.apache.xmlbeans.XmlObject)11 AbstractCRSType (net.opengis.gml.x32.AbstractCRSType)10 CodeType (net.opengis.gml.x32.CodeType)10 EXExtentType (org.isotc211.x2005.gmd.EXExtentType)10 ProvideAndRegisterDocumentSetRequestType (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)9 ArrayList (java.util.ArrayList)8 CIResponsiblePartyPropertyType (org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType)8 CIResponsiblePartyType (org.isotc211.x2005.gmd.CIResponsiblePartyType)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 BaseUnitType (net.opengis.gml.x32.BaseUnitType)6 VerticalDatumPropertyType (net.opengis.gml.x32.VerticalDatumPropertyType)5 VerticalDatumType (net.opengis.gml.x32.VerticalDatumType)5