gate.creole.ResourceInstantiationException Java Examples

The following examples show how to use gate.creole.ResourceInstantiationException. 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: TikaFormat.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Resource init() throws ResourceInstantiationException {		
  super.init();
  setMimeType(new MimeType("application","tika"));
  assignMime(getMimeType());
  assignMime(new MimeType("application","pdf"), "pdf");
  assignMime(new MimeType("application","msword"), "doc");
  assignMime(new MimeType("application","vnd.ms-powerpoint"), "ppt");
  assignMime(new MimeType("application","vnd.ms-excel"), "xls");
  assignMime(new MimeType("application","vnd.openxmlformats-officedocument.wordprocessingml.document"), "docx");   
  assignMime(new MimeType("application","vnd.openxmlformats-officedocument.presentationml.presentation"), "pptx");
  assignMime(new MimeType("application","vnd.openxmlformats-officedocument.spreadsheetml.sheet"), "xlsx");       
  assignMime(new MimeType("application", "vnd.oasis.opendocument.text"), "odt");
  assignMime(new MimeType("application", "vnd.oasis.opendocument.presentation"), "odp");
  assignMime(new MimeType("application", "vnd.oasis.opendocument.spreadsheet"), "ods");
  assignMime(new MimeType("application", "rtf"), "rtf");
  
  //There are bugs in Tika related to ePub as of 0.7
  //assignMime(new MimeType("application", "epub+zip"), "epub");
  return this;
}
 
Example #2
Source File: XmlDocumentFormat.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** Initialise this resource, and return it. */
@Override
public Resource init() throws ResourceInstantiationException {
  // Register XML mime type
  MimeType mime = new MimeType("text", "xml");
  // Register the class handler for this mime type
  mimeString2ClassHandlerMap.put(mime.getType() + "/" + mime.getSubtype(),
          this);
  // Register the mime type with mine string
  mimeString2mimeTypeMap.put(mime.getType() + "/" + mime.getSubtype(), mime);
  // sometimes XML file appear as application/xml
  mimeString2mimeTypeMap.put("application/xml", mime);
  // Register file sufixes for this mime type
  suffixes2mimeTypeMap.put("xml", mime);
  suffixes2mimeTypeMap.put("xhtm", mime);
  suffixes2mimeTypeMap.put("xhtml", mime);
  // Register magic numbers for this mime type
  magic2mimeTypeMap.put("<?xml", mime);
  // Set the mimeType for this language resource
  setMimeType(mime);
  return this;
}
 
Example #3
Source File: EmailDocumentFormat.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** Initialise this resource, and return it. */
@Override
public Resource init() throws ResourceInstantiationException{
  // Register EMAIL mime type
  MimeType mime = new MimeType("text","email");
  // Register the class handler for this mime type
  mimeString2ClassHandlerMap.put(mime.getType()+ "/" + mime.getSubtype(),
                                                                        this);
  // Register the mime type with mine string
  mimeString2mimeTypeMap.put(mime.getType() + "/" + mime.getSubtype(), mime);
  // Register file sufixes for this mime type
  suffixes2mimeTypeMap.put("eml",mime);
  suffixes2mimeTypeMap.put("email",mime);
  suffixes2mimeTypeMap.put("mail",mime);
  // Register magic numbers for this mime type
  magic2mimeTypeMap.put("Subject:",mime);
  // Set the mimeType for this language resource
  setMimeType(mime);
  return this;
}
 
Example #4
Source File: ConllDocumentFormat.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** Initialise this resource, and return it. */
@Override
public Resource init() throws ResourceInstantiationException{
  // Register ad hoc MIME-type
  MimeType mime = new MimeType("text","x-conll");
  // Register the class handler for this MIME-type
  mimeString2ClassHandlerMap.put(mime.getType()+ "/" + mime.getSubtype(), this);
  // Register the mime type with string
  mimeString2mimeTypeMap.put(mime.getType() + "/" + mime.getSubtype(), mime);
  // Register file suffixes for this mime type
  suffixes2mimeTypeMap.put("conll",mime);
  suffixes2mimeTypeMap.put("iob",mime);
  // Register magic numbers for this mime type
  //magic2mimeTypeMap.put("Subject:",mime);
  // Set the mimeType for this language resource
  setMimeType(mime);
  return this;
}
 
