Skip to content

Commit

Permalink
1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
abrami committed Apr 1, 2020
1 parent 344c8ab commit ba890a2
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 23 deletions.
41 changes: 27 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.texttechnologylab.annotation</groupId>
<artifactId>UIMADatabaseInterface</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>

<repositories>
<repository>
Expand Down Expand Up @@ -62,16 +62,33 @@
</build>

<dependencies>

<dependency>
<groupId>org.hucompute.textimager.uima</groupId>
<artifactId>textimager-uima</artifactId>
<version>0.0.1-SNAPSHOT</version>
<groupId>com.github.texttechnologylab</groupId>
<artifactId>UIMATypeSystem</artifactId>
<version>master-4262ceb3c8-1</version>
</dependency>

<dependency>
<groupId>org.texttechnologylab.annotation</groupId>
<artifactId>typesystem</artifactId>
<version>1.7.5</version>
</dependency>
<groupId>com.github.texttechnologylab</groupId>
<artifactId>textimager-uima</artifactId>
<version>54dda3f4af</version>
<exclusions>
<exclusion>
<groupId>org.texttechnologylab.annotation</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.texttechnologylab</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.texttechnologylab.annotation</groupId>-->
<!-- <artifactId>typesystem</artifactId>-->
<!-- <version>1.7.5</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.github.jitpack</groupId>
<artifactId>maven-modular</artifactId>
Expand All @@ -88,11 +105,7 @@
<artifactId>Utilities</artifactId>
<version>1.0.2-uima-2.10.4</version>
</dependency>
<dependency>
<groupId>org.texttechnologylab.annotation</groupId>
<artifactId>typesystem</artifactId>
<version>1.7.5</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver -->
<dependency>
<groupId>org.mongodb</groupId>
Expand Down Expand Up @@ -251,4 +264,4 @@
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.json.JSONException;
import org.json.JSONObject;
import org.texttechnologylab.uimadb.UIMADatabaseInterface;
import org.texttechnologylab.uimadb.UIMADatabaseInterfaceService;
import org.texttechnologylab.uimadb.wrapper.couchbase.CouchbaseConfig;
import org.texttechnologylab.uimadb.wrapper.couchbase.CouchbaseConnection;
import org.texttechnologylab.uimadb.wrapper.couchbase.CouchbaseHelper;
Expand Down Expand Up @@ -215,7 +216,7 @@ public String createElement(JCas jCas, JSONArray pAttributes) throws UIMAExcepti
}

@Override
public void updateElement(JCas pJCas) throws CasSerializationException, SerializerInitializationException, UnknownFactoryException, CASException {
public void updateElement(JCas pJCas) throws CasSerializationException, SerializerInitializationException, UnknownFactoryException {
// replace existing document with updated version
try {
updateElement(pJCas, false);
Expand Down Expand Up @@ -306,7 +307,7 @@ public long getSize(String sID) {
}

@Override
public Set<JCas> getElements(String sQuery) throws UIMAException, IOException {
public Set<JCas> getElements(String sQuery) {
// return results of query as Set of JCas'
// only use if Query returns whole documents, otherwise deserializeJCas runs into problems currently

Expand All @@ -322,19 +323,24 @@ public Set<JCas> getElements(String sQuery) throws UIMAException, IOException {
JsonObject jsonObject = row.value();
String jsonString = jsonObject.toString();
System.out.println(jsonString);
JCas rCasObject = UIMADatabaseInterface.deserializeJCas(jsonString);
JCas rCasObject = null;
try {
rCasObject = UIMADatabaseInterface.deserializeJCas(jsonString);
} catch (UIMAException e) {
e.printStackTrace();
}
rCas.add(rCasObject);
}
return rCas;
}

@Override
public Set<JCas> getElementsDirect(String sQuery) throws UIMAException, IOException {
public Set<JCas> getElementsDirect(String sQuery) {
return getElements(sQuery);
}

@Override
public Set<JCas> getElementsDirect(String sQuery, String queryValue) throws UIMAException, IOException {
public Set<JCas> getElementsDirect(String sQuery, String queryValue) {
return getElementsDirect(sQuery);
}

Expand All @@ -349,18 +355,18 @@ public Set<JCas> getElementsWithType(String sSourceObject, String sTargetObject)
}

@Override
public Set<JCas> getElements(KeyValue... kvs) throws UIMAException, IOException {
public Set<JCas> getElements(KeyValue... kvs) {
StringBuilder sb = new StringBuilder();
return getElements(sb.toString());
}

@Override
public Set<JCas> getElementsByGeoLocation(double lat, double lon, double distance) throws UIMAException, IOException {
public Set<JCas> getElementsByGeoLocation(double lat, double lon, double distance) {
return getElementsByGeoLocation("", lat, lon, distance);
}

@Override
public Set<JCas> getElementsByGeoLocation(String sType, double lat, double lon, double distance) throws UIMAException, IOException {
public Set<JCas> getElementsByGeoLocation(String sType, double lat, double lon, double distance) {
// not working

JsonObject geoWithin = JsonObject.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
import org.apache.uima.UIMAException;
import org.apache.uima.cas.CASException;
import org.apache.uima.fit.factory.JCasFactory;
import org.apache.uima.fit.factory.TypeSystemDescriptionFactory;
import org.apache.uima.fit.util.CasIOUtil;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.json.JSONArray;
Expand All @@ -46,6 +48,8 @@
import org.texttechnologylab.uimadb.wrapper.mongo.serilization.exceptions.CasSerializationException;
import org.texttechnologylab.uimadb.wrapper.mongo.serilization.exceptions.SerializerInitializationException;
import org.texttechnologylab.uimadb.wrapper.mongo.serilization.exceptions.UnknownFactoryException;
import org.texttechnologylab.utilities.helper.FileUtils;
import org.texttechnologylab.utilities.helper.StringUtils;
import org.texttechnologylab.utilities.helper.TempFileHandler;

import java.io.File;
Expand Down Expand Up @@ -123,7 +127,28 @@ public JCas getElementGridFS(String sID) throws IOException, UIMAException {
FileOutputStream streamToDownloadTo = new FileOutputStream(tf2);
getBucketConnection().downloadToStream(new ObjectId(sID), streamToDownloadTo);
streamToDownloadTo.close();
System.out.println(streamToDownloadTo.toString());

JCas rCas = JCasFactory.createJCas();
CasIOUtil.readXmi(rCas, tf2);

return rCas;

}
public JCas getElementGridFS(String sID, String sSearch, String sReplace) throws IOException, UIMAException {

File tf2 = TempFileHandler.getTempFile("aaa", "bbb");
FileOutputStream streamToDownloadTo = new FileOutputStream(tf2);
getBucketConnection().downloadToStream(new ObjectId(sID), streamToDownloadTo);
streamToDownloadTo.close();

String sFile = FileUtils.getContentFromFile(tf2);
System.out.println(tf2.getName());
sFile = sFile.replace(sSearch, sReplace);
StringUtils.writeContent(sFile, tf2);

// for (String s : TypeSystemDescriptionFactory.scanTypeDescriptors()) {
// System.out.println(s);
// }

JCas rCas = JCasFactory.createJCas();
CasIOUtil.readXmi(rCas, tf2);
Expand Down

0 comments on commit ba890a2

Please sign in to comment.