use of org.kie.workbench.common.stunner.core.definition.morph.BindablePropertyMorphDefinition in project kie-wb-common by kiegroup.
the class BPMNGraphObjectBuilderFactory method builderFor.
@Override
@SuppressWarnings("all")
public GraphObjectBuilder<?, ?> builderFor(final String oryxId) {
if (oryxId == null) {
throw new NullPointerException();
}
final Class<?> defClass = oryxManager.getMappingsManager().getDefinition(oryxId);
if (null != defClass) {
final String defId = oryxManager.getMappingsManager().getDefinitionId(oryxId);
if (ServiceTask.class.equals(defClass)) {
return new ServiceTaskNodeBuilder(defId, workItemDefinitionRegistries);
}
MorphAdapter<Object> morphAdapter = definitionManager.adapters().registry().getMorphAdapter(defClass);
BindablePropertyMorphDefinition propertyMorphDefinition = null;
if (null != morphAdapter) {
final Iterable<MorphDefinition> morphDefinitions = ((BindableMorphAdapter<Object>) morphAdapter).getMorphDefinitionsForType(defClass);
if (null != morphDefinitions && morphDefinitions.iterator().hasNext()) {
for (MorphDefinition morphDefinition : morphDefinitions) {
if (morphDefinition instanceof BindablePropertyMorphDefinition) {
propertyMorphDefinition = (BindablePropertyMorphDefinition) morphDefinition;
break;
}
}
}
}
if (null != propertyMorphDefinition) {
// Specific handle for morphing based on class inheritance.
return new NodePropertyMorphBuilderImpl(defClass, propertyMorphDefinition);
} else {
Class<? extends ElementFactory> elementFactory = BackendDefinitionAdapter.getGraphFactory(defClass);
if (isNodeFactory(elementFactory)) {
return new NodeBuilderImpl(defClass, defId);
} else if (isEdgeFactory(elementFactory)) {
return new EdgeBuilderImpl(defClass);
} else {
throw new RuntimeException("No graph element found for definition with class [" + defClass.getName() + "]");
}
}
}
throw new DefinitionNotFoundException("No definition found for oryx stencil with id [" + oryxId + "]", oryxId);
}
Aggregations