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.scenegraph.profile.request;
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.Collections;
17 import java.util.Comparator;
19 import org.simantics.db.ReadGraph;
20 import org.simantics.db.Resource;
21 import org.simantics.db.common.request.ResourceRead;
22 import org.simantics.db.exception.DatabaseException;
23 import org.simantics.scenegraph.profile.ProfileEntry;
26 * @author Antti Villberg
28 public class RuntimeProfileActiveEntries extends ResourceRead<Collection<ProfileEntry>> {
30 private static Comparator<ProfileEntry> COMPARATOR = new Comparator<ProfileEntry>() {
33 public int compare(ProfileEntry arg0, ProfileEntry arg1) {
34 return Double.compare(arg0.getPriority(), arg1.getPriority());
39 public RuntimeProfileActiveEntries(Resource resource) {
44 public Collection<ProfileEntry> perform(ReadGraph graph) throws DatabaseException {
45 ArrayList<ProfileEntry> result = new ArrayList<ProfileEntry>();
46 for (Resource entry : graph.syncRequest(new RuntimeProfileActiveEntryResources(resource))) {
47 result.add(graph.adapt(entry, ProfileEntry.class));
49 Collections.sort(result, COMPARATOR);
50 // for(ProfileEntry e : result) System.err.println("-RuntimeProfileActiveEntries: " + e + " " + e.getPriority());