1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.db.layer0.request;
\r
14 import gnu.trove.map.hash.THashMap;
\r
16 import java.util.Collection;
\r
17 import java.util.Map;
\r
19 import org.simantics.db.ReadGraph;
\r
20 import org.simantics.db.Resource;
\r
21 import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
\r
22 import org.simantics.db.common.request.ResourceRead;
\r
23 import org.simantics.db.exception.DatabaseException;
\r
25 public class UnescapedPropertyMapOfResource extends ResourceRead<Map<String, PropertyInfo>> {
\r
27 public UnescapedPropertyMapOfResource(Resource resource) {
\r
32 public Map<String,PropertyInfo> perform(ReadGraph graph) throws DatabaseException {
\r
34 Collection<Resource> predicates = graph.getPredicates(resource);
\r
35 THashMap<String, PropertyInfo> result = new THashMap<String, PropertyInfo>(predicates.size());
\r
36 for(Resource predicate : predicates) {
\r
37 PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(predicate), TransientCacheAsyncListener.<PropertyInfo>instance());
\r
38 if(info != null && info.isHasProperty) {
\r
39 String name = info.name;
\r
40 if (result.put(name, info) != null)
\r
41 System.err.println(this + ": The database resource $" + resource.getResourceId() + " contains siblings with the same name " + name + " (resource=$" + info.predicate.getResourceId() +").");
\r