use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method getActivitiesWithEvents.
private ActivitiesWithEvents_type0 getActivitiesWithEvents(ScopeDAO scope) {
ActivitiesWithEvents_type0 activitiesWithEvents = new ActivitiesWithEvents_type0();
Collection<ActivityRecoveryDAO> recoveries = scope.getProcessInstance().getActivityRecoveries();
// List<BpelEvent> events = scope.listEvents();
Set<EventDAOImpl> eventsEntities = ((ScopeDAOImpl) scope).getEvents();
List<BpelEvent> events = new ArrayList<BpelEvent>();
for (EventDAOImpl event : eventsEntities) {
events.add(event.getEvent());
}
ActivityStateAndEventDocumentBuilder docBuilder = new ActivityStateAndEventDocumentBuilder();
for (BpelEvent e : events) {
docBuilder.onEvent(e);
}
for (ActivityInfoWithEventsDocument aweDoc : docBuilder.getActivitiesWithEvents()) {
for (ActivityRecoveryDAO recovery : recoveries) {
if (String.valueOf(recovery.getActivityId()).equals(aweDoc.getActivityInfoDoc().getActivityInfo().getAiid())) {
TFailureInfo failure = aweDoc.getActivityInfoDoc().getActivityInfo().addNewFailure();
failure.setReason(recovery.getReason());
failure.setDtFailure(toCalendar(recovery.getDateTime()));
failure.setActions(recovery.getActions());
failure.setRetries(recovery.getRetries());
aweDoc.getActivityInfoDoc().getActivityInfo().setStatus(TActivityStatus.FAILURE);
}
}
ActivityInfoWithEventsType activityWE = new ActivityInfoWithEventsType();
TActivityInfo actInfoDoc = aweDoc.getActivityInfoDoc().getActivityInfo();
TEventInfoList evtInfoList = aweDoc.getEventInfoList().getEventInfoList();
// add activityInfo
// add event info
ActivityInfoType activity = fillActivityInfo(new ActivityInfoType(), actInfoDoc);
/*XmlOptions opt = new XmlOptions();
opt = opt.setSaveOuter();*/
EventInfoList eventList = fillEventInfo(new EventInfoList(), evtInfoList);
activityWE.setActivityInfo(activity);
activityWE.setActivityEventsList(eventList);
activitiesWithEvents.addActivityInfoWithEvents(activityWE);
}
return activitiesWithEvents;
}
use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.
the class ProcessManagementServiceSkeleton method getPaginatedProcessList.
public PaginatedProcessInfoList getPaginatedProcessList(String processListFilter, String processListOrderByKey, int page) throws ProcessManagementException {
int tPage = page;
PaginatedProcessInfoList processList = new PaginatedProcessInfoList();
TenantProcessStoreImpl tenantProcessStore = AdminServiceUtils.getTenantProcessStore();
if (tPage < 0 || tPage == Integer.MAX_VALUE) {
tPage = 0;
}
Integer itemsPerPage = 10;
Integer startIndexForCurrentPage = tPage * itemsPerPage;
Integer endIndexForCurrentPage = (tPage + 1) * itemsPerPage;
final ProcessFilter processFilter = new ProcessFilter(processListFilter, processListOrderByKey);
Collection<ProcessConf> processListForCurrentPage = processQuery(processFilter, tenantProcessStore);
Integer processListSize = processListForCurrentPage.size();
Integer pages = (int) Math.ceil((double) processListSize / itemsPerPage);
processList.setPages(pages);
ProcessConf[] processConfigurations = processListForCurrentPage.toArray(new ProcessConf[processListSize]);
for (int i = startIndexForCurrentPage; (i < endIndexForCurrentPage && i < processListSize); i++) {
processList.addProcessInfo(AdminServiceUtils.createLimitedProcessInfoObject(processConfigurations[i]));
}
return processList;
}
use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.
the class ProcessImpl method getLinkArrows.
/**
* Gets the Link arrow coordinates when there is a FLOW activity in the process
*
* @param doc SVG document which defines the components including shapes, gradients etc. of the process
* @return An element which contains the link arrow coordinates of the Process
*/
private Element getLinkArrows(SVGDocument doc) {
Element group = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
// Checks whether the any links exist
if (links != null && !links.isEmpty()) {
// Returns a collection-view of the map with the link names, sources(starting activity) and the target
// (ending activity)
Set linksSet = links.entrySet();
Iterator linksIterator = linksSet.iterator();
// Iterates through the links
while (linksIterator.hasNext()) {
Map.Entry<String, Link> link = (Map.Entry<String, Link>) linksIterator.next();
// Gets the source/start activity of the link
ActivityInterface startActivity = link.getValue().getSource();
// Gets the target/end activity of the link
ActivityInterface endActivity = link.getValue().getTarget();
// Get the link name
String linkName = link.getKey();
// Check if the source and the target of the link contains a value
if (endActivity != null && startActivity != null) {
// Define the link flow/path by giving the coordinates of the start and end activity
group.appendChild(drawLink(doc, startActivity.getExitArrowCoords().getXLeft(), startActivity.getExitArrowCoords().getYTop(), endActivity.getEntryArrowCoords().getXLeft(), endActivity.getEntryArrowCoords().getYTop(), startActivity.getStartIconWidth(), link.getKey(), linkName));
}
}
}
return group;
}
use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.
the class HumanTaskPackageRepository method addLatestArchiveToRegistryCollection.
/**
* Add latest human task package zip to the registry
*
* @param humanTaskDeploymentUnit
* @param humanTaskFile
* @throws HumanTaskStoreException
* @throws RegistryException
*/
private void addLatestArchiveToRegistryCollection(HumanTaskDeploymentUnit humanTaskDeploymentUnit, File humanTaskFile) throws HumanTaskStoreException, RegistryException {
FileInputStream fileInputStream = null;
try {
Resource latestHumanTaskArchive = configRegistry.newResource();
fileInputStream = new FileInputStream(humanTaskFile);
latestHumanTaskArchive.setContent(fileInputStream);
configRegistry.put(HumanTaskPackageRepositoryUtils.getHumanTaskPackageArchiveResourcePath(humanTaskDeploymentUnit.getPackageName()), latestHumanTaskArchive);
} catch (FileNotFoundException ex) {
String errMsg = "HumanTask package zip file couldn't found on given location " + humanTaskFile.getAbsolutePath();
throw new HumanTaskStoreException(errMsg, ex);
} catch (RegistryException ex) {
String errMsg = "Exception occurred while adding latest archive to registry collection";
throw new RegistryException(errMsg, ex);
} finally {
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException e) {
log.warn("Cannot close file input stream.", e);
}
}
}
}
use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.
the class HumanTaskPackageRepository method createHumanTaskPackageParentCollectionWithProperties.
/**
* Create parent collection for human task package using DeploymentUnitDAO
*
* @param deploymentUnitDAO
* @throws RegistryException
*/
private void createHumanTaskPackageParentCollectionWithProperties(DeploymentUnitDAO deploymentUnitDAO) throws RegistryException {
Collection humanPackage = configRegistry.newCollection();
humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_CHECKSUM, deploymentUnitDAO.getChecksum());
if (log.isDebugEnabled()) {
log.debug(deploymentUnitDAO.getPackageName() + " updating checksum: " + deploymentUnitDAO.getChecksum() + " in registry");
}
humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_STATUS, String.valueOf(deploymentUnitDAO.getStatus()));
humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_VERSION, Long.toString(deploymentUnitDAO.getVersion()));
configRegistry.put(HumanTaskPackageRepositoryUtils.getResourcePathForHumanTaskPackage(deploymentUnitDAO), humanPackage);
}
Aggregations