org.apache.uima.resource.ResourceCreationSpecifier Java Examples

The following examples show how to use org.apache.uima.resource.ResourceCreationSpecifier. 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: InitializerEngine.java    From biomedicus with Apache License 2.0 6 votes vote down vote up
@Override
public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
    throws ResourceInitializationException {
  if (!(aSpecifier instanceof ResourceCreationSpecifier)) {
    throw new ResourceInitializationException();
  }

  ResourceMetaData metaData = ((ResourceCreationSpecifier) aSpecifier).getMetaData();

  if (!(metaData instanceof AnalysisEngineMetaData)) {
    throw new ResourceInitializationException();
  }

  AnalysisEngineMetaData aeMetaData = (AnalysisEngineMetaData) metaData;

  TypeSystemDescription typeSystem = aeMetaData.getTypeSystem();

  return super.initialize(aSpecifier, aAdditionalParams);
}
 
Example #2
Source File: ResourceDependencySection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Adds the delegate to GUI.
 *
 * @param keys the keys
 * @param newKey the new key
 * @param o the o
 */
private void addDelegateToGUI(String keys, String newKey, ResourceSpecifier o) {
  if (o instanceof AnalysisEngineDescription) {
    AnalysisEngineDescription aeDescription = (AnalysisEngineDescription) o;
    if (aeDescription.isPrimitive())
      addPrimitiveToGUI(keys + newKey + "/", aeDescription);
    else {
      for (Iterator it = editor.getDelegateAEdescriptions(aeDescription).entrySet().iterator(); it
              .hasNext();) {
        Map.Entry item = (Map.Entry) it.next();
        addDelegateToGUI(keys + newKey + "/", (String) item.getKey(), (ResourceSpecifier) item
                .getValue());
      }
      FlowControllerDeclaration fcd = getFlowControllerDeclaration();
      if (null != fcd) {
        addPrimitiveToGUI(keys + fcd.getKey() + "/", ((ResourceCreationSpecifier) editor
                .getResolvedFlowControllerDeclaration().getSpecifier()));
      }
    }
  }
}
 
Example #3
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Get the metadata for a local or remote descriptor. If the descriptor is remote, but cannot be
 * currently connected to, return null. Note that this make take some time to determine.
 * 
 * @param o
 *          is the AnalysisEngineDescription or the URISpecifier for remotes.
 * @return AnalysisEngineMetaData or null
 */
public ResourceMetaData getMetaDataFromDescription(ResourceSpecifier o) {
  if (o instanceof ResourceCreationSpecifier) {
    return ((ResourceCreationSpecifier) o).getMetaData();
  }
  if (o instanceof URISpecifier) {
    URISpecifier uriSpec = ((URISpecifier) o);
    AnalysisEngine ae = null;
    try {
      setVnsHostAndPort(o);
      ae = UIMAFramework.produceAnalysisEngine(uriSpec);
    } catch (ResourceInitializationException e) {
      return null;
    }
    AnalysisEngineMetaData aemd = ae.getAnalysisEngineMetaData();
    ae.destroy();
    return aemd;
  }
  
  throw new InternalErrorCDE("invalid call");
}
 
Example #4
Source File: SearchThread.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Delegate component matches capability reqs.
 *
 * @param rs the rs
 * @param inputTypeSearch the input type search
 * @param outputTypeSearch the output type search
 * @return true, if successful
 */
private boolean delegateComponentMatchesCapabilityReqs(ResourceCreationSpecifier rs,
        Pattern inputTypeSearch, Pattern outputTypeSearch) {

  if (inputTypeSearch == null && outputTypeSearch == null) {
    return true;
  }

  Capability[] capabilities = AbstractSection.getCapabilities(rs);
  if (capabilities == null || capabilities.length == 0) {
    return false;
  }

  boolean inputSatisfied = matchCapabilitiesTo(capabilities, inputTypeSearch, INPUT);
  boolean outputSatisfied = matchCapabilitiesTo(capabilities, outputTypeSearch, OUTPUT);
  return inputSatisfied && outputSatisfied;
}
 
