Exemplo n.º 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();
  }
Exemplo n.º 2
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();
  }
Exemplo n.º 3
0
  /**
   * Cette fonction permet de retourner la branche entière d'un groupe en JsonLd
   *
   * @param idGroup
   * @param idTheso
   * @return
   */
  public StreamedContent groupToJsonLd(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);

    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;
  }