/******************************************************************************* * Copyright (c) 2016 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: * THTH ry - initial API and implementation *******************************************************************************/ package org.simantics.debug.browser.internal.rewriters; import java.util.ArrayList; import java.util.Collection; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.Statement; import org.simantics.db.exception.DatabaseException; import org.simantics.debug.browser.content.ResourceBrowserContent; import org.simantics.debug.browser.content.ResourceBrowserRewriter; import org.simantics.debug.browser.sections.PageHeaderSection; import org.simantics.debug.browser.sections.RawStatementsSection; public enum RawStatementsCreator implements ResourceBrowserRewriter { INSTANCE; @Override public void rewrite(ReadGraph graph, ResourceBrowserContent content) throws DatabaseException { RawStatementsSection section = new RawStatementsSection(); section.resource = content.resource; for(Resource predicate : graph.getPredicates(content.resource)) { Collection statements = graph.getStatements(content.resource, predicate); ArrayList filteredStatements = new ArrayList(statements.size()); for(Statement statement : statements) if(statement.getPredicate().equals(predicate)) filteredStatements.add(statement); section.statementsByPredicates.put(predicate, filteredStatements); } content.putSection(RawStatementsSection.class, section); // Add custom CSS to header PageHeaderSection hdr = content.getSection(PageHeaderSection.class); hdr.getHeadWriter().println(""); hdr.getHeadWriter().println(""); hdr.getHeadWriter().println(""); } @Override public double getPriority() { return 0; } }