Menu

Apelon Create Concept/Term Association Error

Help
sagar sul
2012-11-02
2012-11-07
  • sagar sul

    sagar sul - 2012-11-02

    1] This step is used to create association type for concept. I have successfully created association type in
    'dts_association_type' table.

    AssociationQuery associationQuery = AssociationQuery.createInstance(DTSConnection.getServerConnection());
    AssociationType associationType = new AssociationType("ConceptAssociation"+10,
    10, ""+10, 42511,
    ItemsConnected.CONCEPTS,
    Purpose.ARBITRARY,
    "ConceptAssociationInverseName"+10);

    associationQuery.addAssociationType(associationType));

    2] After that I have created two DTSConcept for association and this concepts also created successfully,
    then I execute the AddConcept association it is getting added successfully but the association_iid is zero,
    Please suggest if I missed any step. It is not generating Association Id correctly.
    See the code below.

    DTSConcept conceptFrom = createConcept("Concept8", 8, ""+8, 42511);
    DTSConcept conceptTo = createConcept("Concept9", 9, ""+9, 42511);
    ConceptAssociation association = new ConceptAssociation(conceptFrom, associationType, conceptTo);

    System.out.println(" CONCEPT ASSOCIATION CREATED " + addConceptAssociation(association));
    public DTSConcept createConcept(String name, int id, String code, int namespaceId) {
    DTSConcept concept = null;
    try {
    ThesaurusConceptQuery conceptQuery = getThesaurusConceptQuery();
    concept = new DTSConcept(name, id, code, namespaceId);
    concept = conceptQuery.addConcept(concept);
    dtsConnection.closeServerConnectionSocket();
    } catch (Exception e) {
    e.printStackTrace();
    }
    return concept;
    }

     
    • bg2

      bg2 - 2012-11-07

      What database are you using?

      From: sagar sul [mailto:sagarsul@users.sf.net]
      Sent: Friday, November 02, 2012 7:36 AM
      To: [apelon-dts:discussion]
      Subject: [apelon-dts:discussion] Apelon Create Concept/Term Association
      Error

      1] This step is used to create association type for concept. I have
      successfully created association type in
      'dts_association_type' table.

      AssociationQuery associationQuery =
      AssociationQuery.createInstance(DTSConnection.getServerConnection());
      AssociationType associationType = new
      AssociationType("ConceptAssociation"+10,
      10, ""+10, 42511,
      ItemsConnected.CONCEPTS,
      Purpose.ARBITRARY,
      "ConceptAssociationInverseName"+10);

      associationQuery.addAssociationType(associationType));

      2] After that I have created two DTSConcept for association and this
      concepts also created successfully,
      then I execute the AddConcept association it is getting added successfully
      but the association_iid is zero,
      Please suggest if I missed any step. It is not generating Association Id
      correctly.

      See the code below.

      DTSConcept conceptFrom = createConcept("Concept8", 8, ""+8, 42511);
      DTSConcept conceptTo = createConcept("Concept9", 9, ""+9, 42511);
      ConceptAssociation association = new ConceptAssociation(conceptFrom,
      associationType, conceptTo);

      System.out.println(" CONCEPT ASSOCIATION CREATED " +
      addConceptAssociation(association));
      public DTSConcept createConcept(String name, int id, String code, int
      namespaceId) {
      DTSConcept concept = null;
      try {
      ThesaurusConceptQuery conceptQuery = getThesaurusConceptQuery();
      concept = new DTSConcept(name, id, code, namespaceId);
      concept = conceptQuery.addConcept(concept);
      dtsConnection.closeServerConnectionSocket();
      } catch (Exception e) {
      e.printStackTrace();
      }
      return concept;
      }


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/apelon-dts/discussion/679244/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/prefs/

       
  • Jack Bowie

    Jack Bowie - 2012-11-03

    You're on the right track. Just remember that the golden rule of DTS API programming is "nothing changes the database unless it is done with a query server". So after you have created the Concepts via ThesaurusConceptQuery.addConcept, you need to use AssociationQuery.addConceptAssociation(con1, assn, con2) to store the association in the db.
    This will apprpriately set the IIDs.

    One other suggestion: using the static methods in DTSAppManager is an easy way to manage query servers. Just do DTSAppManager.getQuery().setConnection(conn) once at the top of your app. Then you can simply say DTSAppManager.getQuery().getThesaurusConceptQuery().addConcept(...) without worrying about instantiating the servers individually. DTSQuery does that for you.

    Good luck!

     

Log in to post a comment.