Example #1
0
  /**
   * Cette fonction permet d'exporter un concept en JsonLd
   *
   * @param idC
   * @param idTheso
   * @return
   */
  public StreamedContent conceptToJsonLd(String idC, String idTheso) {
    ExportFromBDD exportFromBDD = new ExportFromBDD();

    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);

    InputStream stream;
    StringBuffer skos_local = exportFromBDD.exportConcept(connect.getPoolConnexion(), idTheso, idC);

    JsonHelper jsonHelper = new JsonHelper();
    SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos_local);
    StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);
    if (jsonLd == null) {
      FacesContext.getCurrentInstance()
          .addMessage(
              null,
              new FacesMessage(
                  FacesMessage.SEVERITY_ERROR,
                  languageBean.getMsg("error") + " :",
                  languageBean.getMsg("index.exportJsonError")));
      return file;
    }

    try {
      stream = new ByteArrayInputStream(jsonLd.toString().getBytes("UTF-8"));
      file = new DefaultStreamedContent(stream, "application/xml", idC + "_jsonLd.xml");
    } catch (UnsupportedEncodingException ex) {
      Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return file;

    //   new ExportFromBDD().exportConcept(connect.getPoolConnexion(), idTheso, idC).toString();
  }
Example #2
0
  public String groupSkos(String idGroup, String idTheso) {
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);

    return exportFromBDD.exportThisGroup(connect.getPoolConnexion(), idTheso, idGroup).toString();
  }
Example #3
0
  public String conceptSkos(String idC, String idTheso) {
    ExportFromBDD exportFromBDD = new ExportFromBDD();

    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);

    return exportFromBDD.exportConcept(connect.getPoolConnexion(), idTheso, idC).toString();

    //   new ExportFromBDD().exportConcept(connect.getPoolConnexion(), idTheso, idC).toString();
  }
Example #4
0
  public String groupJsonLd(String idGroup, String idTheso) {
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);

    StringBuffer skos_local =
        exportFromBDD.exportThisGroup(connect.getPoolConnexion(), idTheso, idGroup);

    JsonHelper jsonHelper = new JsonHelper();
    SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos_local);
    StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);
    return jsonLd.toString();
  }
Example #5
0
  /**
   * Cette fonction permet de retourner la branche antière d'un groupe en SKOS
   *
   * @param idGroup
   * @param idTheso
   * @return
   */
  public StreamedContent groupToSkos(String idGroup, String idTheso) {
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);

    StringBuffer skos_local =
        exportFromBDD.exportGroup(connect.getPoolConnexion(), idTheso, idGroup);

    InputStream stream;

    try {
      stream = new ByteArrayInputStream(skos_local.toString().getBytes("UTF-8"));
      file = new DefaultStreamedContent(stream, "application/xml", idGroup + "_Group_skos.xml");
    } catch (UnsupportedEncodingException ex) {
      Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return file;
  }
Example #6
0
  /*    public void branchSkos(String idC, String idTheso) {
      ExportFromBDD exportFromBDD = new ExportFromBDD();
      exportFromBDD.setServerAdress(serverAdress);
      exportFromBDD.setServerArk(serverArk);
      exportFromBDD.setArkActive(arkActive);

      StringBuffer temp = exportFromBDD.exportBranchOfConcept(connect.getPoolConnexion(), idTheso, idC);
      if (temp.length() <= 1500000) {
          //    if(temp.length() <= 150) {
          skos = temp.toString();
          vue.setBranchToSkos(true);
      } else {
          InputStream stream;
          try {
              stream = new ByteArrayInputStream(temp.toString().getBytes("UTF-8"));
              file = new DefaultStreamedContent(stream, "application/xml ", "downloadedSkos.xml");
          } catch (UnsupportedEncodingException ex) {
              Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
          }
          vue.setBranchToSkosFile(true);
      }
  }*/
  public void branchGroupSkos(String idGroup, String idTheso) {
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);

    StringBuffer temp = exportFromBDD.exportGroup(connect.getPoolConnexion(), idTheso, idGroup);
    if (temp.length() <= 1500000) {
      skos = temp.toString();
      vue.setBranchToSkos(true);
    } else {
      InputStream stream;
      try {
        stream = new ByteArrayInputStream(temp.toString().getBytes("UTF-8"));
        file = new DefaultStreamedContent(stream, "application/xml ", "downloadedSkos.xml");
      } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
      }
      vue.setBranchToSkosFile(true);
    }
  }
Example #7
0
  /**
   * Cette fonction permet de retourner pour téléchargement un groupe en JsonLd
   *
   * @param idGroup
   * @param idTheso
   * @return
   */
  public StreamedContent thisGroupToJsonLd(String idGroup, String idTheso) {
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);

    StringBuffer skos_local =
        exportFromBDD.exportThisGroup(connect.getPoolConnexion(), idTheso, idGroup);

    JsonHelper jsonHelper = new JsonHelper();
    SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos_local);
    StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);

    InputStream stream;

    try {
      stream = new ByteArrayInputStream(jsonLd.toString().getBytes("UTF-8"));
      file = new DefaultStreamedContent(stream, "application/xml", idGroup + "_Group_jsonld.xml");
    } catch (UnsupportedEncodingException ex) {
      Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return file;
  }
Example #8
0
  /**
   * Cette fonction permet d'exporter un thésaurus au format SKOS à partir de son identifiant. Le
   * résultat est enregistré dans la variable 'skos' du downloadBean si la taille est petite, ou
   * dans la variable 'file' du downloadBean sinon. Dans le premier cas on affiche la variable, dans
   * le second cas l'utilisateur télécharge de fichier.
   *
   * @param idTheso
   * @return
   */
  public StreamedContent thesoSkos(String idTheso) {

    /** Cette initialisation est pour exporter les PACTOLS au format accepté par Koha */
    // ExportFromBDD_Frantiq exportFromBDD = new ExportFromBDD_Frantiq();
    /** ici c'est la classe à utiliser pour un export standard au foramt SKOS */
    ExportFromBDD exportFromBDD = new ExportFromBDD();

    exportFromBDD.setServerAdress(serverAdress);
    exportFromBDD.setServerArk(serverArk);
    exportFromBDD.setArkActive(arkActive);

    StringBuffer skos_local = exportFromBDD.exportThesaurus(connect.getPoolConnexion(), idTheso);
    InputStream stream;

    try {
      stream = new ByteArrayInputStream(skos_local.toString().getBytes("UTF-8"));
      file = new DefaultStreamedContent(stream, "application/xml", idTheso + "_skos.xml");
    } catch (UnsupportedEncodingException ex) {
      Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    vue.setThesoToSkosCsvFile(true);
    return file;

    /*        if (temp.length() <= 1500000) {
        skos = temp.toString();
        vue.setThesoToSkosCsv(true);
    } else {
        InputStream stream;
        try {
            stream = new ByteArrayInputStream(temp.toString().getBytes("UTF-8"));
            file = new DefaultStreamedContent(stream, "application/xml ", "downloadedSkos.xml");
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        vue.setThesoToSkosCsvFile(true);
    }*/
  }