@Override public Collection getScope() { return occ.getScope(); }
public static List<OccurrenceIF> findOccurrences(TopicIF oType, TopicIF topicIF, Collection<TopicIF> scope) { List<OccurrenceIF> result = new ArrayList<OccurrenceIF>(); Iterator<OccurrenceIF> it = topicIF.getOccurrences().iterator(); while (it.hasNext()) { OccurrenceIF occurIF = it.next(); if (Objects.equals(occurIF.getType(), oType) && CollectionUtils.equalsUnorderedSet(occurIF.getScope(), scope)) result.add(occurIF); } return result; }
public static List<OccurrenceIF> findOccurrences(TopicIF oType, TopicIF topicIF, LocatorIF datatype, Collection<TopicIF> scope) { List<OccurrenceIF> result = new ArrayList<OccurrenceIF>(); Iterator<OccurrenceIF> it = topicIF.getOccurrences().iterator(); while (it.hasNext()) { OccurrenceIF occurIF = it.next(); if (Objects.equals(occurIF.getType(), oType) && Objects.equals(occurIF.getDataType(), datatype) && CollectionUtils.equalsUnorderedSet(occurIF.getScope(), scope)) result.add(occurIF); } return result; }
public static List<OccurrenceIF> findOccurrences(TopicIF oType, TopicIF topicIF, String value, Collection<TopicIF> scope) { List<OccurrenceIF> result = new ArrayList<OccurrenceIF>(); Iterator<OccurrenceIF> it = topicIF.getOccurrences().iterator(); while (it.hasNext()) { OccurrenceIF occurIF = it.next(); if (Objects.equals(occurIF.getValue(), value) && Objects.equals(occurIF.getType(), oType) && CollectionUtils.equalsUnorderedSet(occurIF.getScope(), scope)) result.add(occurIF); } return result; }
public static List<OccurrenceIF> findOccurrences(TopicIF oType, TopicIF topicIF, Collection<TopicIF> scope) { List<OccurrenceIF> result = new ArrayList<OccurrenceIF>(); Iterator<OccurrenceIF> it = topicIF.getOccurrences().iterator(); while (it.hasNext()) { OccurrenceIF occurIF = it.next(); if (ObjectUtils.equals(occurIF.getType(), oType) && CollectionUtils.equalsUnorderedSet(occurIF.getScope(), scope)) result.add(occurIF); } return result; }
public static List<OccurrenceIF> findOccurrences(TopicIF oType, TopicIF topicIF, String value, LocatorIF datatype, Collection<TopicIF> scope) { List<OccurrenceIF> result = new ArrayList<OccurrenceIF>(); Iterator<OccurrenceIF> it = topicIF.getOccurrences().iterator(); while (it.hasNext()) { OccurrenceIF occurIF = it.next(); if (Objects.equals(occurIF.getValue(), value) && Objects.equals(occurIF.getType(), oType) && Objects.equals(occurIF.getDataType(), datatype) && CollectionUtils.equalsUnorderedSet(occurIF.getScope(), scope)) result.add(occurIF); } return result; }
public static OccurrenceIF findOccurrence(TopicIF oType, TopicIF topicIF, LocatorIF datatype, Collection<TopicIF> scope) { Iterator<OccurrenceIF> it = topicIF.getOccurrences().iterator(); while (it.hasNext()) { OccurrenceIF occurIF = it.next(); if (Objects.equals(occurIF.getType(), oType) && Objects.equals(occurIF.getDataType(), datatype) && CollectionUtils.equalsUnorderedSet(occurIF.getScope(), scope)) return occurIF; } return null; }
public static List<OccurrenceIF> findOccurrences(TopicIF oType, TopicIF topicIF, LocatorIF datatype, Collection<TopicIF> scope) { List<OccurrenceIF> result = new ArrayList<OccurrenceIF>(); Iterator<OccurrenceIF> it = topicIF.getOccurrences().iterator(); while (it.hasNext()) { OccurrenceIF occurIF = it.next(); if (ObjectUtils.equals(occurIF.getType(), oType) && ObjectUtils.equals(occurIF.getDataType(), datatype) && CollectionUtils.equalsUnorderedSet(occurIF.getScope(), scope)) result.add(occurIF); } return result; }
public static List<OccurrenceIF> findOccurrences(TopicIF oType, TopicIF topicIF, String value, Collection<TopicIF> scope) { List<OccurrenceIF> result = new ArrayList<OccurrenceIF>(); Iterator<OccurrenceIF> it = topicIF.getOccurrences().iterator(); while (it.hasNext()) { OccurrenceIF occurIF = it.next(); if (ObjectUtils.equals(occurIF.getValue(), value) && ObjectUtils.equals(occurIF.getType(), oType) && CollectionUtils.equalsUnorderedSet(occurIF.getScope(), scope)) result.add(occurIF); } return result; }
public static OccurrenceIF findOccurrence(TopicIF oType, TopicIF topicIF, LocatorIF datatype, Collection<TopicIF> scope) { Iterator<OccurrenceIF> it = topicIF.getOccurrences().iterator(); while (it.hasNext()) { OccurrenceIF occurIF = it.next(); if (ObjectUtils.equals(occurIF.getType(), oType) && ObjectUtils.equals(occurIF.getDataType(), datatype) && CollectionUtils.equalsUnorderedSet(occurIF.getScope(), scope)) return occurIF; } return null; }
public static List<OccurrenceIF> findOccurrences(TopicIF oType, TopicIF topicIF, String value, LocatorIF datatype, Collection<TopicIF> scope) { List<OccurrenceIF> result = new ArrayList<OccurrenceIF>(); Iterator<OccurrenceIF> it = topicIF.getOccurrences().iterator(); while (it.hasNext()) { OccurrenceIF occurIF = it.next(); if (ObjectUtils.equals(occurIF.getValue(), value) && ObjectUtils.equals(occurIF.getType(), oType) && ObjectUtils.equals(occurIF.getDataType(), datatype) && CollectionUtils.equalsUnorderedSet(occurIF.getScope(), scope)) result.add(occurIF); } return result; }
@Override public void run(MasterTest mt) { OccurrenceIF o = (OccurrenceIF)topicmap.getObjectById(mt.objectId); assertTrue("Occurrence theme is set", o.getScope().isEmpty()); } });
@Override public void run(MasterTest mt) { OccurrenceIF o = (OccurrenceIF)topicmap.getObjectById(mt.objectId); TopicIF theme = (TopicIF)topicmap.getObjectById(mt.value); assertTrue("Occurrence theme is not set", o.getScope().contains(theme)); } });
@Override public int compare(Object o1, Object o2) { OccurrenceIF occ1 = (OccurrenceIF) o1; OccurrenceIF occ2 = (OccurrenceIF) o2; int cmp = compareString(occ1.getValue(), occ2.getValue()); if (cmp == 0) cmp = compareLocator(occ1.getDataType(), occ2.getDataType()); if (cmp == 0) cmp = compareTopic(occ1.getType(), occ2.getType()); if (cmp == 0) cmp = compareTopicSet(occ1.getScope(), occ2.getScope()); return cmp; }
/** * Return true iff the type of the occurrence is accepted * @param occurrence The occurence to test for acceptance. It is assumed that * occurrence will only be tested for acceptance if its parent topic * has already been tested and passed. * @return true iff occurrence is accepted. */ public boolean ok(OccurrenceIF occurrence) { return filter.ok(occurrence) && ok(occurrence.getType()) && ok(occurrence.getScope()) && ok(occurrence.getTopic()); }
@Override public int compare(OccurrenceIF occ1, OccurrenceIF occ2) { if (occ1 == occ2) return 0; // Compare occurrence values int cval1 = compareObjects(occ1.getValue(), occ2.getValue()); if (cval1 != 0) return cval1; // Compare occurrence locators int cval2 = compareObjects(occ1.getLocator(), occ2.getLocator(), LocatorComparator.getInstance()); if (cval2 != 0) return cval2; // Compare type int cval3 = compareObjects(occ1.getType(), occ2.getType(), TopicComparator.getInstance()); if (cval3 != 0) return cval3; // Compare scope return compareCollections(occ1.getScope(), occ2.getScope(), TopicComparator.getInstance()); } }
private void write(OccurrenceIF occurrence, int number) { AttributesImpl attributes = reifier(occurrence); attributes.addAttribute("", "", AT_NUMBER, null, "" + number); startElement(EL_OCCURRENCE, attributes); attributes.clear(); write(occurrence.getValue()); // normalized in FakeOccurrence below write(occurrence.getDataType(), "datatype"); writeType(occurrence); write(occurrence.getScope()); writeLocators(occurrence.getItemIdentifiers(), EL_ITEMIDENTIFIERS); endElement(EL_OCCURRENCE); }
public void testMergeOccurrenceScopeUse() { try { TopicIF t1 = builder1.makeTopic(); TopicIF t2 = builder1.makeTopic(); TopicIF ot = builder1.makeTopic(); OccurrenceIF occ = builder1.makeOccurrence(t1, ot, ""); occ.addTheme(t2); MergeUtils.mergeInto(t1, t2); assertTrue("occurrence scope corrupted", occ.getScope().size() == 1); assertTrue("occurrence theme replacement not done correctly", occ.getScope().contains(t1)); } catch (ConstraintViolationException e) { fail("merge of topics unaccountably failed" + e.getMessage()); } }
/** * PUBLIC: Merges the source occurrence into the target topic in * another topic map. Makes no attempt to verify that the source * topic represents the same subject as the target topic. * @return The new occurrence in the target topic map. * @since 5.1.3 */ public static OccurrenceIF mergeInto(TopicIF target, OccurrenceIF source) { TopicMapIF tm = target.getTopicMap(); TopicMapBuilderIF builder = tm.getBuilder(); TopicIF type = findTopic(tm, source.getType()); OccurrenceIF newocc = builder.makeOccurrence(target, type, source.getValue(), source.getDataType()); for (TopicIF theme : source.getScope()) newocc.addTheme(findTopic(tm, theme)); return newocc; }
@Override public void run(MasterTest mt) { OccurrenceIF o = (OccurrenceIF)topicmap.getObjectById(mt.objectId); assertTrue("Added occurrence not found", o != null); if (testInitialProperties) { assertTrue("Source locators is set", o.getItemIdentifiers().isEmpty()); assertTrue("Scope is set", o.getScope().isEmpty()); assertTrue("Type is set", o.getType() == null); assertTrue("Value is set", o.getValue() == null); assertTrue("Locator is set", o.getLocator() == null); } } });