Skip to content

Commit

Permalink
Merge branch 'main' into release/146-Apache-UIMA-Ruta-3.4.0
Browse files Browse the repository at this point in the history
* main:
  Issue #157: Mark Maven Mojos as thread-safe
  Issue #155: UIMA Core plugins not found when installing Ruta
  Issue #152: Better error messages in query view
  Issue #151: Unable to use Ruta Query view in Ruta 3.4.0-RC-1

% Conflicts:
%	ruta-eclipse-feature/feature.xml
%	ruta-eclipse-update-site/category.xml
  • Loading branch information
reckart committed Jan 10, 2024
2 parents 069eb93 + b7eca94 commit c06f046
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 122 deletions.
4 changes: 2 additions & 2 deletions ruta-eclipse-feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<feature
id="org.apache.uima.ruta.feature"
label="UIMA Ruta Workbench"
version="3.4.1.qualifier"
version="3.4.0.qualifier"
provider-name="Apache Software Foundation">

<description url="http://uima.apache.org">
Expand Down Expand Up @@ -145,7 +145,7 @@ Apache UIMA is a trademark of the Apache Software Foundation in the United State
</license>

<url>
<discovery label="UIMA Eclipse Plugins update site" url="https://www.apache.org/dist/uima/eclipse-update-site-v3/"/>
<discovery label="UIMA Eclipse Plugins update site" url="https://downloads.apache.org/uima/eclipse-update-site-v3/"/>
</url>

<requires>
Expand Down
4 changes: 2 additions & 2 deletions ruta-eclipse-update-site/category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
***************************************************************
-->
<site>
<feature url="features/org.apache.uima.ruta.feature_3.4.1.qualifier.jar" id="org.apache.uima.ruta.feature" version="3.4.1.qualifier">
<feature url="features/org.apache.uima.ruta.feature_3.4.0.qualifier.jar" id="org.apache.uima.ruta.feature" version="3.4.0.qualifier">
<category name="apache-uima-ruta"/>
</feature>
<category-def name="apache-uima-ruta" label="Apache UIMA Ruta">
Expand All @@ -29,5 +29,5 @@
</description>
</category-def>
<repository-reference location="https://download.eclipse.org/releases/2018-12/" enabled="true" />
<repository-reference location="https://www.apache.org/dist/uima/eclipse-update-site-v3/" enabled="true" />
<repository-reference location="https://downloads.apache.org/uima/eclipse-update-site-v3/" enabled="true" />
</site>
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ private class QueryJobChangeAdapter extends JobChangeAdapter {
private QueryComposite composite;

QueryJobChangeAdapter(QueryComposite composite) {
super();
this.composite = composite;
}

@Override
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
composite.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
composite.update();
}
Expand Down Expand Up @@ -142,6 +142,7 @@ public IStatus run(IProgressMonitor monitor) {
queryView.showBusy(true);
monitor.beginTask("Initializing analysis engine...", 1);
queryComposite.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
queryComposite.setResult(null);
}
Expand All @@ -150,8 +151,22 @@ public void run() {
int files = 0;
int found = 0;

if (monitor.isCanceled())
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}

if (StringUtils.isBlank(dataLocation)) {
return Status.error("No data location specified.");
}

if (StringUtils.isBlank(typeSystemLocation)) {
return Status.error("No type system specified.");
}

File dir = new File(dataLocation);
if (!dir.exists() || !dir.isDirectory() || !dir.canRead()) {
return Status.error("Data location does not exist, is not a directory or cannot be read.");
}

