From: Xuan B. <med...@us...> - 2008-01-23 20:54:11
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/tmdm/tm4j1 In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv11760/src/org/tm4j/topicmap/tmdm/tm4j1 Modified Files: TopicImpl.java TopicMapImpl.java Log Message: Support for default occurence type topic. Index: TopicImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/tmdm/tm4j1/TopicImpl.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TopicImpl.java 23 Jan 2008 20:30:40 -0000 1.9 --- TopicImpl.java 23 Jan 2008 20:54:15 -0000 1.10 *************** *** 455,459 **** public Occurrence createOccurrence(String id) throws DuplicateObjectIDException, PropertyVetoException { try { ! return getContainer().unmergedToExternal(maybeAddID(id,getRepresentedObject().createOccurrence(getContainer().getInternalUnspecifiedTopic(),OccurrenceImpl.createLocator(PSI.XMLSchema.String,this),"",null))); // dummy, not allowed in TMDM } catch (LocatorFactoryException e) { throw new RuntimeException("This should never happen.",e); --- 455,459 ---- public Occurrence createOccurrence(String id) throws DuplicateObjectIDException, PropertyVetoException { try { ! return getContainer().unmergedToExternal(maybeAddID(id,getRepresentedObject().createOccurrence(getContainer().getInternalDefaultOccurenceTypeTopic(),OccurrenceImpl.createLocator(PSI.XMLSchema.String,this),"",null))); // dummy, not allowed in TMDM } catch (LocatorFactoryException e) { throw new RuntimeException("This should never happen.",e); *************** *** 463,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); --- 463,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((type!=null)?getContainer().externalToUnmerged(type):getContainer().getInternalDefaultOccurenceTypeTopic(),OccurrenceImpl.createLocator(PSI.XMLSchema.IRI,this),TM4J1Utils.locatorToIRI(ref),getContainer().convertToInternalScope(themes)))); } catch (LocatorFactoryException e) { throw new RuntimeException("This should never happen.",e); *************** *** 471,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); --- 471,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((type!=null)?getContainer().externalToUnmerged(type):getContainer().getInternalDefaultOccurenceTypeTopic(),OccurrenceImpl.createLocator(PSI.XMLSchema.String,this),data,getContainer().convertToInternalScope(themes)))); } catch (LocatorFactoryException e) { throw new RuntimeException("This should never happen.",e); Index: TopicMapImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/tmdm/tm4j1/TopicMapImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** TopicMapImpl.java 23 Jan 2008 20:30:40 -0000 1.17 --- TopicMapImpl.java 23 Jan 2008 20:54:15 -0000 1.18 *************** *** 66,69 **** --- 66,71 ---- protected org.tm4j.topicmap.tmdm.Topic unspecifiedTopic; + protected org.tm4j.topicmap.tmdm.Topic defaultOccurenceTypeTopic; + protected static HashMap<String,Boolean> defaultProperties = new HashMap<String,Boolean>(); *************** *** 149,152 **** --- 151,170 ---- } + protected org.tm4j.topicmap.tmdm.Topic getInternalDefaultOccurenceTypeTopic() { + if (defaultOccurenceTypeTopic==null) { + /* + this topic does not have properties, but this should be fine for now. + However, when having multiple merged topic maps, maybe the instances of the internal unspecified topic should merge, too? + */ + try { + defaultOccurenceTypeTopic = createInternalTopic(XTMPSI.OCCURRENCE); + } catch (LocatorFactoryException e) { + throw new RuntimeException("This should not happen.",e); + } + } + + return defaultOccurenceTypeTopic; + } + /** Having this method is good, as this method may evaluate faster than getInternalUnspecifiedTopic()==t, because: |