Example #5
Source File: ParameterDelegatesSection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Adds the delegate groups to GUI.
 *
 * @param parent the parent
 * @param delegate the delegate
 */
private void addDelegateGroupsToGUI(TreeItem parent, ResourceCreationSpecifier delegate) {
  ConfigurationParameterDeclarations cpd1 = delegate.getMetaData()
          .getConfigurationParameterDeclarations();
  // if (delegate instanceof AnalysisEngineDescription)
  // cpd1 = ((AnalysisEngineDescription)delegate)
  // .getAnalysisEngineMetaData().getConfigurationParameterDeclarations();
  // else if (delegate instanceof CasConsumerDescription)
  // cpd1 = ((CasConsumerDescription)delegate)
  // .getMetaData().getConfigurationParameterDeclarations();
  // else
  // throw new InternalErrorCDE("Invalid state");

  ConfigGroup noGroup = new ConfigGroup(cpd1, ConfigGroup.NOT_IN_ANY_GROUP);
  ConfigGroup commonGroup = new ConfigGroup(cpd1, ConfigGroup.COMMON);

  addDelegateGroupToGUI(parent, noGroup);
  addDelegateGroupToGUI(parent, commonGroup);
  ConfigurationGroup[] cgs = cpd1.getConfigurationGroups();
  if (cgs != null) {
    for (int i = 0; i < cgs.length; i++) {
      addDelegateGroupToGUI(parent, new ConfigGroup(cpd1, cgs[i]));
    }
  }
}
 
Example #6
Source File: SofaMapSection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Adds the sofas to all component sofa map.
 *
 * @param allComponentSofas the all component sofas
 * @param key the key
 * @param delegate the delegate
 * @param isInput the is input
 */
private void addSofasToAllComponentSofaMap(Map allComponentSofas, String key,
        ResourceSpecifier delegate, boolean isInput) {
  // delegates can be AnalysisEngines, CasConsmers, flowControllers, or remotes
  if (delegate instanceof AnalysisEngineDescription || delegate instanceof CasConsumerDescription
          || delegate instanceof FlowControllerDescription) {
    Set[] inAndOut = getCapabilitySofaNames((ResourceCreationSpecifier) delegate, key);
    Set inOut = inAndOut[isInput ? 0 : 1];
    if (!isInput) { // Aggr "output" can be mapped to delegate "input"
      inOut.addAll(inAndOut[0]);
    }
    if (inOut.size() == 0) {
      // no sofas defined in this delegate
      // create default sofa
      allComponentSofas.put(key, null);
    }
    for (Iterator i2 = inOut.iterator(); i2.hasNext();) {
      allComponentSofas.put(i2.next(), null);
    }
  }
}
 
Example #7
Source File: UimaFactoryInjectionTest.java    From uima-uimafit with Apache License 2.0 6 votes vote down vote up
private static void initUimaApplicationContext(final ApplicationContext aApplicationContext) {
  new UIMAFramework_impl() {
    {
      CompositeResourceFactory_impl factory = (CompositeResourceFactory_impl) getResourceFactory();
      factory.registerFactory(CasConsumerDescription.class,
              aApplicationContext.getBean(CasConsumerFactory_impl.class));
      factory.registerFactory(CasInitializerDescription.class,
              aApplicationContext.getBean(CasInitializerFactory_impl.class));
      factory.registerFactory(CollectionReaderDescription.class,
              aApplicationContext.getBean(CollectionReaderFactory_impl.class));
      factory.registerFactory(ResourceCreationSpecifier.class,
              aApplicationContext.getBean(AnalysisEngineFactory_impl.class));
      factory.registerFactory(CustomResourceSpecifier.class,
              aApplicationContext.getBean(CustomResourceFactory_impl.class));
    }
  };
}
 
