Search in sources :

Example 1 with ImagesHelper

use of mom.trd.opentheso.bdd.helper.ImagesHelper in project opentheso by miledrousset.

the class FileBean method chargeImage.

/*    public void chargeCsv(FileUploadEvent event) {
        ReadFileTabule readFileTabule = new ReadFileTabule();
        if (!PhaseId.INVOKE_APPLICATION.equals(event.getPhaseId())) {
            event.setPhaseId(PhaseId.INVOKE_APPLICATION);
            event.queue();
        } else {
            System.out.println(sepCol + " " + sepChamps + " " + sepLangue + " " + formatDate);
            UploadedFile file = event.getFile();
            if (sepCol == null || sepCol.equals("") || sepChamps == null || sepChamps.equals("") || sepLangue == null || sepLangue.equals("") || formatDate == null || formatDate.equals("")) {
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("file.error3")));
            } else {
                try {
                    readFileTabule.setReadFile(file.getInputstream(), sepCol, sepChamps, sepLangue, formatDate);
                    readFileTabule.setFields();
                    readFileTabule.setDatas();
                    ArrayList<String> fields = readFileTabule.getFieldsList();
                    ArrayList<TabulateDocument> tabulateDocuments = readFileTabule.getTabulateDocumentList();
                    //new ImportTabuleIntoBDD().insertDatas(connect.getPoolConnexion(), source, tabulateDocuments, idUser);
                    System.out.println(fields);
                    System.out.println(tabulateDocuments);
                    vue.setAddSkos(false);
                } catch (Exception ex) {
                    Logger.getLogger(FileBean.class.getName()).log(Level.SEVERE, null, ex);
                }
                vue.setAddSkos(false);

            }
        }
    }*/
public void chargeImage(FileUploadEvent event) {
    int idUser = selectedTerme.getUser().getUser().getId();
    if (selectedTerme.getUser().nodePreference == null)
        return;
    if (!PhaseId.INVOKE_APPLICATION.equals(event.getPhaseId())) {
        event.setPhaseId(PhaseId.INVOKE_APPLICATION);
        event.queue();
    } else {
        UploadedFile file = event.getFile();
        if (source == null || source.equals("")) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("file.error1")));
        } else {
            try {
                // Traitement
                String suffix = FilenameUtils.getExtension(file.getFileName());
                InputStream input = file.getInputstream();
                // pathImage;
                String path = selectedTerme.getUser().nodePreference.getPathImage();
                SimpleDateFormat dateFormatDirectory = new SimpleDateFormat(" dd-MM-yyyy HH-mm-ss");
                String dateDirectory = dateFormatDirectory.format(new Date());
                File image = new File(path + selectedTerme.getIdC() + dateDirectory + "." + suffix);
                OutputStream output = new FileOutputStream(image);
                IOUtils.copy(input, output);
                IOUtils.closeQuietly(output);
                IOUtils.closeQuietly(input);
                // System.out.println(image.getName());
                BufferedImage bimg = ImageIO.read(image);
                int width = bimg.getWidth();
                int height = bimg.getHeight();
                if (width > 1024 || height > 768) {
                    resizeToBigImage(image.getName());
                }
                if (!resizeImage(image.getName())) {
                    return;
                }
                addFiligrane(image.getName(), source, suffix);
                addFiligrane(selectedTerme.getUser().nodePreference.getDossierResize() + /*dossierResize*/
                "/" + image.getName(), source, suffix);
                new ImagesHelper().addImage(connect.getPoolConnexion(), selectedTerme.getIdC(), selectedTerme.getIdTheso(), image.getName(), source, idUser);
            } catch (IOException ex) {
                Logger.getLogger(FileBean.class.getName()).log(Level.SEVERE, null, ex);
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", ex.toString()));
                vue.setAddImage(false);
                return;
            }
            selectedTerme.setImages(new ImagesHelper().getImage(connect.getPoolConnexion(), selectedTerme.getIdC(), selectedTerme.getIdTheso(), idUser));
            vue.setAddImage(false);
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("file.info1.1") + " " + source + langueBean.getMsg("file.info1.2") + "."));
            source = "";
        }
    }
}
Also used : ImagesHelper(mom.trd.opentheso.bdd.helper.ImagesHelper) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) Date(java.util.Date) BufferedImage(java.awt.image.BufferedImage) UploadedFile(org.primefaces.model.UploadedFile) FileOutputStream(java.io.FileOutputStream) FacesMessage(javax.faces.application.FacesMessage) SimpleDateFormat(java.text.SimpleDateFormat) UploadedFile(org.primefaces.model.UploadedFile) File(java.io.File)

