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