Search in sources :

Example 1 with ArkClient

use of mom.trd.opentheso.ws.ark.ArkClient in project opentheso by miledrousset.

the class ArkeoJUnitTest method testCreateArk.

/**
 * Test de création d'identifiant Ark sous Arkéo de la MOM
 */
@org.junit.Test
public void testCreateArk() {
    /*    HikariDataSource conn = openConnexionPool();
*/
    ArkClient ark_Client = new ArkClient();
    ArrayList<DcElement> dcElementsList = new ArrayList<>();
    DcElement dcElement1 = new DcElement();
    // cette fonction permet de remplir la table Permutée
    dcElement1.setName("title");
    dcElement1.setValue("test_valeur1 en francais_modifiés");
    dcElement1.setLanguage("fr");
    dcElementsList.add(dcElement1);
    DcElement dcElement2 = new DcElement();
    dcElement2.setName("title");
    dcElement2.setValue("test_valeur2 en anglais modifiés");
    dcElement2.setLanguage("en");
    dcElementsList.add(dcElement2);
    DcElement dcElement3 = new DcElement();
    dcElement3.setName("description");
    dcElement3.setValue("description en francais modifiés");
    dcElement3.setLanguage("fr");
    dcElementsList.add(dcElement3);
    // String date, String url, String title, String creator, String description, String type
    String idArk = ark_Client.getArkId(new FileUtilities().getDate(), "http://pactols2.frantiq.fr/" + "?idc=" + "334545334340ezaeeza0" + "&idt=" + "TH_35", "3345453343eeeeza0_modifiés", "Frantiq", dcElementsList, // pcrt : p= pactols, crt=code DCMI pour collection
    "pcrt");
    System.out.println(idArk);
// conn.close();*/
}
Also used : DcElement(fr.mom.arkeo.soap.DcElement) FileUtilities(mom.trd.opentheso.bdd.tools.FileUtilities) ArrayList(java.util.ArrayList) ArkClient(mom.trd.opentheso.ws.ark.ArkClient)

Example 2 with ArkClient

use of mom.trd.opentheso.ws.ark.ArkClient in project opentheso by miledrousset.

the class ConceptHelper method addIdArk.

/**
 * @param conn
 * @param idConcept
 * @param idThesaurus
 * @param urlSite
 * @param nodeMetaData
 * @return
 */
private boolean addIdArk(Connection conn, String idConcept, String idThesaurus, NodeMetaData nodeMetaData) {
    /**
     * récupération du code Ark via WebServices
     */
    if (nodePreference == null) {
        return false;
    }
    if (!nodePreference.isUseArk()) {
        return false;
    }
    ArkClient ark_Client = new ArkClient();
    Properties propertiesArk = new Properties();
    propertiesArk.setProperty("idNaan", nodePreference.getIdNaan());
    propertiesArk.setProperty("user", nodePreference.getUserArk());
    propertiesArk.setProperty("password", nodePreference.getPassArk());
    ark_Client.setPropertiesArk(propertiesArk);
    String idArk = ark_Client.getArkId(new FileUtilities().getDate(), nodePreference.getCheminSite() + "?idc=" + idConcept + "&idt=" + idThesaurus, // title
    nodeMetaData.getTitle(), // creator
    nodeMetaData.getCreator(), nodeMetaData.getDcElementsList(), // pcrt : p= pactols, crt=code DCMI pour collection
    nodePreference.getPrefixArk());
    // description
    if (idArk == null) {
        message = "La connexion Ark a échouée";
        return false;
    }
    return updateArkIdOfConcept(conn, idConcept, idThesaurus, idArk);
}
Also used : FileUtilities(mom.trd.opentheso.bdd.tools.FileUtilities) Properties(java.util.Properties) ArkClient(mom.trd.opentheso.ws.ark.ArkClient)

Example 3 with ArkClient

use of mom.trd.opentheso.ws.ark.ArkClient in project opentheso by miledrousset.

the class ThesaurusHelper method addThesaurusRollBack.

/**
 * Permet de créer un nouveau Thésaurus. Retourne l'identifiant du thésaurus
 * ou null
 *
 * @param conn
 * @param urlSite
 * @param isArkActive
 * @param visible
 * @return String Id du thésaurus rajouté
 */
