private List<IArc> generateArcsInstancesCaseNN(
      Collection<INode> sourcesNodes,
      Collection<INode> targetsNodes,
      AssociationDefinition associationDefinition) {
    List<IArc> arcsInstances = new ArrayList<IArc>();
    while (!sourcesNodes.isEmpty()) {
      INode source = RandomMethods.selectRandomlyNode(sourcesNodes);
      Collection<INode> tempTargetsNodes = targetsNodes;
      int numberOfArcs = 0;
      if (!targetsNodes.isEmpty()) {
        while (numberOfArcs < numberOfOutputArcs && /*
															 * targetsNodes.size(
															 * ) >=
															 * numberOfOutputArcs
															 */ !tempTargetsNodes.isEmpty()) {
          INode target = RandomMethods.selectRandomlyNode(targetsNodes);
          IArc arc = createRandomlyArc(source, target, associationDefinition);
          if (arc != null) {
            arcsInstances.add(arc);
            numberOfArcs++;
          }
          tempTargetsNodes.remove(target);
        }
      }
      sourcesNodes.remove(source);
    }
    return arcsInstances;
  }
 private List<IArc> generateArcsInstancesCase11(
     Collection<INode> sourcesNodes,
     Collection<INode> targetsNodes,
     AssociationDefinition associationDefinition,
     Collection<AssociationDefinition> associations,
     Collection<IArc> generatedArcs) {
   List<IArc> arcsInstances = new ArrayList<IArc>();
   if (numberOfOutputArcs > 0) {
     while (!sourcesNodes.isEmpty() && !targetsNodes.isEmpty()) {
       INode source = RandomMethods.selectRandomlyNode(sourcesNodes);
       INode target = RandomMethods.selectRandomlyNode(targetsNodes);
       IArc arc = createRandomlyArc(source, target, associationDefinition);
       AssociationDefinition invAssoc =
           generatorServices.searchInverseAssoc(
               source, target, associationDefinition, associations);
       if (invAssoc != null) {
         IArc invArc =
             generatorServices.getInverseGeneratedArc(source, target, invAssoc, generatedArcs);
         if (invArc != null) {
           arc = null;
         }
       }
       if (arc != null) {
         arcsInstances.add(arc);
       }
       sourcesNodes.remove(source);
       targetsNodes.remove(target);
     }
   }
   return arcsInstances;
 }
  public boolean generateNodesInstances(IStructure structure) throws Exception {
    List<INode> nodesInstances = new ArrayList<INode>();
    Collection<ClassDefinition> createdTypes = new ArrayList<ClassDefinition>();
    Collection<ClassDefinition> types = ((AlfrescoModelStructure) structure).getTypes();
    Collection<AssociationDefinition> compositions =
        generatorServices.extractCompositions(
            ((AlfrescoModelStructure) structure).getAssociations());

    for (int numOfNodes = 0; numOfNodes < numberOfNodes; numOfNodes++) {
      ClassDefinition type = RandomMethods.selectRandomlyType(types);
      createdTypes.add(type);
    }

    Map<AssociationDefinition, Collection<ClassDefinition>> sourcesTypesOfCompositions =
        generatorServices.getSourcesTypesOfCompositions(createdTypes, compositions);
    Collection<ClassDefinition> deletedTargetsTypes =
        generatorServices.deleteTargetsTypesOfNotCreatedTargetsTypesOfCompositions(
            sourcesTypesOfCompositions, createdTypes);
    createdTypes.removeAll(deletedTargetsTypes);

    for (ClassDefinition type : createdTypes) {
      indexType.put(type, Integer.valueOf(0));
    }

    for (ClassDefinition type : createdTypes) {
      generatorServices.getSerializedDataFromFile();

      generatorServices.initializeUnicityVariables(createdTypes, type);

      nodesInstances.add(((Instance) instance).instanciation(type));

      Integer newValue = Integer.valueOf(indexType.get(type).intValue() + 1);
      indexType.put(type, newValue);

      generatorServices.serializeData();
    }
    ((AlfrescoModelData) alfrescoModelDatas).setGeneratedTypesInstances(nodesInstances);

    // Reinitialization because beans still exist until Alfresco be shutdown
    generatorServices.reInitialization();

    return true;
  }
 private Object generateDatasProperty(PropertyDefinition propertyDefinition) throws Exception {
   if (scenario.equals("incremental")) {
     if (numOfSame.get(typeRef).get(propertyDefinition) == null) {
       Integer value =
           Integer.valueOf(
               RandomMethods.nextIntInInterval(
                   startAttributeIndex, startAttributeIndex + numOfTypes + 1));
       numOfSame.get(typeRef).put(propertyDefinition, value);
       index.get(typeRef).put(propertyDefinition, Integer.valueOf(startAttributeIndex));
     } else {
       Integer value =
           Integer.valueOf(numOfSame.get(typeRef).get(propertyDefinition).intValue() - 1);
       if (value.intValue() >= startAttributeIndex) {
         numOfSame.get(typeRef).put(propertyDefinition, value);
         Integer indexValue =
             Integer.valueOf(index.get(typeRef).get(propertyDefinition).intValue() + 1);
         index.get(typeRef).put(propertyDefinition, indexValue);
       } else {
         Integer newValue =
             Integer.valueOf(
                 RandomMethods.nextIntInInterval(
                     startAttributeIndex, startAttributeIndex + numOfTypes + 1));
         numOfSame.get(typeRef).put(propertyDefinition, newValue);
         index.get(typeRef).put(propertyDefinition, Integer.valueOf(startAttributeIndex));
       }
     }
   } else if (scenario.equals("random")) {
     numOfSame.get(typeRef).put(propertyDefinition, Integer.valueOf(0));
   }
   Object randomData = new Object();
   String defaultValue = propertyDefinition.getDefaultValue();
   QName dataTypeOfProperty = propertyDefinition.getDataType().getName();
   List<ConstraintDefinition> constraints = propertyDefinition.getConstraints();
   if (constraints.size()
       == 1) { // we suppose there is a one-to-one correspondence between property and enumeration
     for (ConstraintDefinition constraint : constraints) {
       randomData = RandomMethods.getRandomlyValue(constraint);
     }
   } else {
     if (numOfSame
         .get(typeRef)
         .get(propertyDefinition)
         .equals(Integer.valueOf(startAttributeIndex))) {
       randomData =
           RandomMethods.generateDataByDataTypeProperty(
               dataTypeOfProperty, defaultValue, propertyDefinition);
     } else if (!numOfSame
             .get(typeRef)
             .get(propertyDefinition)
             .equals(Integer.valueOf(startAttributeIndex))
         && sameData.get(typeRef).get(propertyDefinition) == null) {
       randomData =
           RandomMethods.generateDataByDataTypeProperty(
               dataTypeOfProperty, defaultValue, propertyDefinition);
       sameData.get(typeRef).put(propertyDefinition, randomData);
     } else if (!numOfSame
             .get(typeRef)
             .get(propertyDefinition)
             .equals(Integer.valueOf(startAttributeIndex))
         && sameData.get(typeRef).get(propertyDefinition) != null) {
       randomData = sameData.get(typeRef).get(propertyDefinition);
     }
   }
   return randomData;
 }