Example #5
Source File: SgmlDocumentFormat.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** Initialise this resource, and return it. */
@Override
public Resource init() throws ResourceInstantiationException{
  // Register SGML mime type
  MimeType mime = new MimeType("text","sgml");
  // Register the class handler for this mime type
  mimeString2ClassHandlerMap.put(mime.getType()+ "/" + mime.getSubtype(),
                                                                        this);
  // Register the mime type with mine string
  mimeString2mimeTypeMap.put(mime.getType() + "/" + mime.getSubtype(), mime);
  // Register file sufixes for this mime type
  suffixes2mimeTypeMap.put("sgm",mime);
  suffixes2mimeTypeMap.put("sgml",mime);
  setMimeType(mime);
  return this;
}
 
Example #6
Source File: DSPersistence.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new object from the data contained. This new object is supposed
 * to be a copy for the original object used as source for data extraction.
 */
@Override
public Object createObject()throws PersistenceException,
                                   ResourceInstantiationException{
  if(storageUrl != null) {
    storageUrlString =
      ((URL)PersistenceManager.getTransientRepresentation(storageUrl))
        .toExternalForm();
  }

  //check if the same datastore is not already open
  Iterator<DataStore> dsIter = Gate.getDataStoreRegister().iterator();
  while(dsIter.hasNext()){
    DataStore aDS = dsIter.next();
    if(aDS.getStorageUrl().equals(storageUrlString)) {
      return aDS;
    }
  }
  //if we got this far, then it's a new datastore that needs opening
  return Factory.openDataStore(className, storageUrlString);
}
 
Example #7
Source File: TestRepositioningInfo.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * This method sets up the parameters for the files to be tested
 */
@Override
protected void setUp() throws Exception {

  if (!Gate.isInitialised()) {
    Gate.runInSandbox(true);
    Gate.init();
  }
  
  testFile = TestDocument.getTestServerName() + "tests/test-inline.xml";

  // creating documents
  try {
    FeatureMap params = Factory.newFeatureMap();
    params.put("sourceUrl",new URL(testFile));
    params.put("preserveOriginalContent", new Boolean("true"));
    params.put("collectRepositioningInfo", new Boolean("true"));
    doc = (Document) Factory.createResource("gate.corpora.DocumentImpl",params);
  }
  catch (MalformedURLException murle) {
    fail("Document cannot be created ");
  }
  catch (ResourceInstantiationException rie) {
    fail("Resources cannot be created for the test document");
  }
}
 
Example #8
Source File: UimaDocumentFormat.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Resource init() throws ResourceInstantiationException {
  // Register XML mime type
  MimeType mime = new MimeType("text", "xmi+xml");
  // Register the class handler for this mime type
  mimeString2ClassHandlerMap.put(mime.getType() + "/" + mime.getSubtype(),
    this);
  // Register the mime type with mine string
  mimeString2mimeTypeMap.put(mime.getType() + "/" + mime.getSubtype(), mime);
  // Register file suffixes for this mime type
  suffixes2mimeTypeMap.put("xcas", mime);
  suffixes2mimeTypeMap.put("xmicas", mime);
  suffixes2mimeTypeMap.put("xmi", mime);
  // Register magic numbers for this mime type
  magic2mimeTypeMap.put("<CAS version=\"2\">", mime);
  magic2mimeTypeMap.put("xmlns:cas=", mime);
  // Set the mimeType for this language resource
  setMimeType(mime);
  return this;
}
 
Example #9
Source File: CorpusAnnotationDiff.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Sets the value for a specified parameter.
 *
 * @param paramaterName the name for the parameteer
 * @param parameterValue the value the parameter will receive
 */
@Override
public void setParameterValue(String paramaterName, Object parameterValue)
            throws ResourceInstantiationException{
  // get the beaninfo for the resource bean, excluding data about Object
  BeanInfo resBeanInf = null;
  try {
    resBeanInf = Introspector.getBeanInfo(this.getClass(), Object.class);
  } catch(Exception e) {
    throw new ResourceInstantiationException(
      "Couldn't get bean info for resource " + this.getClass().getName()
      + Strings.getNl() + "Introspector exception was: " + e
    );
  }
  AbstractResource.setParameterValue(this, resBeanInf, paramaterName, parameterValue);
}
 
