use of org.cristalise.kernel.persistency.outcome.Outcome in project kernel by cristal-ise.
the class ProxyLoader method get.
/**
* retrieve object by path
*/
@Override
public C2KLocalObject get(ItemPath thisItem, String path) throws PersistencyException {
try {
Item thisEntity = getIOR(thisItem);
ClusterType type = getClusterType(path);
// fetch the xml from the item
String queryData = thisEntity.queryData(path);
if (Logger.doLog(8))
Logger.msg("ProxyLoader.get() - " + thisItem + " : " + path + " = " + queryData);
if (queryData != null) {
if (type == ClusterType.OUTCOME)
return new Outcome(path, queryData);
else
return (C2KLocalObject) Gateway.getMarshaller().unmarshall(queryData);
}
} catch (ObjectNotFoundException e) {
return null;
} catch (Exception e) {
Logger.error(e);
throw new PersistencyException(e.getMessage());
}
return null;
}
use of org.cristalise.kernel.persistency.outcome.Outcome in project kernel by cristal-ise.
the class DefaultResourceImportHandler method getResourceOutcomes.
@Override
public Set<Outcome> getResourceOutcomes(String name, String ns, String location, Integer version) throws Exception {
HashSet<Outcome> retArr = new HashSet<Outcome>();
String data = Gateway.getResource().getTextResource(ns, location);
if (data == null)
throw new Exception("No data found for " + type.getSchemaName() + " " + name);
Outcome resOutcome = new Outcome(0, data, LocalObjectLoader.getSchema(type.getSchemaName(), 0));
retArr.add(resOutcome);
return retArr;
}
use of org.cristalise.kernel.persistency.outcome.Outcome in project kernel by cristal-ise.
the class OutcomeTest method testGetRecord.
@Test
public void testGetRecord() throws Exception {
Outcome patient1 = getOutcome("patient1", "PatientDetails");
compareRecord(patient1.getRecord());
compareRecord(patient1.getRecord("/PatientDetails"));
String[] names = { "InsuranceNumber", "DateOfBirth", "Gender", "Weight" };
compareRecord(patient1.getRecord(Arrays.asList(names)));
compareRecord(patient1.getRecord("/PatientDetails", Arrays.asList(names)));
}
use of org.cristalise.kernel.persistency.outcome.Outcome in project kernel by cristal-ise.
the class OutcomeTest method testSetRecord.
@Test
public void testSetRecord() throws Exception {
Outcome patient2 = getOutcome("patient2", "PatientDetails");
Map<String, String> record = new HashMap<>();
record.put("InsuranceNumber", "123456789ABC");
record.put("DateOfBirth", "1999-12-12");
record.put("Gender", "male");
record.put("Weight", "85");
record.put("Note", "no comment");
patient2.setRecord(record);
Logger.msg(patient2.getData());
patient2.getDOM().normalize();
patient2.validateAndCheck();
compareRecord(patient2.getRecord());
}
use of org.cristalise.kernel.persistency.outcome.Outcome in project kernel by cristal-ise.
the class OutcomeTest method testComplexXpath.
@Test
public void testComplexXpath() throws Exception {
Outcome complexTestOc = getOutcome("complexOutcomeTest.xml");
String slotID = complexTestOc.getNodeByXPath("/Fields/@slotID").getNodeValue();
assertEquals("1", slotID);
NodeList fields = complexTestOc.getNodesByXPath("//Field");
for (int i = 0; i < fields.getLength(); i++) {
NodeList children = fields.item(i).getChildNodes();
// There are actually 5 nodes, becuase of the text nodes
assertEquals(5, children.getLength());
String fieldName = "";
String fieldValue = "";
for (int j = 0; j < children.getLength(); j++) {
if (children.item(j).getNodeType() == Node.ELEMENT_NODE) {
if (children.item(j).getNodeName().equals("FieldName"))
fieldName = children.item(j).getTextContent().trim();
else if (children.item(j).getNodeName().equals("FieldValue"))
fieldValue = children.item(j).getTextContent().trim();
} else {
Logger.msg("testComplexXpath() - SKIPPING nodeName:" + children.item(j).getNodeName() + " nodeType:" + children.item(j).getNodeType());
}
}
assertNotNull("fieldName shall not be null", fieldName);
assertNotNull("fieldValue shall not be null", fieldValue);
Logger.msg("testComplexXpath() - slotID:" + slotID + " fieldName:" + fieldName + " fieldValue:" + fieldValue);
}
}
Aggregations