Examples of ResourceMetadata


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

    }
  }

  public void testGetMetaData() throws Exception {
    try {
      ResourceMetaData md = new ResourceMetaData_impl();
      md.setName("Test");
      md.setDescription("This is a test");
      ConfigurationParameter p1 = new ConfigurationParameter_impl();
      p1.setName("IntegerArrayParam");
      p1.setDescription("multi-valued parameter with Integer data type");
      p1.setType(ConfigurationParameter.TYPE_INTEGER);
      p1.setMultiValued(true);
      md.getConfigurationParameterDeclarations().setConfigurationParameters(
              new ConfigurationParameter[] { p1 });

      mServiceStub.getMetaDataReturnValue = md;
      ResourceMetaData result = mAdapter.getMetaData();
      Assert.assertEquals("callGetMetaData", mServiceStub.lastMethodName);
      Assert.assertEquals(md, result);
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
View Full Code Here

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

    }
  }

  public void testGetMetaData() throws Exception {
    try {
      ResourceMetaData md = service.getMetaData();
      Assert.assertNotNull(md);
      Assert.assertEquals("Test Annotator", md.getName());
      Assert.assertNotNull(md.getUUID());
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

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

  public void testReconfigure() throws Exception {
    try {
      // set up some resource metadata and create a resource
      ResourceCreationSpecifier specifier = new MyTestSpecifier();
      ResourceMetaData md = specifier.getMetaData();
      md.setName("TestResource");
      md.setDescription("Resource used for Testing the Resource_impl base class");
      ConfigurationParameter p1 = new ConfigurationParameter_impl();
      p1.setName("StringParam");
      p1.setDescription("parameter with String data type");
      p1.setType(ConfigurationParameter.TYPE_STRING);
      ConfigurationParameter p2 = new ConfigurationParameter_impl();
      p2.setName("IntegerParam");
      p2.setDescription("parameter with Integer data type");
      p2.setType(ConfigurationParameter.TYPE_INTEGER);
      ConfigurationParameter p3 = new ConfigurationParameter_impl();
      p3.setName("BooleanParam");
      p3.setDescription("parameter with Boolean data type");
      p3.setType(ConfigurationParameter.TYPE_BOOLEAN);
      ConfigurationParameter p4 = new ConfigurationParameter_impl();
      p4.setName("FloatParam");
      p4.setDescription("parameter with Float data type");
      p4.setType(ConfigurationParameter.TYPE_FLOAT);
      ConfigurationParameter p5 = new ConfigurationParameter_impl();
      p5.setName("StringArrayParam");
      p5.setDescription("mutli-valued parameter with String data type");
      p5.setType(ConfigurationParameter.TYPE_STRING);
      p5.setMultiValued(true);
      ConfigurationParameter p6 = new ConfigurationParameter_impl();
      p6.setName("IntegerArrayParam");
      p6.setDescription("multi-valued parameter with Integer data type");
      p6.setType(ConfigurationParameter.TYPE_INTEGER);
      p6.setMultiValued(true);
      ConfigurationParameter p7 = new ConfigurationParameter_impl();
      p7.setName("BooleanArrayParam");
      p7.setDescription("multi-valued parameter with Boolean data type");
      p7.setType(ConfigurationParameter.TYPE_BOOLEAN);
      p7.setMultiValued(true);
      ConfigurationParameter p8 = new ConfigurationParameter_impl();
      p8.setName("FloatArrayParam");
      p8.setDescription("multi-valued parameter with Float data type");
      p8.setType(ConfigurationParameter.TYPE_FLOAT);
      p8.setMultiValued(true);
      md.getConfigurationParameterDeclarations().setConfigurationParameters(
              new ConfigurationParameter[] { p1, p2, p3, p4, p5, p6, p7, p8 });
      ConfigurableResource testResource1 = new MyTestResource();
      testResource1.initialize(specifier, null);

      // valid settings
      String[] paramNames = { "StringParam", "BooleanParam", "IntegerParam", "FloatParam",
          "StringArrayParam", "BooleanArrayParam", "IntegerArrayParam", "FloatArrayParam" };

      String theStr = "hello world";
      Boolean theBool = Boolean.valueOf(false);
      Integer theInt = Integer.valueOf(42);
      Float theFloat = Float.valueOf(2.718281828459045F);
      String[] theStrArr = { "the", "quick", "brown", "fox" };
      Boolean[] theBoolArr = { Boolean.valueOf(false), Boolean.valueOf(true) };
      Integer[] theIntArr = { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) };
      Float[] theFloatArr = { Float.valueOf(3.0F), Float.valueOf(3.1F), Float.valueOf(3.14F) };

      Object[] values = new Object[] { theStr, theBool, theInt, theFloat, theStrArr, theBoolArr,
          theIntArr, theFloatArr };

      for (int i = 0; i < paramNames.length; i++) {
        testResource1.setConfigParameterValue(paramNames[i], values[i]);
      }
      testResource1.reconfigure();

      // check
      for (int i = 0; i < paramNames.length; i++) {
        Object val = testResource1.getConfigParameterValue(paramNames[i]);
        Assert.assertEquals(val, values[i]);
      }

      // invalid settings
      // wrong type
      Exception ex = null;
      testResource1.setConfigParameterValue("StringParam", Integer.valueOf(13));
      try {
        testResource1.reconfigure();
      } catch (ResourceConfigurationException e) {
        ex = e;
      }
      Assert.assertNotNull(ex);

      ex = null;
      testResource1.setConfigParameterValue("IntegerArrayParam", new Object[] { "A", "B", "C" });
      try {
        testResource1.reconfigure();
      } catch (ResourceConfigurationException e) {
        ex = e;
      }
      Assert.assertNotNull(ex);

      // inappropriate array
      ex = null;
      testResource1.setConfigParameterValue("FloatParam", new Float[] { Float.valueOf(0.1F),
          Float.valueOf(0.2F), Float.valueOf(0.3F) });
      try {
        testResource1.reconfigure();
      } catch (ResourceConfigurationException e) {
        ex = e;
      }
      Assert.assertNotNull(ex);

      // array required
      ex = null;
      testResource1.setConfigParameterValue("BooleanArrayParam", Boolean.valueOf(true));
      try {
        testResource1.reconfigure();
      } catch (ResourceConfigurationException e) {
        ex = e;
      }
      Assert.assertNotNull(ex);

      // required parameter set to null
      ex = null;
      testResource1.setConfigParameterValue("StringParam", null);
      try {
        testResource1.reconfigure();
      } catch (ResourceConfigurationException e) {
        ex = e;
      }
      Assert.assertNotNull(ex);

      // Now try a resource that defines configuration groups
      // (instantiate metadata from XML TAE descriptor because it's convenient)
      XMLInputSource in = new XMLInputSource(JUnitExtension
              .getFile("ConfigurableResourceImplTest/AnnotatorWithConfigurationGroups.xml"));
      AnalysisEngineDescription desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
      ResourceMetaData metadata = desc.getMetaData();
      MyTestSpecifier spec = new MyTestSpecifier();
      spec.setMetaData(metadata);
      ConfigurableResource testResource2 = new MyTestResource();
      testResource2.initialize(spec, null);
View Full Code Here

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

    AnalysisEnginePanel aePanel = new AnalysisEnginePanel(aeSpecifier, f, fileModStamp);
    String tabName;
    if (aeSpecifier instanceof AnalysisEngineDescription) {
      AnalysisEngineDescription aeDescription = (AnalysisEngineDescription) aeSpecifier;
      ResourceMetaData md = aeDescription.getMetaData();
      aePanel.populate(md, cpeCasProc.getConfigurationParameterSettings());
      tabName = md.getName();
    } else {
      tabName = f.getName();
    }

    tabName = makeUniqueCasProcessorName(tabName);
View Full Code Here

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

            consumerInputSource);
    ConsumerPanel consumerPanel = new ConsumerPanel(casConsumerSpecifier, f, fileModStamp);

    String tabName;
    if (casConsumerSpecifier instanceof CasConsumerDescription) {
      ResourceMetaData md = ((CasConsumerDescription) casConsumerSpecifier)
              .getCasConsumerMetaData();
      consumerPanel.populate(md, cpeCasProc.getConfigurationParameterSettings());
      tabName = md.getName();
    } else {
      tabName = f.getName();
    }

    tabName = makeUniqueCasProcessorName(tabName);
View Full Code Here

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

    } else {
      sDesc = fileRef + ":\n";
      if (rs instanceof PearSpecifier) {
        sDesc += " (Pear descriptor)";
      } else {
        ResourceMetaData resourceMetaData = getMetaDataFromDescription(rs);
        if (null == resourceMetaData) {
          sDesc += "(Remote service is not responding)";
        } else {
          String description = resourceMetaData.getDescription();
          if (null != description && !description.equals("")) {
            sDesc += parseToFitInToolTips(description);
          } else
            sDesc += "(No Description)";
        }
View Full Code Here

Examples of org.cedj.geekseek.web.rest.core.ResourceMetadata

    }

    @PostConstruct
    public void initialize() {
        for(MetadataResource resource : resources) {
            ResourceMetadata meta = resource.getResourceMetadata();
            this.metadata.put(meta.getModel(), meta);
        }
    }
View Full Code Here

Examples of org.cedj.geekseek.web.rest.core.ResourceMetadata

        }
    }

    public Collection<RelationMatch> getMatchingRelations(Class<?> sourceType) {
        List<RelationMatch> result = new ArrayList<RelationMatch>();
        ResourceMetadata sourceMeta = this.metadata.get(sourceType);
        for(ResourceMetadata targetMeta : this.metadata.values()) {
            if(targetMeta.getModel() == sourceType) {
                continue;
            }
            for(NamedRelation match : targetMeta.match(sourceMeta)) {
                result.add(new RelationMatch(
                    sourceMeta.getModel(), match, targetMeta.getModel()));
            }
        }
        return result;
    }
View Full Code Here

Examples of org.cedj.geekseek.web.rest.core.ResourceMetadata

        return new String[]{USER_XML_MEDIA_TYPE, USER_JSON_MEDIA_TYPE};
    }

    @Override
    public ResourceMetadata getResourceMetadata() {
        return new ResourceMetadata(User.class)
            .incoming(new Relation("presented_by"))
            .incoming(new Relation("tracked_by"))
            .incoming(new Relation("attended_by"))
            .outgoing(new NamedRelation("attachments", "attached_to"))
            .outgoing(new NamedRelation("sessions", "presented_by"));
View Full Code Here

Examples of org.cedj.geekseek.web.rest.core.ResourceMetadata

@Path("target")
public class TargetResource implements MetadataResource {

    @Override
    public ResourceMetadata getResourceMetadata() {
        return new ResourceMetadata(TargetObject.class)
            .incoming(new Relation("connected_to"));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.