public String addThesaurusRollBack(Connection conn, String urlSite, boolean isArkActive) {
    String idThesaurus = null;
    String idArk = "";
    Statement stmt;
    ResultSet resultSet;
    try {
        try {
            stmt = conn.createStatement();
            try {
                String query;
                if (identifierType.equalsIgnoreCase("1")) {
                    // identifiants types alphanumérique
                    ToolsHelper toolsHelper = new ToolsHelper();
                    idThesaurus = toolsHelper.getNewId(10);
                    while (isThesaurusExiste(conn, idThesaurus)) {
                        idThesaurus = toolsHelper.getNewId(10);
                    }
                } else {
                    query = "select max(id) from thesaurus";
                    stmt.executeQuery(query);
                    resultSet = stmt.getResultSet();
                    resultSet.next();
                    int idNumeriqueThesaurus = resultSet.getInt(1);
                    idThesaurus = "" + ++idNumeriqueThesaurus;
                    while (isThesaurusExiste(conn, idThesaurus)) {
                        idThesaurus = "" + ++idNumeriqueThesaurus;
                    }
                }
                /**
                 * récupération du code Ark via WebServices
                 */
                if (isArkActive) {
                    ArrayList<DcElement> dcElementsList = new ArrayList<>();
                    ArkClient ark_Client = new ArkClient();
                    idArk = ark_Client.getArkId(new FileUtilities().getDate(), urlSite + "?idt=" + idThesaurus, "", "", dcElementsList, // pcrt : p= pactols, crt=code DCMI pour collection
                    "pcrt");
                }
                query = "Insert into thesaurus (id_thesaurus," + " id_ark, created, modified)" + " values (" + "'" + idThesaurus + "'" + ",'" + idArk + "'" + "," + "current_date," + "current_date)";
                stmt.executeUpdate(query);
            // thesaurus.setId_thesaurus(idThesaurus);
            /* if(thesaurus.getTitle().isEmpty()) {
                        thesaurus.setTitle("theso_" + idThesaurus);
                    }
                    if(!addThesaurusTraductionRollBack(conn, thesaurus)) {
                        stmt.close();
                        return null;
                    }*/
            } finally {
                stmt.close();
            }
        } finally {
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding Thesaurus : " + idThesaurus, sqle);
        idThesaurus = null;
    }
    return idThesaurus;
}
Also used : DcElement(fr.mom.arkeo.soap.DcElement) FileUtilities(mom.trd.opentheso.bdd.tools.FileUtilities) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) ArkClient(mom.trd.opentheso.ws.ark.ArkClient)

Example 4 with ArkClient

use of mom.trd.opentheso.ws.ark.ArkClient in project opentheso by miledrousset.

the class GroupHelper method insertGroup.

/**
 * Cette fonction permet d'ajouter un group (MT, domaine etc..) avec le
 * libellé dans le cas d'un import avec idGroup existant
 *
 * @param ds
 * @param idThesaurus
 * @param typeCode
 * @param idGroup
 * @param notation
 * @param urlSite
 * @param isArkActive
 * @param idUser
 * @return
 */
public boolean insertGroup(HikariDataSource ds, String idGroup, String idThesaurus, String typeCode, String notation, String urlSite, boolean isArkActive, int idUser) {
    // idGroup = "MT_" + idGroup;//"ark:/66666/srvq9a5Ll41sk";
    Connection conn;
    Statement stmt;
    boolean status = false;
    // à faire
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String idArk = "";
                if (isArkActive) {
                    ArrayList<DcElement> dcElementsList = new ArrayList<>();
                    ArkClient ark_Client = new ArkClient();
                    idArk = ark_Client.getArkId(new FileUtilities().getDate(), urlSite + "?idc=" + idGroup + "&idt=" + idThesaurus, "", "", dcElementsList, // pcrt : p= pactols, crt=code DCMI pour collection
                    "pcrt");
                }
                /**
                 * Ajout des informations dans la table de ConceptGroup
                 */
                String query = "Insert into concept_group values (" + "'" + idGroup + "'" + ",'" + idArk + "'" + ",'" + idThesaurus + "'" + ",'" + typeCode + "'" + ",'" + notation + "'" + ")";
                stmt.executeUpdate(query);
                status = true;
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding ConceptGroup : " + idGroup, sqle);
    }
    return status;
}
Also used : DcElement(fr.mom.arkeo.soap.DcElement) FileUtilities(mom.trd.opentheso.bdd.tools.FileUtilities) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) ArkClient(mom.trd.opentheso.ws.ark.ArkClient)