Example #8
Source File: SofaMapSection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Called when removing a delegate from the aggr. Removes from the sofaMappings, any and all
 * mappings associated with the delegate.
 *
 * @param componentKey the component key
 * @param delegate the delegate
 * @param pEditor the editor
 */
 public static void removeSofaMappings(String componentKey, ResourceSpecifier delegate,
        MultiPageEditor pEditor) {
  if (delegate instanceof AnalysisEngineDescription || delegate instanceof CasConsumerDescription) {
    Set[] inOut = getCapabilitySofaNames((ResourceCreationSpecifier) delegate, componentKey);
    inOut[0].addAll(inOut[1]);
    final Set allDelegateComponentSofas = inOut[0];
    Comparator comparator = new Comparator() {
      @Override
      public int compare(Object ignore, Object elementOfArray) {
        SofaMapping sofaMapping = (SofaMapping) elementOfArray;
        String key = sofaMapping.getComponentKey();
        if (null != sofaMapping.getComponentSofaName())
          key = key + '/' + sofaMapping.getComponentSofaName();
        if (allDelegateComponentSofas.contains(key)) {
          return 0;
        }
        return -1;
      }
    };

    pEditor.getAeDescription().setSofaMappings(
            (SofaMapping[]) Utility.removeElementsFromArray(getSofaMappings(pEditor), null,
                    SofaMapping.class, comparator));
  }
}
 
Example #9
Source File: PickOverrideKeysAndParmName.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Fill parameter candidates.
 */
private void fillParameterCandidates() {
  paramsUI.setRedraw(false);
  paramsUI.removeAll();
  TableItem selectedItem = keysUI.getSelection()[0];

  Map.Entry entry = (Map.Entry) selectedItem.getData();
  String keyName = (String) entry.getKey();
  // support CasConsumers also
  // support Flow Controllers too
  // and skip remote service descriptors

  ResourceSpecifier rs = (ResourceSpecifier) entry.getValue();
  if (rs instanceof AnalysisEngineDescription || rs instanceof CasConsumerDescription
          || rs instanceof FlowControllerDescription) {
    ConfigurationParameterDeclarations delegateCpd = ((ResourceCreationSpecifier) rs)
            .getMetaData().getConfigurationParameterDeclarations();
    
    addSelectedParms(delegateCpd, keyName);

  }
  if (0 < paramsUI.getItemCount()) {
    paramsUI.setSelection(0);
  }
  paramsUI.setRedraw(true);
}
 
Example #10
Source File: CPMEngine.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Parses Cas Processor descriptor and checks if it is parallelizable.
 * 
 * @param aDescPath -
 *          fully qualified path to a CP descriptor
 * @param aCpName -
 *          name of the CP
 * @param isConsumer -
 *          true if the CP is a Cas Consumer, false otherwise
 * @return - true if CP is parallelizable, false otherwise
 * 
 * @throws Exception -
 */
private boolean isMultipleDeploymentAllowed(String aDescPath, String aCpName, boolean isConsumer)
        throws Exception {
  OperationalProperties op = null;
  // Parse the descriptor to access Operational Properties
  ResourceSpecifier resourceSpecifier = cpeFactory.getSpecifier(new File(aDescPath).toURL());
  if (resourceSpecifier != null && resourceSpecifier instanceof ResourceCreationSpecifier) {
    ResourceMetaData md = ((ResourceCreationSpecifier) resourceSpecifier).getMetaData();
    if (md instanceof ProcessingResourceMetaData) {
      op = ((ProcessingResourceMetaData) md).getOperationalProperties();
      if (op == null) {
        // Operational Properties not defined, so use defaults
        if (isConsumer) {
          return false; // the default for CasConsumer
        }
        return true; // default for AEs
      }
      return op.isMultipleDeploymentAllowed();
    }
  }
  throw new ResourceConfigurationException(ResourceInitializationException.NOT_A_CAS_PROCESSOR,
          new Object[] { aCpName, "<unknown>", aDescPath });

}
 