Example #10
Source File: CorpusPersistence.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new object from the data contained. This new object is supposed
 * to be a copy for the original object used as source for data extraction.
 */
@Override
public Object createObject()throws PersistenceException,
                                   ResourceInstantiationException{
  Corpus corpus = (Corpus)super.createObject();
  if(docList != null){
    //transient corpus; we need to recreate the docs
    if(!docList.isEmpty() && corpus.isEmpty()){
      Iterator<Serializable> docIter = docList.iterator();
      while(docIter.hasNext()){
        corpus.add((Document) PersistenceManager.getTransientRepresentation(
                docIter.next(),containingControllerName,initParamOverrides));
      }

    }
  }
  return corpus;
}
 
Example #11
Source File: SerialDatastoreViewer.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Sets the value for a specified parameter.
 * 
 * @param paramaterName the name for the parameteer
 * @param parameterValue the value the parameter will receive
 */
@Override
public void setParameterValue(String paramaterName, Object parameterValue)
        throws ResourceInstantiationException {
  // get the beaninfo for the resource bean, excluding data about
  // Object
  BeanInfo resBeanInf = null;
  try {
    resBeanInf = Introspector.getBeanInfo(this.getClass(), Object.class);
  }
  catch(Exception e) {
    throw new ResourceInstantiationException(
            "Couldn't get bean info for resource "
                    + this.getClass().getName() + Strings.getNl()
                    + "Introspector exception was: " + e);
  }
  AbstractResource.setParameterValue(this, resBeanInf, paramaterName,
          parameterValue);
}
 
Example #12
Source File: NekoHtmlDocumentFormat.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** Initialise this resource, and return it. */
@Override
public Resource init() throws ResourceInstantiationException {
  // Register HTML mime type
  MimeType mime = new MimeType("text", "html");
  // Register the class handler for this mime type
  mimeString2ClassHandlerMap.put(mime.getType() + "/" + mime.getSubtype(),
          this);
  // Register the mime type with mine string
  mimeString2mimeTypeMap.put(mime.getType() + "/" + mime.getSubtype(), mime);
  // sometimes XHTML file appear as application/xhtml+xml
  mimeString2mimeTypeMap.put("application/xhtml+xml", mime);
  // Register file sufixes for this mime type
  suffixes2mimeTypeMap.put("html", mime);
  suffixes2mimeTypeMap.put("htm", mime);
  // Register magic numbers for this mime type
  magic2mimeTypeMap.put("<html", mime);
  // Set the mimeType for this language resource
  setMimeType(mime);
  return this;
}
 
Example #13
Source File: Factory.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** Create a new transient textual Document from a string. */
public static Document newDocument(String content)
        throws ResourceInstantiationException {
  FeatureMap params = newFeatureMap();
  params.put(Document.DOCUMENT_STRING_CONTENT_PARAMETER_NAME, content);
  Document doc =
          (Document)createResource("gate.corpora.DocumentImpl", params);
  /*
   * // laziness: should fit this into createResource by adding a new
   * // document parameter, but haven't time right now...
   * doc.setContent(new DocumentContentImpl(content));
   */
  // various classes are in the habit of assuming that a document
  // inevitably has a source URL... so give it a dummy one
  /*
   * try { doc.setSourceUrl(new URL("http://localhost/")); }
   * catch(MalformedURLException e) { throw new
   * ResourceInstantiationException(
   * "Couldn't create dummy URL in newDocument(String): " + e ); }
   */
  doc.setSourceUrl(null);
  return doc;
}
 
Example #14
Source File: LRPersistence.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new object from the data contained. This new object is supposed
 * to be a copy for the original object used as source for data extraction.
 */
@SuppressWarnings("unchecked")
@Override
public Object createObject()throws PersistenceException,
                                   ResourceInstantiationException{
  if(dsData == null) return super.createObject();
  else{
    //persistent doc
    initParams = PersistenceManager.getTransientRepresentation(
            initParams,containingControllerName,initParamOverrides);

    DataStore ds = (DataStore)PersistenceManager.getTransientRepresentation(
            dsData,containingControllerName,initParamOverrides);
    ((Map<Object,Object>)initParams).put(DataStore.DATASTORE_FEATURE_NAME, ds);
    ((Map<Object,Object>)initParams).put(DataStore.LR_ID_FEATURE_NAME, persistenceID);
    return super.createObject();
  }
}
 
