static String generateRandomString(String defaultValue, PropertyDefinition property) {
   String data = null;
   if (scenario.equals("random")) {
     if (defaultValue != null) {
       data = defaultValue + "_" + Integer.valueOf(randomGenerator.nextInt()).toString();
     } else {
       String[] parts = property.getName().toString().split("_");
       String propertyName = parts[parts.length - 1];
       data =
           propertyName.substring(0, propertyName.length() / 2)
               + "_"
               + Integer.valueOf(randomGenerator.nextInt()).toString();
     }
   } else if (scenario.equals("incremental")) {
     if (defaultValue != null) {
       data = defaultValue + "_" + Integer.valueOf(index.get(typeRef).get(property)).toString();
     } else {
       String[] parts = property.getName().toString().split("_");
       String propertyName = parts[parts.length - 1];
       data =
           propertyName.substring(0, propertyName.length() / 2)
               + "_"
               + Integer.valueOf(index.get(typeRef).get(property)).toString();
     }
   }
   return data;
 }
  public Map<PropertyDefinition, Object> generateDatasProperties(
      ClassDefinition type, Collection<PropertyDefinition> properties) throws Exception {
    Map<PropertyDefinition, Object> datasProperties = new HashMap<PropertyDefinition, Object>();

    Collection<PropertyDefinition> unicityProperties =
        generatorServices.getUnicityProperties(type, properties);

    Collection<PropertyDefinition> tempProperties = new ArrayList<PropertyDefinition>();
    tempProperties.addAll(properties);
    tempProperties.removeAll(unicityProperties);
    for (PropertyDefinition propertyDefinition : tempProperties) {
      if (!propertyDefinition.getName().getNamespaceURI().contains("alfresco")) {
        startAttributeIndex = 0;
        datasProperties.put(propertyDefinition, generateDatasProperty(propertyDefinition));
      }
    }

    if (unicityProperties.size() > 0) {
      startAttributeIndex = savedStartIndexAttribute.intValue();
      Map<PropertyDefinition, Object> dataUnicityProperties =
          generateDataForUnicityProperties(type, unicityProperties);
      if (dataUnicityProperties.size() > 0) {
        datasProperties.putAll(dataUnicityProperties);
      }
    }

    return datasProperties;
  }
 private Map<PropertyDefinition, Object> generateDataForUnicityProperties(
     ClassDefinition type, Collection<PropertyDefinition> unicityProperties) throws Exception {
   Collection<Serial> dataProperties = new ArrayList<Serial>();
   boolean same = true;
   while (same) {
     dataProperties.clear();
     for (PropertyDefinition propertyDefinition : unicityProperties) {
       dataProperties.add(
           new Serial(
               type.getName().toString(),
               propertyDefinition.getName().toString(),
               generateDatasProperty(propertyDefinition)));
     }
     if (serializedData.size() > 0 && unicityProperties.size() > 0) {
       for (Serial dataProperty : dataProperties) {
         boolean contains = false;
         for (Serial serializedDataProperty : serializedData) {
           if (dataProperty.getType().equals(serializedDataProperty.getType())
               && dataProperty.getProperty().equals(serializedDataProperty.getProperty())
               && dataProperty
                   .getData()
                   .toString()
                   .equals(serializedDataProperty.getData().toString())) {
             contains = true;
           }
         }
         same &= contains;
       }
     } else {
       same = false;
     }
   }
   Map<PropertyDefinition, Object> finalDataProperties = new HashMap<PropertyDefinition, Object>();
   for (Serial dataProperty : dataProperties) {
     PropertyDefinition property =
         service.getProperty(QName.createQName(dataProperty.getProperty()));
     finalDataProperties.put(property, dataProperty.getData());
   }
   return finalDataProperties;
 }
  private CategoryPaths getCategoryPaths(
      NodeRef nodeRef, Set<QName> aspects, Map<QName, Serializable> properties) {
    ArrayList<Pair<Path, QName>> categoryPaths = new ArrayList<Pair<Path, QName>>();
    ArrayList<ChildAssociationRef> categoryParents = new ArrayList<ChildAssociationRef>();

    nodeDAO.setCheckNodeConsistency();
    for (QName classRef : aspects) {
      AspectDefinition aspDef = dictionaryService.getAspect(classRef);
      if (!isCategorised(aspDef)) {
        continue;
      }
      LinkedList<Pair<Path, QName>> aspectPaths = new LinkedList<Pair<Path, QName>>();
      for (PropertyDefinition propDef : aspDef.getProperties().values()) {
        if (!propDef.getDataType().getName().equals(DataTypeDefinition.CATEGORY)) {
          // The property is not a category
          continue;
        }
        // Don't try to iterate if the property is null
        Serializable propVal = properties.get(propDef.getName());
        if (propVal == null) {
          continue;
        }
        for (NodeRef catRef : DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, propVal)) {
          if (catRef == null) {
            continue;
          }
          // can be running in context of System user, hence use input nodeRef
          catRef = tenantService.getName(nodeRef, catRef);

          try {
            Pair<Long, NodeRef> pair = nodeDAO.getNodePair(catRef);
            if (pair != null) {
              for (Path path : nodeDAO.getPaths(pair, false)) {
                aspectPaths.add(new Pair<Path, QName>(path, aspDef.getName()));
              }
            }
          } catch (InvalidNodeRefException e) {
            // If the category does not exists we move on the next
          }
        }
      }
      categoryPaths.addAll(aspectPaths);
    }
    // Add member final element
    for (Pair<Path, QName> pair : categoryPaths) {
      if (pair.getFirst().last() instanceof Path.ChildAssocElement) {
        Path.ChildAssocElement cae = (Path.ChildAssocElement) pair.getFirst().last();
        ChildAssociationRef assocRef = cae.getRef();
        ChildAssociationRef categoryParentRef =
            new ChildAssociationRef(
                assocRef.getTypeQName(),
                assocRef.getChildRef(),
                QName.createQName("member"),
                nodeRef);
        pair.getFirst().append(new Path.ChildAssocElement(categoryParentRef));
        categoryParents.add(categoryParentRef);
      }
    }

    return new CategoryPaths(categoryPaths, categoryParents);
  }