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);
}
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);
}
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);
}
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
}
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);
}
Aggregations