public IArc createRandomlyArc( INode source, INode target, AssociationDefinition associationDefinition) { IArc arc = null; boolean isCreated = RandomMethods.randomGenerator.nextBoolean(); if (associationDefinition.isTargetMandatory()) { isCreated = true; } if (isCreated) { arc = ((Instance) instance).instanciation(source, target, associationDefinition); } return arc; }
private List<IArc> generateArcsInstancesCase1N( Collection<INode> sourcesNodes, Collection<INode> targetsNodes, AssociationDefinition associationDefinition, Collection<AssociationDefinition> associations, Collection<IArc> generatedArcs) { List<IArc> arcsInstances = new ArrayList<IArc>(); while (!sourcesNodes.isEmpty()) { INode source = RandomMethods.selectRandomlyNode(sourcesNodes); int numberOfArcs = 0; while (numberOfArcs < numberOfOutputArcs && !targetsNodes.isEmpty()) { INode target = RandomMethods.selectRandomlyNode(targetsNodes); IArc arc = createRandomlyArc(source, target, associationDefinition); AssociationDefinition invAssoc = generatorServices.searchInverseAssoc( source, target, associationDefinition, associations); if (invAssoc != null && (invAssoc.isTargetMandatory() || invAssoc.isSourceMandatory())) { arc = null; } if (invAssoc != null) { IArc invArc = generatorServices.getInverseGeneratedArc(source, target, invAssoc, generatedArcs); if (invArc != null) { arc = null; } } if (arc != null) { arcsInstances.add(arc); numberOfArcs++; } targetsNodes.remove(target); } sourcesNodes.remove(source); } return arcsInstances; }