Search in sources :

Example 6 with Concept

use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.

the class ImportRdf4jHelper method initAddConceptsStruct.

private void initAddConceptsStruct(AddConceptsStruct acs, SKOSResource conceptResource) throws ParseException {
    acs.conceptResource = conceptResource;
    acs.concept = new Concept();
    String idConcept = getOriginalId(conceptResource.getUri());
    acs.concept.setIdConcept(idConcept);
    // option cochée
    if (identifierType.equalsIgnoreCase("ark")) {
        acs.concept.setIdArk(getIdArkFromUri(conceptResource.getUri()));
    }
    if (identifierType.equalsIgnoreCase("handle")) {
        acs.concept.setIdHandle(getIdHandleFromUri(conceptResource.getUri()));
    }
    acs.concept.setIdThesaurus(idTheso);
    addNotation(acs);
    addGPSCoordinates(acs);
    addLabel(acs);
    addDocumentation(acs);
    addDate(acs);
    addMatch(acs);
    // autre
    // ajout des termes et traductions
    acs.nodeTerm.setNodeTermTraduction(acs.nodeTermTraductionList);
    acs.nodeTerm.setIdTerm(acs.concept.getIdConcept());
    acs.nodeTerm.setIdConcept(acs.concept.getIdConcept());
    acs.nodeTerm.setIdThesaurus(idTheso);
    acs.nodeTerm.setSource("");
    acs.nodeTerm.setStatus("");
    acs.nodeTerm.setCreated(acs.concept.getCreated());
    acs.nodeTerm.setModified(acs.concept.getModified());
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept)

Example 7 with Concept

use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.

the class ConceptHelper method reactiveConcept.

/**
 * Cette fonction permet de réactiver un concept (!hidden)
 *
 * @param ds
 * @param idConcept
 * @param idTheso
 * @param idUser
 * @return
 */
public boolean reactiveConcept(HikariDataSource ds, String idConcept, String idTheso, int idUser) {
    Connection conn;
    Statement stmt;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                Concept concept = getThisConcept(ds, idConcept, idTheso);
                concept.setStatus("D");
                if (!addConceptHistorique(conn, concept, idUser)) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
                String query = "UPDATE concept " + "set status='D'" + " WHERE id_concept ='" + idConcept + "'" + " AND id_thesaurus='" + idTheso + "'";
                stmt.executeUpdate(query);
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error during reactivation of Concept : " + idConcept, sqle);
        return false;
    }
    return true;
}
Also used : NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) Concept(mom.trd.opentheso.bdd.datas.Concept) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection)

Example 8 with Concept

use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.

the class ConceptHelper method addConceptFusion.

/**
 * Cette fonction permet de fusionner deux concepts. Le premier concept
 * reste, le second passe en état 'fusionné'.
 *
 * @param ds
 * @param idConcept1
 * @param idConcept2
 * @param idTheso
 * @param idUser
 * @return
 */
public boolean addConceptFusion(HikariDataSource ds, String idConcept1, String idConcept2, String idTheso, int idUser) {
    boolean status = false;
    String idArk = "";
    Connection conn;
    Statement stmt;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        conn.setAutoCommit(false);
        Concept concept = getThisConcept(ds, idConcept2, idTheso);
        concept.setStatus("hidden");
        if (!addConceptHistorique(conn, concept, idUser)) {
            conn.rollback();
            conn.close();
            return false;
        } else if (!updateStatusConcept(ds, idConcept2, idTheso, "hidden")) {
            conn.rollback();
            conn.close();
            return false;
        }
        try {
            stmt = conn.createStatement();
            try {
                String query = "Insert into concept_fusion " + "(id_concept1, id_concept2, id_thesaurus, id_user)" + " values (" + "'" + idConcept1 + "'" + ",'" + idConcept2 + "'" + ",'" + idTheso + "'" + ",'" + idUser + "')";
                stmt.executeUpdate(query);
                status = true;
                conn.commit();
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while melting Concept : " + idConcept1 + " and " + idConcept2, sqle);
    }
    return status;
}
Also used : NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) Concept(mom.trd.opentheso.bdd.datas.Concept) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection)

Example 9 with Concept

use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.

the class ConceptHelper method getConceptForExport.

/**
 * Cette fonction permet de récupérer toutes les informations concernant un
 * Concept par son id et son thésaurus et la langue On récupère aussi les
 * IdArk si Ark est actif
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @param isArkActive
 * @return Objet class NodeConcept
 */
