Changeset 29429

Show
Ignore:
Timestamp:
01/18/08 03:06:46 (11 months ago)
Author:
bstefanescu
Message:

merged 28933 29042 29428 from trunk - fixed NXP-1913 + PATXT-46

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.nuxeo.ecm.core/branches/1.4/nuxeo-core-api/src/main/java/org/nuxeo/ecm/core/api/impl/DocumentModelImpl.java

    r28563 r29429  
    413413        if (hasSchema(schema)) { // lazy data model 
    414414            if (sid == null) { 
    415                 return new DataModelImpl(schema); // supports non bound docs 
     415                DataModel dataModel = new DataModelImpl(schema); // supports non bound docs 
     416                dataModels.put(schema, dataModel); 
     417                return dataModel; 
    416418            } 
    417419            CoreSession client = getClient(); 
     
    11341136 
    11351137        DataModelMap newDataModels = new DataModelMapImpl(); 
    1136         for (String key : sourceDoc.getDataModels().keySet()) { 
    1137             DataModel oldDM = sourceDoc.getDataModels().get(key); 
     1138        // dataModels could not be all loaded 
     1139        //for (String key : sourceDoc.getDataModels().keySet()) { 
     1140        for (String key : declaredSchemas) { 
     1141            //DataModel oldDM = sourceDoc.getDataModels().get(key); 
     1142            DataModel oldDM = sourceDoc.getDataModel(key); 
    11381143            DataModel newDM = cloneDataModel(oldDM); 
    11391144            newDataModels.put(key, newDM); 
     
    11581163            Type ftype = lfield.getType(); 
    11591164            List<Object> list = null; 
    1160             if (ftype.isSimpleType()) { // these are stored as arrays 
     1165            //if (ftype.isSimpleType()) { // these are stored as arrays 
     1166            if (value instanceof Object[]) { // these are stored as arrays 
    11611167                list = Arrays.asList((Object[]) value); 
    11621168            } else { 
     
    14131419        int p = segment.indexOf(':'); 
    14141420        if (p == -1) { // support also other schema paths? like schema.property 
     1421            // allow also unprefixed schemas -> make a search for the first matching schema having a property with same name as path segment 0 
     1422            DocumentPart[] parts = getParts(); 
     1423            for (DocumentPart part : parts) { 
     1424                if (part.getSchema().hasField(segment)) { 
     1425                    return part.resolvePath(path.toString()); 
     1426                } 
     1427            } 
     1428            // could not find any matching schema 
    14151429            throw new PropertyNotFoundException(xpath, "Schema not specified"); 
    14161430        } 
     
    14231437                throw new PropertyNotFoundException(xpath, "No such schema: " + prefix); 
    14241438            } 
     1439            // workaround for a schema prefix bug -> XPATH lookups in DocumentPart must use prefixed 
     1440            // names for schema with prefixes and non prefixed names for the rest o schemas. 
     1441            // Until then we used the name as the prefix but we must remove it since it is not a valid prefix: 
     1442            // NXP-1913 
     1443            String[] segments = path.segments(); 
     1444            segments[0] = segments[0].substring(p+1); 
     1445            path = Path.createFromSegments(segments); 
    14251446        } 
    14261447 
  • org.nuxeo.ecm.core/branches/1.4/nuxeo-core-facade/src/test/java/org/nuxeo/ecm/core/api/TestLocalAPI.java

    r29029 r29429  
    143143    } 
    144144 
     145    public void testPropertyXPath() throws Exception { 
     146        DocumentModel root = getRootDocument(); 
     147        DocumentModel parent = new DocumentModelImpl(root.getPathAsString(), 
     148                "theParent", "OrderedFolder"); 
     149 
     150        parent = remote.createDocument(parent); 
     151 
     152        DocumentModel doc = new DocumentModelImpl(parent.getPathAsString(), 
     153                "theDoc", "File"); 
     154 
     155        doc.setProperty("dublincore", "title", "my title"); 
     156        assertEquals("my title", doc.getPropertyValue("dc:title")); 
     157        doc.setProperty("file", "filename", "the file name"); 
     158        assertEquals("the file name", doc.getPropertyValue("filename")); 
     159        assertEquals("the file name", doc.getPropertyValue("file:filename")); 
     160 
     161    } 
     162 
    145163    @SuppressWarnings("unchecked") 
    146164    public void testComplexList() throws Exception { 
     
    203221 
    204222        list = (List) doc.getProperty("testList", "attachments"); 
    205         assertNotNull(list); 
    206         assertEquals(0, list.size()); 
     223        assertNull(list); 
     224//        assertNotNull(list); 
     225//        assertEquals(0, list.size()); 
    207226    } 
    208227 
     
    221240 
    222241            dm.setValue("price", 123); 
    223             assertEquals(123, dm.getValue("price")); 
     242            assertEquals((long)123, dm.getValue("price")); 
    224243            dm.setValue("price", 124); 
    225             assertEquals(124, dm.getValue("price")); 
     244            assertEquals((long)124, dm.getValue("price")); 
    226245 
    227246            dm.setValue("author/pJob", "Programmer");