Java Code Examples for org.apache.uima.collection.CollectionReaderDescription#getMetaData()

The following examples show how to use org.apache.uima.collection.CollectionReaderDescription#getMetaData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AggregateCollectionReader.java    From bluima with Apache License 2.0 6 votes vote down vote up
public AggregateCollectionReader(List<CollectionReader> readers,
    TypeSystemDescription tsd) {
try {
    CollectionReaderDescription crd = CollectionReaderFactory
	    .createReaderDescription(AggregateCollectionReader.class, tsd);
    ResourceMetaData metaData = crd.getMetaData();
    ConfigurationParameterSettings paramSettings = metaData
	    .getConfigurationParameterSettings();
    Map<String, Object> additionalParameters = new HashMap<String, Object>();
    additionalParameters
	    .put(CollectionReader.PARAM_CONFIG_PARAM_SETTINGS,
		    paramSettings);
    initialize(crd, additionalParameters);

    this.readers = readers;
    this.readerIterator = this.readers.iterator();
    currentReader = this.readerIterator.next();
} catch (ResourceInitializationException rie) {
    throw new RuntimeException(rie);
}
   }
 
Example 2
Source File: CollectionReaderFactoryTest.java    From uima-uimafit with Apache License 2.0 5 votes vote down vote up
@Test
public void testResourceMetaData() throws Exception
{
  CollectionReaderDescription desc = CollectionReaderFactory
          .createReaderDescription(TestCR.class);
  
  org.apache.uima.resource.metadata.ResourceMetaData meta = desc.getMetaData();
  
  assertEquals("dummy", meta.getName());
  assertEquals("1.0", meta.getVersion());
  assertEquals("Just a dummy", meta.getDescription());
  assertEquals("ASL 2.0", meta.getCopyright());
  assertEquals("uimaFIT", meta.getVendor());
}
 
Example 3
Source File: CollectionReaderFactory.java    From uima-uimafit with Apache License 2.0 4 votes vote down vote up
/**
 * The factory method for creating CollectionReaderDescription objects for a given class,
 * TypeSystemDescription, TypePriorities, capabilities, and configuration data
 * 
 * @param readerClass
 *          The class of the CollectionReader to be created.
 * @param typeSystem
 *          A description of the types used by the CollectionReader (may be null).
 * @param typePriorities
 *          the type priorities
 * @param indexes
 *          the index definitions
 * @param capabilities
 *          the input and output capabilities
 * @param configurationParameters
 *          the configuration parameters
 * @param configurationValues
 *          the configuration values associated with the parameters
 * @param externalResources
 *          the external resources
 * @return the description created from the default parameters specified in the class and the
 *         configuration parameters
 * @throws ResourceInitializationException
 *           if the descriptor could not be set up
 */
public static CollectionReaderDescription createReaderDescription(
        Class<? extends CollectionReader> readerClass, TypeSystemDescription typeSystem,
        TypePriorities typePriorities, FsIndexCollection indexes, Capability[] capabilities,
        ConfigurationParameter[] configurationParameters, Object[] configurationValues,
        Map<String, ExternalResourceDescription> externalResources)
        throws ResourceInitializationException {
  // create the descriptor and set configuration parameters
  CollectionReaderDescription desc = UIMAFramework.getResourceSpecifierFactory()
          .createCollectionReaderDescription();
  desc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
  desc.setImplementationName(readerClass.getName());

  // set parameters
  setParameters(desc, readerClass, configurationParameters, configurationValues);

  // Configure resource meta data
  ResourceMetaData meta = desc.getMetaData();
  ResourceMetaDataFactory.configureResourceMetaData(meta, readerClass);

  // set the type system
  if (typeSystem != null) {
    desc.getCollectionReaderMetaData().setTypeSystem(typeSystem);
  }

  if (typePriorities != null) {
    desc.getCollectionReaderMetaData().setTypePriorities(typePriorities);
  }

  // set indexes from the argument to this call or from the annotation present in the
  // component if the argument is null
  if (indexes != null) {
    desc.getCollectionReaderMetaData().setFsIndexCollection(indexes);
  } else {
    desc.getCollectionReaderMetaData().setFsIndexCollection(createFsIndexCollection(readerClass));
  }

  // set capabilities from the argument to this call or from the annotation present in the
  // component if the argument is null
  if (capabilities != null) {
    desc.getCollectionReaderMetaData().setCapabilities(capabilities);
  } else {
    Capability capability = CapabilityFactory.createCapability(readerClass);
    if (capability != null) {
      desc.getCollectionReaderMetaData().setCapabilities(new Capability[] { capability });
    }
  }

  // Extract external resource dependencies
  desc.setExternalResourceDependencies(createResourceDependencies(readerClass));

  // Bind External Resources
  if (externalResources != null) {
    for (Entry<String, ExternalResourceDescription> e : externalResources.entrySet()) {
      bindResourceOnce(desc, e.getKey(), e.getValue());
    }
  }

  return desc;
}