Example 2 with ImagesHelper

use of mom.trd.opentheso.bdd.helper.ImagesHelper in project opentheso by miledrousset.

the class SelectedThesaurus method regenIdConcept.

/**
 * Cette fonction remplace tout les id des concepts du théso
 */
private void regenIdConcept(Connection conn, String idTheso, ArrayList<String> idGroup) throws Exception {
    /*récup les concepts*/
    ConceptHelper conceptHelper = new ConceptHelper();
    ArrayList<String> idConcepts = conceptHelper.getAllIdConceptOfThesaurus(conn, idTheso);
    if (idConcepts == null || idConcepts.isEmpty()) {
        throw new Exception("No concept in this thesaurus");
    }
    /*génération des nouveaux id*/
    ArrayList<String> reservedId = idConcepts;
    reservedId.addAll(idGroup);
    ArrayList<String> newIdConcepts = createNewId(reservedId, idConcepts.size());
    /*maj des tables*/
    NoteHelper noteHelper = new NoteHelper();
    GpsHelper gpsHelper = new GpsHelper();
    ImagesHelper imagesHelper = new ImagesHelper();
    AlignmentHelper alignmentHelper = new AlignmentHelper();
    for (int i = 0; i < idConcepts.size(); i++) {
        String id = idConcepts.get(i);
        String newId = newIdConcepts.get(i);
        // table concept
        conceptHelper.setIdConcept(conn, idTheso, id, newId);
        // table concept_group_concept
        conceptHelper.setIdConceptGroupConcept(conn, idTheso, id, newId);
        // table concept_historique
        conceptHelper.setIdConceptHistorique(conn, idTheso, id, newId);
        // table concept_orphan
        conceptHelper.setIdConceptOrphan(conn, idTheso, id, newId);
        // table gps
        gpsHelper.setIdConceptGPS(conn, idTheso, id, newId);
        // table hierarchical_relationship
        conceptHelper.setIdConceptHieraRelation(conn, idTheso, id, newId);
        // table hierarchical_relationship_historique
        conceptHelper.setIdConceptHieraRelationHisto(conn, idTheso, id, newId);
        // table note
        noteHelper.setIdConceptNote(conn, idTheso, id, newId);
        // table note_historique
        noteHelper.setIdConceptNoteHisto(conn, idTheso, id, newId);
        // table images
        imagesHelper.setIdConceptImage(conn, idTheso, id, newId);
        // table concept_fusion
        conceptHelper.setIdConceptFusion(conn, idTheso, id, newId);
        // table preferred_term
        conceptHelper.setIdConceptPreferedTerm(conn, idTheso, id, newId);
        // table alignement
        alignmentHelper.setIdConceptAlignement(conn, idTheso, id, newId);
    }
}
Also used : ImagesHelper(mom.trd.opentheso.bdd.helper.ImagesHelper) GpsHelper(mom.trd.opentheso.bdd.helper.GpsHelper) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) AlignmentHelper(mom.trd.opentheso.bdd.helper.AlignmentHelper) SQLException(java.sql.SQLException)

Example 3 with ImagesHelper

use of mom.trd.opentheso.bdd.helper.ImagesHelper in project opentheso by miledrousset.

the class SelectedTerme method delImage.

public void delImage(String nomImage) {
    new ImagesHelper().deleteImage(connect.getPoolConnexion(), idC, idTheso, nomImage);
    images = new ArrayList<>();
    images = new ImagesHelper().getImage(connect.getPoolConnexion(), idC, idTheso, user.getUser().getId());
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.info8")));
}
Also used : ImagesHelper(mom.trd.opentheso.bdd.helper.ImagesHelper) FacesMessage(javax.faces.application.FacesMessage)

Example 4 with ImagesHelper

use of mom.trd.opentheso.bdd.helper.ImagesHelper in project opentheso by miledrousset.

the class FileBean_progress method chargeImage.

