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();*/
}
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);
}
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;
}
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;
}
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;
}
Aggregations