Search in sources :

Example 1 with ClusterType

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;
}
Also used : Item(org.cristalise.kernel.entity.Item) Outcome(org.cristalise.kernel.persistency.outcome.Outcome) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) PersistencyException(org.cristalise.kernel.common.PersistencyException) ClusterType(org.cristalise.kernel.persistency.ClusterType) PersistencyException(org.cristalise.kernel.common.PersistencyException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

Example 2 with ClusterType

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);
    }
}
Also used : C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject) ClusterType(org.cristalise.kernel.persistency.ClusterType) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 3 with ClusterType

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());
    }
}
Also used : Outcome(org.cristalise.kernel.persistency.outcome.Outcome) PersistencyException(org.cristalise.kernel.common.PersistencyException) ClusterType(org.cristalise.kernel.persistency.ClusterType) IOException(java.io.IOException) PersistencyException(org.cristalise.kernel.common.PersistencyException)

Example 4 with ClusterType

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);
        }
    }
}
Also used : ClusterType(org.cristalise.kernel.persistency.ClusterType)

Aggregations

ClusterType (org.cristalise.kernel.persistency.ClusterType)4 PersistencyException (org.cristalise.kernel.common.PersistencyException)2 Outcome (org.cristalise.kernel.persistency.outcome.Outcome)2 IOException (java.io.IOException)1 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)1 C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)1 Item (org.cristalise.kernel.entity.Item)1 ItemPath (org.cristalise.kernel.lookup.ItemPath)1