Example #11
Source File: ResourceCreationSpecifierFactory.java    From uima-uimafit with Apache License 2.0 6 votes vote down vote up
/**
 * Create configuration parameter declarations and settings from a list of (name, value) pairs.
 * 
 * @param specifier
 *          The ResourceCreationSpecifier whose parameters are to be set.
 * @param configurationData
 *          The configuration parameters to be set. These should be supplied as (name, value)
 *          pairs, so there should always be an even number of parameters.
 */
public static void setConfigurationParameters(ResourceCreationSpecifier specifier,
        Object... configurationData) {
  if (configurationData == null || configurationData.length == 0) {
    return;
  }

  ConfigurationParameterFactory.ensureParametersComeInPairs(configurationData);

  ConfigurationParameter[] configurationParameters = new ConfigurationParameter[configurationData.length / 2];
  Object[] configurationValues = new Object[configurationData.length / 2];

  for (int i = 0; i < configurationValues.length; i++) {
    String name = (String) configurationData[i * 2];
    Object value = configurationData[i * 2 + 1];
    ConfigurationParameter param = ConfigurationParameterFactory.createPrimitiveParameter(name,
            value.getClass(), null, false);
    configurationParameters[i] = param;
    configurationValues[i] = ConfigurationParameterFactory.convertParameterValue(param, value);
  }
  setConfigurationParameters(specifier, configurationParameters, configurationValues);
}
 
Example #12
Source File: ASB_impl.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes this ASB.
 * 
 * @param aSpecifier
 *          describes how to create this ASB.
 * @param aAdditionalParams
 *          parameters which are passed along to the delegate Analysis Engines when they are
 *          constructed
 * 
 * @return true if and only if initialization completed successfully. Returns false if this
 *         implementation cannot handle the given <code>ResourceSpecifier</code>.
 * 
 * @see org.apache.uima.resource.Resource#initialize(ResourceSpecifier, Map)
 */
public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
        throws ResourceInitializationException {
  UIMAFramework.getLogger(CLASS_NAME).logrb(Level.CONFIG, CLASS_NAME.getName(), "initialize",
          LOG_RESOURCE_BUNDLE, "UIMA_asb_init_begin__CONFIG");
  if (!(aSpecifier instanceof ResourceCreationSpecifier)) {
    return false;
  }

  // copy the additional parameters, since this method will modify them
  super.initialize(aSpecifier, aAdditionalParams = new HashMap<>(aAdditionalParams));

  // save parameters for later
  mInitParams = aAdditionalParams;

  // save the sofa mappings of the aggregate AE that this AE is part of
  mSofaMappings = (SofaMapping[]) mInitParams.remove(Resource.PARAM_AGGREGATE_SOFA_MAPPINGS);
  // also remove them from the aAdditionalParams map, as they don't need to be passed
  // on to delegates
  // if (mSofaMappings != null)
  // mInitParams.remove(mInitParams.get(Resource.PARAM_AGGREGATE_SOFA_MAPPINGS));

  UIMAFramework.getLogger(CLASS_NAME).logrb(Level.CONFIG, CLASS_NAME.getName(), "initialize",
          LOG_RESOURCE_BUNDLE, "UIMA_asb_init_successful__CONFIG");
  return true;
}
 
Example #13
Source File: CPEFactory.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Override component's parameters. This overridde effects the in-memory settings. The actual
 * component's descriptor will not be changed.
 *
 * @param aResourceSpecifier -
 *          in-memory descriptor of the component
 * @param aCPE_nvp -
 *          parameter represented as name-value pair. If the name of the parameter is found in the
 *          component's descriptor its value will be changed.
 * @param aComponentName the a component name
 * @return true, if successful
 * @throws Exception -
 *           error during processing
 */
