use of com.liferay.ide.kaleo.core.model.WorkflowDefinition in project liferay-ide by liferay.
the class KaleoModelUtil method getDefaultValue.
public static String getDefaultValue(Element modelElement, QualifiedName key, Enum<?> defaultValue) {
String value = null;
IFile definitionFile = null;
WorkflowDefinition workflowDefinition = modelElement.nearest(WorkflowDefinition.class);
if (workflowDefinition == null) {
workflowDefinition = modelElement.adapt(WorkflowDefinition.class);
}
if (workflowDefinition != null) {
definitionFile = workflowDefinition.adapt(IFile.class);
}
if (definitionFile != null) {
try {
value = definitionFile.getPersistentProperty(key);
} catch (CoreException ce) {
}
}
if (value == null) {
value = getEnumSerializationAnnotation(defaultValue);
}
return value;
}
use of com.liferay.ide.kaleo.core.model.WorkflowDefinition in project liferay-ide by liferay.
the class WorkflowProjectAdapterService method convert.
@Override
public <A> A convert(Object object, Class<A> adapterType) {
A retval = null;
if (IProject.class.equals(adapterType)) {
ISapphirePart sapphirePart = context().find(ISapphirePart.class);
WorkflowDefinition workflowDefinition = sapphirePart.getLocalModelElement().nearest(WorkflowDefinition.class);
IFile file = workflowDefinition.adapt(IFile.class);
if (file != null) {
retval = adapterType.cast(file.getProject());
} else {
// create support project
WorkflowSupportManager workflowSupportManager = KaleoCore.getDefault().getWorkflowSupportManager();
IEditorInput editorInput = workflowDefinition.adapt(IEditorInput.class);
if (editorInput instanceof WorkflowDefinitionEditorInput) {
WorkflowDefinitionEditorInput workflowInput = (WorkflowDefinitionEditorInput) editorInput;
WorkflowDefinitionEntry workflowEntry = workflowInput.getWorkflowDefinitionEntry();
IServer server = workflowEntry.getParent().getParent();
workflowSupportManager.setCurrentServer(server);
}
IJavaProject supportProject = workflowSupportManager.getSupportProject();
retval = adapterType.cast(supportProject.getProject());
}
}
return retval;
}
use of com.liferay.ide.kaleo.core.model.WorkflowDefinition in project liferay-ide by liferay.
the class ForkNodeAddActionHandler method postDiagramNodePartAdded.
@Override
public void postDiagramNodePartAdded(NewNodeOp op, CanTransition newNodeFromWizard, CanTransition newNode) {
NewForkNodeOp newForkOp = op.nearest(NewForkNodeOp.class);
NewForkNode newForkNodeFromWizard = newNodeFromWizard.nearest(NewForkNode.class);
Fork newFork = newNode.nearest(Fork.class);
WorkflowDefinition workflowDefinition = newFork.nearest(WorkflowDefinition.class);
if (newForkOp.isAddJoin().content(true)) {
Join newJoin = workflowDefinition.getJoins().insert();
String newJoinName = newForkNodeFromWizard.getName().content() + " Join";
newJoin.setName(newJoinName);
for (Node connectedNode : op.getConnectedNodes()) {
for (WorkflowNode diagramNode : workflowDefinition.getDiagramNodes()) {
Value<String> nodeName = connectedNode.getName();
if (nodeName.content().equals(diagramNode.getName().content())) {
CanTransition canTransition = diagramNode.nearest(CanTransition.class);
ElementList<Transition> transitions = canTransition.getTransitions();
Transition newTransition = transitions.insert();
newTransition.setName(newJoinName);
newTransition.setTarget(newJoinName);
}
}
}
}
}
use of com.liferay.ide.kaleo.core.model.WorkflowDefinition in project liferay-ide by liferay.
the class RoleNamePossibleValuesMetaService method initIfNecessary.
protected void initIfNecessary(Object object) {
if (object instanceof WorkflowDefinition) {
for (WorkflowNode node : ((WorkflowDefinition) object).getDiagramNodes()) {
Assignable assignable = node.nearest(Assignable.class);
if (assignable != null) {
for (Role role : assignable.getRoles()) {
Value<String> roleName = role.getName();
String name = roleName.content(false);
if (!CoreUtil.isNullOrEmpty(name)) {
_originalRoleNames.add(name);
}
}
}
}
} else if (object instanceof AssignableOp) {
ElementList<RoleName> roleNames = ((AssignableOp) object).getRoleNames();
for (RoleName roleName : roleNames) {
Value<String> nameValue = roleName.getName();
String name = nameValue.content(false);
if (!CoreUtil.isNullOrEmpty(name)) {
_originalRoleNames.add(name);
}
}
}
}
use of com.liferay.ide.kaleo.core.model.WorkflowDefinition in project liferay-ide by liferay.
the class RoleNamePossibleValuesService method _initMetaServiceIfNecessary.
private void _initMetaServiceIfNecessary() {
WorkflowDefinition definition = _op().nearest(WorkflowDefinition.class);
if (definition != null) {
_metaService.initIfNecessary(definition);
}
AssignableOp assignableOp = _op().nearest(AssignableOp.class);
if (assignableOp != null) {
_metaService.initIfNecessary(assignableOp);
}
}
Aggregations