use of org.camunda.bpm.model.xml.ModelInstance in project camunda-xml-model by camunda.
the class ReferenceImpl method setReferenceTargetElement.
/**
* Set the reference target model element instance
*
* @param referenceSourceElement the reference source model element instance
* @param referenceTargetElement the reference target model element instance
* @throws ModelReferenceException if element is not already added to the model
*/
public void setReferenceTargetElement(ModelElementInstance referenceSourceElement, T referenceTargetElement) {
ModelInstance modelInstance = referenceSourceElement.getModelInstance();
String referenceTargetIdentifier = referenceTargetAttribute.getValue(referenceTargetElement);
ModelElementInstance existingElement = modelInstance.getModelElementById(referenceTargetIdentifier);
if (existingElement == null || !existingElement.equals(referenceTargetElement)) {
throw new ModelReferenceException("Cannot create reference to model element " + referenceTargetElement + ": element is not part of model. Please connect element to the model first.");
} else {
setReferenceIdentifier(referenceSourceElement, referenceTargetIdentifier);
}
}
use of org.camunda.bpm.model.xml.ModelInstance in project camunda-xml-model by camunda.
the class AnimalTest method createModel.
public static Object[] createModel() {
TestModelParser modelParser = new TestModelParser();
ModelInstance modelInstance = modelParser.getEmptyModel();
Animals animals = modelInstance.newInstance(Animals.class);
modelInstance.setDocumentElement(animals);
// add a tns namespace prefix for QName testing
animals.getDomElement().registerNamespace("tns", MODEL_NAMESPACE);
Animal tweety = createBird(modelInstance, "tweety", Gender.Female);
Animal hedwig = createBird(modelInstance, "hedwig", Gender.Male);
Animal birdo = createBird(modelInstance, "birdo", Gender.Female);
Animal plucky = createBird(modelInstance, "plucky", Gender.Unknown);
Animal fiffy = createBird(modelInstance, "fiffy", Gender.Female);
createBird(modelInstance, "timmy", Gender.Male);
createBird(modelInstance, "daisy", Gender.Female);
// create and add some relationships
RelationshipDefinition hedwigRelationship = createRelationshipDefinition(modelInstance, hedwig, ChildRelationshipDefinition.class);
addRelationshipDefinition(tweety, hedwigRelationship);
RelationshipDefinition birdoRelationship = createRelationshipDefinition(modelInstance, birdo, ChildRelationshipDefinition.class);
addRelationshipDefinition(tweety, birdoRelationship);
RelationshipDefinition pluckyRelationship = createRelationshipDefinition(modelInstance, plucky, FriendRelationshipDefinition.class);
addRelationshipDefinition(tweety, pluckyRelationship);
RelationshipDefinition fiffyRelationship = createRelationshipDefinition(modelInstance, fiffy, FriendRelationshipDefinition.class);
addRelationshipDefinition(tweety, fiffyRelationship);
tweety.getRelationshipDefinitionRefs().add(hedwigRelationship);
tweety.getRelationshipDefinitionRefs().add(birdoRelationship);
tweety.getRelationshipDefinitionRefs().add(pluckyRelationship);
tweety.getRelationshipDefinitionRefs().add(fiffyRelationship);
tweety.getBestFriends().add(birdo);
tweety.getBestFriends().add(plucky);
return new Object[] { "created", modelInstance, modelParser };
}
use of org.camunda.bpm.model.xml.ModelInstance in project camunda-xml-model by camunda.
the class BirdTest method createModel.
public static Object[] createModel() {
TestModelParser modelParser = new TestModelParser();
ModelInstance modelInstance = modelParser.getEmptyModel();
Animals animals = modelInstance.newInstance(Animals.class);
modelInstance.setDocumentElement(animals);
// add a tns namespace prefix for QName testing
animals.getDomElement().registerNamespace("tns", MODEL_NAMESPACE);
Bird tweety = createBird(modelInstance, "tweety", Gender.Female);
Bird hedwig = createBird(modelInstance, "hedwig", Gender.Female);
Bird timmy = createBird(modelInstance, "timmy", Gender.Female);
Egg egg1 = createEgg(modelInstance, "egg1");
egg1.setMother(tweety);
Collection<Animal> guards = egg1.getGuardians();
guards.add(hedwig);
guards.add(timmy);
Egg egg2 = createEgg(modelInstance, "egg2");
egg2.setMother(tweety);
guards = egg2.getGuardians();
guards.add(hedwig);
guards.add(timmy);
Egg egg3 = createEgg(modelInstance, "egg3");
guards = egg3.getGuardians();
guards.add(timmy);
tweety.setSpouse(hedwig);
tweety.getEggs().add(egg1);
tweety.getEggs().add(egg2);
tweety.getEggs().add(egg3);
Collection<Egg> guardedEggs = hedwig.getGuardedEggs();
guardedEggs.add(egg1);
guardedEggs.add(egg2);
GuardEgg guardEgg = modelInstance.newInstance(GuardEgg.class);
guardEgg.setTextContent(egg1.getId() + " " + egg2.getId());
timmy.getGuardedEggRefs().add(guardEgg);
timmy.getGuardedEggs().add(egg3);
return new Object[] { "created", modelInstance, modelParser };
}
use of org.camunda.bpm.model.xml.ModelInstance in project camunda-xml-model by camunda.
the class FlyingAnimalTest method createModel.
public static Object[] createModel() {
TestModelParser modelParser = new TestModelParser();
ModelInstance modelInstance = modelParser.getEmptyModel();
Animals animals = modelInstance.newInstance(Animals.class);
modelInstance.setDocumentElement(animals);
// add a tns namespace prefix for QName testing
animals.getDomElement().registerNamespace("tns", MODEL_NAMESPACE);
FlyingAnimal tweety = createBird(modelInstance, "tweety", Gender.Female);
FlyingAnimal hedwig = createBird(modelInstance, "hedwig", Gender.Male);
FlyingAnimal birdo = createBird(modelInstance, "birdo", Gender.Female);
FlyingAnimal plucky = createBird(modelInstance, "plucky", Gender.Unknown);
FlyingAnimal fiffy = createBird(modelInstance, "fiffy", Gender.Female);
createBird(modelInstance, "timmy", Gender.Male);
createBird(modelInstance, "daisy", Gender.Female);
tweety.setFlightInstructor(hedwig);
tweety.getFlightPartnerRefs().add(hedwig);
tweety.getFlightPartnerRefs().add(birdo);
tweety.getFlightPartnerRefs().add(plucky);
tweety.getFlightPartnerRefs().add(fiffy);
return new Object[] { "created", modelInstance, modelParser };
}
use of org.camunda.bpm.model.xml.ModelInstance in project camunda-xml-model by camunda.
the class ChildElementCollectionTest method createModel.
public static Object[] createModel() {
TestModelParser modelParser = new TestModelParser();
ModelInstance modelInstance = modelParser.getEmptyModel();
Animals animals = modelInstance.newInstance(Animals.class);
modelInstance.setDocumentElement(animals);
Bird tweety = createBird(modelInstance, "tweety", Gender.Female);
Bird daffy = createBird(modelInstance, "daffy", Gender.Male);
Bird daisy = createBird(modelInstance, "daisy", Gender.Female);
Bird plucky = createBird(modelInstance, "plucky", Gender.Male);
createBird(modelInstance, "birdo", Gender.Female);
tweety.setFlightInstructor(daffy);
tweety.getFlightPartnerRefs().add(daisy);
tweety.getFlightPartnerRefs().add(plucky);
return new Object[] { "created", modelInstance, modelParser };
}
Aggregations