X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.common%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fcommon%2Frequest%2FResourceSetURIs.java;fp=bundles%2Forg.simantics.db.common%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fcommon%2Frequest%2FResourceSetURIs.java;h=0cc29e11653cc47b3ebf16f74851e39bf2808267;hb=55d1e6f63df516019032ebf0c1e9c8c0495a619d;hp=0000000000000000000000000000000000000000;hpb=ceff53434e48f94c5d84ce12f3b1e21cabda457b;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/ResourceSetURIs.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/ResourceSetURIs.java new file mode 100644 index 000000000..0cc29e116 --- /dev/null +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/ResourceSetURIs.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2019 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: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.db.common.request; + +import java.util.Collections; +import java.util.Set; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; + +import gnu.trove.set.hash.THashSet; + +/** + * @author Tuukka Lehtonen + * @since 1.41.0, 1.35.2 + */ +public class ResourceSetURIs extends UnaryRead, Set> { + + public ResourceSetURIs(Set set) { + super(set); + } + + @Override + public Set perform(ReadGraph graph) throws DatabaseException { + if (parameter == null || parameter.isEmpty()) + return Collections.emptySet(); + + Set result = new THashSet(parameter.size()); + for (Resource r : parameter) { + String uri = graph.getPossibleURI(r); + if (uri != null) + result.add(uri); + } + + return result; + } + +} \ No newline at end of file