Search in sources :

Example 1 with Instance

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

the class ModelRifToRifTranslator method createTargetInstanceMembershipFormula.

private Assert createTargetInstanceMembershipFormula(Actions actions, ModelSentence sentence, RifVariable instanceVariable) {
    Assert assert1 = factory.createAssert();
    Target target = factory.createAssertTarget();
    Member member = factory.createMember();
    Instance instance = factory.createInstance();
    Var var = factory.createVar();
    var.getContent().add(instanceVariable.getName());
    instance.setVar(var);
    member.setInstance(instance);
    org.w3._2007.rif.Class clazz = factory.createClass();
    Const const1 = factory.createConst();
    // $NON-NLS-1$
    const1.setType("rif:iri");
    const1.getContent().add(instanceVariable.getClassName());
    clazz.setConst(const1);
    member.setClazz(clazz);
    target.setMember(member);
    assert1.setTarget(target);
    return assert1;
}
Also used : Target(org.w3._2007.rif.Assert.Target) Assert(org.w3._2007.rif.Assert) Instance(org.w3._2007.rif.Instance) ActionVar(org.w3._2007.rif.Do.ActionVar) Var(org.w3._2007.rif.Var) Const(org.w3._2007.rif.Const) Member(org.w3._2007.rif.Member)

Example 2 with Instance

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

the class ModelRifToRifTranslator method createSourceInstanceMembershipFormula.

private Formula createSourceInstanceMembershipFormula(ModelSentence sentence, RifVariable instanceVariable) {
    Formula result = factory.createFormula();
    Member member = factory.createMember();
    Instance instance = factory.createInstance();
    Var var = factory.createVar();
    String name = sentence.getSourceClass().getName();
    var.getContent().add(name);
    Const const1 = factory.createConst();
    // $NON-NLS-1$
    const1.setType("rif:iri");
    const1.getContent().add(instanceVariable.getClassName());
    org.w3._2007.rif.Class clazz = factory.createClass();
    instance.setVar(var);
    clazz.setConst(const1);
    member.setInstance(instance);
    member.setClazz(clazz);
    result.setMember(member);
    return result;
}
Also used : Formula(org.w3._2007.rif.Formula) Instance(org.w3._2007.rif.Instance) ActionVar(org.w3._2007.rif.Do.ActionVar) Var(org.w3._2007.rif.Var) Const(org.w3._2007.rif.Const) Member(org.w3._2007.rif.Member)

Example 3 with Instance

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

the class ModelRifToRifTranslator method processChildren.

