-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.ui.tester;\r
-\r
-import java.util.Arrays;\r
-import java.util.Set;\r
-import java.util.regex.Matcher;\r
-import java.util.regex.Pattern;\r
-\r
-import org.eclipse.core.expressions.PropertyTester;\r
-import org.simantics.DatabaseJob;\r
-import org.simantics.Simantics;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.PossibleTypedParent;\r
-import org.simantics.db.common.request.Queries;\r
-import org.simantics.db.common.request.UniqueRead;\r
-import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.common.utils.RequestUtil;\r
-import org.simantics.db.exception.BindingException;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.exception.ResourceNotFoundException;\r
-import org.simantics.db.exception.ValueTypeMismatchException;\r
-import org.simantics.db.management.ISessionContext;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.scl.reflection.OntologyVersions;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.ResourceAdaptionUtils;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class BasicResourcePropertyTester extends PropertyTester {\r
-\r
- private static final boolean DEBUG = false;\r
-\r
- /**\r
- * Tests if the received resource is an instance of any of the URIs\r
- * listed in the arguments.\r
- */\r
- protected static final String RESOURCE_TYPE = "resourceType";\r
-\r
- /**\r
- * Tests if the received resource(s) are all instances of any of the URIs\r
- * listed in the arguments.\r
- */\r
- protected static final String ALL_RESOURCES_OF_TYPE = "allResourcesOfType";\r
-\r
- /**\r
- * Tests if the received resource inherits any of the URIs\r
- * listed in the arguments.\r
- */\r
- protected static final String INHERITS = "inherits";\r
-\r
- /**\r
- * Tests if all the received resource(s) inherit any of the URIs\r
- * listed in the arguments.\r
- */\r
- protected static final String ALL_INHERIT = "allInherit";\r
-\r
- /**\r
- * Tests if the received resource has a name property that matches any of\r
- * the regular expressions specified in the arguments.\r
- */\r
- protected static final String NAME_MATCHES = "nameMatches";\r
-\r
- /**\r
- * Tests if the received resource has any of the tags listed as URIs in the\r
- * arguments.\r
- */\r
- protected static final String HAS_TAG = "hasTag";\r
-\r
- /**\r
- * Tests if the received resource has any of the tags listed as URIs in the\r
- * arguments.\r
- */\r
- protected static final String HAS_PARENT = "hasParent";\r
- \r
- /**\r
- * Tests if the received resource has any of the statements with the predicate type listed as URI in the\r
- * arguments.\r
- */\r
- protected static final String HAS_STATEMENT = "hasStatement";\r
- \r
- private static final OntologyVersions VERSIONS = OntologyVersions.getInstance();\r
-\r
- @Override\r
- public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {\r
- if (DEBUG)\r
- System.out.println("TEST: " + receiver + ", " + property + ", " + Arrays.toString(args) + ", " + expectedValue);\r
-\r
- // Receiver sanity check related to tested property\r
- final Resource resource = ResourceAdaptionUtils.toSingleResource(receiver);\r
- final Resource[] resources = ResourceAdaptionUtils.toResources(receiver);\r
- if (resources.length == 0)\r
- return false;\r
-\r
- // Don't test with multi-selection and single resource test.\r
- final boolean multiResourceTest = ALL_RESOURCES_OF_TYPE.equals(property) || ALL_INHERIT.equals(property);\r
- if (!multiResourceTest && resource == null)\r
- return false;\r
-\r
- if (DatabaseJob.inProgress())\r
- return false;\r
-\r
- ISessionContext ctx = Simantics.getSessionContext();\r
- if (ctx == null)\r
- return false;\r
-\r
- try {\r
- return RequestUtil.trySyncRequest(\r
- ctx.getSession(),\r
- SimanticsUI.UI_THREAD_REQUEST_START_TIMEOUT,\r
- SimanticsUI.UI_THREAD_REQUEST_EXECUTION_TIMEOUT,\r
- false,\r
- new UniqueRead<Boolean>() {\r
- @Override\r
- public Boolean perform(ReadGraph g) throws DatabaseException {\r
- if (multiResourceTest) {\r
- return Boolean.valueOf(doTest(g, resources, property, args, expectedValue));\r
- } else {\r
- return Boolean.valueOf(doTest(g, resource, property, args, expectedValue));\r
- }\r
- }\r
- });\r
- } catch (DatabaseException | InterruptedException e) {\r
- // Purposefully not logging these exceptions, there might be way too\r
- // many even under normal circumstances.\r
- // TODO: add debug tracing options controlling the printing of these exceptions\r
- return false;\r
- }\r
- }\r
-\r
- protected boolean doTest(ReadGraph g, Resource resource, String property, Object[] args, Object expectedValue) throws DatabaseException {\r
- if (RESOURCE_TYPE.equals(property)) {\r
- if (DEBUG)\r
- System.out.println("** " + NameUtils.getSafeName(g, resource));\r
- try {\r
- for (int i = 0; i < args.length; i++) {\r
- if (g.isInstanceOf(resource, g.getResource(VERSIONS.currentVersion((String) args[i])))) {\r
- if (DEBUG)\r
- System.out.println("IS INSTANCE OF " + args[i]);\r
- return true;\r
- }\r
- }\r
- } catch (ResourceNotFoundException e) {\r
- /* This is a natural situation (database does not contain all resources\r
- referred in plugins). No error reporting.\r
- */\r
- return false;\r
- }\r
- if (DEBUG)\r
- System.out.println("NOT AN INSTANCE OF ANY OF: " + Arrays.toString(args));\r
- return false;\r
- } else if (INHERITS.equals(property)) {\r
- if (DEBUG)\r
- System.out.println("** " + NameUtils.getSafeName(g, resource));\r
- try {\r
- for (int i = 0; i < args.length; i++) {\r
- if (g.isInheritedFrom(resource, g.getResource(VERSIONS.currentVersion((String) args[i])))) {\r
- if (DEBUG)\r
- System.out.println("INHERITS " + args[i]);\r
- return true;\r
- }\r
- }\r
- } catch (ResourceNotFoundException e) {\r
- /* This is a natural situation (database does not contain all resources\r
- referred in plugins). No error reporting.\r
- */\r
- return false;\r
- }\r
- if (DEBUG)\r
- System.out.println("DOES NOT INHERIT ANY OF: " + Arrays.toString(args));\r
- return false;\r
- } else if (NAME_MATCHES.equals(property)) {\r
- if (args.length == 0)\r
- return false;\r
- Pattern[] patterns = new Pattern[args.length];\r
- for (int i = 0; i < args.length; i++) {\r
- patterns[i] = Pattern.compile((String) args[i]);\r
- }\r
- try {\r
- Layer0 L0 = Layer0.getInstance(g);\r
- for (Resource r : g.getObjects(resource, L0.HasName)) {\r
- String name = g.getPossibleValue(r, Bindings.STRING);\r
- if (name == null)\r
- continue;\r
- for (Pattern p : patterns) {\r
- Matcher m = p.matcher(name);\r
- if (m.matches())\r
- return true;\r
- }\r
- }\r
- } catch (ValueTypeMismatchException e) {\r
- e.printStackTrace();\r
- } catch (BindingException e) {\r
- e.printStackTrace();\r
- }\r
- return false;\r
- } else if (HAS_TAG.equals(property)) {\r
- try {\r
- for (int i = 0; i < args.length; i++) {\r
- Resource tag = g.syncRequest(Queries.resource((String) args[i]));\r
- if (g.hasStatement(resource, tag)) {\r
- if (DEBUG)\r
- System.out.println("HAS TAG " + args[i]);\r
- return true;\r
- }\r
- }\r
- } catch (ResourceNotFoundException e) {\r
- /* This is a natural situation (database does not contain all resources\r
- referred in plugins). No error reporting.\r
- */\r
- return false;\r
- }\r
- } else if (HAS_PARENT.equals(property)) {\r
- try {\r
- for (int i = 0; i < args.length; i++) {\r
- Resource type = g.syncRequest(Queries.resource((String) args[i]));\r
- Resource parent = g.syncRequest(new PossibleTypedParent(resource, type));\r
- if(parent != null) {\r
- if (DEBUG)\r
- System.out.println("HAS PARENT " + args[i]);\r
- return true;\r
- }\r
- }\r
- } catch (ResourceNotFoundException e) {\r
- /* This is a natural situation (database does not contain all resources\r
- referred in plugins). No error reporting.\r
- */\r
- return false;\r
- }\r
- } else if (HAS_STATEMENT.equals(property)) {\r
- try {\r
- for (int i = 0; i < args.length; i++) {\r
- Resource predicate = g.getResource(VERSIONS.currentVersion((String) args[i]));\r
- if (g.hasStatement(resource, predicate)) {\r
- if (DEBUG)\r
- System.out.println("HAS STATEMENT " + args[i]);\r
- return true;\r
- }\r
- }\r
- } catch (ResourceNotFoundException e) {\r
- /* This is a natural situation (database does not contain all resources\r
- referred in plugins). No error reporting.\r
- */\r
- return false;\r
- }\r
- }\r
- return false;\r
- }\r
-\r
- protected boolean doTest(ReadGraph g, Resource[] resources, String property, Object[] args, Object expectedValue) throws DatabaseException {\r
- if (ALL_RESOURCES_OF_TYPE.equals(property)) {\r
- Resource[] argTypes = new Resource[args.length];\r
- boolean argTypesResolved = false;\r
- for (int i = 0; i < args.length; i++) {\r
- try {\r
- argTypes[i] = g.getResource(VERSIONS.currentVersion((String) args[i]));\r
- argTypesResolved = true;\r
- } catch (ResourceNotFoundException e) {\r
- /* This is a natural situation (database does not contain all resources\r
- referred in plugins). No error reporting.\r
- */\r
- }\r
- }\r
- if (!argTypesResolved) {\r
- if (DEBUG)\r
- System.out.println("(WW) NO ARGUMENTS RESOLVED INTO RESOURCES!");\r
- return false;\r
- }\r
-\r
- for (Resource resource : resources) {\r
- if (DEBUG)\r
- System.out.println("** " + NameUtils.getSafeName(g, resource));\r
- Set<Resource> rts = g.getTypes(resource);\r
- boolean hasArgType = false;\r
- for (int t = 0; t < argTypes.length; ++t) {\r
- if (argTypes[t] == null)\r
- continue;\r
- if (rts.contains(argTypes[t])) {\r
- hasArgType = true;\r
- if (DEBUG)\r
- System.out.println("IS INSTANCE OF " + args[t]);\r
- }\r
- }\r
- if (!hasArgType) {\r
- if (DEBUG)\r
- System.out.println("IS NOT AN INSTANCE OF ANY ARGUMENT TYPE");\r
- return false;\r
- }\r
- }\r
- if (DEBUG)\r
- System.out.println("ALL RESOURCES ARE INSTANCES OF ONE OF: " + Arrays.toString(args));\r
- return true;\r
- } else if (ALL_INHERIT.equals(property)) {\r
- Resource[] argTypes = new Resource[args.length];\r
- boolean argTypesResolved = false;\r
- for (int i = 0; i < args.length; i++) {\r
- try {\r
- argTypes[i] = g.getResource(VERSIONS.currentVersion((String) args[i]));\r
- argTypesResolved = true;\r
- } catch (ResourceNotFoundException e) {\r
- /* This is a natural situation (database does not contain all resources\r
- referred in plugins). No error reporting.\r
- */\r
- }\r
- }\r
- if (!argTypesResolved) {\r
- if (DEBUG)\r
- System.out.println("(WW) NO ARGUMENTS RESOLVED INTO RESOURCES!");\r
- return false;\r
- }\r
-\r
- for (Resource resource : resources) {\r
- if (DEBUG)\r
- System.out.println("** " + NameUtils.getSafeName(g, resource));\r
- boolean inheritsArgType = false;\r
- for (int t = 0; t < argTypes.length; ++t) {\r
- if (argTypes[t] == null)\r
- continue;\r
- if (g.isInheritedFrom(resource, argTypes[t])) {\r
- inheritsArgType = true;\r
- if (DEBUG)\r
- System.out.println("INHERITS " + args[t]);\r
- }\r
- }\r
- if (!inheritsArgType) {\r
- if (DEBUG)\r
- System.out.println("DOES NOT INHERIT ANY ARGUMENT TYPE");\r
- return false;\r
- }\r
- }\r
- if (DEBUG)\r
- System.out.println("ALL RESOURCES INHERIT ONE OF: " + Arrays.toString(args));\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.ui.tester;
+
+import java.util.Arrays;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.simantics.DatabaseJob;
+import org.simantics.Simantics;
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.PossibleTypedParent;
+import org.simantics.db.common.request.Queries;
+import org.simantics.db.common.request.UniqueRead;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.common.utils.RequestUtil;
+import org.simantics.db.exception.BindingException;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.exception.ResourceNotFoundException;
+import org.simantics.db.exception.ValueTypeMismatchException;
+import org.simantics.db.management.ISessionContext;
+import org.simantics.layer0.Layer0;
+import org.simantics.scl.reflection.OntologyVersions;
+import org.simantics.ui.SimanticsUI;
+import org.simantics.ui.utils.ResourceAdaptionUtils;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class BasicResourcePropertyTester extends PropertyTester {
+
+ private static final boolean DEBUG = false;
+
+ /**
+ * Tests if the received resource is an instance of any of the URIs
+ * listed in the arguments.
+ */
+ protected static final String RESOURCE_TYPE = "resourceType";
+
+ /**
+ * Tests if the received resource(s) are all instances of any of the URIs
+ * listed in the arguments.
+ */
+ protected static final String ALL_RESOURCES_OF_TYPE = "allResourcesOfType";
+
+ /**
+ * Tests if the received resource inherits any of the URIs
+ * listed in the arguments.
+ */
+ protected static final String INHERITS = "inherits";
+
+ /**
+ * Tests if all the received resource(s) inherit any of the URIs
+ * listed in the arguments.
+ */
+ protected static final String ALL_INHERIT = "allInherit";
+
+ /**
+ * Tests if the received resource has a name property that matches any of
+ * the regular expressions specified in the arguments.
+ */
+ protected static final String NAME_MATCHES = "nameMatches";
+
+ /**
+ * Tests if the received resource has any of the tags listed as URIs in the
+ * arguments.
+ */
+ protected static final String HAS_TAG = "hasTag";
+
+ /**
+ * Tests if the received resource has any of the tags listed as URIs in the
+ * arguments.
+ */
+ protected static final String HAS_PARENT = "hasParent";
+
+ /**
+ * Tests if the received resource has any of the statements with the predicate type listed as URI in the
+ * arguments.
+ */
+ protected static final String HAS_STATEMENT = "hasStatement";
+
+ private static final OntologyVersions VERSIONS = OntologyVersions.getInstance();
+
+ @Override
+ public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
+ if (DEBUG)
+ System.out.println("TEST: " + receiver + ", " + property + ", " + Arrays.toString(args) + ", " + expectedValue);
+
+ // Receiver sanity check related to tested property
+ final Resource resource = ResourceAdaptionUtils.toSingleResource(receiver);
+ final Resource[] resources = ResourceAdaptionUtils.toResources(receiver);
+ if (resources.length == 0)
+ return false;
+
+ // Don't test with multi-selection and single resource test.
+ final boolean multiResourceTest = ALL_RESOURCES_OF_TYPE.equals(property) || ALL_INHERIT.equals(property);
+ if (!multiResourceTest && resource == null)
+ return false;
+
+ if (DatabaseJob.inProgress())
+ return false;
+
+ ISessionContext ctx = Simantics.getSessionContext();
+ if (ctx == null)
+ return false;
+
+ try {
+ return RequestUtil.trySyncRequest(
+ ctx.getSession(),
+ SimanticsUI.UI_THREAD_REQUEST_START_TIMEOUT,
+ SimanticsUI.UI_THREAD_REQUEST_EXECUTION_TIMEOUT,
+ false,
+ new UniqueRead<Boolean>() {
+ @Override
+ public Boolean perform(ReadGraph g) throws DatabaseException {
+ if (multiResourceTest) {
+ return Boolean.valueOf(doTest(g, resources, property, args, expectedValue));
+ } else {
+ return Boolean.valueOf(doTest(g, resource, property, args, expectedValue));
+ }
+ }
+ });
+ } catch (DatabaseException | InterruptedException e) {
+ // Purposefully not logging these exceptions, there might be way too
+ // many even under normal circumstances.
+ // TODO: add debug tracing options controlling the printing of these exceptions
+ return false;
+ }
+ }
+
+ protected boolean doTest(ReadGraph g, Resource resource, String property, Object[] args, Object expectedValue) throws DatabaseException {
+ if (RESOURCE_TYPE.equals(property)) {
+ if (DEBUG)
+ System.out.println("** " + NameUtils.getSafeName(g, resource));
+ try {
+ for (int i = 0; i < args.length; i++) {
+ if (g.isInstanceOf(resource, g.getResource(VERSIONS.currentVersion((String) args[i])))) {
+ if (DEBUG)
+ System.out.println("IS INSTANCE OF " + args[i]);
+ return true;
+ }
+ }
+ } catch (ResourceNotFoundException e) {
+ /* This is a natural situation (database does not contain all resources
+ referred in plugins). No error reporting.
+ */
+ return false;
+ }
+ if (DEBUG)
+ System.out.println("NOT AN INSTANCE OF ANY OF: " + Arrays.toString(args));
+ return false;
+ } else if (INHERITS.equals(property)) {
+ if (DEBUG)
+ System.out.println("** " + NameUtils.getSafeName(g, resource));
+ try {
+ for (int i = 0; i < args.length; i++) {
+ if (g.isInheritedFrom(resource, g.getResource(VERSIONS.currentVersion((String) args[i])))) {
+ if (DEBUG)
+ System.out.println("INHERITS " + args[i]);
+ return true;
+ }
+ }
+ } catch (ResourceNotFoundException e) {
+ /* This is a natural situation (database does not contain all resources
+ referred in plugins). No error reporting.
+ */
+ return false;
+ }
+ if (DEBUG)
+ System.out.println("DOES NOT INHERIT ANY OF: " + Arrays.toString(args));
+ return false;
+ } else if (NAME_MATCHES.equals(property)) {
+ if (args.length == 0)
+ return false;
+ Pattern[] patterns = new Pattern[args.length];
+ for (int i = 0; i < args.length; i++) {
+ patterns[i] = Pattern.compile((String) args[i]);
+ }
+ try {
+ Layer0 L0 = Layer0.getInstance(g);
+ for (Resource r : g.getObjects(resource, L0.HasName)) {
+ String name = g.getPossibleValue(r, Bindings.STRING);
+ if (name == null)
+ continue;
+ for (Pattern p : patterns) {
+ Matcher m = p.matcher(name);
+ if (m.matches())
+ return true;
+ }
+ }
+ } catch (ValueTypeMismatchException e) {
+ e.printStackTrace();
+ } catch (BindingException e) {
+ e.printStackTrace();
+ }
+ return false;
+ } else if (HAS_TAG.equals(property)) {
+ try {
+ for (int i = 0; i < args.length; i++) {
+ Resource tag = g.syncRequest(Queries.resource((String) args[i]));
+ if (g.hasStatement(resource, tag)) {
+ if (DEBUG)
+ System.out.println("HAS TAG " + args[i]);
+ return true;
+ }
+ }
+ } catch (ResourceNotFoundException e) {
+ /* This is a natural situation (database does not contain all resources
+ referred in plugins). No error reporting.
+ */
+ return false;
+ }
+ } else if (HAS_PARENT.equals(property)) {
+ try {
+ for (int i = 0; i < args.length; i++) {
+ Resource type = g.syncRequest(Queries.resource((String) args[i]));
+ Resource parent = g.syncRequest(new PossibleTypedParent(resource, type));
+ if(parent != null) {
+ if (DEBUG)
+ System.out.println("HAS PARENT " + args[i]);
+ return true;
+ }
+ }
+ } catch (ResourceNotFoundException e) {
+ /* This is a natural situation (database does not contain all resources
+ referred in plugins). No error reporting.
+ */
+ return false;
+ }
+ } else if (HAS_STATEMENT.equals(property)) {
+ try {
+ for (int i = 0; i < args.length; i++) {
+ Resource predicate = g.getResource(VERSIONS.currentVersion((String) args[i]));
+ if (g.hasStatement(resource, predicate)) {
+ if (DEBUG)
+ System.out.println("HAS STATEMENT " + args[i]);
+ return true;
+ }
+ }
+ } catch (ResourceNotFoundException e) {
+ /* This is a natural situation (database does not contain all resources
+ referred in plugins). No error reporting.
+ */
+ return false;
+ }
+ }
+ return false;
+ }
+
+ protected boolean doTest(ReadGraph g, Resource[] resources, String property, Object[] args, Object expectedValue) throws DatabaseException {
+ if (ALL_RESOURCES_OF_TYPE.equals(property)) {
+ Resource[] argTypes = new Resource[args.length];
+ boolean argTypesResolved = false;
+ for (int i = 0; i < args.length; i++) {
+ try {
+ argTypes[i] = g.getResource(VERSIONS.currentVersion((String) args[i]));
+ argTypesResolved = true;
+ } catch (ResourceNotFoundException e) {
+ /* This is a natural situation (database does not contain all resources
+ referred in plugins). No error reporting.
+ */
+ }
+ }
+ if (!argTypesResolved) {
+ if (DEBUG)
+ System.out.println("(WW) NO ARGUMENTS RESOLVED INTO RESOURCES!");
+ return false;
+ }
+
+ for (Resource resource : resources) {
+ if (DEBUG)
+ System.out.println("** " + NameUtils.getSafeName(g, resource));
+ Set<Resource> rts = g.getTypes(resource);
+ boolean hasArgType = false;
+ for (int t = 0; t < argTypes.length; ++t) {
+ if (argTypes[t] == null)
+ continue;
+ if (rts.contains(argTypes[t])) {
+ hasArgType = true;
+ if (DEBUG)
+ System.out.println("IS INSTANCE OF " + args[t]);
+ }
+ }
+ if (!hasArgType) {
+ if (DEBUG)
+ System.out.println("IS NOT AN INSTANCE OF ANY ARGUMENT TYPE");
+ return false;
+ }
+ }
+ if (DEBUG)
+ System.out.println("ALL RESOURCES ARE INSTANCES OF ONE OF: " + Arrays.toString(args));
+ return true;
+ } else if (ALL_INHERIT.equals(property)) {
+ Resource[] argTypes = new Resource[args.length];
+ boolean argTypesResolved = false;
+ for (int i = 0; i < args.length; i++) {
+ try {
+ argTypes[i] = g.getResource(VERSIONS.currentVersion((String) args[i]));
+ argTypesResolved = true;
+ } catch (ResourceNotFoundException e) {
+ /* This is a natural situation (database does not contain all resources
+ referred in plugins). No error reporting.
+ */
+ }
+ }
+ if (!argTypesResolved) {
+ if (DEBUG)
+ System.out.println("(WW) NO ARGUMENTS RESOLVED INTO RESOURCES!");
+ return false;
+ }
+
+ for (Resource resource : resources) {
+ if (DEBUG)
+ System.out.println("** " + NameUtils.getSafeName(g, resource));
+ boolean inheritsArgType = false;
+ for (int t = 0; t < argTypes.length; ++t) {
+ if (argTypes[t] == null)
+ continue;
+ if (g.isInheritedFrom(resource, argTypes[t])) {
+ inheritsArgType = true;
+ if (DEBUG)
+ System.out.println("INHERITS " + args[t]);
+ }
+ }
+ if (!inheritsArgType) {
+ if (DEBUG)
+ System.out.println("DOES NOT INHERIT ANY ARGUMENT TYPE");
+ return false;
+ }
+ }
+ if (DEBUG)
+ System.out.println("ALL RESOURCES INHERIT ONE OF: " + Arrays.toString(args));
+ return true;
+ }
+ return false;
+ }
+
+}