private boolean overrideParameterIfExists(ResourceSpecifier aResourceSpecifier,
        org.apache.uima.collection.metadata.NameValuePair aCPE_nvp,
        String aComponentName) throws Exception {
  // Retrieve component's parameter settings from the in-memory descriptor
  ConfigurationParameterDeclarations cpd = ((ResourceCreationSpecifier) aResourceSpecifier)
          .getMetaData().getConfigurationParameterDeclarations();
  // Get the name of the parameter to find in the component's parameter list
  String param_name = aCPE_nvp.getName().trim();
  // Extract parameter with a matching name from the parameter declaration section of the
  // component's descriptor
  ConfigurationParameter cparam = cpd.getConfigurationParameter(null, param_name);
  if (cparam != null) {
    // Retrieve component's parameter settings from the in-memory descriptor
    ConfigurationParameterSettings cps = ((ResourceCreationSpecifier) aResourceSpecifier)
            .getMetaData().getConfigurationParameterSettings();
    // Determie if it is a multi-value parameter (array)
    boolean isMultiValue = cparam.isMultiValued();
    // Check if there is a match based on param name
    if (cparam.getName().equals(param_name)) {
      boolean mandatory = cparam.isMandatory();
      if (isMultiValue) {
        // Override array with values from the CPE descriptor
        replaceArray(cparam.getType(), mandatory, cps, aCPE_nvp, aComponentName);
      } else {
        // Override primitive parameter with value from the CPE descriptor
        replacePrimitive(cparam.getType(), mandatory, cps, aCPE_nvp,
                aComponentName);
      }
      return true; // Found a match and did the override
    }

  }
  return false; // The parameter does not exist in the component's descriptor
}
 
Example #14
Source File: UimacppAnalysisComponent.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public UimacppAnalysisComponent(ResourceCreationSpecifier aeDescription, AnalysisEngineImplBase ae) {
  super();
  this.ae = ae;
  // TAF won't except the new <fsIndexCollection> element, but actuall it doesn't need it,
  // because the index definitions are transmitted with the serialized CAS. So we can
  // just null it out.
   // BUT do this in a clone, so we don't affect Java!
   this.resourceDescription = (ResourceCreationSpecifier)aeDescription.clone();
  ((ProcessingResourceMetaData)this.resourceDescription.getMetaData()).setFsIndexCollection(null);
  this.tsReinit = true;
  // System.out.println("Data path: " + dataPath);
}
 
Example #15
Source File: MultiPageEditor.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Link local processing descriptors to ae.
 *
 * @param r the r
 * @throws ResourceInitializationException the resource initialization exception
 */
private void linkLocalProcessingDescriptorsToAe(ResourceCreationSpecifier r)
        throws ResourceInitializationException {
  aeDescription.setExternalResourceDependencies(r.getExternalResourceDependencies());
  aeDescription.setMetaData(convertToAeMetaData(r.getMetaData()));
  aeDescription.setPrimitive(true);
  aeDescription.setResourceManagerConfiguration(r.getResourceManagerConfiguration());
  setAeDescription(aeDescription);
}
 
