Search in sources :

Example 41 with If

use of org.w3._2007.rif.If in project poi by apache.

the class RelationshipTransformService method init.

@Override
public void init(XMLStructure parent, XMLCryptoContext context) throws InvalidAlgorithmParameterException {
    LOG.log(POILogger.DEBUG, "init(parent,context)");
    LOG.log(POILogger.DEBUG, "parent java type: " + parent.getClass().getName());
    DOMStructure domParent = (DOMStructure) parent;
    Node parentNode = domParent.getNode();
    try {
        TransformDocument transDoc = TransformDocument.Factory.parse(parentNode, DEFAULT_XML_OPTIONS);
        XmlObject[] xoList = transDoc.getTransform().selectChildren(RelationshipReferenceDocument.type.getDocumentElementName());
        if (xoList.length == 0) {
            LOG.log(POILogger.WARN, "no RelationshipReference/@SourceId parameters present");
        }
        for (XmlObject xo : xoList) {
            String sourceId = ((CTRelationshipReference) xo).getSourceId();
            LOG.log(POILogger.DEBUG, "sourceId: ", sourceId);
            this.sourceIds.add(sourceId);
        }
    } catch (XmlException e) {
        throw new InvalidAlgorithmParameterException(e);
    }
}
Also used : InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) XmlException(org.apache.xmlbeans.XmlException) Node(org.w3c.dom.Node) DOMStructure(javax.xml.crypto.dom.DOMStructure) TransformDocument(org.w3.x2000.x09.xmldsig.TransformDocument) XmlObject(org.apache.xmlbeans.XmlObject) CTRelationshipReference(org.openxmlformats.schemas.xpackage.x2006.digitalSignature.CTRelationshipReference)

Example 42 with If

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

the class TestModelRifToRifTranslator method checkJavaBindings.

private Sentence checkJavaBindings(Document result) {
    assertNotNull(result);
    assertNotNull(result.getPayload());
    assertNotNull(result.getPayload().getGroup());
    assertNotNull(result.getPayload().getGroup().getSentence());
    assertThat(result.getPayload().getGroup().getSentence().size(), is(1));
    Sentence actualSentence = result.getPayload().getGroup().getSentence().get(0);
    assertNotNull(actualSentence.getImplies());
    assertNotNull(actualSentence.getImplies().getIf());
    assertNotNull(actualSentence.getImplies().getIf().getExists());
    assertNotNull(actualSentence.getImplies().getThen());
    assertNotNull(actualSentence.getImplies().getThen().getDo());
    checkDoElements(actualSentence.getImplies().getThen().getDo());
    // check contents of if
    And and = checkDeclareElement(actualSentence);
    checkAndChildren(and);
    return actualSentence;
}
Also used : And(org.w3._2007.rif.And) Sentence(org.w3._2007.rif.Sentence)

Example 43 with If

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

the class TestModelRifToRifTranslator method testTranslateExample1NegationFilter.

/**
 * Tests that it is possible to translate the example 3 CP source dataset,
 * including a logical negation 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 testTranslateExample1NegationFilter() throws TranslationException, JAXBException {
    URL url = getClass().getClassLoader().getResource(// $NON-NLS-1$
    "com/onespatial/jrc/tnstg/proto/oml_to_rif/alignments/example1_tn_road.goml");
    org.w3._2007.rif.Document doc = translator.translate(url);
    assertNotNull(doc);
    assertNotNull(doc.getPayload());
    assertNotNull(doc.getPayload().getGroup());
    assertNotNull(doc.getPayload().getGroup().getSentence());
    // CHECKSTYLE:OFF
    assertThat(doc.getPayload().getGroup().getSentence().size(), is(3));
    // CHECKSTYLE:ON
    assertNotNull(doc.getPayload().getGroup().getSentence().get(0));
    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 44 with If

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

the class ModelRifToRifTranslator method createExternalPredicateFilter.

private void createExternalPredicateFilter(ModelRifMappingCondition mappingCondition, Formula filterFormula) {
    // create an <External>/<content>/<Atom> element hierarchy
    ExternalFORMULAType external = factory.createExternalFORMULAType();
    filterFormula.setExternal(external);
    ContentFORMULAType content = factory.createContentFORMULAType();
    external.setContent(content);
    Atom atom = factory.createAtom();
    content.setAtom(atom);
    Op op = factory.createOp();
    ArgsUNITERMType args = factory.createArgsUNITERMType();
    atom.setOp(op);
    Const opConst = factory.createConst();
    // $NON-NLS-1$
    opConst.setType("rif:iri");
    opConst.getContent().add(mappingCondition.getOperator().getRifPredicate());
    op.setConst(opConst);
    atom.setArgs(args);
    // $NON-NLS-1$
    args.setOrdered("yes");
    Var var = factory.createVar();
    var.getContent().add(mappingCondition.getLeft().getName());
    args.getTERM().add(var);
    Const argsConst = factory.createConst();
    argsConst.setType(getLiteralTypeFor(mappingCondition.getLiteralClass()));
    String literalValue = mappingCondition.getLiteralValue().toString();
    // remove any wildcards
    if (mappingCondition.getOperator().equals(ComparisonType.STRING_CONTAINS)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        literalValue = literalValue.replaceAll("%", "");
    }
    argsConst.getContent().add(literalValue);
    args.getTERM().add(argsConst);
    // $NON-NLS-1$ //$NON-NLS-2$
    log.fine("Filter is a " + mappingCondition.getOperator().toString() + " filter");
}
Also used : Op(org.w3._2007.rif.Op) ExternalFORMULAType(org.w3._2007.rif.ExternalFORMULAType) ContentFORMULAType(org.w3._2007.rif.ContentFORMULAType) ActionVar(org.w3._2007.rif.Do.ActionVar) Var(org.w3._2007.rif.Var) Const(org.w3._2007.rif.Const) ArgsUNITERMType(org.w3._2007.rif.ArgsUNITERMType) Atom(org.w3._2007.rif.Atom)

Example 45 with If

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

the class ModelRifToRifTranslator method createComparativeFilter.

private void createComparativeFilter(List<Formula> list, ModelRifMappingCondition mappingCondition) {
    // $NON-NLS-1$
    log.fine("Creating comparative filter");
    Formula filterFormula = factory.createFormula();
    list.add(filterFormula);
    if (mappingCondition.getOperator().equals(ComparisonType.NUMBER_EQUALS) || mappingCondition.getOperator().equals(ComparisonType.STRING_EQUALS)) {
        createEqualsFilter(mappingCondition, filterFormula);
    } else if (mappingCondition.getOperator().equals(ComparisonType.NUMBER_GREATER_THAN) || mappingCondition.getOperator().equals(ComparisonType.NUMBER_LESS_THAN) || mappingCondition.getOperator().equals(ComparisonType.STRING_CONTAINS)) {
        createExternalPredicateFilter(mappingCondition, filterFormula);
    } else {
        throw new UnsupportedOperationException(// $NON-NLS-1$
        "Comparison type is not supported: " + mappingCondition.getOperator().toString());
    }
}
Also used : Formula(org.w3._2007.rif.Formula)

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