use of org.cristalise.kernel.persistency.ClusterType 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.ClusterType in project kernel by cristal-ise.
the class BulkImport method importAllClusters.
public void importAllClusters() throws InvalidDataException, PersistencyException {
for (ItemPath item : getItemsToImport(root)) {
Object sublocker = new Object();
for (ClusterType type : importCluster.getClusters(item)) {
switch(type) {
case PATH:
importPath(item, sublocker);
break;
case PROPERTY:
importProperty(item, sublocker);
break;
case LIFECYCLE:
importLifeCycle(item, sublocker);
break;
case HISTORY:
importHistory(item, sublocker);
break;
case VIEWPOINT:
importViewPoint(item, sublocker);
break;
case OUTCOME:
importOutcome(item, sublocker);
break;
case COLLECTION:
importCollection(item, sublocker);
break;
case JOB:
importJob(item, sublocker);
break;
default:
break;
}
}
// importCluster.delete(item, "");
Gateway.getStorage().commit(sublocker);
}
}
use of org.cristalise.kernel.persistency.ClusterType in project kernel by cristal-ise.
the class XMLClusterStorage method get.
@Override
public C2KLocalObject get(ItemPath itemPath, String path) throws PersistencyException {
try {
ClusterType type = ClusterStorage.getClusterType(path);
String filePath = getFilePath(itemPath, path) + fileExtension;
String objString = FileStringUtility.file2String(filePath);
if (objString.length() == 0)
return null;
Logger.debug(9, "XMLClusterStorage.get() - objString:" + objString);
if (type == ClusterType.OUTCOME)
return new Outcome(path, objString);
else
return (C2KLocalObject) Gateway.getMarshaller().unmarshall(objString);
} catch (Exception e) {
Logger.msg(3, "XMLClusterStorage.get() - The path " + path + " from " + itemPath + " does not exist: " + e.getMessage());
Logger.error(e);
throw new PersistencyException(e.getMessage());
}
}
use of org.cristalise.kernel.persistency.ClusterType in project kernel by cristal-ise.
the class XMLClusterStorageTest method checkXMLClusterStorage.
public void checkXMLClusterStorage(XMLClusterStorage importCluster) throws Exception {
ClusterType[] types = importCluster.getClusters(itemPath);
assertEquals(6, types.length);
for (ClusterType type : types) {
String[] contents = importCluster.getClusterContents(itemPath, type);
switch(type) {
case PATH:
assertEquals(2, contents.length);
assertArrayEquals(new String[] { "Domain", "Item" }, contents);
assertNotNull(importCluster.get(itemPath, PATH + "/Item"));
assertNotNull(importCluster.get(itemPath, PATH + "/Domain/Batches2016FG160707C-08"));
break;
case PROPERTY:
assertEquals(19, contents.length);
assertNotNull(importCluster.get(itemPath, PROPERTY + "/Name"));
break;
case LIFECYCLE:
assertEquals(1, contents.length);
assertNotNull(importCluster.get(itemPath, LIFECYCLE + "/workflow"));
break;
case OUTCOME:
assertEquals(14, contents.length);
assertNotNull(importCluster.get(itemPath, OUTCOME + "/PredefinedStepOutcome/0/7"));
break;
case VIEWPOINT:
assertEquals(14, contents.length);
assertNotNull(importCluster.get(itemPath, VIEWPOINT + "/NextStepData/last"));
break;
case HISTORY:
assertEquals(30, contents.length);
assertNotNull(importCluster.get(itemPath, HISTORY + "/0"));
assertNotNull(importCluster.get(itemPath, HISTORY + "/29"));
break;
default:
fail("Unhandled ClusterType:" + type);
}
}
}
Aggregations