From: Xuan B. <med...@us...> - 2008-01-23 20:30:37
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/tmdm/tm4j1 In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv1186/src/org/tm4j/topicmap/tmdm/tm4j1 Modified Files: TopicImpl.java TopicMapImpl.java TopicMapObjectImpl.java Log Message: Infrastructure for adding item identifiers by resource locators easily if these resource locators are supplied. Index: TopicImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/tmdm/tm4j1/TopicImpl.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TopicImpl.java 23 Jan 2008 20:21:45 -0000 1.8 --- TopicImpl.java 23 Jan 2008 20:30:40 -0000 1.9 *************** *** 462,469 **** public Occurrence createOccurrence(String id, Locator resourceLocator,Topic type,Locator ref, Topic[] themes) throws DuplicateObjectIDException,DuplicateResourceLocatorException,PropertyVetoException { - assert resourceLocator==null; // not supported - try { ! return getContainer().unmergedToExternal(maybeAddID(id,getRepresentedObject().createOccurrence(getContainer().externalToUnmerged(type),OccurrenceImpl.createLocator(PSI.XMLSchema.IRI,this),TM4J1Utils.locatorToIRI(ref),getContainer().convertToInternalScope(themes)))); } catch (LocatorFactoryException e) { throw new RuntimeException("This should never happen.",e); --- 462,467 ---- public Occurrence createOccurrence(String id, Locator resourceLocator,Topic type,Locator ref, Topic[] themes) throws DuplicateObjectIDException,DuplicateResourceLocatorException,PropertyVetoException { try { ! return getContainer().unmergedToExternal(maybeAddID(id,resourceLocator,getRepresentedObject().createOccurrence(getContainer().externalToUnmerged(type),OccurrenceImpl.createLocator(PSI.XMLSchema.IRI,this),TM4J1Utils.locatorToIRI(ref),getContainer().convertToInternalScope(themes)))); } catch (LocatorFactoryException e) { throw new RuntimeException("This should never happen.",e); *************** *** 472,479 **** public Occurrence createOccurrence(String id, Locator resourceLocator,Topic type,String data, Topic[] themes) throws DuplicateObjectIDException,DuplicateResourceLocatorException,PropertyVetoException { - assert resourceLocator==null; // not supported - try { ! return getContainer().unmergedToExternal(maybeAddID(id,getRepresentedObject().createOccurrence(getContainer().externalToUnmerged(type),OccurrenceImpl.createLocator(PSI.XMLSchema.String,this),data,getContainer().convertToInternalScope(themes)))); } catch (LocatorFactoryException e) { throw new RuntimeException("This should never happen.",e); --- 470,475 ---- public Occurrence createOccurrence(String id, Locator resourceLocator,Topic type,String data, Topic[] themes) throws DuplicateObjectIDException,DuplicateResourceLocatorException,PropertyVetoException { try { ! return getContainer().unmergedToExternal(maybeAddID(id,resourceLocator,getRepresentedObject().createOccurrence(getContainer().externalToUnmerged(type),OccurrenceImpl.createLocator(PSI.XMLSchema.String,this),data,getContainer().convertToInternalScope(themes)))); } catch (LocatorFactoryException e) { throw new RuntimeException("This should never happen.",e); Index: TopicMapObjectImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/tmdm/tm4j1/TopicMapObjectImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TopicMapObjectImpl.java 23 Jan 2008 20:17:43 -0000 1.4 --- TopicMapObjectImpl.java 23 Jan 2008 20:30:41 -0000 1.5 *************** *** 378,381 **** --- 378,395 ---- } + protected <T extends TopicMapConstruct> T maybeAddID(String id,Locator resourceLocator,T tmo) throws DuplicateObjectIDException,DuplicateResourceLocatorException { + maybeAddID(id,tmo); + + if (resourceLocator!=null) { + try { + tmo.addItemIdentifier(resourceLocator); + } catch (org.tm4j.topicmap.tmdm.DuplicateItemIdentifierException e) { + throw new DuplicateResourceLocatorException(e); + } + } + + return tmo; + } + public String toString() { return "TopicMapObjectImpl[sourceLocators="+getSourceLocators()+"]"; Index: TopicMapImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/tmdm/tm4j1/TopicMapImpl.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** TopicMapImpl.java 23 Jan 2008 20:17:43 -0000 1.16 --- TopicMapImpl.java 23 Jan 2008 20:30:40 -0000 1.17 *************** *** 422,428 **** */ public Association createAssociation(String id, org.tm4j.net.Locator resourceLocator,Topic type, Topic[] themes) throws DuplicateObjectIDException, DuplicateResourceLocatorException,PropertyVetoException { ! assert resourceLocator==null; // not implemented ! ! return unmergedToExternal(maybeAddID(id,getRepresentedObject().createAssociation(type!=null?(((TopicImpl) type).getRepresentedObject()):getInternalUnspecifiedTopic(),convertToInternalScope(themes)))); } --- 422,426 ---- */ public Association createAssociation(String id, org.tm4j.net.Locator resourceLocator,Topic type, Topic[] themes) throws DuplicateObjectIDException, DuplicateResourceLocatorException,PropertyVetoException { ! return unmergedToExternal(maybeAddID(id,resourceLocator,getRepresentedObject().createAssociation(type!=null?(((TopicImpl) type).getRepresentedObject()):getInternalUnspecifiedTopic(),convertToInternalScope(themes)))); } |