public NodeConceptExport getConceptForExport(HikariDataSource ds, String idConcept, String idThesaurus, boolean isArkActive) {
    NodeConceptExport nodeConceptExport = new NodeConceptExport();
    // récupération des BT
    RelationsHelper relationsHelper = new RelationsHelper();
    ArrayList<NodeHieraRelation> nodeListOfBT_Ark = relationsHelper.getListBT(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeListOfBT(nodeListOfBT_Ark);
    // récupération du Concept
    Concept concept = getThisConcept(ds, idConcept, idThesaurus);
    /**
     * Attention si on passe par le null, ca veut dire qu'il y a une
     * incohérence dans la base à corriger !!!!!
     */
    if (concept == null) {
        return null;
    }
    nodeConceptExport.setConcept(concept);
    AlignmentHelper alignmentHelper = new AlignmentHelper();
    ArrayList<NodeAlignment> nodeAlignmentList = alignmentHelper.getAllAlignmentOfConcept(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeAlignmentsList(nodeAlignmentList);
    // récupération des termes spécifiques
    ArrayList<NodeHieraRelation> nodeListIdsOfNT_Ark = relationsHelper.getListNT(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeListOfNT(nodeListIdsOfNT_Ark);
    // récupération des termes associés
    ArrayList<NodeHieraRelation> nodeListIdsOfRT_Ark = relationsHelper.getListRT(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeListIdsOfRT(nodeListIdsOfRT_Ark);
    // récupération des Non Prefered Term
    nodeConceptExport.setNodeEM(new TermHelper().getAllNonPreferredTerms(ds, new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus), idThesaurus));
    // récupération des traductions
    nodeConceptExport.setNodeTermTraductions(new TermHelper().getAllTraductionsOfConcept(ds, idConcept, idThesaurus));
    // récupération des Groupes ou domaines
    ArrayList<NodeUri> nodeListIdsOfConceptGroup_Ark = getListIdArkOfGroup(ds, new GroupHelper().getListIdGroupOfConcept(ds, idThesaurus, idConcept), idThesaurus);
    nodeConceptExport.setNodeListIdsOfConceptGroup(nodeListIdsOfConceptGroup_Ark);
    // récupération des notes du Terme
    String idTerm = new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeNoteTerm(new NoteHelper().getListNotesTermAllLang(ds, idTerm, idThesaurus));
    // récupération des Notes du Concept
    nodeConceptExport.setNodeNoteConcept(new NoteHelper().getListNotesConceptAllLang(ds, idConcept, idThesaurus));
    // récupération des coordonnées GPS
    GpsHelper gpsHelper = new GpsHelper();
    NodeGps nodeGps = gpsHelper.getCoordinate(ds, idConcept, idThesaurus);
    if (nodeGps != null) {
        nodeConceptExport.setNodeGps(nodeGps);
    }
    return nodeConceptExport;
}
Also used : NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) Concept(mom.trd.opentheso.bdd.datas.Concept) NodeConceptExport(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport) NodeGps(mom.trd.opentheso.bdd.helper.nodes.NodeGps) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) NodeAlignment(mom.trd.opentheso.bdd.helper.nodes.NodeAlignment) NodeHieraRelation(mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation)

Example 10 with Concept

use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.

the class NewTreeBean method loadOrphan.

public void loadOrphan(String idTheso, String langue) {
    String typeNode, value = "";
    /*
        this.typeMot = type;
      this.idMot = id;
      this.idTheso = idT;
      this.langue = l;
      this.idDomaine = idD;
      this.typeDomaine = typeDomaine; 
      this.idTopConcept = idTC;
         */
    TreeNode dynamicTreeNode = (TreeNode) new MyTreeNode(1, null, idTheso, langue, null, null, null, "orphan", langueBean.getMsg("index.orphans"), root);
    orphans = new OrphanHelper().getListOrphanId(connect.getPoolConnexion(), idTheso);
    for (String idC : orphans) {
        if (new ConceptHelper().haveChildren(connect.getPoolConnexion(), idTheso, idC)) {
            typeNode = "dossier";
        } else {
            typeNode = "fichier";
        }
        Term term = new TermHelper().getThisTerm(connect.getPoolConnexion(), idC, idTheso, langue);
        if (term != null) {
            value = term.getLexical_value() + " (id_" + idC + ")";
            Concept temp = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idC, idTheso);
            MyTreeNode mtn = new MyTreeNode(3, idC, idTheso, langue, "Orphan", null, null, typeNode, value, dynamicTreeNode);
            if (typeNode.equals("dossier")) {
                new DefaultTreeNode("fake", mtn);
            }
        }
    }
}
Also used : OrphanHelper(mom.trd.opentheso.bdd.helper.OrphanHelper) Concept(mom.trd.opentheso.bdd.datas.Concept) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) TreeNode(org.primefaces.model.TreeNode) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) Term(mom.trd.opentheso.bdd.datas.Term) StructIdBroaderTerm(mom.trd.opentheso.dragdrop.StructIdBroaderTerm) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Aggregations

Concept (mom.trd.opentheso.bdd.datas.Concept)30 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)18 Term (mom.trd.opentheso.bdd.datas.Term)15 SQLException (java.sql.SQLException)12 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)12 Connection (java.sql.Connection)11 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)10 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)10 NodeConcept (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept)10 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)10 ArrayList (java.util.ArrayList)9 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)9 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)9 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)7 PreparedStatement (java.sql.PreparedStatement)6 Statement (java.sql.Statement)6 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)5 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)5 SKOSMapping (skos.SKOSMapping)5 SKOSTopConcept (skos.SKOSTopConcept)5