Example #15
Source File: AbstractDocumentProcessor.java    From gateplugin-LearningFramework with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public Resource duplicate(Factory.DuplicationContext ctx) throws ResourceInstantiationException {
  // System.err.println("DEBUG duplicate(), getNDuplicates="+getNDuplicates()+" this="+this);

  // NOTE: this piece of code does not need to get synchronized since we 
  // always expect duplication to happen in a single thread, one after the
  // other. Usually, all duplicates will get created from the same first
  // created instance, but we do not rely on that.
  
  // This should never happen since we should have dealt with getNDuplicates() being
  // null in the init() of the template before any duplication occurs!
  if(getNDuplicates() == null || getNDuplicates().get() == 0) {    
    throw new GateRuntimeException("This should not happen!");
  } else {
    // create a new instance of whatever we are and cast to what we need to handle it
    AbstractDocumentProcessor newRes = (AbstractDocumentProcessor)defaultDuplicate(this, ctx);
    int thisn = getNDuplicates().getAndAdd(1);
    // set the duplicateId in the newly created instance
    newRes.duplicateId = thisn;
    LOGGER.debug("DEBUG: created duplicate "+newRes.duplicateId+" of PR "+this.getName());
    // System.err.println("DEBUG duplicate() END, getNDuplicates="+getNDuplicates()+" new="+newRes+" id="+newRes.duplicateId+" hash="+System.identityHashCode(newRes));
    // return the duplicate
    return newRes;
  }
}
 
Example #16
Source File: NameBearerHandle.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
  try {
    Corpus corpus = Factory.newCorpus("Corpus for " + target.getName());
    corpus.add((Document)target);
  }
  catch(ResourceInstantiationException rie) {
    Err.println("Exception creating corpus");
    rie.printStackTrace(Err.getPrintWriter());
  }
}
 
Example #17
Source File: SerialCorpusImpl.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Document get(int index) {
  if(index >= docDataList.size()) return null;

  Document res = documents.get(index);

  if(DEBUG)
    Out.prln("SerialCorpusImpl: get(): index " + index + "result: " + res);

  // if the document is null, then I must get it from the DS
  if(res == null) {
    FeatureMap parameters = Factory.newFeatureMap();
    parameters.put(DataStore.DATASTORE_FEATURE_NAME, this.dataStore);
    try {
      parameters.put(DataStore.LR_ID_FEATURE_NAME, docDataList
              .get(index).getPersistentID());
      Document lr = (Document) Factory.createResource(docDataList
              .get(index).getClassType(), parameters);
      if(DEBUG) Out.prln("Loaded document :" + lr.getName());
      // change the result to the newly loaded doc
      res = lr;

      // finally replace the doc with the instantiated version
      documents.set(index, lr);
    }
    catch(ResourceInstantiationException ex) {
      Err.prln("Error reading document inside a serialised corpus.");
      throw new GateRuntimeException(ex);
    }
  }

  return res;
}
 
Example #18
Source File: FeaturesSchemaEditor.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Initialise this resource, and return it. */
@Override
public Resource init() throws ResourceInstantiationException {
  featureList = new ArrayList<Feature>();
  emptyFeature = new Feature("", null);
  featureList.add(emptyFeature);
  initGUI();
  return this;
}
 
