use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.
the class LookupPathClusterStorageTest method storeDomainPath.
@Test
public void storeDomainPath() throws Exception {
DomainPath domain = new DomainPath("/my/path.2", new ItemPath());
inMemoryCluster.put(storingItem, domain);
String name = StringUtils.remove(StringUtils.join(domain.getPath(), ""), ".");
DomainPath domainPrime = (DomainPath) inMemoryCluster.get(storingItem, PATH + "/Domain/" + name);
assertNotNull(domainPrime);
assertEquals(domain.getStringPath(), domainPrime.getStringPath());
assertEquals(domain.getTargetUUID(), domainPrime.getTargetUUID());
}
use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.
the class DescriptionObjectCache method get.
public D get(String name, int version) throws ObjectNotFoundException, InvalidDataException {
D thisDef = null;
synchronized (cache) {
CacheEntry<D> thisDefEntry = cache.get(name + "_" + version);
if (thisDefEntry == null) {
Logger.msg(6, "DescriptionObjectCache.get() - " + name + " v" + version + " not found in cache. Checking id.");
try {
ItemPath defItemPath = findItem(name);
String defId = defItemPath.getUUID().toString();
thisDefEntry = cache.get(defId + "_" + version);
if (thisDefEntry == null) {
Logger.msg(6, "DescriptionObjectCache.get() - " + name + " v" + version + " not found in cache. Loading from database.");
ItemProxy defItemProxy = Gateway.getProxyManager().getProxy(defItemPath);
if (name.equals(defId)) {
String itemName = defItemProxy.getName();
if (itemName != null)
name = itemName;
}
thisDef = loadObject(name, version, defItemProxy);
cache.put(defId + "_" + version, new CacheEntry<D>(thisDef, defItemProxy, this));
}
} catch (ObjectNotFoundException ex) {
// for bootstrap and testing, try to load built-in kernel objects from resources
if (version == 0) {
try {
return loadObjectFromBootstrap(name);
} catch (ObjectNotFoundException ex2) {
}
}
throw ex;
}
}
if (thisDefEntry != null && thisDef == null) {
Logger.msg(6, "DescriptionObjectCache.get() - " + name + " v" + version + " found in cache.");
thisDef = thisDefEntry.def;
}
}
return thisDef;
}
use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.
the class CreateItemFromDescription method runActivityLogic.
/**
* Params:
* <ol>
* <li>Item name</li>
* <li>Domain context</li>
* <li>Description version to use(optional)</li>
* <li>Initial properties to set in the new Agent (optional)</li>
* </ol>
* @throws ObjectNotFoundException
* @throws InvalidDataException The input parameters were incorrect
* @throws ObjectAlreadyExistsException The Agent already exists
* @throws CannotManageException The Agent could not be created
* @throws ObjectCannotBeUpdated The addition of the new entries into the LookupManager failed
* @throws PersistencyException
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath descItemPath, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectNotFoundException, ObjectAlreadyExistsException, CannotManageException, ObjectCannotBeUpdated, PersistencyException {
String[] input = getDataList(requestData);
String newName = input[0];
String domPath = input[1];
String descVer = input.length > 2 ? input[2] : "last";
PropertyArrayList initProps = input.length > 3 ? unmarshallInitProperties(input[3]) : new PropertyArrayList();
Logger.msg(1, "CreateItemFromDescription - name:" + newName);
// check if the path is already taken
DomainPath context = new DomainPath(new DomainPath(domPath), newName);
if (context.exists())
throw new ObjectAlreadyExistsException("The path " + context + " exists already.");
// generate new item path with random uuid
Logger.msg(6, "CreateItemFromDescription - Requesting new item path");
ItemPath newItemPath = new ItemPath();
// create the Item object
Logger.msg(3, "CreateItemFromDescription - Creating Item");
CorbaServer factory = Gateway.getCorbaServer();
if (factory == null)
throw new CannotManageException("This process cannot create new Items");
TraceableEntity newItem = factory.createItem(newItemPath);
Gateway.getLookupManager().add(newItemPath);
initialiseItem(newItem, agent, descItemPath, initProps, newName, descVer, context, newItemPath, locker);
return requestData;
}
use of org.cristalise.kernel.lookup.ItemPath 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.lookup.ItemPath in project kernel by cristal-ise.
the class Activity method getTypeName.
public String getTypeName() {
if (mType == null)
return null;
if (mTypeName == null) {
try {
ItemPath actType = new ItemPath(mType);
Property nameProp = (Property) Gateway.getStorage().get(actType, ClusterType.PROPERTY + "/" + NAME, null);
mTypeName = nameProp.getValue();
} catch (Exception e) {
mTypeName = mType;
}
}
return mTypeName;
}
Aggregations