import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
import javax.inject.Named;
import org.simantics.db.layer0.SelectionHints;
import org.simantics.db.procedure.Procedure;
import org.simantics.db.request.Read;
+import org.simantics.district.network.DistrictNetworkUtil;
import org.simantics.district.network.ontology.DistrictNetworkResource;
import org.simantics.district.network.ui.function.Functions;
import org.simantics.district.network.ui.internal.Activator;
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
for (Map.Entry<Resource, Collection<NamedResource>> entry : results.entrySet()) {
- Resource newMapping = entry.getKey();
- Collection<NamedResource> elements = entry.getValue();
- for (NamedResource element : elements) {
- graph.deny(element.getResource(), DN.HasMapping);
- graph.claim(element.getResource(), DN.HasMapping, newMapping);
- }
+ List<Resource> elements = entry.getValue().stream()
+ .map(NamedResource::getResource)
+ .collect(Collectors.toList());
+ DistrictNetworkUtil.changeMappingType(graph, entry.getKey(), elements);
}
}
});
importJava "org.simantics.district.network.DistrictNetworkUtil" where
createNetworkDiagram :: Resource -> Resource -> String -> Resource -> Resource -> Resource -> Resource -> Resource -> <WriteGraph, Proc> Resource
+ changeMappingType :: Resource -> [Resource] -> <WriteGraph, Proc> ()
import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
import org.simantics.databoard.Bindings;
import org.simantics.datatypes.literal.RGB;
this.isConsumer = isConsumer;
}
}
+
+ public static void changeMappingType(WriteGraph graph, Resource newMapping, List<Resource> elements) throws DatabaseException {
+ DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+ for (Resource element : elements) {
+ graph.deny(element, DN.HasMapping);
+ graph.claim(element, DN.HasMapping, newMapping);
+ }
+ }
}