import java.util.Map;
import java.util.Set;
+import java.util.function.BiFunction;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.simantics.databoard.Bindings;
import org.simantics.databoard.binding.Binding;
import org.simantics.databoard.type.Datatype;
import org.simantics.graph.db.TransferableGraphs;
import org.simantics.graph.representation.TransferableGraph1;
import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.BinaryFunction;
/**
* This class contains utility methods for the basic cut/copy operations
* @return the copied resource
* @throws DatabaseException
*/
- public static Resource copy(WriteGraph graph, Resource source, BinaryFunction<Boolean, ReadGraph, Statement> advisor) throws DatabaseException {
+ public static Resource copy(WriteGraph graph, Resource source, BiFunction<ReadGraph, Statement, Boolean> advisor) throws DatabaseException {
return copy(graph, source, 0, advisor, new THashMap<Object, Object>());
}
* @return
* @throws DatabaseException
*/
- public static Resource copy(WriteGraph graph, Resource source, BinaryFunction<Boolean, ReadGraph, Statement> advisor, Map<Object, Object> copyMap) throws DatabaseException {
+ public static Resource copy(WriteGraph graph, Resource source, BiFunction<ReadGraph, Statement, Boolean> advisor, Map<Object, Object> copyMap) throws DatabaseException {
return copy(graph, source, 0, advisor, copyMap);
}
- private static Resource copy(WriteGraph graph, Resource source, int level, BinaryFunction<Boolean, ReadGraph, Statement> advisor, Map<Object, Object> copyMap) throws DatabaseException {
+ private static Resource copy(WriteGraph graph, Resource source, int level, BiFunction<ReadGraph, Statement, Boolean> advisor, Map<Object, Object> copyMap) throws DatabaseException {
if (DEBUG_COPY)
System.out.println("[" + level + "] CopyAdvisorUtil.copy(" + NameUtils.getSafeName(graph, source) + ", advisor=" + advisor + ")");
}
} else {
if (advisor != null) {
- Boolean result = advisor.call(graph, stm);
+ Boolean result = advisor.apply(graph, stm);
if (Boolean.TRUE.equals(result)) {
// Don't clone the object, just add relation to the same object.
if (inverse != null)
* @throws DatabaseException
*/
public static Resource copy2(WriteGraph graph, Resource source,
- BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor) throws DatabaseException {
+ BiFunction<ReadGraph, Statement, StatementEvaluation> advisor) throws DatabaseException {
return copy2(graph, source, 0, advisor, new THashMap<Object, Object>());
}
* @throws DatabaseException
*/
public static Resource copy2(WriteGraph graph, Resource source,
- BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor, Map<Object, Object> copyMap)
+ BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap)
throws DatabaseException {
return copy2(graph, source, 0, advisor, copyMap);
}
private static Resource copy2(final WriteGraph graph, final Resource source, final int level,
- BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor, Map<Object, Object> copyMap)
+ BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap)
throws DatabaseException {
if (DEBUG_COPY)
System.out.println("[" + level + "] CopyAdvisorUtil.copy(" + NameUtils.getSafeName(graph, source) + ", advisor=" + advisor + ")");
* @throws DatabaseException
*/
public static Resource copy3(WriteGraph graph, Resource source, Resource model,
- BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor) throws DatabaseException {
+ BiFunction<ReadGraph, Statement, StatementEvaluation> advisor) throws DatabaseException {
String modelURI = graph.getURI(model);
return copy3(graph, modelURI, source, 0, advisor, new THashMap<Object, Object>());
}
* @throws DatabaseException
*/
public static Resource copy3(WriteGraph graph, Resource source, Resource model,
- BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor, Map<Object, Object> copyMap) throws DatabaseException {
+ BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap) throws DatabaseException {
String modelURI = graph.getURI(model);
return copy3(graph, modelURI, source, 0, advisor, copyMap);
}
private static Resource copy3(WriteGraph graph, String modelURI, Resource source, int level,
- BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor, Map<Object, Object> copyMap)
+ BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap)
throws DatabaseException {
if (DEBUG_COPY)
System.out.println("[" + level + "] CopyAdvisorUtil.copy(" + NameUtils.getSafeName(graph, source) + ", advisor=" + advisor + ")");
return copy;
}
- protected static StatementEvaluation evaluate(ReadGraph graph, Statement stm, BinaryFunction<StatementEvaluation, ReadGraph, Statement> tester) {
+ protected static StatementEvaluation evaluate(ReadGraph graph, Statement stm, BiFunction<ReadGraph, Statement, StatementEvaluation> tester) {
if (tester == null)
return StatementEvaluation.USE_DEFAULT;
- return tester.call(graph, stm);
+ return tester.apply(graph, stm);
}
/**
*/
public static Resource copy4(WriteGraph graph, Resource source, CopyHandler copyHandler) throws DatabaseException {
SimanticsClipboardImpl builder = new SimanticsClipboardImpl();
- copyHandler.copyToClipboard(graph, builder);
+ copyHandler.copyToClipboard(graph, builder, new NullProgressMonitor());
for(Set<Representation> object : builder.getContents()) {
TransferableGraph1 tg = ClipboardUtils.accept(graph, object, SimanticsKeys.KEY_TRANSFERABLE_GRAPH);