/*    public void chargeCsv(FileUploadEvent event) {
        ReadFileTabule readFileTabule = new ReadFileTabule();
        if (!PhaseId.INVOKE_APPLICATION.equals(event.getPhaseId())) {
            event.setPhaseId(PhaseId.INVOKE_APPLICATION);
            event.queue();
        } else {
            System.out.println(sepCol + " " + sepChamps + " " + sepLangue + " " + formatDate);
            UploadedFile file = event.getFile();
            if (sepCol == null || sepCol.equals("") || sepChamps == null || sepChamps.equals("") || sepLangue == null || sepLangue.equals("") || formatDate == null || formatDate.equals("")) {
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("file.error3")));
            } else {
                try {
                    readFileTabule.setReadFile(file.getInputstream(), sepCol, sepChamps, sepLangue, formatDate);
                    readFileTabule.setFields();
                    readFileTabule.setDatas();
                    ArrayList<String> fields = readFileTabule.getFieldsList();
                    ArrayList<TabulateDocument> tabulateDocuments = readFileTabule.getTabulateDocumentList();
                    //new ImportTabuleIntoBDD().insertDatas(connect.getPoolConnexion(), source, tabulateDocuments, idUser);
                    System.out.println(fields);
                    System.out.println(tabulateDocuments);
                    vue.setAddSkos(false);
                } catch (Exception ex) {
                    Logger.getLogger(FileBean.class.getName()).log(Level.SEVERE, null, ex);
                }
                vue.setAddSkos(false);

            }
        }
    }*/
public void chargeImage(FileUploadEvent event) {
    int idUser = selectedTerme.getUser().getUser().getId();
    if (!PhaseId.INVOKE_APPLICATION.equals(event.getPhaseId())) {
        event.setPhaseId(PhaseId.INVOKE_APPLICATION);
        event.queue();
    } else {
        UploadedFile file = event.getFile();
        if (source == null || source.equals("")) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("file.error1")));
        } else {
            try {
                // Traitement
                String suffix = FilenameUtils.getExtension(file.getFileName());
                InputStream input = file.getInputstream();
                String path = pathImage;
                SimpleDateFormat dateFormatDirectory = new SimpleDateFormat(" dd-MM-yyyy HH-mm-ss");
                String dateDirectory = dateFormatDirectory.format(new Date());
                File image = new File(path + selectedTerme.getIdC() + dateDirectory + "." + suffix);
                OutputStream output = new FileOutputStream(image);
                IOUtils.copy(input, output);
                IOUtils.closeQuietly(output);
                IOUtils.closeQuietly(input);
                System.out.println(image.getName());
                BufferedImage bimg = ImageIO.read(image);
                int width = bimg.getWidth();
                int height = bimg.getHeight();
                if (width > 1024 || height > 768) {
                    resizeToBigImage(image.getName());
                }
                resizeImage(image.getName());
                addFiligrane(image.getName(), source, suffix);
                addFiligrane(dossierResize + "/" + image.getName(), source, suffix);
                new ImagesHelper().addImage(connect.getPoolConnexion(), selectedTerme.getIdC(), selectedTerme.getIdTheso(), image.getName(), source, idUser);
            } catch (IOException ex) {
                Logger.getLogger(FileBean.class.getName()).log(Level.SEVERE, null, ex);
            }
            selectedTerme.setImages(new ImagesHelper().getImage(connect.getPoolConnexion(), selectedTerme.getIdC(), selectedTerme.getIdTheso(), idUser));
            vue.setAddImage(false);
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("file.info1.1") + " " + source + langueBean.getMsg("file.info1.2") + "."));
            source = "";
        }
    }
}
Also used : ImagesHelper(mom.trd.opentheso.bdd.helper.ImagesHelper) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) Date(java.util.Date) BufferedImage(java.awt.image.BufferedImage) UploadedFile(org.primefaces.model.UploadedFile) FileOutputStream(java.io.FileOutputStream) FacesMessage(javax.faces.application.FacesMessage) SimpleDateFormat(java.text.SimpleDateFormat) UploadedFile(org.primefaces.model.UploadedFile) File(java.io.File)

Example 5 with ImagesHelper

use of mom.trd.opentheso.bdd.helper.ImagesHelper in project opentheso by miledrousset.

the class SelectedTerme method majTerme.

/**
 * *************************************** MISE A JOUR
 * ****************************************
 */
