- StructuralResource2 STR = StructuralResource2.getInstance(graph);
-
- List<SCLIssuesTableEntry> results = new ArrayList<>();
-
- for (Resource ontology : indexRoots) {
- List<Resource> components = ModelingUtils.searchByTypeShallow(graph, ontology, STR.Component);
- for (Resource component : components) {
-
- for (Resource predicate : graph.getPredicates(component)) {
- if (graph.isSubrelationOf(predicate, L0.HasProperty)) {
- for (Resource object : graph.getObjects(component, predicate)) {
- if (graph.isInstanceOf(object, L0.SCLValue)) {
- Resource type = graph.getPossibleType(object, L0.SCLValue);
- Variable typeVariable = Variables.getVariable(graph, type);
-
- Function1<Variable, String> func = typeVariable.getPossiblePropertyValue(graph, "validator");
- if (func == null) {
- // No validator available
- if (LOGGER.isTraceEnabled())
- LOGGER.trace("No validator available for " + typeVariable.getURI(graph));
- continue;
- }
-
- Variable componentVariable = Variables.getVariable(graph, component);
- Variable propertyVariable = componentVariable.getProperty(graph, predicate);
-
- SCLContext sclContext = SCLContext.getCurrent();
- Object oldGraph = sclContext.get("graph");
- try {
- sclContext.put("graph", graph);
- String validatorValue = func.apply(propertyVariable);
- if (validatorValue != null && !validatorValue.isEmpty()) {
- results.add(new SCLIssuesTableEntry(propertyVariable.getURI(graph), new CompilationError(Locations.NO_LOCATION, validatorValue.replace("\n", " "))) {
- @Override
- public void openLocation() {
- openResource(Display.getCurrent().getActiveShell(), component);
- }
- });
- }
- } catch (Throwable t) {
- LOGGER.error("Failed to invoke type validator function " + func, t);
- } finally {
- sclContext.put("graph", oldGraph);
- }
- }
- }
- }
+ StructuralResource2 STR = StructuralResource2.getInstance(graph);
+
+ Set<Resource> allComponents = new HashSet<>();
+ for (Resource ontology : indexRoots) {
+ List<Resource> components = ModelingUtils.searchByTypeShallow(graph, ontology, STR.Component);
+ allComponents.addAll(components);
+ }
+ return allComponents;
+ }
+ }
+
+ private static class SCLValueRequest extends UnaryRead<Resource, Set<ResourceHolder>> {
+
+ public SCLValueRequest(Resource parameter) {
+ super(parameter);
+ }
+
+ @Override
+ public Set<ResourceHolder> perform(ReadGraph graph) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ Set<ResourceHolder> results = new HashSet<>();
+ for (Resource predicate : graph.getPredicates(parameter)) {
+ if (graph.isSubrelationOf(predicate, L0.HasProperty)) {
+ for (Resource object : graph.getObjects(parameter, predicate)) {
+ if (graph.isInstanceOf(object, L0.SCLValue)) {
+ results.add(new ResourceHolder(parameter, predicate, object));