Пример #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();
  }
Пример #2
0
 public String translate(Enum<?> enumInstance) {
   String result = null;
   if (enumInstance != null) {
     String messageKey = getMessageKey(enumInstance);
     result = messageSource.getMessage(messageKey, null, languageBean.getLocale());
   }
   return result;
 }