Example #16
Source File: CollectionReader_ImplBase.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Called by the framework to initialize this Collection Reader. Subclasses should generally NOT
 * override this method; instead they should override the zero-argument {@link #initialize()}
 * method and access metadata via the {@link #getProcessingResourceMetaData()} method. This method
 * is non-final only for legacy reasons.
 * 
 * @see org.apache.uima.resource.Resource#initialize(org.apache.uima.resource.ResourceSpecifier,
 *      java.util.Map)
 */
public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
        throws ResourceInitializationException {
  if (aSpecifier instanceof ResourceCreationSpecifier) {
    // do framework intitialiation
    if (super.initialize(aSpecifier, aAdditionalParams)) {
      // do user initialization
      initialize();
      return true;
    }
  }
  return false;
}
 
Example #17
Source File: CasConsumer_ImplBase.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Called by the framework to initialize this CAS Consumer. Subclasses should NOT override this
 * method; instead they should override the zero-argument {@link #initialize()} method and access
 * metadata via the {@link #getProcessingResourceMetaData()} method. This method is non-final only
 * for legacy reasons.
 * 
 * @see org.apache.uima.resource.Resource#initialize(org.apache.uima.resource.ResourceSpecifier,
 *      java.util.Map)
 */
public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
        throws ResourceInitializationException {
  // aSpecifier must be a CasConsumerDescription
  if (aSpecifier instanceof ResourceCreationSpecifier) {
    // do framework intitialiation
    if (super.initialize(aSpecifier, aAdditionalParams)) {
      // do user initialization
      initialize();
      return true;
    }
  }
  return false;
}
 
Example #18
Source File: CasInitializer_ImplBase.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Called by the framework to initialize this CAS Initializer. Subclasses should NOT override this
 * method; instead they should override the zero-argument {@link #initialize()} method and access
 * metadata via the {@link #getProcessingResourceMetaData()} method. This method is non-final only
 * for legacy reasons.
 * 
 * @see org.apache.uima.resource.Resource#initialize(org.apache.uima.resource.ResourceSpecifier,
 *      java.util.Map)
 */
public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
        throws ResourceInitializationException {
  // aSpecifier must be a CasInitializerDescription
  if (aSpecifier instanceof ResourceCreationSpecifier) {
    // do framework intitialiation
    if (super.initialize(aSpecifier, aAdditionalParams)) {
      // do user initialization
      initialize();
      return true;
    }
  }
  return false;
}
 
Example #19
Source File: PickTaeForTypesDialog.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Update.
 */
public void update() {

  int nSelectedAeIndex = delegateComponentListGUI.getSelectionIndices()[0];
  ResourceSpecifier rs = (ResourceSpecifier) m_delegateComponentDescriptions
          .get(nSelectedAeIndex);

  String description = rs instanceof ResourceCreationSpecifier ? ((ResourceCreationSpecifier) rs)
          .getMetaData().getDescription() : "No Description - remote service descriptor";
  delegateComponentDescriptionText.setText(convertNull(description));

  inputTypesList.removeAll();
  outputTypesList.removeAll();
  Capability[] capabilities = AbstractSection.getCapabilities(rs);
  if (capabilities != null && capabilities.length > 0) {
    TypeOrFeature[] inputs = capabilities[0].getInputs();
    if (inputs != null) {
      for (int i = 0; i < inputs.length; i++) {
        if (inputs[i].isType()) {
          inputTypesList.add(section.formatName(inputs[i].getName()));
        }
      }
    }

    TypeOrFeature[] outputs = capabilities[0].getOutputs();
    if (outputs != null) {
      for (int i = 0; i < outputs.length; i++) {
        if (outputs[i].isType()) {
          outputTypesList.add(section.formatName(outputs[i].getName()));
        }
      }
    }
  }
  if (okButton != null)
    enableOK();
}
 
Example #20
Source File: FlowControllerContainer.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates the FlowController class specified in the descriptor.
 */
private FlowController instantiateFlowController(ResourceCreationSpecifier aDescriptor)
        throws ResourceInitializationException {
  String flowControllerClassName;
  flowControllerClassName = aDescriptor.getImplementationName();

  if (flowControllerClassName == null || flowControllerClassName.length() == 0) {
    throw new ResourceInitializationException(
            ResourceInitializationException.MISSING_IMPLEMENTATION_CLASS_NAME,
            new Object[] { aDescriptor.getSourceUrlString() });
  }
  // load FlowController class
  Class<?> flowControllerClass = loadUserClassOrThrow(flowControllerClassName, aDescriptor);

  Object userObject;
  try {
    userObject = flowControllerClass.newInstance();
  } catch (Exception e) {
    throw new ResourceInitializationException(
            ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] {
                flowControllerClassName, aDescriptor.getSourceUrlString() }, e);
  }
  if (!(userObject instanceof FlowController)) {
    throw new ResourceInitializationException(
            ResourceInitializationException.RESOURCE_DOES_NOT_IMPLEMENT_INTERFACE, new Object[] {
                flowControllerClassName, FlowController.class, aDescriptor.getSourceUrlString() });
  }
  return (FlowController) userObject;
}
 
Example #21
Source File: ResourceCreationSpecifier_implTest.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public void testDoFullValidation() throws Exception {
  try {
    File descFile = JUnitExtension.getFile("UimaContextTest/CasConsumerForUimaContextTest.xml");
    ResourceCreationSpecifier resCreaSpec = (ResourceCreationSpecifier) UIMAFramework
            .getXMLParser().parseResourceSpecifier(new XMLInputSource(descFile));
    resCreaSpec.doFullValidation();
  } catch (Exception e) {
    JUnitExtension.handleException(e);
  }
}
 
Example #22
Source File: SearchThread.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Test one resource.
 *
 * @param resource the resource
 */
private void testOneResource(IResource resource) {
  switch (resource.getType()) {
    case IResource.FILE:
      if (resource.getName().toLowerCase().endsWith(".xml")
              // exclude potentially many data files, not descriptors
              && !resource.getName().toLowerCase().endsWith(".txt.xml")
              && (m_fileNameSearch == null || m_fileNameSearch.matcher(resource.getName()).find())) {
        String fileDescriptorRelPath = m_aggregateSection.editor
                .getDescriptorRelativePath(resource.getLocation().toString());
        setStatusMsg(2, "Examining " + getBriefDisplayVersion(fileDescriptorRelPath));
        ResourceSpecifier rs = MultiPageEditor.getDelegateResourceSpecifier((IFile) resource,
                m_componentHeaders);
        // rs == null if wrong kind of descriptor
        if (null == rs)
          return;
        if (!(rs instanceof ResourceCreationSpecifier)) // is a remote descriptor
          if (m_inputTypeSearch != null || m_outputTypeSearch != null)
            return; // don't find remote descriptors when types are wanted

        if (!(rs instanceof ResourceCreationSpecifier) || // is a remote descriptor
                delegateComponentMatchesCapabilityReqs((ResourceCreationSpecifier) rs,
                        m_inputTypeSearch, m_outputTypeSearch)) {
          m_matchingDelegateComponentDescriptors.add(fileDescriptorRelPath);
          m_matchingDelegateComponentDescriptions.add(rs);
        }
      }
      break;
    case IResource.FOLDER:
      getDelegateComponentsByIOTypesBeginningAt((IFolder) resource);
      break;
  }

}
 
Example #23
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the capability sofa names.
 *
 * @param rs the rs
 * @param componentKey the component key
 * @return the capability sofa names
 */
protected static Set[] getCapabilitySofaNames(ResourceCreationSpecifier rs, String componentKey) {
  Capability[] cs = getCapabilities(rs);
  Set inputSofasSet = new TreeSet();
  Set outputSofasSet = new TreeSet();
  for (int i = 0; i < cs.length; i++) {
    Capability c = cs[i];
    mergeSofaNames(inputSofasSet, c.getInputSofas(), componentKey);
    mergeSofaNames(outputSofasSet, c.getOutputSofas(), componentKey);
  }
  return new Set[] { inputSofasSet, outputSofasSet };
}
 
Example #24
Source File: ConfigurationParameterFactory.java    From uima-uimafit with Apache License 2.0 5 votes vote down vote up
/**
 * Provides a mechanism to add configuration parameter information to a specifier for the given
 * classes. This method may be useful in situations where a class definition has annotated
 * configuration parameters that you want to include in the given specifier.
 * 
 * @param specifier
 *          the specified to add the parameters to
 * @param dynamicallyLoadedClasses
 *          the classes to analyze and extract parameter information from
 */
public static void addConfigurationParameters(ResourceCreationSpecifier specifier,
        List<Class<?>> dynamicallyLoadedClasses) {
  for (Class<?> dynamicallyLoadedClass : dynamicallyLoadedClasses) {
    ConfigurationData reflectedConfigurationData = ConfigurationParameterFactory
            .createConfigurationData(dynamicallyLoadedClass);
    ResourceCreationSpecifierFactory.setConfigurationParameters(specifier,
            reflectedConfigurationData.configurationParameters,
            reflectedConfigurationData.configurationValues);
  }
}
 
Example #25
Source File: ConfigurationParameterFactory.java    From uima-uimafit with Apache License 2.0 5 votes vote down vote up
/**
 * Provides a mechanism to add configuration parameter information to a specifier for the given
 * classes. This method may be useful in situations where a class definition has annotated
 * configuration parameters that you want to include in the given specifier
 * 
 * @param specifier
 *          the specified to add the parameters to
 * @param dynamicallyLoadedClasses
 *          the classes to analyze and extract parameter information from
 */
public static void addConfigurationParameters(ResourceCreationSpecifier specifier,
        Class<?>... dynamicallyLoadedClasses) {
  for (Class<?> dynamicallyLoadedClass : dynamicallyLoadedClasses) {
    ConfigurationData reflectedConfigurationData = ConfigurationParameterFactory
            .createConfigurationData(dynamicallyLoadedClass);
    ResourceCreationSpecifierFactory.setConfigurationParameters(specifier,
            reflectedConfigurationData.configurationParameters,
            reflectedConfigurationData.configurationValues);
  }
}
 
Example #26
Source File: ResourceDependencySection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the primitive to GUI.
 *
 * @param keys the keys
 * @param aeDescription the ae description
 */
private void addPrimitiveToGUI(String keys, ResourceCreationSpecifier aeDescription) {
  ExternalResourceDependency[] xrd = aeDescription.getExternalResourceDependencies();
  if (null != xrd) {
    for (int i = 0; i < xrd.length; i++) {
      addXrdToGUI(keys, xrd[i]);
    }
  }
}
 
Example #27
Source File: ParameterDelegatesSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the delegate to GUI.
 *
 * @param key the key
 * @param delegate the delegate
 */
private void addDelegateToGUI(String key, ResourceSpecifier delegate) {
  if (delegate instanceof AnalysisEngineDescription || delegate instanceof CasConsumerDescription
          || delegate instanceof FlowControllerDescription) {
    TreeItem d = new TreeItem(tree, SWT.NONE);
    d.setText(((delegate instanceof FlowControllerDescription) ? FLOWCTLR_HEADER
            : DELEGATE_HEADER)
            + key);
    d.setData(key);
    addDelegateGroupsToGUI(d, (ResourceCreationSpecifier) delegate);
    d.setExpanded(true);
  }
}
 
Example #28
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the capabilities.
 *
 * @param rs the rs
 * @return the capabilities
 */
public static Capability[] getCapabilities(ResourceSpecifier rs) {
  if (rs instanceof ResourceCreationSpecifier)
    return ((ProcessingResourceMetaData) ((ResourceCreationSpecifier) rs).getMetaData())
            .getCapabilities();
  return null;
}
 
Example #29
Source File: ResourceCreationSpecifierFactoryTest.java    From uima-uimafit with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void test1() {
  ResourceCreationSpecifierFactory.setConfigurationParameters((ResourceCreationSpecifier) null,
          ParameterizedAE.PARAM_BOOLEAN_1);
}
 
Example #30
Source File: MultiPageEditor.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
/**
 * Link common collection descriptors from ae.
 *
 * @param r the r
 */
private void linkCommonCollectionDescriptorsFromAe(ResourceCreationSpecifier r) {
  r.setExternalResourceDependencies(aeDescription.getExternalResourceDependencies());
  r.setMetaData(convertFromAeMetaData((AnalysisEngineMetaData) aeDescription.getMetaData()));
  r.setResourceManagerConfiguration(aeDescription.getResourceManagerConfiguration());
}