List of usage examples for org.apache.commons.lang3 StringUtils leftPad
public static String leftPad(final String str, final int size, String padStr)
Left pad a String with a specified String.
Pad to a size of size .
StringUtils.leftPad(null, *, *) = null StringUtils.leftPad("", 3, "z") = "zzz" StringUtils.leftPad("bat", 3, "yz") = "bat" StringUtils.leftPad("bat", 5, "yz") = "yzbat" StringUtils.leftPad("bat", 8, "yz") = "yzyzybat" StringUtils.leftPad("bat", 1, "yz") = "bat" StringUtils.leftPad("bat", -1, "yz") = "bat" StringUtils.leftPad("bat", 5, null) = " bat" StringUtils.leftPad("bat", 5, "") = " bat"
From source file:ontopoly.conversion.Upgrade_1_9.java
@Override protected void transform() throws InvalidQueryException { TopicIF topicmapType = getTopic(topicmap, base_on, "topic-map"); TopicIF reifier = topicmap.getReifier(); reifier.addType(topicmapType);// w w w . j a v a 2 s . c o m // on:ontology-topic-type -> on:ontology-type renameSubjectIdentifier(topicmap, base_on, "ontology-topic-type", "ontology-type"); // on:identity-field -> on:identity-type and introduce new on:identity-field renameSubjectIdentifier(topicmap, base_on, "identity-field", "identity-type"); renameTopics(topicmap, "Identity field", "Identity type"); renameSubjectIdentifier(topicmap, base_on, "identity-field-temp", "identity-field"); renameTopics(topicmap, "Identity field temp", "Identity field"); // on:field no longer instance of on:field-type TopicIF fieldTopic = getTopic(topicmap, base_on, "field"); TopicIF fieldType = getTopic(topicmap, base_on, "field-type"); fieldTopic.removeType(fieldType); // remove topics removeTopic(topicmap, base_on, "pattern"); // make ontology topics instances of on:system-topic TopicIF systemTopic = getTopic(topicmap, base_on, "system-topic"); getTopic(topicmap, base_on, "datatype-html").addType(systemTopic); getTopic(topicmap, base_on, "datatype-image").addType(systemTopic); getTopic(topicmap, base_on, "cardinality-1-1").addType(systemTopic); getTopic(topicmap, base_on, "cardinality-0-1").addType(systemTopic); getTopic(topicmap, base_on, "cardinality-1-M").addType(systemTopic); getTopic(topicmap, base_on, "cardinality-0-M").addType(systemTopic); getTopic(topicmap, base_on, "subject-identifier").addType(systemTopic); getTopic(topicmap, base_on, "subject-locator").addType(systemTopic); getTopic(topicmap, base_on, "auto-complete").addType(systemTopic); getTopic(topicmap, base_on, "browse-dialog").addType(systemTopic); getTopic(topicmap, base_on, "search-dialog").addType(systemTopic); getTopic(topicmap, base_on, "drop-down-list").addType(systemTopic); // make types of ontology topics explicit TopicIF topicType = getTopic(topicmap, base_on, "topic-type"); getTopic(topicmap, base_on, "cardinality").addType(topicType); getTopic(topicmap, base_on, "datatype").addType(topicType); getTopic(topicmap, base_on, "interface-control").addType(topicType); getTopic(topicmap, base_on, "identity-type").addType(topicType); getTopic(topicmap, base_on, "role-type").addType(topicType); getTopic(topicmap, base_on, "association-type").addType(topicType); getTopic(topicmap, base_on, "name-type").addType(topicType); getTopic(topicmap, base_on, "occurrence-type").addType(topicType); getTopic(topicmap, base_on, "topic-type").addType(topicType); getTopic(topicmap, base_tech, "#hierarchical-relation-type").addType(topicType); getTopic(topicmap, base_tech, "#subordinate-role-type").addType(topicType); getTopic(topicmap, base_tech, "#superordinate-role-type").addType(topicType); TopicIF roleType = getTopic(topicmap, base_on, "role-type"); getTopic(topicmap, base_on, "cardinality").addType(roleType); getTopic(topicmap, base_on, "datatype").addType(roleType); getTopic(topicmap, base_on, "interface-control").addType(roleType); getTopic(topicmap, base_on, "identity-type").addType(roleType); getTopic(topicmap, base_on, "role-type").addType(roleType); getTopic(topicmap, base_on, "association-type").addType(roleType); getTopic(topicmap, base_on, "name-type").addType(roleType); getTopic(topicmap, base_on, "occurrence-type").addType(roleType); getTopic(topicmap, base_on, "ontology-type").addType(roleType); getTopic(topicmap, base_on, "topic-type").addType(roleType); // ISSUE: what to do with xtm:sort topic? // on:is-hidden translateAssociations("on:is-hidden", new String[] { "on:topic-type" }, "is-hidden-type", new String[] { "ontology-type" }, topicmap, base_on, qp, dc); removeAssociations("on:is-hidden", new String[] { "on:topic-type" }, qp, dc); removeAssociations("on:is-hidden", new String[] { "on:ontology-type" }, qp, dc); translateAssociations("on:is-hidden", new String[] { "on:field-type" }, "is-hidden-type", new String[] { "ontology-type" }, topicmap, base_on, qp, dc); removeAssociations("on:is-hidden", new String[] { "on:field-type" }, qp, dc); removeAssociations("on:is-hidden", new String[] { "on:ontology-type" }, qp, dc); // on:is-readonly translateAssociations("on:is-readonly", new String[] { "on:topic-type" }, "is-readonly-type", new String[] { "ontology-type" }, topicmap, base_on, qp, dc); removeAssociations("on:is-readonly", new String[] { "on:topic-type" }, qp, dc); translateAssociations("on:is-readonly", new String[] { "on:field-type" }, "is-readonly-type", new String[] { "ontology-type" }, topicmap, base_on, qp, dc); removeAssociations("on:is-readonly", new String[] { "on:field-type" }, qp, dc); // on:has-role // translateAssociations("on:has-role", new String[] { "on:association-type", "on:role-type" }, // "has-valid-roletype", new String[] { "association-type", "role-type" }, // topicmap, base_on, qp, dc); removeAssociations("on:has-role", new String[] { "on:association-type", "on:role-type" }, qp, dc); // create association fields TopicIF tt_association_field = getTopic(topicmap, base_on, "association-field"); TopicIF tt_role_field = getTopic(topicmap, base_on, "role-field"); // track field definitions with cardinalities Set<TopicIF> assignedCardinality = new HashSet<TopicIF>(); // retrieve all association fields List<TopicIF[]> afields = new ArrayList<TopicIF[]>(); QueryResultIF qr = null; try { qr = qp.execute( "select $TT, $AT, $RT from on:has-field($TT : on:topic-type, $AT : on:field, $RT : on:role-type)?", dc); while (qr.next()) { afields.add(new TopicIF[] { (TopicIF) qr.getValue(0), (TopicIF) qr.getValue(1), (TopicIF) qr.getValue(2) }); } } finally { if (qr != null) qr.close(); } removeAssociations("on:has-field", new String[] { "on:topic-type", "on:field", "on:role-type" }, qp, dc); // loop over the fields so that we can execute other queries as we go Iterator<TopicIF[]> afiter = afields.iterator(); while (afiter.hasNext()) { TopicIF[] fen = afiter.next(); TopicIF tt = fen[0]; TopicIF at = fen[1]; TopicIF rt = fen[2]; TopicMapBuilderIF builder = topicmap.getBuilder(); TopicIF associationField = null; boolean existingAField = false; try { Map<String, TopicIF> params = Collections.singletonMap("AT", at); qr = qp.execute("select $AF from " + "on:has-association-type(%AT% : on:association-type, $AF : on:association-field)?", params, dc); if (qr.next()) { existingAField = true; associationField = (TopicIF) qr.getValue(0); } else { associationField = builder.makeTopic(tt_association_field); } } finally { if (qr != null) qr.close(); } if (!existingAField) { // on:has-association-type(%new-association-field% : on:association-field, $AT : on:association-type) AssociationIF a3 = builder.makeAssociation(getTopic(topicmap, base_on, "has-association-type")); builder.makeAssociationRole(a3, getTopic(topicmap, base_on, "association-field"), associationField); builder.makeAssociationRole(a3, getTopic(topicmap, base_on, "association-type"), at); } TopicIF roleField = null; boolean existingRField = false; try { Map<String, TopicIF> params = new HashMap<String, TopicIF>(2); params.put("AT", at); params.put("RT", rt); qr = qp.execute("select $RF from " + "on:has-association-type(%AT% : on:association-type, $AF : on:association-field), " + "on:has-association-field($AF : on:association-field, $RF : on:role-field), " + "on:has-role-type($RF : on:role-field, %RT% : on:role-type)?", params, dc); if (qr.next()) { existingRField = true; roleField = (TopicIF) qr.getValue(0); } else { roleField = builder.makeTopic(tt_role_field); } } finally { if (qr != null) qr.close(); } if (!existingRField) { AssociationIF hasAssociationField = builder .makeAssociation(getTopic(topicmap, base_on, "has-association-field")); builder.makeAssociationRole(hasAssociationField, getTopic(topicmap, base_on, "role-field"), roleField); builder.makeAssociationRole(hasAssociationField, getTopic(topicmap, base_on, "association-field"), associationField); // on:has-role-type(%new-role-field% : on:role-field, $RT : on:role-type) AssociationIF a4 = builder.makeAssociation(getTopic(topicmap, base_on, "has-role-type")); builder.makeAssociationRole(a4, getTopic(topicmap, base_on, "role-field"), roleField); builder.makeAssociationRole(a4, getTopic(topicmap, base_on, "role-type"), rt); // move role labels from association type to role field try { Map<String, TopicIF> params = new HashMap<String, TopicIF>(); params.put("AT", at); params.put("RT", rt); qr = qp.execute( "select $TN from topic-name(%AT%, $TN), scope($TN, %RT%), not(type($TN, $NT)), not(scope($TN, $SC), $SC /= %RT%)?", params, dc); if (qr.next()) { TopicNameIF tn1 = (TopicNameIF) qr.getValue(0); builder.makeTopicName(roleField, tn1.getValue()); tn1.remove(); } else { // builder.makeTopicName(newRoleField, TopicStringifiers.toString(at)); } } finally { if (qr != null) qr.close(); } // on:use-control($AT : on:association-type, $RT : on:role-type, $IC : on:interface-control) try { Map<String, TopicIF> params = new HashMap<String, TopicIF>(); params.put("AT", at); params.put("RT", rt); qr = qp.execute( "select $IC from on:use-control(%AT% : on:association-type, %RT% : on:role-type, $IC : on:interface-control)?", params, dc); if (qr.next()) { TopicIF ic = (TopicIF) qr.getValue(0); // on:use-control($RF : on:field-definition, $IC : on:interface-control) AssociationIF a5 = builder .makeAssociation(getTopic(topicmap, base_on, "use-interface-control")); builder.makeAssociationRole(a5, getTopic(topicmap, base_on, "field-definition"), roleField); builder.makeAssociationRole(a5, getTopic(topicmap, base_on, "interface-control"), ic); } } finally { if (qr != null) qr.close(); } } // on:has-field(%new-field-assignment% : on:field-assignment, %new-role-field% : on:field-definition) assignField(topicmap, base_on, roleField, tt); // on:has-cardinality($TT : on:topic-type, $AT : on:field, $RT : on:role-type, $C : on:cardinality) if (!assignedCardinality.contains(roleField)) { try { Map<String, TopicIF> params = new HashMap<String, TopicIF>(); params.put("TT", tt); params.put("AT", at); params.put("RT", rt); qr = qp.execute( "select $C from on:has-cardinality(%TT% : on:topic-type, %AT% : on:field, %RT% : on:role-type, $C : on:cardinality)?", params, dc); if (qr.next()) { TopicIF card = (TopicIF) qr.getValue(0); // on:has-cardinality($TT : on:topic-type, $RF : on:field-definition, $C : on:cardinality) AssociationIF a6 = builder.makeAssociation(getTopic(topicmap, base_on, "has-cardinality")); builder.makeAssociationRole(a6, getTopic(topicmap, base_on, "field-definition"), roleField); builder.makeAssociationRole(a6, getTopic(topicmap, base_on, "cardinality"), card); assignedCardinality.add(roleField); } } finally { if (qr != null) qr.close(); } } // update field order scope try { Map<String, TopicIF> params = new HashMap<String, TopicIF>(); params.put("TT", tt); params.put("AT", at); params.put("RT", rt); String query = "subclasses-of($SUP, $SUB) :- { " + " xtm:superclass-subclass($SUP : xtm:superclass, $SUB : xtm:subclass) | " + " xtm:superclass-subclass($SUP : xtm:superclass, $MID : xtm:subclass), subclasses-of($MID, $SUB) " + "}. " + "select $OC from { $TT = %TT% | subclasses-of(%TT%, $TT) }, occurrence($TT, $OC), type($OC, on:field-order), scope($OC, %RT%), scope($OC, %AT%)?"; qr = qp.execute(query, params, dc); while (qr.next()) { OccurrenceIF oc = (OccurrenceIF) qr.getValue(0); oc.removeTheme(at); oc.removeTheme(rt); oc.addTheme(roleField); } } finally { if (qr != null) qr.close(); } } // retrieve all non-association fields List<TopicIF[]> ofields = new ArrayList<TopicIF[]>(); try { qr = qp.execute( "select $TT, $XT from on:has-field($TT : on:topic-type, $XT : on:field), not(direct-instance-of($XT, on:association-type)), not(direct-instance-of($XT, on:role-type))?", dc); while (qr.next()) { ofields.add(new TopicIF[] { (TopicIF) qr.getValue(0), (TopicIF) qr.getValue(1) }); } } finally { if (qr != null) qr.close(); } removeAssociations("on:has-field", new String[] { "on:topic-type", "on:field" }, qp, dc); // create default fields for identity types, name types and occurrence types TopicMapBuilderIF builder = topicmap.getBuilder(); Map<TopicIF, TopicIF> xtfields = new HashMap<TopicIF, TopicIF>(); // identity types: subject identifier TopicIF subjectIdentifier = getTopic(topicmap, base_on, "subject-identifier"); TopicIF subjectIdentifierField = defineIdentityField(topicmap, base_on, "subject-identifier", "cardinality-0-M"); xtfields.put(subjectIdentifier, subjectIdentifierField); // assignFieldsView(topicmap, base_on, subjectIdentifierField, "default-fields-view"); // assignFieldsView(topicmap, base_on, subjectIdentifierField, "association-field-embedded-view"); // assignFieldsView(topicmap, base_on, subjectIdentifierField, "role-field-embedded-view"); // assignFieldsView(topicmap, base_on, subjectIdentifierField, "name-field-embedded-view"); // assignFieldsView(topicmap, base_on, subjectIdentifierField, "occurrence-field-embedded-view"); // assignFieldsView(topicmap, base_on, subjectIdentifierField, "identity-field-embedded-view"); TopicIF subjectLocator = getTopic(topicmap, base_on, "subject-locator"); TopicIF subjectLocatorField = defineIdentityField(topicmap, base_on, "subject-locator", "cardinality-0-M"); xtfields.put(subjectLocator, subjectLocatorField); TopicIF itemIdentifier = getTopic(topicmap, base_on, "item-identifier"); TopicIF itemIdentifierField = defineIdentityField(topicmap, base_on, "item-identifier", "cardinality-0-M"); xtfields.put(itemIdentifier, itemIdentifierField); assignField(topicmap, base_on, subjectIdentifierField, "topic-type"); assignField(topicmap, base_on, subjectIdentifierField, "identity-type"); assignField(topicmap, base_on, subjectIdentifierField, "name-type"); assignField(topicmap, base_on, subjectIdentifierField, "occurrence-type"); assignField(topicmap, base_on, subjectIdentifierField, "role-type"); assignField(topicmap, base_on, subjectIdentifierField, "association-type"); assignField(topicmap, base_on, subjectIdentifierField, "field-definition"); assignField(topicmap, base_on, subjectIdentifierField, "association-field"); assignField(topicmap, base_on, subjectIdentifierField, "cardinality"); assignField(topicmap, base_on, subjectIdentifierField, "datatype"); assignField(topicmap, base_on, subjectIdentifierField, "interface-control"); assignField(topicmap, base_on, subjectIdentifierField, "view-mode"); assignField(topicmap, base_on, subjectIdentifierField, "edit-mode"); assignField(topicmap, base_on, subjectIdentifierField, "create-action"); assignField(topicmap, base_on, subjectIdentifierField, "fields-view"); // occurrence types Collection<TopicIF> nonFieldOccurrenceTypes = new HashSet<TopicIF>(); nonFieldOccurrenceTypes.add(getTopic(topicmap, base_on, "field-order")); nonFieldOccurrenceTypes.add(getTopic(topicmap, base_on, "field-value-order")); nonFieldOccurrenceTypes.add(getTopic(topicmap, base_on, "ted-ontology-version")); try { qr = qp.execute( "select $XT, $DT from instance-of($XT, on:occurrence-type), { on:has-datatype($XT : on:field, $DT : on:datatype) }?", dc); while (qr.next()) { TopicIF xtType = (TopicIF) qr.getValue(0); if (nonFieldOccurrenceTypes.contains(xtType)) continue; TopicIF xtField = builder.makeTopic(getTopic(topicmap, base_on, "occurrence-field")); xtfields.put(xtType, xtField); // on:has-occurrence-type(%new-field% : on:occurrence-field, $XT : on:occurrence-type) AssociationIF a3 = builder.makeAssociation(getTopic(topicmap, base_on, "has-occurrence-type")); builder.makeAssociationRole(a3, getTopic(topicmap, base_on, "occurrence-field"), xtField); builder.makeAssociationRole(a3, getTopic(topicmap, base_on, "occurrence-type"), xtType); // on:has-datatype($TT : on:topic-type, $RF : on:field-definition, $C : on:datatype) TopicIF datatype = (TopicIF) qr.getValue(1); if (datatype != null) { AssociationIF a6 = builder.makeAssociation(getTopic(topicmap, base_on, "has-datatype")); builder.makeAssociationRole(a6, getTopic(topicmap, base_on, "field-definition"), xtField); builder.makeAssociationRole(a6, getTopic(topicmap, base_on, "datatype"), datatype); } } } finally { if (qr != null) qr.close(); } // name types try { qr = qp.execute("select $XT from instance-of($XT, on:name-type)?", dc); while (qr.next()) { TopicIF xtType = (TopicIF) qr.getValue(0); TopicIF xtField = builder.makeTopic(getTopic(topicmap, base_on, "name-field")); xtfields.put(xtType, xtField); // on:has-name-type(%new-field% : on:name-field, $XT : on:name-type) AssociationIF a3 = builder.makeAssociation(getTopic(topicmap, base_on, "has-name-type")); builder.makeAssociationRole(a3, getTopic(topicmap, base_on, "name-field"), xtField); builder.makeAssociationRole(a3, getTopic(topicmap, base_on, "name-type"), xtType); } } finally { if (qr != null) qr.close(); } // loop over the fields so that we can execute other queries as we go Iterator<TopicIF[]> ofiter = ofields.iterator(); while (ofiter.hasNext()) { TopicIF[] fen = ofiter.next(); TopicIF tt = fen[0]; TopicIF xt = fen[1]; TopicIF xtField = xtfields.get(xt); if (xtField == null) throw new OntopiaRuntimeException("Could not find field for " + xt); // builder.makeTopicName(newField, TopicStringifiers.toString(xt)); assignField(topicmap, base_on, xtField, tt); // update field order scope try { Map<String, TopicIF> params = new HashMap<String, TopicIF>(); params.put("TT", tt); params.put("XT", xt); String query = "subclasses-of($SUP, $SUB) :- { " + " xtm:superclass-subclass($SUP : xtm:superclass, $SUB : xtm:subclass) | " + " xtm:superclass-subclass($SUP : xtm:superclass, $MID : xtm:subclass), subclasses-of($MID, $SUB) " + "}. " + "select $OC from { $TT = %TT% | subclasses-of(%TT%, $TT) }, occurrence($TT, $OC), type($OC, on:field-order), scope($OC, %XT%)?"; qr = qp.execute(query, params, dc); while (qr.next()) { OccurrenceIF oc = (OccurrenceIF) qr.getValue(0); oc.removeTheme(xt); oc.addTheme(xtField); } } finally { if (qr != null) qr.close(); } // on:has-cardinality($XT : on:field-definition, $C : on:cardinality) if (!assignedCardinality.contains(xtField)) { try { Map<String, TopicIF> params = new HashMap<String, TopicIF>(); params.put("TT", tt); params.put("XT", xt); qr = qp.execute( "select $C from on:has-cardinality(%TT% : on:topic-type, %XT% : on:field, $C : on:cardinality)?", params, dc); if (qr.next()) { TopicIF card = (TopicIF) qr.getValue(0); // on:has-cardinality($TT : on:topic-type, $RF : on:field-definition, $C : on:cardinality) AssociationIF a6 = builder.makeAssociation(getTopic(topicmap, base_on, "has-cardinality")); builder.makeAssociationRole(a6, getTopic(topicmap, base_on, "field-definition"), xtField); builder.makeAssociationRole(a6, getTopic(topicmap, base_on, "cardinality"), card); assignedCardinality.add(xtField); } } finally { if (qr != null) qr.close(); } } } removeAssociations("on:has-datatype", new String[] { "on:field", "on:datatype" }, qp, dc); removeAssociations("on:has-cardinality", new String[] { "on:topic-type", "on:field", "on:role-type", "on:cardinality" }, qp, dc); removeAssociations("on:has-cardinality", new String[] { "on:topic-type", "on:field", "on:cardinality" }, qp, dc); removeAssociations("on:use-control", new String[] { "on:association-type", "on:role-type", "on:interface-control" }, qp, dc); // remove on:default-cardinality removeAssociations("on:default-cardinality", new String[] { "on:cardinality", "on:field" }, qp, dc); removeAssociations("on:default-cardinality", new String[] { "on:cardinality", "on:field-type" }, qp, dc); // remove on:field-type getTopic(topicmap, base_on, "role-type").removeType(fieldType); getTopic(topicmap, base_on, "association-type").removeType(fieldType); getTopic(topicmap, base_on, "identity-type").removeType(fieldType); getTopic(topicmap, base_on, "name-type").removeType(fieldType); getTopic(topicmap, base_on, "occurrence-type").removeType(fieldType); removeTopic(topicmap, base_on, "field-type"); // remove topics removeTopicIfExist(topicmap, base_on, "is-hierarchical"); removeTopic(topicmap, base_on, "is-hidden"); removeTopic(topicmap, base_on, "is-readonly"); removeTopic(topicmap, base_on, "field"); removeTopic(topicmap, base_on, "use-control"); removeTopic(topicmap, base_on, "default-cardinality"); removeTopic(topicmap, base_on, "has-role"); // define meta-ontology associations RoleFieldDefinition hasField = defineRoleFields(topicmap, base_on, "has-field", "Has field", new String[] { "field-owner", "field-definition" }, new String[] { "Fields", "Used by" }, new String[][] { new String[] { "topic-type", "cardinality-0-M" }, new String[] { "field-definition", "cardinality-1-M" } }); //assignFieldsView(topicmap, base_on, hasField.rfields[0], "advanced-fields-view"); assignFieldsView(topicmap, base_on, hasField.rfields[0], "declared-fields-view"); assignFieldsView(topicmap, base_on, hasField.rfields[1], "default-fields-view"); // assignFieldsView(topicmap, base_on, hasField.rfields[1], "association-field-embedded-view"); assignFieldsView(topicmap, base_on, hasField.rfields[1], "role-field-embedded-view"); assignFieldsView(topicmap, base_on, hasField.rfields[1], "name-field-embedded-view"); assignFieldsView(topicmap, base_on, hasField.rfields[1], "occurrence-field-embedded-view"); assignFieldsView(topicmap, base_on, hasField.rfields[1], "identity-field-embedded-view"); // defineRoleFields(topicmap, base_on, "use-as-role-type", "Use as role type", // new String[] {"topic-type"}, // new String[] {"Use as role type"}, // new String[][] { // new String[] {"topic-type", "cardinality-0-1"}}); RoleFieldDefinition fieldInView = defineRoleFields(topicmap, base_on, "field-in-view", "Fields in view", new String[] { "field-definition", "fields-view" }, new String[] { "Part of views", "Fields in view" }, new String[][] { new String[] { "field-definition", "cardinality-0-M" }, new String[] { "fields-view", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, fieldInView.rfields[0], "advanced-fields-view"); defineRoleFields(topicmap, base_on, "is-hidden-view", "Hidden views", new String[] { "fields-view" }, new String[] { "Is hidden view" }, new String[][] { new String[] { "fields-view", "cardinality-0-1" } }); defineRoleFields(topicmap, base_on, "is-embedded-view", "Embedded views", new String[] { "fields-view" }, new String[] { "Is embedded view" }, new String[][] { new String[] { "fields-view", "cardinality-0-1" } }); RoleFieldDefinition hasCardinality = defineRoleFields(topicmap, base_on, "has-cardinality", "Has cardinality", new String[] { "cardinality", "field-definition" }, new String[] { "Field cardinalities", "Cardinality" }, new String[][] { new String[] { "cardinality", "cardinality-0-M" }, new String[] { "field-definition", "cardinality-0-1" } }); assignFieldsView(topicmap, base_on, hasCardinality.rfields[0], "declared-fields-view"); assignFieldsView(topicmap, base_on, hasCardinality.rfields[1], "default-fields-view"); //! assignFieldsView(topicmap, base_on, hasCardinality.rfields[1], "association-field-embedded-view"); assignFieldsView(topicmap, base_on, hasCardinality.rfields[1], "role-field-embedded-view"); assignFieldsView(topicmap, base_on, hasCardinality.rfields[1], "name-field-embedded-view"); assignFieldsView(topicmap, base_on, hasCardinality.rfields[1], "occurrence-field-embedded-view"); assignFieldsView(topicmap, base_on, hasCardinality.rfields[1], "identity-field-embedded-view"); RoleFieldDefinition formsHierarchyFor = defineRoleFields(topicmap, base_on, "forms-hierarchy-for", "Forms hierarchy for", new String[] { "association-type", "topic-type" }, new String[] { "Hierarchical for", "Hierarchical associations" }, new String[][] { new String[] { "association-type", "cardinality-0-M" }, new String[] { "topic-type", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, formsHierarchyFor.rfields[0], "advanced-fields-view"); assignFieldsView(topicmap, base_on, formsHierarchyFor.rfields[1], "advanced-fields-view"); RoleFieldDefinition superOrdinateRoleType = defineRoleFields(topicmap, base_on, "superordinate-role-type", "Superordinate role type", new String[] { "association-type", "role-type" }, new String[] { "Superordinate role type", "Superordinate role type for" }, new String[][] { new String[] { "association-type", "cardinality-0-1" }, new String[] { "role-type", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, superOrdinateRoleType.rfields[0], "advanced-fields-view"); assignFieldsView(topicmap, base_on, superOrdinateRoleType.rfields[1], "advanced-fields-view"); assignEditMode(topicmap, base_on, superOrdinateRoleType.rfields[0], "edit-mode-existing-values-only"); assignEditMode(topicmap, base_on, superOrdinateRoleType.rfields[1], "edit-mode-existing-values-only"); RoleFieldDefinition subOrdinateRoleType = defineRoleFields(topicmap, base_on, "subordinate-role-type", "Subordinate role type", new String[] { "association-type", "role-type" }, new String[] { "Subordinate role type", "Subordinate role type for" }, new String[][] { new String[] { "association-type", "cardinality-0-1" }, new String[] { "role-type", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, subOrdinateRoleType.rfields[0], "advanced-fields-view"); assignFieldsView(topicmap, base_on, subOrdinateRoleType.rfields[1], "advanced-fields-view"); assignEditMode(topicmap, base_on, subOrdinateRoleType.rfields[0], "edit-mode-existing-values-only"); assignEditMode(topicmap, base_on, subOrdinateRoleType.rfields[1], "edit-mode-existing-values-only"); RoleFieldDefinition hasAssociationType = defineRoleFields(topicmap, base_on, "has-association-type", "Has association type", new String[] { "association-type", "association-field" }, new String[] { "Association field", "Association type" }, new String[][] { new String[] { "association-type", "cardinality-0-M" }, new String[] { "association-field", "cardinality-0-M" } }); assignValueView(topicmap, base_on, hasAssociationType.rfields[0], "default-fields-view", "association-field-embedded-view"); assignEmbedded(topicmap, base_on, hasAssociationType.rfields[0], "association-field-embedded-view"); assignEditMode(topicmap, base_on, hasAssociationType.rfields[0], "edit-mode-owned-values"); // assignFieldsView(topicmap, base_on, hasAssociationType.rfields[0], "association-field-embedded-view"); //!assignFieldsView(topicmap, base_on, hasAssociationType.rfields[1], "advanced-fields-view"); RoleFieldDefinition hasAssociationField = defineRoleFields(topicmap, base_on, "has-association-field", "Has association field", new String[] { "association-field", "role-field" }, new String[] { "Roles", "Association field" }, new String[][] { new String[] { "association-field", "cardinality-0-M" }, new String[] { "role-field", "cardinality-0-M" } }); assignValueView(topicmap, base_on, hasAssociationField.rfields[0], "default-fields-view", "role-field-embedded-view"); assignValueView(topicmap, base_on, hasAssociationField.rfields[0], "association-field-embedded-view", "role-field-embedded-view"); assignEmbedded(topicmap, base_on, hasAssociationField.rfields[0], "role-field-embedded-view"); assignEditMode(topicmap, base_on, hasAssociationField.rfields[0], "edit-mode-owned-values"); assignFieldsView(topicmap, base_on, hasAssociationField.rfields[0], "default-fields-view"); assignFieldsView(topicmap, base_on, hasAssociationField.rfields[0], "association-field-embedded-view"); //!assignFieldsView(topicmap, base_on, hasAssociationField.rfields[1], "advanced-fields-view"); RoleFieldDefinition hasRoleType = defineRoleFields(topicmap, base_on, "has-role-type", "Has role type", new String[] { "role-type", "role-field" }, new String[] { "Role field", "Role type" }, new String[][] { new String[] { "role-type", "cardinality-0-M" }, new String[] { "role-field", "cardinality-1-1" } }); assignValueView(topicmap, base_on, hasRoleType.rfields[0], "default-fields-view", "role-field-embedded-view"); assignEmbedded(topicmap, base_on, hasRoleType.rfields[0], "role-field-embedded-view"); assignEditMode(topicmap, base_on, hasRoleType.rfields[0], "edit-mode-no-edit"); assignFieldsView(topicmap, base_on, hasRoleType.rfields[1], "default-fields-view"); assignFieldsView(topicmap, base_on, hasRoleType.rfields[1], "role-field-embedded-view"); addOccurrence(topicMap, base_on, hasRoleType.rfields[0], "allowed-players-query", "datatype-string", "select $T from { instance-of($T, on:topic-type) | instance-of($T, on:role-type) }?"); // RoleFieldDefinition hasRoleTypeTT = // defineRoleFields(topicmap, base_on, "has-role-type", "Has role type", // new String[] {"role-type", "role-field"}, // new String[] {"Role field", "Role type"}, // new String[][] { // new String[] {"topic-type", "cardinality-0-M"}, // new String[] {"role-field", "cardinality-1-1"}}); // assignFieldsView(topicmap, base_on, hasRoleTypeTT.rfields[0], "advanced-fields-view"); // assignEmbedded(topicmap, base_on, hasRoleTypeTT.rfields[0], "advanced-fields-view", "role-field-embedded-view"); // assignEditMode(topicmap, base_on, hasRoleTypeTT.rfields[0], "edit-mode-no-edit"); // assignFieldsView(topicmap, base_on, hasRoleTypeTT.rfields[1], "default-fields-view"); // assignFieldsView(topicmap, base_on, hasRoleTypeTT.rfields[1], "role-field-embedded-view"); RoleFieldDefinition hasIdentityType = defineRoleFields(topicmap, base_on, "has-identity-type", "Has identity type", new String[] { "identity-type", "identity-field" }, new String[] { "Identity field", "Identity type" }, new String[][] { new String[] { "identity-type", "cardinality-0-M" }, new String[] { "identity-field", "cardinality-0-M" } }); assignValueView(topicmap, base_on, hasIdentityType.rfields[0], "default-fields-view", "identity-field-embedded-view"); assignEmbedded(topicmap, base_on, hasIdentityType.rfields[0], "identity-field-embedded-view"); assignFieldsView(topicmap, base_on, hasIdentityType.rfields[0], "default-fields-view"); assignFieldsView(topicmap, base_on, hasIdentityType.rfields[0], "identity-field-embedded-view"); assignEditMode(topicmap, base_on, hasIdentityType.rfields[0], "edit-mode-owned-values"); RoleFieldDefinition hasNameType = defineRoleFields(topicmap, base_on, "has-name-type", "Has name type", new String[] { "name-type", "name-field" }, new String[] { "Name field", "Name type" }, new String[][] { new String[] { "name-type", "cardinality-0-M" }, new String[] { "name-field", "cardinality-0-M" } }); assignValueView(topicmap, base_on, hasNameType.rfields[0], "default-fields-view", "name-field-embedded-view"); assignEmbedded(topicmap, base_on, hasNameType.rfields[0], "name-field-embedded-view"); assignFieldsView(topicmap, base_on, hasNameType.rfields[0], "default-fields-view"); assignFieldsView(topicmap, base_on, hasNameType.rfields[0], "name-field-embedded-view"); assignEditMode(topicmap, base_on, hasNameType.rfields[0], "edit-mode-owned-values"); RoleFieldDefinition hasOccurrenceType = defineRoleFields(topicmap, base_on, "has-occurrence-type", "Has occurrence type", new String[] { "occurrence-type", "occurrence-field" }, new String[] { "Occurrence field", "Occurrence type" }, new String[][] { new String[] { "occurrence-type", "cardinality-0-M" }, new String[] { "occurrence-field", "cardinality-0-M" } }); assignValueView(topicmap, base_on, hasOccurrenceType.rfields[0], "default-fields-view", "occurrence-field-embedded-view"); assignEmbedded(topicmap, base_on, hasOccurrenceType.rfields[0], "occurrence-field-embedded-view"); assignFieldsView(topicmap, base_on, hasOccurrenceType.rfields[0], "default-fields-view"); assignFieldsView(topicmap, base_on, hasOccurrenceType.rfields[0], "occurrence-field-embedded-view"); assignEditMode(topicmap, base_on, hasOccurrenceType.rfields[0], "edit-mode-owned-values"); RoleFieldDefinition hasDataType = defineRoleFields(topicmap, base_on, "has-datatype", "Has data type", new String[] { "datatype", "field-definition" }, new String[] { "Occurrence field", "Data type" }, new String[][] { new String[] { "datatype", "cardinality-0-M" }, new String[] { "occurrence-field", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, hasDataType.rfields[1], "default-fields-view"); assignFieldsView(topicmap, base_on, hasDataType.rfields[1], "occurrence-field-embedded-view"); RoleFieldDefinition useInterfaceControl = defineRoleFields(topicmap, base_on, "use-interface-control", "Uses interface control", new String[] { "field-definition", "interface-control" }, new String[] { "Interface control", "Field" }, new String[][] { new String[] { "role-field", "cardinality-0-1" }, new String[] { "interface-control", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, useInterfaceControl.rfields[0], "default-fields-view"); //! assignFieldsView(topicmap, base_on, useInterfaceControl.rfields[0], "association-field-embedded-view"); assignFieldsView(topicmap, base_on, useInterfaceControl.rfields[0], "role-field-embedded-view"); RoleFieldDefinition hasLargeInstanceSet = defineRoleFields(topicmap, base_on, "has-large-instance-set", "Has large instance set", new String[] { "topic-type" }, new String[] { "Large instance set" }, new String[][] { new String[] { "topic-type", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, hasLargeInstanceSet.rfields[0], "advanced-fields-view"); defineRoleFields(topicmap, base_on, "is-abstract", "Is abstract", new String[] { "topic-type" }, new String[] { "Abstract", "" }, new String[][] { new String[] { "topic-type", "cardinality-0-M" } }); RoleFieldDefinition isHiddenType = defineRoleFields(topicmap, base_on, "is-hidden-type", "Is hidden type", new String[] { "ontology-type" }, new String[] { "Hidden" }, new String[][] { new String[] { "topic-type", "identity-type", "name-type", "occurrence-type", "role-type", "association-type", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, isHiddenType.rfields[0], "advanced-fields-view"); RoleFieldDefinition isReadOnlyType = defineRoleFields(topicmap, base_on, "is-readonly-type", "Is read-only type", new String[] { "ontology-type" }, new String[] { "Read-only" }, new String[][] { new String[] { "topic-type", "identity-type", "name-type", "occurrence-type", "role-type", "association-type", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, isReadOnlyType.rfields[0], "advanced-fields-view"); RoleFieldDefinition useViewMode = defineRoleFields(topicmap, base_on, "use-view-mode", "Use view mode", new String[] { "field-definition", "view-mode", "fields-view" }, new String[] { "View mode", "View mode", "Used by" }, new String[][] { new String[] { "field-definition", "cardinality-0-M" }, new String[] { "view-mode", "cardinality-0-M" }, new String[] { "fields-view", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, useViewMode.rfields[0], "advanced-fields-view"); RoleFieldDefinition valueView = defineRoleFields(topicmap, base_on, "use-value-view", "Use value view", new String[] { "field-definition", "parent-view", "child-view" }, new String[] { "Value view", "Parent view", "Child view" }, new String[][] { new String[] { "field-definition", "cardinality-0-M" }, new String[] { "fields-view", "cardinality-0-M" }, new String[] { "fields-view", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, valueView.rfields[0], "advanced-fields-view"); RoleFieldDefinition useEditMode = defineRoleFields(topicmap, base_on, "use-edit-mode", "Use edit mode", new String[] { "field-definition", "edit-mode" }, new String[] { "Edit modes", "Used by" }, new String[][] { new String[] { "field-definition", "cardinality-0-1" }, new String[] { "edit-mode", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, useEditMode.rfields[0], "advanced-fields-view"); assignEditMode(topicmap, base_on, useEditMode.rfields[0], "edit-mode-existing-values-only"); RoleFieldDefinition useCreateAction = defineRoleFields(topicmap, base_on, "use-create-action", "Use create action", new String[] { "field-definition", "create-action" }, new String[] { "Create actions", "Used by" }, new String[][] { new String[] { "field-definition", "cardinality-0-1" }, new String[] { "create-action", "cardinality-0-M" } }); assignFieldsView(topicmap, base_on, useCreateAction.rfields[0], "advanced-fields-view"); assignEditMode(topicmap, base_on, useCreateAction.rfields[0], "edit-mode-existing-values-only"); RoleFieldDefinition isSortableField = defineRoleFields(topicmap, base_on, "is-sortable-field", "Is sortable field", new String[] { "field-definition" }, new String[] { "Sortable" }, new String[][] { new String[] { "field-definition", "cardinality-0-1" } }); assignFieldsView(topicmap, base_on, isSortableField.rfields[0], "advanced-fields-view"); defineRoleFields(topicmap, base_on, "is-symmetric", "Is symmetric", new String[] { "association-type" }, new String[] { "Symmetric" }, new String[][] { new String[] { "association-type", "cardinality-0-M" } }); RoleFieldDefinition supsubClass = defineRoleFields(topicmap, base_on, getTopic(topicmap, base_xtm, "#superclass-subclass"), "Superclass-subclass", new TopicIF[] { getTopic(topicmap, base_xtm, "#superclass"), getTopic(topicmap, base_xtm, "#subclass") }, new String[] { "Subclass", "Superclass" }, new TopicIF[][] { new TopicIF[] { getTopic(topicmap, base_on, "topic-type"), getTopic(topicmap, base_on, "cardinality-0-M") }, new TopicIF[] { getTopic(topicmap, base_on, "topic-type"), getTopic(topicmap, base_on, "cardinality-0-1") } }); addOccurrence(topicMap, base_on, supsubClass.rfields[0], "allowed-players-query", "datatype-string", "select $T from direct-instance-of(%topic%, $TT), direct-instance-of($T, $TT), $T /= %topic%?"); // 91 addOccurrence(topicMap, base_on, supsubClass.rfields[1], "allowed-players-query", "datatype-string", "select $T from direct-instance-of(%topic%, $TT), direct-instance-of($T, $TT), $T /= %topic%?"); // 91 addOccurrence(topicMap, base_on, supsubClass.rfields[0], "allowed-players-types-query", "datatype-string", "select $TT from direct-instance-of(%topic%, $TT), {$TT = on:topic-type | $TT = on:association-type | $TT = on:occurrence-type | $TT = on:name-type | $TT = on:role-type}?"); // 91 addOccurrence(topicMap, base_on, supsubClass.rfields[1], "allowed-players-types-query", "datatype-string", "select $TT from direct-instance-of(%topic%, $TT), {$TT = on:topic-type | $TT = on:association-type | $TT = on:occurrence-type | $TT = on:name-type | $TT = on:role-type}?"); // 91 // 91: commented out // supsubClass = // defineRoleFields(topicmap, base_on, getTopic(topicmap, base_xtm, "#superclass-subclass"), "Superclass-subclass", // new TopicIF[] {getTopic(topicmap, base_xtm, "#superclass"), getTopic(topicmap, base_xtm, "#subclass")}, // new String[] {"Subclass", "Superclass"}, // new TopicIF[][] { // new TopicIF[] {getTopic(topicmap, base_on, "name-type"), getTopic(topicmap, base_on, "cardinality-0-M")}, // new TopicIF[] {getTopic(topicmap, base_on, "name-type"), getTopic(topicmap, base_on, "cardinality-0-1")}}); // assignFieldsView(topicmap, base_on, supsubClass.rfields[0], "advanced-fields-view"); // assignFieldsView(topicmap, base_on, supsubClass.rfields[1], "advanced-fields-view"); // // supsubClass = // defineRoleFields(topicmap, base_on, getTopic(topicmap, base_xtm, "#superclass-subclass"), "Superclass-subclass", // new TopicIF[] {getTopic(topicmap, base_xtm, "#superclass"), getTopic(topicmap, base_xtm, "#subclass")}, // new String[] {"Subclass", "Superclass"}, // new TopicIF[][] { // new TopicIF[] {getTopic(topicmap, base_on, "occurrence-type"), getTopic(topicmap, base_on, "cardinality-0-M")}, // new TopicIF[] {getTopic(topicmap, base_on, "occurrence-type"), getTopic(topicmap, base_on, "cardinality-0-1")}}); // assignFieldsView(topicmap, base_on, supsubClass.rfields[0], "advanced-fields-view"); // assignFieldsView(topicmap, base_on, supsubClass.rfields[1], "advanced-fields-view"); // // supsubClass = // defineRoleFields(topicmap, base_on, getTopic(topicmap, base_xtm, "#superclass-subclass"), "Superclass-subclass", // new TopicIF[] {getTopic(topicmap, base_xtm, "#superclass"), getTopic(topicmap, base_xtm, "#subclass")}, // new String[] {"Subclass", "Superclass"}, // new TopicIF[][] { // new TopicIF[] {getTopic(topicmap, base_on, "association-type"), getTopic(topicmap, base_on, "cardinality-0-M")}, // new TopicIF[] {getTopic(topicmap, base_on, "association-type"), getTopic(topicmap, base_on, "cardinality-0-1")}}); // assignFieldsView(topicmap, base_on, supsubClass.rfields[0], "advanced-fields-view"); // assignFieldsView(topicmap, base_on, supsubClass.rfields[1], "advanced-fields-view"); // // supsubClass = // defineRoleFields(topicmap, base_on, getTopic(topicmap, base_xtm, "#superclass-subclass"), "Superclass-subclass", // new TopicIF[] {getTopic(topicmap, base_xtm, "#superclass"), getTopic(topicmap, base_xtm, "#subclass")}, // new String[] {"Subclass", "Superclass"}, // new TopicIF[][] { // new TopicIF[] {getTopic(topicmap, base_on, "role-type"), getTopic(topicmap, base_on, "cardinality-0-M")}, // new TopicIF[] {getTopic(topicmap, base_on, "role-type"), getTopic(topicmap, base_on, "cardinality-0-1")}}); // assignFieldsView(topicmap, base_on, supsubClass.rfields[0], "advanced-fields-view"); // assignFieldsView(topicmap, base_on, supsubClass.rfields[1], "advanced-fields-view"); // RoleFieldDefinition memberOfOntology = // defineRoleFields(topicmap, base_on, "member-of-ontology", "Part of ontology", // new String[] {"ontology-member", "ontology"}, // new String[] {"Part of ontology", "Ontology topics"}, // new String[][] { // new String[] {"topic-type", "name-type", "occurrence-type", "role-type", "association-type", "cardinality-0-M"}, // new String[] {"ontology", "cardinality-1-M"}}); // assignFieldsView(topicmap, base_on, memberOfOntology.rfields[0], "advanced-fields-view"); TopicIF oField; oField = defineOccurrenceField(topicMap, base_on, "datatype-locator", "datatype-uri", "cardinality-1-1"); assignField(topicmap, base_on, oField, "datatype"); oField = defineOccurrenceField(topicMap, base_on, "description", "datatype-string", "cardinality-0-1"); addOccurrence(topicMap, base_on, oField, "height", "datatype-number", "5"); addOccurrence(topicMap, base_on, oField, "width", "datatype-number", "50"); assignField(topicmap, base_on, oField, "topic-map"); assignField(topicmap, base_on, oField, "topic-type"); assignField(topicmap, base_on, oField, "identity-type"); assignField(topicmap, base_on, oField, "name-type"); assignField(topicmap, base_on, oField, "occurrence-type"); assignField(topicmap, base_on, oField, "association-type"); assignField(topicmap, base_on, oField, "role-type"); // assignFieldsView(topicmap, base_on, oField, "default-fields-view"); // assignFieldsView(topicmap, base_on, oField, "association-field-embedded-view"); // assignFieldsView(topicmap, base_on, oField, "role-field-embedded-view"); // assignFieldsView(topicmap, base_on, oField, "name-field-embedded-view"); // assignFieldsView(topicmap, base_on, oField, "occurrence-field-embedded-view"); // assignFieldsView(topicmap, base_on, oField, "identity-field-embedded-view"); oField = defineOccurrenceField(topicMap, base_on, "creator", "datatype-string", "cardinality-0-1"); assignField(topicmap, base_on, oField, "topic-map"); oField = defineOccurrenceField(topicMap, base_on, "version", "datatype-string", "cardinality-0-1"); assignField(topicmap, base_on, oField, "topic-map"); oField = defineOccurrenceField(topicMap, base_on, "allowed-players-query", "datatype-string", "cardinality-0-1"); assignField(topicmap, base_on, oField, "role-field"); assignFieldsView(topicmap, base_on, oField, "advanced-fields-view"); addOccurrence(topicMap, base_on, oField, "height", "datatype-number", "5"); addOccurrence(topicMap, base_on, oField, "width", "datatype-number", "50"); oField = defineOccurrenceField(topicMap, base_on, "allowed-players-search-query", "datatype-string", "cardinality-0-1"); assignField(topicmap, base_on, oField, "role-field"); assignFieldsView(topicmap, base_on, oField, "advanced-fields-view"); addOccurrence(topicMap, base_on, oField, "height", "datatype-number", "5"); addOccurrence(topicMap, base_on, oField, "width", "datatype-number", "50"); oField = defineOccurrenceField(topicMap, base_on, "allowed-players-types-query", "datatype-string", "cardinality-0-1"); assignField(topicmap, base_on, oField, "role-field"); assignFieldsView(topicmap, base_on, oField, "advanced-fields-view"); addOccurrence(topicMap, base_on, oField, "height", "datatype-number", "5"); addOccurrence(topicMap, base_on, oField, "width", "datatype-number", "50"); oField = defineOccurrenceField(topicMap, base_on, "tolog-declarations", "datatype-string", "cardinality-0-1"); assignField(topicmap, base_on, oField, "topic-map"); assignFieldsView(topicmap, base_on, oField, "advanced-fields-view"); addOccurrence(topicMap, base_on, oField, "height", "datatype-number", "5"); addOccurrence(topicMap, base_on, oField, "width", "datatype-number", "50"); oField = defineOccurrenceField(topicMap, base_on, "height", "datatype-number", "cardinality-0-1"); assignField(topicmap, base_on, oField, "occurrence-field"); assignFieldsView(topicmap, base_on, oField, "default-fields-view"); assignFieldsView(topicmap, base_on, oField, "occurrence-field-embedded-view"); oField = defineOccurrenceField(topicMap, base_on, "width", "datatype-number", "cardinality-0-1"); assignField(topicmap, base_on, oField, "occurrence-field"); assignFieldsView(topicmap, base_on, oField, "default-fields-view"); assignFieldsView(topicmap, base_on, oField, "occurrence-field-embedded-view"); oField = defineOccurrenceField(topicMap, base_on, "min-cardinality", "datatype-number", "cardinality-0-1"); assignField(topicmap, base_on, oField, "cardinality"); oField = defineOccurrenceField(topicMap, base_on, "max-cardinality", "datatype-number", "cardinality-0-1"); assignField(topicmap, base_on, oField, "cardinality"); oField = defineOccurrenceField(topicMap, base_on, "hierarchy-definition-query", "datatype-string", "cardinality-0-1"); assignField(topicmap, base_on, oField, "topic-type"); assignFieldsView(topicmap, base_on, oField, "advanced-fields-view"); addOccurrence(topicMap, base_on, oField, "height", "datatype-number", "5"); addOccurrence(topicMap, base_on, oField, "width", "datatype-number", "50"); // oField = defineOccurrenceField(topicMap, base_on, "pattern", "datatype-string", "cardinality-0-1"); // assignField(topicmap, base_on, oField, "datatype"); // default name fields TopicIF untypedName = getTopic(topicmap, base_on, "untyped-name"); // NOTE: fixed TopicIF cardinality11 = getTopic(topicmap, base_on, "cardinality-1-1"); // NOTE: fixed TopicIF nField = null; try { qr = qp.execute("select $NF from direct-instance-of($NF, on:name-field), " + "on:has-name-type($NF : on:name-field, on:untyped-name : on:name-type)?", dc); if (qr.next()) nField = (TopicIF) qr.getValue(0); } finally { if (qr != null) qr.close(); } if (nField == null) { nField = builder.makeTopic(getTopic(topicmap, base_on, "name-field")); AssociationIF hasNameTypeA = builder.makeAssociation(getTopic(topicmap, base_on, "has-name-type")); builder.makeAssociationRole(hasNameTypeA, getTopic(topicmap, base_on, "name-type"), untypedName); builder.makeAssociationRole(hasNameTypeA, getTopic(topicmap, base_on, "name-field"), nField); } // on:has-cardinality($TT : on:topic-type, $RF : on:field-definition, $C : on:cardinality) if (!assignedCardinality.contains(nField)) { AssociationIF hasCardinalityA = builder.makeAssociation(getTopic(topicmap, base_on, "has-cardinality")); builder.makeAssociationRole(hasCardinalityA, getTopic(topicmap, base_on, "field-definition"), nField); builder.makeAssociationRole(hasCardinalityA, getTopic(topicmap, base_on, "cardinality"), cardinality11); assignedCardinality.add(nField); } assignFieldsView(topicmap, base_on, nField, "default-fields-view"); // assignFieldsView(topicmap, base_on, nField, "association-field-embedded-view"); assignFieldsView(topicmap, base_on, nField, "role-field-embedded-view"); assignFieldsView(topicmap, base_on, nField, "name-field-embedded-view"); assignFieldsView(topicmap, base_on, nField, "occurrence-field-embedded-view"); assignFieldsView(topicmap, base_on, nField, "identity-field-embedded-view"); // assignField(topicmap, base_on, nField, "topic-type"); // assignField(topicmap, base_on, nField, "name-type"); // assignField(topicmap, base_on, nField, "identity-type"); // assignField(topicmap, base_on, nField, "occurrence-type"); // assignField(topicmap, base_on, nField, "role-type"); // assignField(topicmap, base_on, nField, "association-type"); try { qr = qp.execute("select $T from direct-instance-of($T, on:topic-type), " + "direct-instance-of($T, on:system-topic), " + "not(xtm:superclass-subclass($T : xtm:subclass, $P : xtm:superclass))?", dc); while (qr.next()) { TopicIF tt = (TopicIF) qr.getValue(0); assignField(topicmap, base_on, nField, tt); // // on:has-field(%new-field-assignment% : on:field-assignment, %new-role-field% : on:field-definition) // AssociationIF a2 = builder.makeAssociation(getTopic(topicmap, base_on, "has-field")); // builder.makeAssociationRole(a2, getTopic(topicmap, base_on, "field-owner"), tt); // builder.makeAssociationRole(a2, getTopic(topicmap, base_on, "field-definition"), nField); } } finally { if (qr != null) qr.close(); } // try { // TopicIF ontopolyOntology = getTopic(topicmap, base_on, "ontopoly-ontology"); // qr = qp.execute("select $T from direct-instance-of($T, on:system-topic)?", dc); // while (qr.next()) { // TopicIF st = (TopicIF)qr.getValue(0); // // on:member-of-ontology(on:topic-type : on:topic-type, on:ontopoly-ontology : on:ontology) // AssociationIF memberOfOntology = builder.makeAssociation(getTopic(topicmap, base_on, "member-of-ontology")); // builder.makeAssociationRole(memberOfOntology, getTopic(topicmap, base_on, "ontology-member"), st); // builder.makeAssociationRole(memberOfOntology, getTopic(topicmap, base_on, "ontology"), ontopolyOntology); // st.removeType(systemTopic); // } // } finally { // if (qr != null) qr.close(); // } // TODO: turn on:is-symmetric assocation into a duplicate role field // rename topics renameTopics(topicmap, "Ontology Topic type", "Ontology type"); // height and width try { qr = qp.execute( "select $OT, $OF, $OH, $OW from on:has-occurrence-type($OT : on:occurrence-type, $OF : on:occurrence-field), " + "{ occurrence($OT, $OH), type($OH, on:height) }, " + "{ occurrence($OT, $OW), type($OW, on:width) }?", dc); LocatorIF numberType = base_xsd.resolveAbsolute("#decimal"); while (qr.next()) { // TopicIF otype = (TopicIF)qr.getValue(0); TopicIF ofield = (TopicIF) qr.getValue(1); OccurrenceIF occheight = (OccurrenceIF) qr.getValue(2); OccurrenceIF occwidth = (OccurrenceIF) qr.getValue(3); if (occheight != null) { TopicIF heightType = getTopic(topicmap, base_on, "height"); builder.makeOccurrence(ofield, heightType, occheight.getValue(), numberType); occheight.remove(); } if (occwidth != null) { TopicIF widthType = getTopic(topicmap, base_on, "width"); builder.makeOccurrence(ofield, widthType, occwidth.getValue(), numberType); occwidth.remove(); } } } finally { if (qr != null) qr.close(); } // makePublicSystemTopic(topicmap, base_on, base_xtm, "#superclass-subclass"); // makePublicSystemTopic(topicmap, base_on, base_xtm, "#superclass"); // makePublicSystemTopic(topicmap, base_on, base_xtm, "#subclass"); makePublicSystemTopic(topicmap, base_on, base_on, "cardinality-1-1"); makePublicSystemTopic(topicmap, base_on, base_on, "cardinality-1-M"); makePublicSystemTopic(topicmap, base_on, base_on, "cardinality-0-M"); makePublicSystemTopic(topicmap, base_on, base_on, "cardinality-0-1"); makePublicSystemTopic(topicmap, base_on, base_on, "create-action-navigate"); makePublicSystemTopic(topicmap, base_on, base_on, "create-action-none"); makePublicSystemTopic(topicmap, base_on, base_on, "create-action-popup"); makePublicSystemTopic(topicmap, base_on, base_on, "datatype-html"); makePublicSystemTopic(topicmap, base_on, base_on, "datatype-image"); makePublicSystemTopic(topicmap, base_on, base_xsd, "#date"); makePublicSystemTopic(topicmap, base_on, base_xsd, "#dateTime"); makePublicSystemTopic(topicmap, base_on, base_xsd, "#decimal"); makePublicSystemTopic(topicmap, base_on, base_xsd, "#string"); makePublicSystemTopic(topicmap, base_on, base_xsd, "#anyURI"); makePublicSystemTopic(topicmap, base_on, base_on, "edit-mode-existing-values-only"); makePublicSystemTopic(topicmap, base_on, base_on, "edit-mode-new-values-only"); makePublicSystemTopic(topicmap, base_on, base_on, "edit-mode-no-edit"); makePublicSystemTopic(topicmap, base_on, base_on, "edit-mode-normal"); makePublicSystemTopic(topicmap, base_on, base_on, "edit-mode-owned-values"); makePublicSystemTopic(topicmap, base_on, base_on, "advanced-fields-view"); makePublicSystemTopic(topicmap, base_on, base_on, "default-fields-view"); makePublicSystemTopic(topicmap, base_on, base_on, "auto-complete"); makePublicSystemTopic(topicmap, base_on, base_on, "browse-dialog"); makePublicSystemTopic(topicmap, base_on, base_on, "drop-down-list"); makePublicSystemTopic(topicmap, base_on, base_on, "search-dialog"); makePublicSystemTopic(topicmap, base_on, base_on, "untyped-name"); makePublicSystemTopic(topicmap, base_on, base_on, "view-mode-readonly"); makePublicSystemTopic(topicmap, base_on, base_on, "view-mode-hidden"); makePublicSystemTopic(topicmap, base_on, base_on, "view-mode-not-traversable"); makePublicSystemTopic(topicmap, base_on, base_on, "view-mode-embedded"); makePublicSystemTopic(topicmap, base_on, base_on, "description"); // add system topic as type on all field definitions TopicIF publicSystemTopic = getTopic(topicmap, base_on, "public-system-topic"); try { // field definitions qr = qp.execute("select $FD from instance-of($T, on:system-topic), " + "on:has-field($T : on:field-owner, $FD : on:field-definition)?", dc); while (qr.next()) { TopicIF field = (TopicIF) qr.getValue(0); field.addType(systemTopic); } // association fields qr = qp.execute("select $AF from instance-of($T, on:system-topic), " + "on:has-field($T : on:field-owner, $FD : on:field-definition), " + "on:has-association-field($FD : on:role-field, $AF : on:association-field)?", dc); while (qr.next()) { TopicIF field = (TopicIF) qr.getValue(0); field.addType(systemTopic); } // turn description field into public-system-topic qr = qp.execute("select $FD from instance-of($FD, on:field-definition), " + "{ on:has-occurrence-type($FD : on:occurrence-field, on:description : on:occurrence-type) |" + " on:has-name-type($FD : on:name-field, on:untyped-name : on:name-type) }?", dc); while (qr.next()) { TopicIF field = (TopicIF) qr.getValue(0); field.removeType(systemTopic); field.addType(publicSystemTopic); } // remove system-topic from some other fields qr = qp.execute("select $FD from instance-of($FD, on:field-definition), " + "{ on:has-occurrence-type($FD : on:occurrence-field, on:creator : on:occurrence-type) |" + " on:has-occurrence-type($FD : on:occurrence-field, on:version : on:occurrence-type) }?", dc); while (qr.next()) { TopicIF field = (TopicIF) qr.getValue(0); field.removeType(systemTopic); } // remove superclass-subtype between topic-type and ontology-type qr = qp.execute( "select $A from role-player($R1, on:topic-type), association-role($A, $R1), type($R1, xtm:superclass), " + "association-role($A, $R2), type($R2, xtm:subclass), role-player($R2, on:ontology-type)?", dc); while (qr.next()) { AssociationIF assoc = (AssociationIF) qr.getValue(0); assoc.remove(); } // remove on:role-type from topics that are already on:topic-type TopicIF roleType1 = getTopic(topicmap, base_on, "role-type"); qr = qp.execute( "select $T from direct-instance-of($T, on:topic-type), direct-instance-of($T, on:role-type)?", dc); while (qr.next()) { TopicIF topicType1 = (TopicIF) qr.getValue(0); topicType1.removeType(roleType1); } // remove superflous superclass-subclass definitions qr = qp.execute("select $PRF, $CRF, $AF from " + // 91 "on:has-role-type($PRF : on:role-field, xtm:superclass : on:role-type), " + "on:has-association-field($PRF : on:role-field, $AF : on:association-field), " + "on:has-association-type($AF : on:association-field, xtm:superclass-subclass : on:association-type), " + "on:has-association-field($CRF : on:role-field, $AF : on:association-field), " + "on:has-role-type($CRF : on:role-field, xtm:subclass : on:role-type), " + "not(on:has-field($PRF : on:field-definition, on:topic-type : on:field-owner), " + "on:has-field($CRF : on:field-definition, on:topic-type : on:field-owner))?", dc); while (qr.next()) { TopicIF prf = (TopicIF) qr.getValue(0); TopicIF crf = (TopicIF) qr.getValue(1); TopicIF af = (TopicIF) qr.getValue(2); prf.remove(); crf.remove(); af.remove(); } // add psi to field definitions and association fields // role-fields qr = qp.execute( "select $RF, $RT, $AT from instance-of($RF, on:role-field), instance-of($RF, on:system-topic), " + "on:has-role-type($RF : on:role-field, $RT : on:role-type), " + "on:has-association-field($RF : on:role-field, $AF : on:association-field), " + "on:has-association-type($AF : on:association-field, $AT : on:association-type)?", dc); while (qr.next()) { TopicIF rf = (TopicIF) qr.getValue(0); TopicIF rt = (TopicIF) qr.getValue(1); TopicIF at = (TopicIF) qr.getValue(2); String rtid = getSymbolicId(rt); String atid = getSymbolicId(at); if (rtid != null & atid != null) rf.addSubjectIdentifier(base_on.resolveAbsolute("rf-" + rtid + "_" + atid)); } // association fields qr = qp.execute("select $XF, $XT from " + // 91 "instance-of($XF, on:association-field), instance-of($XF, on:system-topic), on:has-association-type($XF : on:association-field, $XT : on:association-type)?", dc); while (qr.next()) { TopicIF xf = (TopicIF) qr.getValue(0); TopicIF xt = (TopicIF) qr.getValue(1); String xtid = getSymbolicId(xt); if (xtid != null) xf.addSubjectIdentifier(base_on.resolveAbsolute("af-" + xtid)); } // identity fields qr = qp.execute("select $XF, $XT from " + "instance-of($XF, on:identity-field), instance-of($XF, on:system-topic), on:has-identity-type($XF : on:identity-field, $XT : on:identity-type)?", dc); while (qr.next()) { TopicIF xf = (TopicIF) qr.getValue(0); TopicIF xt = (TopicIF) qr.getValue(1); String xtid = getSymbolicId(xt); if (xtid != null) xf.addSubjectIdentifier(base_on.resolveAbsolute("if-" + xtid)); } // name fields qr = qp.execute("select $XF, $XT from " + "instance-of($XF, on:name-field), instance-of($XF, on:system-topic), on:has-name-type($XF : on:name-field, $XT : on:name-type)?", dc); while (qr.next()) { TopicIF xf = (TopicIF) qr.getValue(0); TopicIF xt = (TopicIF) qr.getValue(1); String xtid = getSymbolicId(xt); if (xtid != null) xf.addSubjectIdentifier(base_on.resolveAbsolute("nf-" + xtid)); } // occurrence fields qr = qp.execute("select $XF, $XT from " + "instance-of($XF, on:occurrence-field), instance-of($XF, on:system-topic), on:has-occurrence-type($XF : on:occurrence-field, $XT : on:occurrence-type)?", dc); while (qr.next()) { TopicIF xf = (TopicIF) qr.getValue(0); TopicIF xt = (TopicIF) qr.getValue(1); String xtid = getSymbolicId(xt); if (xtid != null) xf.addSubjectIdentifier(base_on.resolveAbsolute("of-" + xtid)); } } finally { if (qr != null) qr.close(); } // remove duplicate fields qr = qp.execute("superclass-subclass($ANC, $DES) :- {" + // 91 "xtm:superclass-subclass($ANC : xtm:superclass, $DES : xtm:subclass) | " + "xtm:superclass-subclass($ANC : xtm:superclass, $MID : xtm:subclass), superclass-subclass($MID, $DES) " + "}. " + "select $A, $FD, $TT from " + "on:has-field($FD : on:field-definition, $TT : on:field-owner), " + "superclass-subclass($ST, $TT), " + "on:has-field($ST : on:field-owner, $FD : on:field-definition), " + "association($A), type($A, on:has-field), " + "association-role($A, $R1), type($R1, on:field-definition), role-player($R1, $FD), " + "association-role($A, $R2), type($R2, on:field-owner), role-player($R2, $TT)?", dc); while (qr.next()) { AssociationIF hasFieldAssoc = (AssociationIF) qr.getValue(0); hasFieldAssoc.remove(); } // remove unused field orders qr = qp.execute("superclass-subclass($ANC, $DES) :- {" + // 91 "xtm:superclass-subclass($ANC : xtm:superclass, $DES : xtm:subclass) | " + "xtm:superclass-subclass($ANC : xtm:superclass, $MID : xtm:subclass), superclass-subclass($MID, $DES) " + "}. " + "select $FOO from " + "occurrence($TT, $FOO), type($FOO, on:field-order), scope($FOO, $FD), " + "not({ on:has-field($FD : on:field-definition, $TT : on:field-owner) | " + "superclass-subclass($ST, $TT), " + "on:has-field($ST : on:field-owner, $FD : on:field-definition) })?", dc); while (qr.next()) { OccurrenceIF fieldOrderOcc = (OccurrenceIF) qr.getValue(0); fieldOrderOcc.remove(); } // reassign field orders < 1000 try { String query = "select $FO from " + "occurrence($TT, $FO), type($FO, on:field-order)?"; qr = qp.execute(query, dc); while (qr.next()) { OccurrenceIF occ = (OccurrenceIF) qr.getValue(0); try { int order = Integer.parseInt(occ.getValue()); if (order < 1000) { int neworder = (order * 1000) + 1000; occ.setValue(StringUtils.leftPad(Integer.toString(neworder), 9, '0')); } } catch (NumberFormatException e) { // ignore } } } finally { if (qr != null) qr.close(); } // order fields List<String> fdo = new ArrayList<String>(); fdo.add("null|http://psi.ontopia.net/ontology/untyped-name"); fdo.add("null|http://psi.ontopia.net/ontology/subject-identifier"); fdo.add("null|http://psi.ontopia.net/ontology/description"); fdo.add("null|http://purl.org/dc/elements/1.1/description"); fdo.add("null|http://psi.ontopia.net/biography/date-of-birth"); fdo.add("null|http://psi.ontopia.net/biography/date-of-death"); fdo.add("null|http://psi.ontopia.net/occurrence-type/#comment"); fdo.add("null|http://psi.ontopia.net/ontology/tolog-declarations"); fdo.add("null|http://psi.ontopia.net/ontology/datatype-locator"); fdo.add("null|http://purl.org/dc/elements/1.1/Date"); fdo.add("null|http://www.kanzaki.com/ns/music#key"); fdo.add("null|http://www.kanzaki.com/ns/music#opus"); fdo.add("null|http://psi.ontopia.net/ontology/creator"); fdo.add("null|http://psi.ontopia.net/ontology/version"); fdo.add("http://psi.ontopia.net/ontology/is-abstract|http://psi.ontopia.net/ontology/topic-type"); // fdo.add("http://psi.ontopia.net/ontology/use-as-role-type|http://psi.ontopia.net/ontology/topic-type"); fdo.add("http://psi.ontopia.net/ontology/is-hidden-view|http://psi.ontopia.net/ontology/fields-view"); fdo.add("http://psi.ontopia.net/ontology/is-embedded-view|http://psi.ontopia.net/ontology/fields-view"); fdo.add("http://psi.ontopia.net/ontology/is-hidden-type|http://psi.ontopia.net/ontology/ontology-type"); fdo.add("http://psi.ontopia.net/ontology/is-readonly-type|http://psi.ontopia.net/ontology/ontology-type"); fdo.add("http://psi.ontopia.net/ontology/is-sortable-field|http://psi.ontopia.net/ontology/field-definition"); fdo.add("http://psi.ontopia.net/ontology/is-symmetric|http://psi.ontopia.net/ontology/association-type"); fdo.add("http://psi.ontopia.net/ontology/has-association-type|http://psi.ontopia.net/ontology/association-field"); fdo.add("http://psi.ontopia.net/ontology/has-association-type|http://psi.ontopia.net/ontology/association-type"); fdo.add("http://psi.ontopia.net/ontology/has-association-field|http://psi.ontopia.net/ontology/association-field"); fdo.add("http://psi.ontopia.net/ontology/has-association-field|http://psi.ontopia.net/ontology/role-field"); fdo.add("http://psi.ontopia.net/ontology/has-role-type|http://psi.ontopia.net/ontology/role-field"); fdo.add("http://psi.ontopia.net/ontology/has-role-type|http://psi.ontopia.net/ontology/role-type"); fdo.add("http://psi.ontopia.net/ontology/has-datatype|http://psi.ontopia.net/ontology/datatype"); fdo.add("http://psi.ontopia.net/ontology/has-datatype|http://psi.ontopia.net/ontology/field-definition"); fdo.add("http://psi.ontopia.net/ontology/has-field|http://psi.ontopia.net/ontology/field-definition"); fdo.add("http://psi.ontopia.net/ontology/has-field|http://psi.ontopia.net/ontology/field-owner"); fdo.add("http://psi.ontopia.net/ontology/has-cardinality|http://psi.ontopia.net/ontology/cardinality"); fdo.add("http://psi.ontopia.net/ontology/has-cardinality|http://psi.ontopia.net/ontology/field-definition"); fdo.add("http://psi.ontopia.net/ontology/has-identity-type|http://psi.ontopia.net/ontology/identity-field"); fdo.add("http://psi.ontopia.net/ontology/has-identity-type|http://psi.ontopia.net/ontology/identity-type"); fdo.add("http://psi.ontopia.net/ontology/has-name-type|http://psi.ontopia.net/ontology/name-field"); fdo.add("http://psi.ontopia.net/ontology/has-name-type|http://psi.ontopia.net/ontology/name-type"); fdo.add("http://psi.ontopia.net/ontology/has-occurrence-type|http://psi.ontopia.net/ontology/occurrence-field"); fdo.add("http://psi.ontopia.net/ontology/has-occurrence-type|http://psi.ontopia.net/ontology/occurrence-type"); fdo.add("http://psi.ontopia.net/ontology/has-large-instance-set|http://psi.ontopia.net/ontology/topic-type"); fdo.add("http://psi.ontopia.net/ontology/use-edit-mode|http://psi.ontopia.net/ontology/edit-mode"); fdo.add("http://psi.ontopia.net/ontology/use-edit-mode|http://psi.ontopia.net/ontology/field-definition"); fdo.add("http://psi.ontopia.net/ontology/use-create-action|http://psi.ontopia.net/ontology/create-action"); fdo.add("http://psi.ontopia.net/ontology/use-create-action|http://psi.ontopia.net/ontology/field-definition"); fdo.add("http://psi.ontopia.net/ontology/field-in-view|http://psi.ontopia.net/ontology/field-definition"); fdo.add("http://psi.ontopia.net/ontology/field-in-view|http://psi.ontopia.net/ontology/fields-view"); fdo.add("http://psi.ontopia.net/ontology/use-interface-control|http://psi.ontopia.net/ontology/field-definition"); fdo.add("http://psi.ontopia.net/ontology/use-interface-control|http://psi.ontopia.net/ontology/interface-control"); fdo.add("http://psi.ontopia.net/ontology/use-view-mode|http://psi.ontopia.net/ontology/field-definition"); fdo.add("http://psi.ontopia.net/ontology/use-view-mode|http://psi.ontopia.net/ontology/fields-view"); fdo.add("http://psi.ontopia.net/ontology/use-view-mode|http://psi.ontopia.net/ontology/view-mode"); fdo.add("http://psi.ontopia.net/ontology/use-value-view|http://psi.ontopia.net/ontology/field-definition"); fdo.add("http://psi.ontopia.net/ontology/use-value-view|http://psi.ontopia.net/ontology/parent-view"); fdo.add("http://psi.ontopia.net/ontology/use-value-view|http://psi.ontopia.net/ontology/child-view"); fdo.add("http://www.kanzaki.com/ns/music#composer|http://www.kanzaki.com/ns/music#Composer"); fdo.add("http://www.kanzaki.com/ns/music#composer|http://www.kanzaki.com/ns/music#Oeuvre"); fdo.add("http://www.kanzaki.com/ns/music#conductor|http://www.kanzaki.com/ns/music#Conductor"); fdo.add("http://www.kanzaki.com/ns/music#conductor|http://www.kanzaki.com/ns/music#Musical_Event"); fdo.add("http://www.kanzaki.com/ns/music#performer|http://www.kanzaki.com/ns/music#Artist"); fdo.add("http://www.kanzaki.com/ns/music#performer|http://www.kanzaki.com/ns/music#Musical_Event"); fdo.add("http://www.kanzaki.com/ns/music#performs|http://www.kanzaki.com/ns/music#Artist"); fdo.add("http://www.kanzaki.com/ns/music#performs|http://www.kanzaki.com/ns/music#Musical_Event"); fdo.add("http://www.kanzaki.com/ns/music#performs|http://www.kanzaki.com/ns/music#Oeuvre"); fdo.add("http://www.kanzaki.com/ns/music#program|http://www.kanzaki.com/ns/music#Musical_Event"); fdo.add("http://www.kanzaki.com/ns/music#program|http://www.kanzaki.com/ns/music#Oeuvre"); fdo.add("http://www.topicmaps.org/xtm/1.0/core.xtm#superclass-subclass|http://www.topicmaps.org/xtm/1.0/core.xtm#subclass"); fdo.add("http://www.topicmaps.org/xtm/1.0/core.xtm#superclass-subclass|http://www.topicmaps.org/xtm/1.0/core.xtm#superclass"); // fdo.add("http://psi.ontopia.net/ontology/member-of-ontology|http://psi.ontopia.net/ontology/ontology"); // fdo.add("http://psi.ontopia.net/ontology/member-of-ontology|http://psi.ontopia.net/ontology/ontology-member"); fdo.add("http://psi.ontopia.net/ontology/superordinate-role-type|http://psi.ontopia.net/ontology/association-type"); fdo.add("http://psi.ontopia.net/ontology/superordinate-role-type|http://psi.ontopia.net/ontology/role-type"); fdo.add("http://psi.ontopia.net/ontology/subordinate-role-type|http://psi.ontopia.net/ontology/association-type"); fdo.add("http://psi.ontopia.net/ontology/subordinate-role-type|http://psi.ontopia.net/ontology/role-type"); fdo.add("http://psi.ontopia.net/ontology/forms-hierarchy-for|http://psi.ontopia.net/ontology/association-type"); fdo.add("http://psi.ontopia.net/ontology/forms-hierarchy-for|http://psi.ontopia.net/ontology/topic-type"); fdo.add("null|http://psi.ontopia.net/ontology/height"); fdo.add("null|http://psi.ontopia.net/ontology/width"); fdo.add("null|http://psi.ontopia.net/ontology/allowed-players-query"); fdo.add("null|http://psi.ontopia.net/ontology/allowed-players-search-query"); fdo.add("null|http://psi.ontopia.net/ontology/allowed-players-types-query"); fdo.add("null|http://psi.ontopia.net/ontology/min-cardinality"); fdo.add("null|http://psi.ontopia.net/ontology/max-cardinality"); fdo.add("null|http://psi.ontopia.net/ontology/hierarchy-definition-query"); // INFO: use this query to locate ontopoly types with no specific ordering: // using on for i"http://psi.ontopia.net/ontology/" // instance-of($TT, on:topic-type), on:has-field($TT : on:field-owner, $FD : on:field-definition), // not(occurrence($TT, $FOO), type($FOO, on:field-order), scope($FOO, $FD))? // assign new field orders to built-in fields try { String query = " subclasses-of($SUP, $SUB) :- { " + " xtm:superclass-subclass($SUP : xtm:superclass, $SUB : xtm:subclass) | " + " xtm:superclass-subclass($SUP : xtm:superclass, $MID : xtm:subclass), subclasses-of($MID, $SUB) " + "}. " + "select $TT, $FD, $AT, $FT from " + "on:has-field($DT : on:field-owner, $FD : on:field-definition), " + "{ $TT = $DT | subclasses-of($DT, $TT) }," + "{ on:has-identity-type($FD : on:identity-field, $FT : on:identity-type) " + "| on:has-name-type($FD : on:name-field, $FT : on:name-type)" + "| on:has-occurrence-type($FD : on:occurrence-field, $FT : on:occurrence-type) " + "| on:has-association-field($FD : on:role-field, $AF : on:association-field)," + "on:has-role-type($FD : on:role-field, $FT : on:role-type), " + "on:has-association-type($AF : on:association-field, $AT : on:association-type) " + "} order by $TT, $AT, $FT?"; qr = qp.execute(query, dc); while (qr.next()) { TopicIF tt = (TopicIF) qr.getValue(0); TopicIF fd = (TopicIF) qr.getValue(1); TopicIF at = (TopicIF) qr.getValue(2); TopicIF ft = (TopicIF) qr.getValue(3); String atkey = (at == null || at.getSubjectIdentifiers().isEmpty() ? null : at.getSubjectIdentifiers().iterator().next().getAddress()); String ftkey = (ft == null || ft.getSubjectIdentifiers().isEmpty() ? null : ft.getSubjectIdentifiers().iterator().next().getAddress()); String fieldkey = atkey + "|" + ftkey; int ix = fdo.indexOf(fieldkey); if (ix > -1) { int order = 1000 * ix; FieldAssignment.setOrder(topicMap, tt, fd, order, false); } } } finally { if (qr != null) qr.close(); } // remove duplicate field orders (keep lowest sortkey) // 91 qr = qp.execute("select $TT, $FD, $FO1, $FOV from " + "occurrence($TT, $FO1), type($FO1, on:field-order), scope($FO1, $FD), " + "occurrence($TT, $FO2), type($FO2, on:field-order), scope($FO2, $FD), " + "$FO1 /= $FO2, value($FO1, $FOV) " + "order by $TT, $FD, $FOV?", dc); Map<String, OccurrenceIF> fieldOrders = new HashMap<String, OccurrenceIF>(); while (qr.next()) { TopicIF tt = (TopicIF) qr.getValue(0); TopicIF fd = (TopicIF) qr.getValue(1); OccurrenceIF fieldOrderOcc = (OccurrenceIF) qr.getValue(2); String key = tt.getObjectId() + ":" + fd.getObjectId(); if (fieldOrders.containsKey(key)) fieldOrderOcc.remove(); else fieldOrders.put(key, fieldOrderOcc); } }
From source file:ontopoly.model.TopicType.java
private static void fieldOrderMaintainance(TopicType tt) { final TopicIF FIELD_ORDER = OntopolyModelUtils.getTopicIF(tt.getTopicMap(), PSI.ON, "field-order"); TopicIF topicIF = tt.getTopicIF();/*from w w w . j av a 2 s. c om*/ List<FieldAssignment> fieldAssignments = tt.getFieldAssignments(); Iterator<FieldAssignment> it = fieldAssignments.iterator(); while (it.hasNext()) { FieldAssignment fa = it.next(); FieldDefinition fieldDefinition = fa.getFieldDefinition(); Collection<TopicIF> scope = Collections.singleton(fieldDefinition.getTopicIF()); OccurrenceIF occurrenceIF = OntopolyModelUtils.findOccurrence(FIELD_ORDER, topicIF, DataTypes.TYPE_STRING, scope); if (occurrenceIF == null) { String fieldOrderAsString; int fieldOrder = fa.getOrder(tt); if (fieldOrder != Integer.MAX_VALUE) fieldOrderAsString = StringUtils.leftPad(Integer.toString(fieldOrder + 1), 9, '0'); else fieldOrderAsString = tt.getNextUnusedFieldOrder(); // create field-order occurrence OntopolyModelUtils.makeOccurrence(FIELD_ORDER, topicIF, fieldOrderAsString, DataTypes.TYPE_STRING, scope); } } }
From source file:ontopoly.model.TopicType.java
private String getNextUnusedFieldOrder() { int fieldOrder = 0; // find field-order occurrence Collection<OccurrenceIF> fieldOrderOccurrences = OntopolyModelUtils.findOccurrences( OntopolyModelUtils.getTopicIF(getTopicMap(), PSI.ON, "field-order"), getTopicIF(), DataTypes.TYPE_STRING);/*from ww w . j a v a2 s . c o m*/ Iterator<OccurrenceIF> it = fieldOrderOccurrences.iterator(); while (it.hasNext()) { OccurrenceIF occurrenceIF = it.next(); int temp = Integer.parseInt(occurrenceIF.getValue()); if (temp > fieldOrder) fieldOrder = temp; } return StringUtils.leftPad(Integer.toString(fieldOrder + 1), 9, '0'); }
From source file:ontopoly.utils.Ordering.java
public static String orderToString(int order) { return StringUtils.leftPad(Integer.toString(order), 9, '0'); }
From source file:org.apache.beam.sdk.extensions.sql.impl.udf.BuiltinStringFunctions.java
@UDF(funcName = "LPAD", parameterArray = { TypeName.STRING, TypeName.INT64, TypeName.STRING }, returnType = TypeName.STRING) public String lpad(String originalValue, Long returnLength, String pattern) { if (originalValue == null || returnLength == null || pattern == null) { return null; }// ww w.j a v a 2 s . com if (returnLength < -1 || pattern.isEmpty()) { throw new IllegalArgumentException("returnLength cannot be 0 or pattern cannot be empty."); } if (originalValue.length() == returnLength) { return originalValue; } else if (originalValue.length() < returnLength) { // add padding to left return StringUtils.leftPad(originalValue, Math.toIntExact(returnLength), pattern); } else { // truncating string by str.substring // Java String can only hold a string with Integer.MAX_VALUE as longest length. return originalValue.substring(0, Math.toIntExact(returnLength)); } }
From source file:org.apache.beam.sdk.io.hbase.HBaseIOTest.java
private static List<Mutation> makeTableData(int numRows) { List<Mutation> mutations = new ArrayList<>(numRows); for (int i = 0; i < numRows; ++i) { // We pad values in hex order 0,1, ... ,F,0, ... String prefix = String.format("%X", i % 16); // This 21 is to have a key longer than an input byte[] rowKey = Bytes.toBytes(StringUtils.leftPad("_" + String.valueOf(i), 21, prefix)); byte[] value = Bytes.toBytes(String.valueOf(i)); byte[] valueEmail = Bytes.toBytes(String.valueOf(i) + "@email.com"); mutations.add(new Put(rowKey).addColumn(COLUMN_FAMILY, COLUMN_NAME, value)); mutations.add(new Put(rowKey).addColumn(COLUMN_FAMILY, COLUMN_EMAIL, valueEmail)); }// w ww . j a v a2 s. c o m return mutations; }
From source file:org.apache.james.jmap.model.MessagePreviewGeneratorTest.java
@Test public void computeShouldReturnStringWithoutTruncation() throws Exception { String body = StringUtils.leftPad("a", 100, "b"); assertThat(testee.compute(Optional.of(body))).hasSize(100).isEqualTo(body); }
From source file:org.apache.james.jmap.model.MessagePreviewGeneratorTest.java
@Test public void computeShouldReturnStringIsLimitedTo256Length() throws Exception { String body = StringUtils.leftPad("a", 300, "b"); String expected = StringUtils.leftPad("b", MessagePreviewGenerator.MAX_PREVIEW_LENGTH, "b"); assertThat(testee.compute(Optional.of(body))).hasSize(MessagePreviewGenerator.MAX_PREVIEW_LENGTH) .isEqualTo(expected);/*from w w w . j a v a2 s.c om*/ }
From source file:org.apache.syncope.client.lib.ConcurrencyTest.java
@Test public void multiThreadTest() throws InterruptedException { for (int i = 0; i < THREAD_NUMBER; i++) { Thread execution = new Thread("Th-" + StringUtils.leftPad(String.valueOf(i), 5, '0')) { @Override/*ww w . j a v a 2 s. c o m*/ public void run() { try { client.getService(ResourceService.class); LOG.info(getName() + " completed successfully!"); } catch (Exception e) { LOG.error(getName() + " did not complete", e); } } }; try { execution.start(); } catch (OutOfMemoryError e) { // ignore } } Thread.sleep(THREAD_NUMBER); }
From source file:org.brickhouse.datatype.HDate.java
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(StringUtils.leftPad(Integer.toString(year), 4, '0')); sb.append('-'); sb.append(StringUtils.leftPad(Integer.toString(month), 2, '0')); sb.append('-'); sb.append(StringUtils.leftPad(Integer.toString(day), 2, '0')); return sb.toString(); }