/** * Find the name of the class implementing this resource. The location where this name is stored * varies, depending if the resource extends {@link SharedResourceObject} or implements * {@link Resource}. * * @param aDesc * the external resource description. * @return the implementation name. */ protected static String getImplementationName(ExternalResourceDescription aDesc) { if (aDesc.getResourceSpecifier() instanceof CustomResourceSpecifier) { return ((CustomResourceSpecifier) aDesc.getResourceSpecifier()).getResourceClassName(); } else { return aDesc.getImplementationName(); } }
/** * Fill xrd item. * * @param item the item * @param xrd the xrd */ private void fillXrdItem(TreeItem item, ExternalResourceDescription xrd) { StringBuffer text = new StringBuffer(); text.append(xrd.getName()); ResourceSpecifier rs = xrd.getResourceSpecifier(); if (rs instanceof FileLanguageResourceSpecifier) { FileLanguageResourceSpecifier flrs = (FileLanguageResourceSpecifier) rs; text.append(" URL_Prefix: ").append(flrs.getFileUrlPrefix()).append(" URL_Suffix: ") .append(flrs.getFileUrlSuffix()); } else if (rs instanceof FileResourceSpecifier) { FileResourceSpecifier frs = (FileResourceSpecifier) rs; text.append(" URL: ").append(frs.getFileUrl()); } else { text.append(" Custom Resource Specifier"); } String implName = xrd.getImplementationName(); if (null != implName && !implName.equals("")) { text.append(" Implementation: ").append(implName); } item.setText(text.toString()); item.setData(xrd); }
/** * Create an external resource description for a file addressable via an URL. * * @param aName * the name of the resource (the key). * @param aUrl * a URL. * @return the description. * @see FileResourceSpecifier */ public static ExternalResourceDescription createExternalResourceDescription(final String aName, String aUrl) { ExternalResourceDescription extRes = new ExternalResourceDescription_impl(); extRes.setName(aName); FileResourceSpecifier frs = new FileResourceSpecifier_impl(); frs.setFileUrl(aUrl); extRes.setResourceSpecifier(frs); return extRes; }
TreeItem item) { valueChanged = false; xrd.setName(setValueChanged(dialog.xrName, xrd.getName())); xrd.setDescription(setValueChanged(dialog.xrDescription, xrd.getDescription())); xrd .setImplementationName(setValueChanged(dialog.xrImplementation, xrd .getImplementationName())); ResourceSpecifier rs = xrd.getResourceSpecifier(); if (null == dialog.xrUrlSuffix || "".equals(dialog.xrUrlSuffix)) { FileResourceSpecifier frs; xrd.setResourceSpecifier(frs); } else { FileLanguageResourceSpecifier flrs; xrd.setResourceSpecifier(flrs);
ResourceSpecifier aDesc = exRes.getResourceSpecifier(); if (aDesc instanceof AnalysisEngineDescription || aDesc instanceof CustomResourceSpecifier_impl) {
xrNameUI.setText(existingXRD.getName()); xrDescriptionUI.setText(convertNull(existingXRD.getDescription())); ResourceSpecifier rs = existingXRD.getResourceSpecifier(); if (rs instanceof FileResourceSpecifier) xrUrlUI.setText(((FileResourceSpecifier) rs).getFileUrl()); MessageDialog.WARNING); String impName = existingXRD.getImplementationName(); xrImplementationUI.setText(convertNull(impName));
/** * Instantiates a new adds the external resource dialog. * * @param aSection the a section * @param aExistingXRD the a existing XRD */ public AddExternalResourceDialog(AbstractSection aSection, ExternalResourceDescription aExistingXRD) { this(aSection); existingXRD = aExistingXRD; originalXrName = existingXRD.getName(); }
Resource r = UIMAFramework.produceResource(aResourceDescription.getResourceSpecifier(), initParams); String implementationName = aResourceDescription.getImplementationName(); } catch (ClassNotFoundException e) { throw new ResourceInitializationException(ResourceInitializationException.CLASS_NOT_FOUND, new Object[] { implementationName, aResourceDescription.getSourceUrlString() }, e); throw new ResourceInitializationException( ResourceInitializationException.NOT_A_SHARED_RESOURCE_OBJECT, new Object[] { implementationName, aResourceDescription.getSourceUrlString() }); throw new ResourceInitializationException( ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] { implClass.getName(), aResourceDescription.getSourceUrlString() }, e); } catch (IllegalAccessException e) { throw new ResourceInitializationException( ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] { implClass.getName(), aResourceDescription.getSourceUrlString() }, e); ResourceInitializationException.NOT_A_DATA_RESOURCE, new Object[] { implClass.getName(), aName, r.getClass().getName(), aResourceDescription.getSourceUrlString() });
ResourceSpecifier aDesc = exRes.getResourceSpecifier(); if (aDesc instanceof AnalysisEngineDescription || aDesc instanceof CustomResourceSpecifier_impl) {
/** * Create an external resource binding. * * @param aKey * the key to bind to. * @param aResource * the resource to bind. * @return the description. */ public static ExternalResourceBinding createExternalResourceBinding(final String aKey, final ExternalResourceDescription aResource) { return createExternalResourceBinding(aKey, aResource.getName()); }
public static Class<?> getClass(ExternalResourceDescription feDesc) throws ClassNotFoundException { String implName; if (feDesc.getResourceSpecifier() instanceof CustomResourceSpecifier) { implName = ((CustomResourceSpecifier) feDesc.getResourceSpecifier()) .getResourceClassName(); } else { implName = feDesc.getImplementationName(); } Class<?> feClass = Class.forName(implName); return feClass; }
private StringBuilder copyParameters(TcFeature f, StringBuilder sb, File aOutputFolder) throws IOException { sb.append(f.getFeatureName() + "\t"); ExternalResourceDescription feDesc = f.getActualValue(); Map<String, Object> parameterSettings = ConfigurationParameterFactory .getParameterSettings(feDesc.getResourceSpecifier()); List<String> keySet = new ArrayList<>(parameterSettings.keySet()); for (int i = 0; i < keySet.size(); i++) { String key = keySet.get(i); String value = parameterSettings.get(key).toString(); if (valueExistAsFileOrFolderInTheFileSystem(value)) { String name = new File(value).getName(); String destination = aOutputFolder + "/" + name; copyToTargetLocation(new File(value), new File(destination)); sb = record(i, keySet, name, sb); continue; } sb = record(i, keySet, parameterSettings, sb); } sb.append("\n"); return sb; }
@Override public Object getDiscriminatorValue() { StringBuilder desc = new StringBuilder(); desc.append("["); desc.append(fullFeatureName); if (params != null && params.length > 0) { desc.append("| "); for (int i = 0; i < params.length; i++) { Object object = params[i]; if (object instanceof ExternalResourceDescription) { ExternalResourceDescription erd = (ExternalResourceDescription) object; desc.append("ExtResDesc[" + erd.getName() + "]"); } else { desc.append(object.toString()); } if (i + 1 < params.length) { desc.append(", "); } } } desc.append("]"); return desc.toString(); }
public static Class<?> getClass(ExternalResourceDescription feDesc) throws ClassNotFoundException { String implName; if (feDesc.getResourceSpecifier() instanceof CustomResourceSpecifier) { implName = ((CustomResourceSpecifier) feDesc.getResourceSpecifier()) .getResourceClassName(); } else { implName = feDesc.getImplementationName(); } Class<?> feClass = Class.forName(implName); return feClass; }
private StringBuilder copyParameters(TcFeature f, StringBuilder sb, File aOutputFolder) throws IOException { sb.append(f.getFeatureName() + "\t"); ExternalResourceDescription feDesc = f.getActualValue(); Map<String, Object> parameterSettings = ConfigurationParameterFactory .getParameterSettings(feDesc.getResourceSpecifier()); List<String> keySet = new ArrayList<>(parameterSettings.keySet()); for (int i = 0; i < keySet.size(); i++) { String key = keySet.get(i); String value = parameterSettings.get(key).toString(); if (valueExistAsFileOrFolderInTheFileSystem(value)) { String name = new File(value).getName(); String destination = aOutputFolder + "/" + name; copyToTargetLocation(new File(value), new File(destination)); sb = record(i, keySet, name, sb); continue; } sb = record(i, keySet, parameterSettings, sb); } sb.append("\n"); return sb; }
@Override public Object getDiscriminatorValue() { StringBuilder desc = new StringBuilder(); desc.append("["); desc.append(fullFeatureName); if (params != null && params.length > 0) { desc.append("| "); for (int i = 0; i < params.length; i++) { Object object = params[i]; if (object instanceof ExternalResourceDescription) { ExternalResourceDescription erd = (ExternalResourceDescription) object; desc.append("ExtResDesc[" + erd.getName() + "]"); } else { desc.append(object.toString()); } if (i + 1 < params.length) { desc.append(", "); } } } desc.append("]"); return desc.toString(); }
private void persistsFeatureClassObject(TcFeature f, File aOutputFolder) throws Exception { ExternalResourceDescription feDesc = f.getActualValue(); String implName; if (feDesc.getResourceSpecifier() instanceof CustomResourceSpecifier) { implName = ((CustomResourceSpecifier) feDesc.getResourceSpecifier()) .getResourceClassName(); } else { implName = feDesc.getImplementationName(); } storeFeature(aOutputFolder, implName); }
.getParameterSettings(feDesc.getResourceSpecifier()); MetaInfoTask.configureStorageLocations(aContext, feDesc.getResourceSpecifier(), (String) feClosure.getId(), conf.extractorOverrides, AccessMode.READONLY);
/** * Resource name already defined. * * @param name the name * @return true, if successful */ public boolean resourceNameAlreadyDefined(String name) { ExternalResourceDescription[] xrds = getExternalResources(); if (xrds != null) { for (int i = 0; i < xrds.length; i++) { if (xrds[i].getName().equals(name)) { Utility.popMessage("Name Already Defined", "The External Resource Name specified is already defined", MessageDialog.ERROR); return true; } } } return false; }
private void persistsFeatureClassObject(TcFeature f, File aOutputFolder) throws Exception { ExternalResourceDescription feDesc = f.getActualValue(); String implName; if (feDesc.getResourceSpecifier() instanceof CustomResourceSpecifier) { implName = ((CustomResourceSpecifier) feDesc.getResourceSpecifier()) .getResourceClassName(); } else { implName = feDesc.getImplementationName(); } storeFeature(aOutputFolder, implName); }