final List<QueryResult> result = new ArrayList<QueryResult>();
String script = "PACKAGE query;\n\n";
Expand All @@ -160,8 +175,8 @@ public void run() {
try {
URL aedesc = RutaEngine.class.getResource("BasicEngine.xml");
XMLInputSource inae = new XMLInputSource(aedesc);
IFile iFile = QueryComposite.getIFile(typeSystemLocation);
IProject project = iFile.getProject();
IFile typeSystemFile = QueryComposite.getIFile(typeSystemLocation);
IProject project = typeSystemFile.getProject();
ClassLoader classLoader = RutaProjectUtils.getClassLoader(project);
ResourceManager resMgr = new ResourceManager_impl(classLoader);
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(inae);
Expand All @@ -174,10 +189,11 @@ public void run() {
Collection<TypeSystemDescription> tsds = new ArrayList<TypeSystemDescription>();
tsds.add(basicTypeSystem);
if (typeSystemLocation.endsWith(RutaEngine.SCRIPT_FILE_EXTENSION)) {
IPath scriptPath = iFile.getLocation();
IPath scriptPath = typeSystemFile.getLocation();
IPath descriptorRootPath = RutaProjectUtils.getDescriptorRootPath(project);
resMgr.setDataPath(descriptorRootPath.toPortableString());
IPath path = RutaProjectUtils.getTypeSystemDescriptorPath(scriptPath, project, classLoader);
IPath path = RutaProjectUtils.getTypeSystemDescriptorPath(scriptPath, project,
classLoader);
tsLocation = path.toPortableString();
}
File tsFile = new File(tsLocation);
Expand Down Expand Up @@ -261,7 +277,6 @@ public void run() {
return Status.CANCEL_STATUS;
}

File dir = new File(dataLocation);
List<File> inputFiles = getFiles(dir, recursive);
monitor.beginTask("Query in " + dir.getName() + "...", inputFiles.size());

Expand All @@ -280,21 +295,21 @@ public void run() {
}

cas.reset();
if (FilenameUtils.getExtension(each.getName()).equalsIgnoreCase("xmi") ||
FilenameUtils.getExtension(each.getName()).equalsIgnoreCase("bcas") ||
FilenameUtils.getExtension(each.getName()).equalsIgnoreCase("scas") ||
FilenameUtils.getExtension(each.getName()).equalsIgnoreCase("xcas")) {
if (FilenameUtils.getExtension(each.getName()).equalsIgnoreCase("xmi")
|| FilenameUtils.getExtension(each.getName()).equalsIgnoreCase("bcas")
|| FilenameUtils.getExtension(each.getName()).equalsIgnoreCase("scas")
|| FilenameUtils.getExtension(each.getName()).equalsIgnoreCase("xcas")) {
CasIOUtils.load(each.toURI().toURL(), cas);
} else {
cas.setDocumentText(getText(each));
}

Type matchedType = cas.getTypeSystem().getType(
"org.apache.uima.ruta.type.DebugMatchedRuleMatch");
Type ruleApplyType = cas.getTypeSystem().getType(
"org.apache.uima.ruta.type.DebugRuleApply");
Type blockApplyType = cas.getTypeSystem().getType(
"org.apache.uima.ruta.type.DebugBlockApply");
Type matchedType = cas.getTypeSystem()
.getType("org.apache.uima.ruta.type.DebugMatchedRuleMatch");
Type ruleApplyType = cas.getTypeSystem()
.getType("org.apache.uima.ruta.type.DebugRuleApply");
Type blockApplyType = cas.getTypeSystem()
.getType("org.apache.uima.ruta.type.DebugBlockApply");

removeDebugAnnotations(cas, matchedType, ruleApplyType, blockApplyType);

Expand All @@ -315,8 +330,8 @@ public void run() {
return Status.CANCEL_STATUS;
}
AnnotationFS fs = iterator.get();
int find = findRuleMatches(result, fs, each, queryComposite, matchedType,
ruleApplyType, blockApplyType, innerApplyFeature, ruleApplyFeature);
int find = findRuleMatches(result, fs, each, queryComposite, matchedType, ruleApplyType,
blockApplyType, innerApplyFeature, ruleApplyFeature);
iterator.moveToNext();
found += find;
if (!foundOne && find > 0) {
Expand All @@ -327,6 +342,7 @@ public void run() {
final int constFound = found;
final int constFiles = files;
queryComposite.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
queryComposite.setResult(result);
queryComposite.setResultInfo(constFound, constFiles);
Expand All @@ -343,6 +359,7 @@ public void run() {
} catch (Exception e) {
// report error in query view:
queryComposite.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
queryComposite.setRutaQuerySyntaxError(true);
}
Expand All @@ -361,6 +378,7 @@ public List<File> getFiles(File dir, boolean recusive) {
}
FileFilter fileFilter = new FileFilter() {

@Override
public boolean accept(File pathname) {
if (Pattern.matches(fileNameFilter, pathname.getName())) {
return true;
Expand All @@ -374,6 +392,7 @@ public boolean accept(File pathname) {
if (recusive) {
for (File subdir : dir.listFiles(new FileFilter() {

@Override
public boolean accept(File pathname) {
return pathname.isDirectory();
}
Expand Down Expand Up @@ -433,14 +452,17 @@ public int findRuleMatches(final List<QueryResult> result, AnnotationFS fs, File
}
}

@Override
public void addHandlerListener(IHandlerListener handlerListener) {

}

@Override
public void dispose() {

}

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

QueryView queryView = (QueryView) HandlerUtil.getActivePart(event);
Expand All @@ -462,14 +484,17 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
return null;
}

@Override
public boolean isEnabled() {
return true;
}

@Override
public boolean isHandled() {
return true;
}

@Override
public void removeHandlerListener(IHandlerListener handlerListener) {

}
Expand Down
Loading

0 comments on commit c06f046

Please sign in to comment.