Author: mfortun Date: 2011-04-20 10:53:21 +0200 (Wed, 20 Apr 2011) New Revision: 821 Url: http://nuiton.org/repositories/revision/wikitty/821 Log: * correct search on wikitty publication file system works Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java 2011-04-19 15:56:51 UTC (rev 820) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java 2011-04-20 08:53:21 UTC (rev 821) @@ -279,6 +279,8 @@ public WikittyEvent store(String securityToken, Collection<Wikitty> wikitties, boolean force) { + + try { for (Wikitty w : wikitties) { @@ -620,6 +622,7 @@ } // recupere la valeur dans le wikitty Object o = w.getFqField(fqfieldName); + // recupere le type de la valeur FieldType t = w.getFieldType(fqfieldName); // convertie la valeur a verifier dans le meme type que la valeur @@ -632,12 +635,9 @@ // dans le inmemory on doit retrouve des collections et non pas // des objets seuls :( value = Collections.singleton(value); - //FIXME mfortun-2011-04-19 ici ça fait bugger plus loin - // vu que on met dans une collection la valeur du startwith - //et que plus loin on tente de caster cette collection en string } value = t.getValidValue(value); - + boolean checked = false; switch (restriction.getName()) { @@ -691,9 +691,33 @@ + " is " + t.getType().name()); } - System.out.println(value.getClass()); - System.out.println(value); - checked = ((String) o).startsWith((String) value); + + // FIXME mfortun-2011-04-20 rustine pour champs multivalué de + // type string + // et restriction startwith dessus. ça marche mais faudrait + // quelque chose de plus + // propre, et surtout généraliser pour toutes les restrictions + + if (o instanceof Collection<?> + && value instanceof Collection<?>) { + + for (Object val : (Collection) value) { + + String valu = (String) val; + + for (Object oo : (Collection) o) { + String cotainedO = (String) oo; + if (cotainedO != null) { + checked = checked || cotainedO.startsWith(valu); + } + } + + } + + } else { + + checked = ((String) o).startsWith((String) value); + } break; } return checked; @@ -931,6 +955,8 @@ e.printStackTrace(); } + + List<PagedResult<String>> result = new ArrayList<PagedResult<String>>(); // for each criteria @@ -946,9 +972,8 @@ String id = entry.getKey(); Wikitty w = entry.getValue(); // if macth - System.out.println(restriction); if (checkRestriction(restriction, w)) { - + // increment result number currentIndex++; if (currentIndex > firstIndex) { @@ -1282,10 +1307,6 @@ File wikittyParentDir = new File(path); PropertiesExtended props = getWikittyPublicationProperties( wikittyParentDir, WIKITTY_FILE_META_PROPERTIES_FILE); - // re set the version - result.setVersion(props - .getProperty(WikittyPublicationFileSystem.META_PREFIX_KEY_VERSION - + completeName)); // set the current label WikittyLabelHelper.addLabels(result, props @@ -1306,16 +1327,19 @@ FileUtil.fileToByte(fileToTransform)); } + // re set the version + result.setVersion(props + .getProperty(WikittyPublicationFileSystem.META_PREFIX_KEY_VERSION + + completeName)); + return result; } protected void harvestNew(File starts, String label) throws Exception { - - - + System.out.println(homeFile + "harvestn new"); File propertyFile = new File(starts + File.separator + PROPERTY_DIRECTORY); - + if (!propertyFile.exists() || !propertyFile.isDirectory()) { propertyFile.mkdir(); @@ -1327,12 +1351,13 @@ WIKITTY_FILE_META_PROPERTIES_FILE); meta.put(META_CURRENT_LABEL, label); + meta.store(); for (File child : starts.listFiles()) { if (child.isDirectory() && !child.getName().equals(PROPERTY_DIRECTORY)) { harvestNew(child, label + WIKITTYLABEL_SEPARATOR + child.getName()); - } else if (!child.isDirectory()){ + } else if (!child.isDirectory()) { List<String> filesWikitty = new ArrayList<String>(); filesWikitty.addAll(CollectionUtil.toGenericCollection( @@ -1348,7 +1373,7 @@ protected void writeWikittyFileProperties(File towrite, String wikittyID) throws Exception { - + if (towrite.exists() && !towrite.isDirectory()) { Wikitty wikitty = new WikittyImpl(wikittyID);