Example 5 with ArkClient

use of mom.trd.opentheso.ws.ark.ArkClient in project opentheso by miledrousset.

the class GroupHelper method addGroup.

/**
 * Cette fonction permet d'ajouter un group (MT, domaine etc..) avec le
 * libellé
 *
 * @param ds
 * @param nodeConceptGroup
 * @param urlSite
 * @param isArkActive
 * @param idUser
 * @return
 */
public String addGroup(HikariDataSource ds, NodeGroup nodeConceptGroup, String urlSite, boolean isArkActive, int idUser) {
    // "ark:/66666/srvq9a5Ll41sk";
    String idConceptGroup = "";
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    nodeConceptGroup.setLexicalValue(new StringPlus().convertString(nodeConceptGroup.getLexicalValue()));
    if (nodeConceptGroup.getConceptGroup().getNotation() == null) {
        nodeConceptGroup.getConceptGroup().setNotation("");
    }
    // à faire
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select max(id) from concept_group";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                resultSet.next();
                int idNumeriqueGroup = resultSet.getInt(1);
                idConceptGroup = nodeConceptGroup.getConceptGroup().getIdtypecode() + ++idNumeriqueGroup;
                /**
                 * récupération du code Ark via WebServices
                 */
                String idArk = "";
                if (isArkActive) {
                    ArrayList<DcElement> dcElementsList = new ArrayList<>();
                    ArkClient ark_Client = new ArkClient();
                    idArk = ark_Client.getArkId(new FileUtilities().getDate(), urlSite + "?idg=" + idConceptGroup + "&idt=" + nodeConceptGroup.getConceptGroup().getIdthesaurus(), "", "", dcElementsList, // pcrt : p= pactols, crt=code DCMI pour collection
                    "pcrt");
                }
                /**
                 * Ajout des informations dans la table de ConceptGroup
                 */
                query = "Insert into concept_group values (" + "'" + idConceptGroup + "'" + ",'" + idArk + "'" + ",'" + nodeConceptGroup.getConceptGroup().getIdthesaurus() + "'" + ",'" + nodeConceptGroup.getConceptGroup().getIdtypecode() + "'" + ",'" + nodeConceptGroup.getConceptGroup().getNotation() + "'" + ")";
                stmt.executeUpdate(query);
                ConceptGroupLabel conceptGroupLabel = new ConceptGroupLabel();
                conceptGroupLabel.setIdgroup(idConceptGroup);
                conceptGroupLabel.setIdthesaurus(nodeConceptGroup.getConceptGroup().getIdthesaurus());
                conceptGroupLabel.setLang(nodeConceptGroup.getIdLang());
                conceptGroupLabel.setLexicalvalue(nodeConceptGroup.getLexicalValue());
                addGroupTraduction(ds, conceptGroupLabel, idUser);
                addGroupHistorique(ds, nodeConceptGroup, urlSite, idArk, idUser, idConceptGroup);
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding ConceptGroup : " + idConceptGroup, sqle);
    }
    return idConceptGroup;
}
Also used : DcElement(fr.mom.arkeo.soap.DcElement) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) ConceptGroupLabel(mom.trd.opentheso.bdd.datas.ConceptGroupLabel) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) FileUtilities(mom.trd.opentheso.bdd.tools.FileUtilities) ResultSet(java.sql.ResultSet) ArkClient(mom.trd.opentheso.ws.ark.ArkClient)

Aggregations

ArkClient (mom.trd.opentheso.ws.ark.ArkClient)9 FileUtilities (mom.trd.opentheso.bdd.tools.FileUtilities)8 DcElement (fr.mom.arkeo.soap.DcElement)6 ArrayList (java.util.ArrayList)6 PreparedStatement (java.sql.PreparedStatement)4 SQLException (java.sql.SQLException)4 Statement (java.sql.Statement)4 Connection (java.sql.Connection)3 ResultSet (java.sql.ResultSet)3 Properties (java.util.Properties)1 Concept (mom.trd.opentheso.bdd.datas.Concept)1 ConceptGroupLabel (mom.trd.opentheso.bdd.datas.ConceptGroupLabel)1 NodeConcept (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept)1 NodeTermTraduction (mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)1 StringPlus (mom.trd.opentheso.bdd.tools.StringPlus)1