/**
 * Met à jour le terme à la sélection d'un node de l'arbre (traitement
 * différent si Domaine/TopConcept/Concept)
 *
 * @param sN
 */
public void majTerme(MyTreeNode sN) {
    // contrôler si la connexion est toujour valide
    // connect.
    selectedNode = sN;
    reInitTerme();
    majPref();
    idC = sN.getIdConcept();
    idTheso = sN.getIdTheso();
    idlangue = sN.getLangue();
    idDomaine = sN.getIdCurrentGroup();
    idTopConcept = sN.getIdTopConcept();
    type = sN.getTypeConcept();
    status = "";
    notation = "";
    latitudLongitud = null;
    totalConceptOfBranch = "";
    totalNoticesOfBranch = "";
    majTAsso();
    GroupHelper groupHelper = new GroupHelper();
    ConceptHelper conceptHelper = new ConceptHelper();
    if (groupHelper.isIdOfGroup(connect.getPoolConnexion(), idC, idTheso)) {
        microTheso = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), idDomaine, idTheso, idlangue);
        NodeGroup ncg = new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(), idC, idTheso, idlangue);
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        nom = ncg.getLexicalValue();
        idArk = ncg.getConceptGroup().getIdARk();
        nomEdit = nom;
        idT = "";
        if (ncg.getCreated() != null && ncg.getModified() != null) {
            dateC = dateFormat.format(ncg.getCreated());
            dateM = dateFormat.format(ncg.getModified());
        }
        majGroupTGen();
        majLangueGroup();
        majTSpeGroup();
        majNotes();
    } else {
        Concept concept = conceptHelper.getThisConcept(connect.getPoolConnexion(), idC, idTheso);
        if (concept == null) {
            return;
        }
        status = concept.getStatus();
        notation = concept.getNotation();
        if (!idDomaine.equals("Orphan")) {
            majGroup();
            majTGen();
        } else {
            microTheso = idDomaine;
        }
        Term t = new TermHelper().getThisTerm(connect.getPoolConnexion(), idC, idTheso, idlangue);
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        nom = t.getLexical_value();
        nomEdit = nom;
        idT = t.getId_term();
        dateC = dateFormat.format(t.getCreated());
        dateM = dateFormat.format(t.getModified());
        creator = t.getCreator();
        contributor = t.getContributor();
        images = new ImagesHelper().getImage(connect.getPoolConnexion(), idC, idTheso, user.getUser().getId());
        majNotes();
        majLangueConcept();
        majSyno();
        updateGps();
        majTSpeConcept();
        align = new AlignmentHelper().getAllAlignmentOfConcept(connect.getPoolConnexion(), idC, idTheso);
        // ResourceBundle bundlePref = getBundlePref();
        if (user.getNodePreference().isZ3950actif()) {
            majNoticeZ3950();
        }
        if (user.getNodePreference().isBddActive()) {
            majNoticeBdd();
        }
        idArk = conceptHelper.getIdArkOfConcept(connect.getPoolConnexion(), idC, idTheso);
        idHandle = conceptHelper.getIdHandleOfConcept(connect.getPoolConnexion(), idC, idTheso);
        reInitFacette();
        initTree();
    }
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) ImagesHelper(mom.trd.opentheso.bdd.helper.ImagesHelper) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) AlignmentHelper(mom.trd.opentheso.bdd.helper.AlignmentHelper) Term(mom.trd.opentheso.bdd.datas.Term) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) SimpleDateFormat(java.text.SimpleDateFormat) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Aggregations

ImagesHelper (mom.trd.opentheso.bdd.helper.ImagesHelper)5 SimpleDateFormat (java.text.SimpleDateFormat)3 FacesMessage (javax.faces.application.FacesMessage)3 BufferedImage (java.awt.image.BufferedImage)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 Date (java.util.Date)2 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)2 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)2 UploadedFile (org.primefaces.model.UploadedFile)2 FileInputStream (java.io.FileInputStream)1 SQLException (java.sql.SQLException)1 DateFormat (java.text.DateFormat)1 Concept (mom.trd.opentheso.bdd.datas.Concept)1 Term (mom.trd.opentheso.bdd.datas.Term)1 GpsHelper (mom.trd.opentheso.bdd.helper.GpsHelper)1 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)1