Example #19
Source File: ITFeatureScaling.java    From gateplugin-LearningFramework with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testEngineMalletClass1() throws MalformedURLException, ResourceInstantiationException {
  File configFile = new File("tests/cl-ionosphere/feats.xml");
  FeatureSpecification spec = new FeatureSpecification(configFile);
  FeatureInfo featureInfo = spec.getFeatureInfo();
  featureInfo.setGlobalScalingMethod(ScalingMethod.MEANVARIANCE_ALL_FEATURES);
  CorpusRepresentationMalletTarget crm = new CorpusRepresentationMalletTarget(featureInfo, TargetType.NOMINAL);
  
  Document doc = loadDocument(new File("tests/cl-ionosphere/ionosphere_gate.xml"));
  
  AnnotationSet instanceAS = doc.getAnnotations().get("Mention");
  AnnotationSet sequenceAS = null;
  AnnotationSet inputAS = doc.getAnnotations();
  AnnotationSet classAS = null;
  String targetFeature = "class";
  String nameFeature = null;
  crm.add(instanceAS, sequenceAS, inputAS, classAS, targetFeature, TargetType.NOMINAL, "", nameFeature, null);
  
  System.err.println("TESTS Scaling 1: added instances, number of instances now: "+crm.getRepresentationMallet().size());

  // TODO: make this test actually work!
  File outDir1 = new File(new File(System.getProperty("java.io.tmpdir")),"lf-unscaled");
  outDir1.mkdir();
  File outDir2 = new File(new File(System.getProperty("java.io.tmpdir")),"lf-scaled");
  outDir2.mkdir();
  //System.err.println("Exporting unscaled");
  //Exporter.export(crm, Exporter.ARFF_CL_MR, outDir1, "Mention", "");
  crm.finishAdding();
  //System.err.println("Exporting scaled");
  //Exporter.export(crm, Exporter.ARFF_CL_MR, outDir2, "Mention", "");

}
 
Example #20
Source File: SerialCorpusImpl.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * SerialCorpusImpl does not support duplication.
 */
@Override
public Resource duplicate(Factory.DuplicationContext ctx)
        throws ResourceInstantiationException {
  throw new ResourceInstantiationException("Duplication of "
          + this.getClass().getName() + " not permitted");
}
 
Example #21
Source File: SerialAnalyserControllerPersistence.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new object from the data contained. This new object is supposed
 * to be a copy for the original object used as source for data extraction.
 */
@Override
public Object createObject()throws PersistenceException,
                                   ResourceInstantiationException{
  SerialAnalyserController sac = (SerialAnalyserController)
                                super.createObject();
  sac.setCorpus((Corpus)PersistenceManager.getTransientRepresentation(
          corpus,resourceName,initParamOverrides));
  return sac;
}
 
Example #22
Source File: ResourcePersistence.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Object createObject()throws PersistenceException,
                                   ResourceInstantiationException {
  if(initParams != null)
    initParams = PersistenceManager.getTransientRepresentation(
            initParams,containingControllerName,initParamOverrides);
  if(features != null)
    features = PersistenceManager.getTransientRepresentation(
            features,containingControllerName,initParamOverrides);
  if(initParamOverrides != null) {
    // check if there is a map for this resource Id in the overrides
    String containingControllerNameToUse = 
            containingControllerName == null ? "" : containingControllerName;
    String resourceId = containingControllerNameToUse+"\t"+resourceName;
    if(initParamOverrides.containsKey(resourceId)) {
      Map<String,Object> parmOverrides = initParamOverrides.get(resourceId);
      if(initParams instanceof FeatureMap) {
        FeatureMap fm = (FeatureMap)initParams;
        // override the values
        // do this in a loop instead of using putAll so we can log the changes
        for(String name : parmOverrides.keySet()) {
          Object obj = parmOverrides.get(name);
          log.info(
                  "Overriding init parameter "+name+
                  " for "+containingControllerNameToUse+
                  "//"+resourceName+" with "+obj);
          fm.put(name, obj);
        }
      }
    }
  } 
  Resource res = Factory.createResource(resourceType, (FeatureMap)initParams,
                                        (FeatureMap)features,resourceName);
  return res;
}
 
Example #23
Source File: CorpusBenchmarkTool.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected AnnotationDiffer measureDocs(
    Document keyDoc, Document respDoc, String annotType) throws
    ResourceInstantiationException {

  if (keyDoc == null || respDoc == null)
    return null;

  if (annotSetName != null
      && keyDoc.getAnnotations(annotSetName).get(annotType) == null)
    return null;
  else if ( (annotSetName == null || annotSetName.equals(""))
           && keyDoc.getAnnotations().get(annotType) == null)
    return null;

  // create an annotation diff
  AnnotationDiffer annotDiffer = new AnnotationDiffer();
  // set the feature names set for annotation differ
  annotDiffer.setSignificantFeaturesSet(diffFeaturesSet);
  // we need to find the sets
  AnnotationSet keys, responses;
  if (annotSetName == null || annotSetName.equals("")) {
    keys = keyDoc.getAnnotations().get(annotType);
    responses = respDoc.getAnnotations().get(annotType);
  }
  else {
    keys = keyDoc.getAnnotations(annotSetName).get(annotType);
    responses = respDoc.getAnnotations(outputSetName).get(annotType);
  }

  // we have annotation sets so call the annotationDiffer
  annotDiffer.calculateDiff(keys, responses);
  
  return annotDiffer;
}
 
