Changeset 29429
- Timestamp:
- 01/18/08 03:06:46 (11 months ago)
- 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 413 413 if (hasSchema(schema)) { // lazy data model 414 414 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; 416 418 } 417 419 CoreSession client = getClient(); … … 1134 1136 1135 1137 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); 1138 1143 DataModel newDM = cloneDataModel(oldDM); 1139 1144 newDataModels.put(key, newDM); … … 1158 1163 Type ftype = lfield.getType(); 1159 1164 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 1161 1167 list = Arrays.asList((Object[]) value); 1162 1168 } else { … … 1413 1419 int p = segment.indexOf(':'); 1414 1420 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 1415 1429 throw new PropertyNotFoundException(xpath, "Schema not specified"); 1416 1430 } … … 1423 1437 throw new PropertyNotFoundException(xpath, "No such schema: " + prefix); 1424 1438 } 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); 1425 1446 } 1426 1447 org.nuxeo.ecm.core/branches/1.4/nuxeo-core-facade/src/test/java/org/nuxeo/ecm/core/api/TestLocalAPI.java
r29029 r29429 143 143 } 144 144 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 145 163 @SuppressWarnings("unchecked") 146 164 public void testComplexList() throws Exception { … … 203 221 204 222 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()); 207 226 } 208 227 … … 221 240 222 241 dm.setValue("price", 123); 223 assertEquals( 123, dm.getValue("price"));242 assertEquals((long)123, dm.getValue("price")); 224 243 dm.setValue("price", 124); 225 assertEquals( 124, dm.getValue("price"));244 assertEquals((long)124, dm.getValue("price")); 226 245 227 246 dm.setValue("author/pJob", "Programmer");
