/* ModularSpace.java * * Copyright (c) 2002, Ted Nelson and Tuomas Lukka * * This file is part of Gzz. * * Gzz is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Gzz is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General * Public License for more details. * * You should have received a copy of the GNU Lesser General * Public License along with Gzz; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * */ /* * Written by Tuomas Lukka */ package org.fenfire.impl; import org.fenfire.*; //import org.fenfire.slices.*; //import org.fenfire.errors.*; import org.nongnu.alph.Enfilade1D; import java.util.*; import com.hp.hpl.mesa.rdf.jena.model.*; import com.hp.hpl.mesa.rdf.jena.common.*; /** An implementation of space that delegates calls to a NodeManager and * a DimManager. */ public class ModularSpace extends AbstractSpace { public static final String rcsid = "$Id: ModularSpace.java,v 1.1 2003/03/27 02:26:40 mudyc Exp $"; private static void pa(String s) { System.out.println("ShortRDF"+s); } protected IdentityManager identityManager; /** Create a new ModularSpace and initialize it from a SliceVersion. * XXX where would this fit well? Is it a Slicer responsibility? * how to do it for slice.0? *

* The correct thing is to load slice versions by calling * slicer.swapIn(sliceId, version). The point is that slice.0 should * be always there, i.e. not only after swapIn() is called... * maybe the ModularSpace constructor should simply call * swapIn(getSlice0())... */ public ModularSpace(ModularNodeTexter nodeTexter, IdentityManager identityManager, ObsTrigger obsTrigger, Model model) { super(nodeTexter, obsTrigger, model); this.identityManager = identityManager; identityManager.setSpace(this); if(nodeTexter != null) nodeTexter.setSpace(this); } /* public RDFNode getHomeRDFNode() { return identityManager.getHomeNode(); } */ public RDFNode getNode(String urn) { try { Selector selector = new SelectorImpl(new ResourceImpl(urn), null, (RDFNode)null); StmtIterator iter = model.listStatements(selector); Resource res = null; if (iter.hasNext()) { Statement stmt = iter.next(); res = stmt.getSubject(); } return res; } catch (RDFException e) { pa("Exception ocurred!: "+e); throw new Error("getNode had RDFException!"); }} /* public RDFNode getIdentity(String s) { return identityManager.getIdentity(s); } public RDFNode getIdentity(RDFNode c) { return identityManager.getIdentity(c); } public Dim getCloneDim() { return getDim(org.fenfire.zzutil.Ids.d_clone); } public RDFNode N(RDFNode inSlice) { return nodeManager.N(inSlice); } public RDFNode N(RDFNode inSlice, Dim dim, int dir, Obs o) { RDFNode c = nodeManager.N(inSlice); inSlice.insert(dim, dir, c); if(o != null) inSlice.s(dim, dir, o); return c; } public void delete(RDFNode c) { nodeManager.delete(c); } */ public boolean exists(String id) { try { Selector selector = new SelectorImpl(new ResourceImpl(id), null, (RDFNode)null); StmtIterator iter = model.listStatements(selector); if (iter.hasNext()) { Statement stmt = iter.next(); if(stmt.getSubject().toString() == id) return true; } selector = new SelectorImpl(null, new PropertyImpl(id), (RDFNode)null); iter = model.listStatements(selector); if (iter.hasNext()) { Statement stmt = iter.next(); if(stmt.getPredicate().toString() == id) return true; } return false; } catch (RDFException e) { pa("Exception ocurred!: "+e); throw new Error("getNode had RDFException!"); }} public org.nongnu.storm.Mediaserver getMediaserver() { return null; } public RDFNode getMSBlockNode(String msid, RDFNode node) { return identityManager.getMSBlockNode(msid, node); } }