private void processChildren(ModelSentence s, final Exists exists, Do do1) {
    Formula existsFormula = factory.createFormula();
    And and = factory.createAnd();
    existsFormula.setAnd(and);
    exists.setFormula(existsFormula);
    Actions actions = factory.createDoActions();
    do1.setActions(actions);
    for (RifVariable instanceVariable : s.getVariables(Type.INSTANCE)) {
        // source instance variables
        if (!instanceVariable.isActionVar()) {
            recurseChildren(exists, do1, instanceVariable, s, true);
        } else // target instance variables
        {
            recurseChildren(exists, do1, instanceVariable, s, false);
        }
    }
    Map<RifVariable, Frame> map = new LinkedHashMap<RifVariable, Frame>();
    for (PropertyMapping mapping : s.getPropertyMappings()) {
        RifVariable contextVariable = mapping.getTarget().getContextVariable();
        Frame match = map.get(contextVariable);
        if (match == null) {
            map.put(contextVariable, initialiseFrame(contextVariable));
        }
    }
    for (StaticAssignment staticAssignment : s.getStaticAssignments()) {
        RifVariable contextVariable = staticAssignment.getTarget().getContextVariable();
        Frame match = map.get(contextVariable);
        if (match == null) {
            map.put(contextVariable, initialiseFrame(contextVariable));
        }
    }
    for (PropertyMapping mapping : s.getPropertyMappings()) {
        Frame frame = map.get(mapping.getTarget().getContextVariable());
        createAssignmentSlot(mapping, frame);
    }
    for (StaticAssignment staticAssignment : s.getStaticAssignments()) {
        Frame frame = map.get(staticAssignment.getTarget().getContextVariable());
        createStaticAssignmentSlot(staticAssignment, frame);
    }
    for (ModelRifMappingCondition mappingCondition : s.getMappingConditions()) {
        createFilter(exists.getFormula().getAnd().getFormula(), mappingCondition);
    }
    for (Frame frame : map.values()) {
        Assert assert1 = factory.createAssert();
        Target target = factory.createAssertTarget();
        target.setFrame(frame);
        assert1.setTarget(target);
        actions.getACTION().add(assert1);
    }
}
Also used : Formula(org.w3._2007.rif.Formula) StaticAssignment(com.onespatial.jrc.tns.oml_to_rif.model.rif.StaticAssignment) Frame(org.w3._2007.rif.Frame) Target(org.w3._2007.rif.Assert.Target) Assert(org.w3._2007.rif.Assert) Actions(org.w3._2007.rif.Do.Actions) And(org.w3._2007.rif.And) ModelRifMappingCondition(com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelRifMappingCondition) PropertyMapping(com.onespatial.jrc.tns.oml_to_rif.model.rif.PropertyMapping) RifVariable(com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with Instance

use of org.w3._2007.rif.Instance in project nhin-d by DirectProject.

the class XDRTest method testDocumentRepositoryProvideAndRegisterDocumentSetB.

/**
     * Test of documentRepositoryProvideAndRegisterDocumentSetB method, of class XDR.
     */
public void testDocumentRepositoryProvideAndRegisterDocumentSetB() throws Exception {
    System.out.println("documentRepositoryProvideAndRegisterDocumentSetB");
    QName qname = new QName("urn:ihe:iti:xds-b:2007", "ProvideAndRegisterDocumentSetRequestType");
    ProvideAndRegisterDocumentSetRequestType body = null;
    try {
        String request = getTestRequest();
        JAXBElement jb = (JAXBElement) XmlUtils.unmarshal(request, ihe.iti.xds_b._2007.ObjectFactory.class);
        body = (ProvideAndRegisterDocumentSetRequestType) jb.getValue();
    } catch (Exception x) {
        x.printStackTrace();
        fail("Failed unmarshalling request");
    }
    DocumentRepositoryAbstract instance = new XDR();
    // Set test objects
    instance.setAuditMessageGenerator(new AuditMessageGenerator(getLogfile()));
    // instance.setMailClient(new SmtpMailClient("gmail-smtp.l.google.com", "lewistower1@gmail.com", "hadron106"));
    instance.setResolver(new RoutingResolverImpl());
    XdConfig config = new XdConfig();
    config.setMailHost("gmail-smtp.l.google.com");
    config.setMailUser("lewistower1@gmail.com");
    config.setMailPass("hadron106");
    instance.setConfig(config);
    RegistryResponseType result = instance.documentRepositoryProvideAndRegisterDocumentSetB(body);
    if (result.getStatus().contains("Failure")) {
        // some organizational firewalls may block this test, so bail out gracefully if that happens
        return;
    }
    String sresult = null;
    try {
        qname = new QName("urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0", "RegistryResponseType");
        sresult = XmlUtils.marshal(qname, result, oasis.names.tc.ebxml_regrep.xsd.rs._3.ObjectFactory.class);
    } catch (Exception x) {
        x.printStackTrace();
        fail("Failed unmarshalling response");
    }
    // System.out.println(sresult);
    assertTrue(sresult.indexOf("ResponseStatusType:Success") >= 0);
}
Also used : QName(javax.xml.namespace.QName) JAXBElement(javax.xml.bind.JAXBElement) RoutingResolverImpl(org.nhindirect.xd.routing.impl.RoutingResolverImpl) XdConfig(org.nhind.xdr.config.XdConfig) AuditMessageGenerator(com.gsihealth.auditclient.AuditMessageGenerator) RegistryResponseType(oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryResponseType) ProvideAndRegisterDocumentSetRequestType(ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)

Example 5 with Instance

use of org.w3._2007.rif.Instance in project nhin-d by DirectProject.

the class XDRTest method testDocumentRepositoryRetrieveDocumentSet.

/**
     * Test the documentRepositoryRetrieveDocumentSet method.
     */
public void testDocumentRepositoryRetrieveDocumentSet() throws Exception {
    try {
        DocumentRepositoryAbstract instance = new XDR();
        // Set test objects
        instance.setAuditMessageGenerator(new AuditMessageGenerator(getLogfile()));
        // instance.setMailClient(new SmtpMailClient("gmail-smtp.l.google.com", "lewistower1@gmail.com", "hadron106"));
        XdConfig config = new XdConfig();
        config.setMailHost("gmail-smtp.l.google.com");
        config.setMailUser("lewistower1@gmail.com");
        config.setMailPass("hadron106");
        instance.setConfig(config);
        @SuppressWarnings("unused") RetrieveDocumentSetResponseType response = null;
        RetrieveDocumentSetRequestType body = new RetrieveDocumentSetRequestType();
        response = instance.documentRepositoryRetrieveDocumentSet(body);
        fail("Exception not thrown");
    } catch (UnsupportedOperationException e) {
        assertTrue(true);
    }
}
Also used : RetrieveDocumentSetResponseType(ihe.iti.xds_b._2007.RetrieveDocumentSetResponseType) XdConfig(org.nhind.xdr.config.XdConfig) AuditMessageGenerator(com.gsihealth.auditclient.AuditMessageGenerator) RetrieveDocumentSetRequestType(ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType)

Aggregations

AuditMessageGenerator (com.gsihealth.auditclient.AuditMessageGenerator)2 XdConfig (org.nhind.xdr.config.XdConfig)2 Assert (org.w3._2007.rif.Assert)2 Target (org.w3._2007.rif.Assert.Target)2 Const (org.w3._2007.rif.Const)2 ActionVar (org.w3._2007.rif.Do.ActionVar)2 Formula (org.w3._2007.rif.Formula)2 Instance (org.w3._2007.rif.Instance)2 Member (org.w3._2007.rif.Member)2 Var (org.w3._2007.rif.Var)2 ModelRifMappingCondition (com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelRifMappingCondition)1 PropertyMapping (com.onespatial.jrc.tns.oml_to_rif.model.rif.PropertyMapping)1 StaticAssignment (com.onespatial.jrc.tns.oml_to_rif.model.rif.StaticAssignment)1 RifVariable (com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable)1 ProvideAndRegisterDocumentSetRequestType (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)1 RetrieveDocumentSetRequestType (ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType)1 RetrieveDocumentSetResponseType (ihe.iti.xds_b._2007.RetrieveDocumentSetResponseType)1 LinkedHashMap (java.util.LinkedHashMap)1 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1