Author: tchemit Date: 2008-02-07 14:45:15 +0000 (Thu, 07 Feb 2008) New Revision: 720 Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java Log: inline variables generations de plus d'un attachment Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java =================================================================== --- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java 2008-02-07 14:39:57 UTC (rev 719) +++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/ElementGenerator.java 2008-02-07 14:45:15 UTC (rev 720) @@ -174,15 +174,15 @@ metaData.setType(element.getClass().getSimpleName()); StringBuffer sb = new StringBuffer(""); - int c = 3 + r.nextInt(5); - for (int i = 0; i < c; i++) { + + for (int i = 0,max = 3 + r.nextInt(5); i < max; i++) { sb.append(randomstrings[r.nextInt(cs)]).append(" "); } metaData.setDescription(sb.toString()); Version v = new Version("0"); - c = 2 + r.nextInt(2); - for (int i = 0; i < c; i++) { + + for (int i = 0,max = 2 + r.nextInt(2); i < max; i++) { v.setVersion(i, r.nextInt(5)); } metaData.setVersion(v.toString()); @@ -191,12 +191,19 @@ metaData.setLatest(true); Map<String, String> descriptors = new HashMap<String, String>(); - int i = 5 + r.nextInt(10); - for (int j = 0; j < i; j++) { - descriptors.put(Integer.toString(j), shortString()); + for (int i = 0,max = 1+ r.nextInt(12); i < max; i++) { + descriptors.put(Integer.toString(i), shortString()); } metaData.setDescriptors(descriptors); + + if (element instanceof Library || element instanceof ExplorationData) { + // generate attachments + for (int i=0,max = r.nextInt(15);i<max;i++) { + metaData.getAttachments().add(generateAttachment()); + } + } + element.setMetaData(metaData); } @@ -211,7 +218,7 @@ * @throws Exception * the exception */ - private <T extends DataEntity> Set<T> generateArray(Class<T> clazz) + public <T extends DataEntity> Set<T> generateArray(Class<T> clazz) throws Exception { Set<T> elements = new HashSet<T>(); int i = 3 + r.nextInt(2); @@ -310,7 +317,7 @@ * the exception */ private void processLibrary(Library library) throws Exception { - library.getMetaData().getAttachments().add(generateAttachment()); + //library.getMetaData().getAttachments().add(generateAttachment()); } /** @@ -348,8 +355,7 @@ throws Exception { Result result = new Result(); explorationData.setResult(result); - explorationData.getMetaData().getAttachments() - .add(generateAttachment()); + //explorationData.getMetaData().getAttachments().add(generateAttachment()); Set<ConstantValue> constantValues = generateArray(ConstantValue.class); for (ConstantValue constantValue : constantValues) {