Example #24
Source File: MapPersistence.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new object from the data contained. This new object is supposed
 * to be a copy for the original object used as source for data extraction.
 */
@SuppressWarnings("unchecked")
@Override
public Object createObject()throws PersistenceException,
                                   ResourceInstantiationException{
  //let's try to create a map of the same type as the original
  Map<Object,Object> result = null;
  try{
    result = (Map<Object,Object>)mapType.newInstance();
  }catch(Exception e){
  }
  if(result == null) result = new HashMap<Object,Object>(localMap.size());

  //now we have a map let's populate it
  Iterator<Serializable> keyIter = localMap.keySet().iterator();
  while(keyIter.hasNext()){
    Object key = keyIter.next();
    Object value = localMap.get(key);

    key = PersistenceManager.getTransientRepresentation(key);
    value = PersistenceManager.getTransientRepresentation(
            value,containingControllerName,initParamOverrides);
    result.put(key, value);
  }

  return result;
}
 
Example #25
Source File: ConditionalControllerPersistence.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new object from the data contained. This new object is supposed
 * to be a copy for the original object used as source for data extraction.
 */
@SuppressWarnings("unchecked")
@Override
public Object createObject()throws PersistenceException,
                                   ResourceInstantiationException{
  ConditionalController controller =
    (ConditionalController)super.createObject();
  controller.setRunningStrategies(
    (Collection<RunningStrategy>)PersistenceManager.getTransientRepresentation(
          strategiesList,resourceName,initParamOverrides));
  return controller;
}
 
Example #26
Source File: ConditionalSerialAnalyserControllerPersistence.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new object from the data contained. This new object is supposed
 * to be a copy for the original object used as source for data extraction.
 */
@Override
public Object createObject()throws PersistenceException,
                                   ResourceInstantiationException{
  ConditionalSerialAnalyserController sac = (ConditionalSerialAnalyserController)
                                super.createObject();
  sac.setCorpus((Corpus)PersistenceManager.getTransientRepresentation(
          corpus,resourceName,initParamOverrides));
  return sac;
}
 
Example #27
Source File: UnconditionalRunningStrategyPersistence.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Object createObject() throws PersistenceException,
                                    ResourceInstantiationException {
  return new UnconditionalRunningStrategy(
          (ProcessingResource)PersistenceManager.
             getTransientRepresentation(pr,containingControllerName,initParamOverrides),
          shouldRun);
}
 
Example #28
Source File: LanguageAnalyserPersistence.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new object from the data contained. This new object is supposed
 * to be a copy for the original object used as source for data extraction.
 */
@Override
public Object createObject()throws PersistenceException,
                                   ResourceInstantiationException{
  LanguageAnalyser la = (LanguageAnalyser)super.createObject();
  la.setCorpus((Corpus)PersistenceManager.getTransientRepresentation(corpus));
  la.setDocument((Document)PersistenceManager.getTransientRepresentation(
          document,containingControllerName,initParamOverrides));
  return la;
}
 
Example #29
Source File: AnalyserRunningStrategyPersistence.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Object createObject() throws PersistenceException,
                                    ResourceInstantiationException {
  return new AnalyserRunningStrategy(
          (LanguageAnalyser)PersistenceManager.getTransientRepresentation(
            pr,containingControllerName,initParamOverrides),
                                     runMode, featureName, featureValue);
}
 
Example #30
Source File: PersistenceManager.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Object createObject()
    throws PersistenceException, ResourceInstantiationException {
  try {
    return new ResourceReference(URLHolder.unpackPersistentRepresentation(
        currentPersistenceURL().toURI(), uriString));
  } catch(URISyntaxException e) {
    throw new PersistenceException(e);
  }
}