コード例 #1
0
  protected static void createXslFile(String fileName, MappingScript script) throws IOException {
    File xsltDir =
        ConfigSingleton.getRepoxContextUtil()
            .getRepoxManager()
            .getMetadataTransformationManager()
            .getXsltDir();
    if (!xsltDir.exists()) xsltDir.mkdirs();

    File xslFile = new File(xsltDir, fileName.toLowerCase() + XSL_END);
    StreamResult tmpResult = new StreamResult(new FileOutputStream(xslFile));
    XsltStylesheet xslt =
        new XSLTCompiler(new ToolsetManagerImpl<XsltFunction>(XsltToolsetLibrary.getToolsets()))
            .compile(script);

    new XsltWriter().write(xslt, tmpResult);
    tmpResult.getOutputStream().close();

    /* DUMMY FILE CREATION CODE
    File xsltDir = ConfigSingleton.getRepoxContextUtil().getRepoxManager().getMetadataTransformationManager().getXsltDir();
    if(!xsltDir.exists())
        xsltDir.mkdirs();

    tmpFile = new File(xsltDir, fileName.toLowerCase()+XSL_END);
    FileWriter fstream = new FileWriter(tmpFile);
    BufferedWriter outFile = new BufferedWriter(fstream);
    outFile.write("<This is a dummy xslt>");
    outFile.close();*/

    // System.out.println("SERVER - XSL created");
  }
コード例 #2
0
 protected static boolean deleteDir(File dir) {
   // First delete all folder contents
   if (dir.isDirectory()) {
     String[] children = dir.list();
     for (String aChildren : children) {
       boolean success = deleteDir(new File(dir, aChildren));
       if (!success) {
         return false;
       }
     }
   }
   // The directory is now empty so delete it
   return dir.delete();
 }
コード例 #3
0
  protected static void createXmapFile(String fileName, MappingScript script) throws IOException {
    File xmapDir =
        ConfigSingleton.getRepoxContextUtil()
            .getRepoxManager()
            .getMetadataTransformationManager()
            .getXmapDir();
    if (!xmapDir.exists()) xmapDir.mkdirs();

    File xmapFile = new File(xmapDir, fileName.toLowerCase() + XMAP_END);
    StreamResult tmpResult = new StreamResult(new FileOutputStream(xmapFile));

    new XMLMappingWriter().write(script, tmpResult);
    tmpResult.getOutputStream().close();
    // System.out.println("SERVER - XMAP created");
  }
コード例 #4
0
  public static MappingScriptProxy getExistingMappingModel(TransformationUI transformationUI) {
    try {
      File xmapDir =
          ConfigSingleton.getRepoxContextUtil()
              .getRepoxManager()
              .getMetadataTransformationManager()
              .getXmapDir();
      String mapFilePath =
          xmapDir.getPath()
              + File.separator
              + FilenameUtils.removeExtension(transformationUI.getXslFilePath())
              + ".xmap";

      URL tmp = new URL(transformationUI.getSourceSchema());
      XMLSchema source = getXSDSchema(tmp);
      tmp = new URL(transformationUI.getDestSchema());
      XMLSchema target = getXSDSchema(tmp);
      MappingScript mapping = getMapping(source, target, mapFilePath);
      return new Mapping2UIAdapter().adapt(mapping);
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }