Package org.apache.uima.resource.metadata

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


    //serialize to XMI
    String xmiStr = serialize(cas, null);
   
    //deserialize into a CAS that's missing the Organization type
    File partialTypeSystemFile = JUnitExtension.getFile("ExampleCas/partialTestTypeSystem.xml");
    TypeSystemDescription partialTypeSystem = UIMAFramework.getXMLParser().parseTypeSystemDescription(
            new XMLInputSource(partialTypeSystemFile));
    testAnnotTypeDesc = partialTypeSystem.addType("org.apache.uima.testTypeSystem.TestAnnotation", "", "uima.tcas.Annotation");
    testAnnotTypeDesc.addFeature("arrayFeat", "", "uima.cas.FSArray");
    CAS partialTsCas = CasCreationUtils.createCas(partialTypeSystem, null, null);
    XmiSerializationSharedData sharedData = new XmiSerializationSharedData();
    deserialize(xmiStr, partialTsCas, sharedData, true, -1);
   
View Full Code Here


    String xmiStr = serialize(cas, null);
//    System.out.println(xmiStr);
   
    //deserialize into a CAS that's missing the Organization type
    File partialTypeSystemFile = JUnitExtension.getFile("ExampleCas/partialTestTypeSystem.xml");
    TypeSystemDescription partialTypeSystem = UIMAFramework.getXMLParser().parseTypeSystemDescription(
            new XMLInputSource(partialTypeSystemFile));
    testAnnotTypeDesc = partialTypeSystem.addType("org.apache.uima.testTypeSystem.TestAnnotation", "", "uima.tcas.Annotation");
    testAnnotTypeDesc.addFeature("listFeat", "", "uima.cas.FSList");
    CAS partialTsCas = CasCreationUtils.createCas(partialTypeSystem, null, null);
    XmiSerializationSharedData sharedData = new XmiSerializationSharedData();
    deserialize(xmiStr, partialTsCas, sharedData, true, -1);
   
View Full Code Here

    CasComparer.assertEquals(originalCas, newCas);
   
    //Test a partial type system with a missing some missing features and
    //missing "Organization" type
    File partialTypeSystemFile = JUnitExtension.getFile("ExampleCas/partialTestTypeSystem.xml");
    TypeSystemDescription partialTypeSystem = UIMAFramework.getXMLParser().parseTypeSystemDescription(
            new XMLInputSource(partialTypeSystemFile));
    CAS partialTsCas = CasCreationUtils.createCas(partialTypeSystem, null, indexes);
    XmiSerializationSharedData sharedData2 = new XmiSerializationSharedData();
    deserialize(xmiStr, partialTsCas, sharedData2, true, -1);
       
View Full Code Here

  public void refresh() {
    super.refresh();

    tt.removeAll();

    TypeSystemDescription tsdFull = getMergedTypeSystemDescription();

    TypeDescription[] tdsFull = tsdFull.getTypes();
    if (null != tdsFull) {
      for (int i = 0; i < tdsFull.length; i++) {
        addTypeToGUI(tdsFull[i]);
      }
    }
View Full Code Here

  public void handleAddType() {
    AddTypeDialog dialog = new AddTypeDialog(this);
    if (dialog.open() == Window.CANCEL)
      return;

    TypeSystemDescription tsd = getMergedTypeSystemDescription();
    TypeSystemDescription localTsd = getTypeSystemDescription();

    TypeDescription td = localTsd.addType(dialog.typeName, multiLineFix(dialog.description),
            dialog.supertypeName);

    if (!isImportedType(dialog.typeName)) {
      td = tsd.addType(dialog.typeName, multiLineFix(dialog.description), dialog.supertypeName);
      addTypeToGUI(td);
View Full Code Here

  }

  private String[] getTypesRequiringThisOne(String typeName) {
    List upstreamTypeNames = new ArrayList();

    TypeSystemDescription typeSystem = getMergedTypeSystemDescription();

    TypeDescription[] types = typeSystem.getTypes();
    for (int i = 0; i < types.length; i++) {
      if (!types[i].getName().equals(typeName)) {
        if (typeRequiresType(types[i], typeName)) {
          upstreamTypeNames.add(types[i].getName());
        }
View Full Code Here

    return false;
  }

  public void enable() {
    jcasGenButton.setEnabled(tt.getItemCount() > 0);
    TypeSystemDescription tsd = getTypeSystemDescription();
    exportButton.setEnabled(false);
    if (null != tsd) {
      TypeDescription[] tsa = tsd.getTypes();
      if (null != tsa)
        exportButton.setEnabled(tsa.length > 0);
    }
    if (isAggregate()) {
      addTypeButton.setEnabled(false);
View Full Code Here

   * @param newTypeName
   * @return
   */
  private boolean alterTypeMentionsInOtherTypes(String oldTypeName, String newTypeName) {
    // only modify locally modifiable types, but scan all types to give appropriate error msgs
    TypeSystemDescription typeSystem = getMergedTypeSystemDescription();
    boolean refreshNeeded = false;
    boolean remergeNeeded = false;
    TypeDescription[] types = typeSystem.getTypes();
    for (int i = 0; i < types.length; i++) {
      TypeDescription td = types[i];
      TypeDescription localTd = getLocalTypeDefinition(td);
      String typeName = td.getName();
      if (td.getSupertypeName().equals(oldTypeName)) {
View Full Code Here

  }
 
  public void testGetSofa() throws Exception {
    try {
      File typeSystemFile = JUnitExtension.getFile("ExampleCas/testTypeSystem.xml");
      TypeSystemDescription typeSystem = UIMAFramework.getXMLParser().parseTypeSystemDescription(
              new XMLInputSource(typeSystemFile));
      CAS newCas = CasCreationUtils.createCas(typeSystem, null, null);
      File xcasFile = JUnitExtension.getFile("ExampleCas/multiSofaCas.xml");
      XCASDeserializer.deserialize(new FileInputStream(xcasFile), newCas);
      JCas newJCas = newCas.getJCas();
View Full Code Here

    ds.setCaseSensitive(true);
    getLog().debug("JCasGen: Scanning for descriptors in '" + ds.getBasedir() + "'");
    ds.scan();

    // Create a merged type system and check if any of the files has a delta
    TypeSystemDescription typeSystem = new TypeSystemDescription_impl();
    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()];
    typeSystem.setImports(imports.toArray(importArray));

    // Save type system to a file so we can pass it to the Jg
    // Do this before resolving the imports
    OutputStream typeSystemOs = null;
    File typeSystemFile;
    try {
      typeSystemFile = new File(project.getBuild().getDirectory(), "jcasgen/typesystem.xml");
      getLog().debug("JCasGen: Writing master descriptor to in '" + typeSystemFile + "'");
      typeSystemFile.getParentFile().mkdirs();
      typeSystemOs = new FileOutputStream(typeSystemFile);
      typeSystem.toXML(typeSystemOs);
    } catch (IOException e) {
      throw new MojoExecutionException(e.getMessage(), e.getCause());
    } catch (SAXException e) {
      throw new MojoExecutionException(e.getMessage(), e.getCause());
    } finally {
View Full Code Here

TOP

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

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.