Package org.apache.uima.resource.metadata

Examples of org.apache.uima.resource.metadata.Import



public class AETreeBuilder {
 
  static public Import createImport(String descriptor, boolean byLocation) {
    Import imp = (Import) UIMAFramework.getResourceSpecifierFactory().createObject(Import.class);
    if (byLocation) {
      imp.setLocation(descriptor);
    } else {
      imp.setName(descriptor);
    }

    return imp;
  }
View Full Code Here


public class XsltImportByName {
 
  public static String resolveByName(String input) {
    ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager();
    Import theImport = new Import_impl();
    theImport.setName(input);
    try {
      return theImport.findAbsoluteUrl(resourceManager).toExternalForm();
    } catch (InvalidXMLException e) {
      e.printStackTrace();
      return "ERROR converting import by name to absolute path";
    }
  }
View Full Code Here

  {
      XMLInputSource input;
     
      if (aFileResource.startsWith(IMPORT_BY_NAME_PREFIX))
      {
        Import theImport = new Import_impl();
        theImport.setName(aFileResource.substring(IMPORT_BY_NAME_PREFIX.length()));
        input = new XMLInputSource(theImport.findAbsoluteUrl(aResourceManager));
      }
      else
      {
        input = new XMLInputSource(aFileResource);
      }
View Full Code Here

    List<Import> imports = new ArrayList<Import>();
    boolean contextDelta = false;
    for (String descriptorLocation : ds.getIncludedFiles()) {
      File descriptorFile = new File(ds.getBasedir(), descriptorLocation);
      this.getLog().info("JCasGen: Found descriptor '" + descriptorFile.getAbsolutePath() + "'");
      Import imp = new Import_impl();
      // setLocation takes a string which must be a URL
      // https://issues.apache.org/jira/browse/UIMA-2983
      URL url;
      try {
        url = descriptorFile.toURI().toURL();
      } catch (MalformedURLException e) {
        throw new RuntimeException(e); // this should never happen for files
      }
      imp.setLocation(url.toString());
      imports.add(imp);

      contextDelta |= this.buildContext.hasDelta(new File(ds.getBasedir(), descriptorLocation));
    }
    Import[] importArray = new Import[imports.size()];
View Full Code Here

    while (entryIterator.hasNext()) {
      Map.Entry entry = (Map.Entry) entryIterator.next();
      String key = (String) entry.getKey();
      keys.add(key);
      if (entry.getValue() instanceof Import) {
        Import aeImport = ((Import) entry.getValue());
        // see if we processed this already
        if (entry.getValue().equals(mProcessedImports.get(key))) {
          continue;
        }
        // make sure Import's relative path base is set, to allow for
        // users who create
        // new import objects
        if (aeImport instanceof Import_impl) {
          ((Import_impl) aeImport).setSourceUrlIfNull(this.getSourceUrl());
        }
        // locate import target
        URL url = aeImport.findAbsoluteUrl(aResourceManager);

        // check for resursive import
        if (aEnclosingAggregateAeUrls.contains(url)) {
          String name = getMetaData() == null ? "<null>" : getMetaData().getName();
          throw new InvalidXMLException(InvalidXMLException.CIRCULAR_AE_IMPORT, new Object[] {
              name, url });
        }

        // parse import target
        XMLInputSource input;
        try {
          input = new XMLInputSource(url);
        } catch (IOException e) {
          throw new InvalidXMLException(InvalidXMLException.IMPORT_FAILED_COULD_NOT_READ_FROM_URL,
                  new Object[] { url, aeImport.getSourceUrlString() }, e);
        }
        ResourceSpecifier spec = UIMAFramework.getXMLParser().parseResourceSpecifier(input);

        // update entry in derived mDelegateAnalysisEngineSpecifiers map.
        mDelegateAnalysisEngineSpecifiers.put(key, spec);
View Full Code Here

   * (non-Javadoc)
   *
   * @see FlowControllerDeclaration#resolveImports(org.apache.uima.resource.ResourceManager)
   */
  public void resolveImports(ResourceManager aResourceManager) throws InvalidXMLException {
    Import theImport = getImport();
    if (theImport != null) {
      URL url = theImport.findAbsoluteUrl(aResourceManager);
      InputStream stream = null;
      try {
        stream = url.openStream();
        XMLInputSource input = new XMLInputSource(url);
        ResourceSpecifier spec = UIMAFramework.getXMLParser().parseResourceSpecifier(input);
View Full Code Here

    AnalysisEngineDescription desc = UIMAFramework.getResourceSpecifierFactory()
            .createAnalysisEngineDescription();
    desc.setPrimitive(false);

    // import pear specifiers
    Import impPear1 = UIMAFramework.getResourceSpecifierFactory().createImport();
    File import1 = new File(instPear1.getComponentPearDescPath());
    impPear1.setLocation(import1.toURI().getPath());

    // import main pear descriptor
    Import impPear2 = UIMAFramework.getResourceSpecifierFactory().createImport();
    File import2 = new File(instPear2.getComponentPearDescPath());
    impPear2.setLocation(import2.toURI().getPath());

    // add delegates as imports
    Map delegates = desc.getDelegateAnalysisEngineSpecifiersWithImports();
    delegates.put("Pear1", impPear1);
    delegates.put("Pear2", impPear2);
View Full Code Here

    while (entryIterator.hasNext()) {
      Map.Entry entry = (Map.Entry) entryIterator.next();
      String key = (String) entry.getKey();
      keys.add(key);
      if (entry.getValue() instanceof Import) {
        Import aeImport = ((Import) entry.getValue());
        // see if we processed this already
        if (entry.getValue().equals(mProcessedImports.get(key))) {
          continue;
        }
        // make sure Import's relative path base is set, to allow for
        // users who create
        // new import objects
        if (aeImport instanceof Import_impl) {
          ((Import_impl) aeImport).setSourceUrlIfNull(this.getSourceUrl());
        }
        // locate import target
        URL url = aeImport.findAbsoluteUrl(aResourceManager);

        // check for resursive import
        if (aEnclosingAggregateAeUrls.contains(url.toString())) {
          String name = getMetaData() == null ? "<null>" : getMetaData().getName();
          throw new InvalidXMLException(InvalidXMLException.CIRCULAR_AE_IMPORT, new Object[] {
              name, url });
        }

        // parse import target
        XMLInputSource input;
        try {
          input = new XMLInputSource(url);
        } catch (IOException e) {
          throw new InvalidXMLException(InvalidXMLException.IMPORT_FAILED_COULD_NOT_READ_FROM_URL,
                  new Object[] { url, aeImport.getSourceUrlString() }, e);
        }
        ResourceSpecifier spec = UIMAFramework.getXMLParser().parseResourceSpecifier(input);

        // update entry in derived mDelegateAnalysisEngineSpecifiers map.
        mDelegateAnalysisEngineSpecifiers.put(key, spec);
View Full Code Here

      //try to find relative path from cpeDescSaveFile to descFile
      String relPath = FileUtils.findRelativePath(descFile, cpeDescSaveFile.getParentFile());
      if (relPath != null) {
        //update CPE descriptor
        descriptor.setInclude(null);
        Import newImport = UIMAFramework.getResourceSpecifierFactory().createImport();
        newImport.setLocation(relPath);
        descriptor.setImport(newImport);
      }
    }   
  }
View Full Code Here

    if (sDescriptorRelativePath.indexOf("file:/") == -1 //$NON-NLS-1$
            && sDescriptorRelativePath.indexOf(":/") > -1) { //$NON-NLS-1$
      sDescriptorRelativePath = "file:/" + sDescriptorRelativePath; //$NON-NLS-1$
    }

    Import imp = new Import_impl();
    // fails on unix? URL url = new URL("file:/" + getDescriptorDirectory());
    // Set relative Path Base
    // a version that might work on all platforms
    URL url = new File(editor.getDescriptorDirectory()).toURL();
    ((Import_impl) imp).setSourceUrl(url);

    imp.setLocation(sDescriptorRelativePath);
    return imp;
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.resource.metadata.Import

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.