blob: ee160c4b7653709aa19da1b76bd5bcb34471a739 [file] [log] [blame]
--- //depot/modules/cordoba/storage/modelstore/src/main/java/com/webify/framework/model/IThing.java 2005/11/14 14:35:48
+++ //depot/modules/cordoba/storage/modelstore/src/main/java/com/webify/framework/model/IThing.java 2005/11/22 07:28:55
@@ -1,10 +1,7 @@
package com.webify.framework.model;
-import com.webify.framework.model.metadata.ClassInfo;
import com.webify.framework.model.metadata.InterfaceInfo;
-
-import java.net.URI;
-import java.util.Set;
+import com.webify.wsf.modelstore.IPersisted;
/**
* Base interface for all model types in WSF. Corresponds to owl:Thing.
@@ -15,52 +12,14 @@
* @version $Id$
* @since 2.0.0
*/
-public interface IThing {
+public interface IThing extends IPersisted {
/**
* @deprecated Should not rely on, or hardcode 3.4 base namespace in code.
*/
String NS_BASE_CATALOG = "http://www.webifysolutions.com/2005/06/base-catalog#";
-
- /**
- * @param name the property <em>URI</em> in string form.
- * @deprecated use {@link #getProperty(URI)} instead.
- */
- Object getProperty(String name);
-
- Object getProperty(URI name);
-
- /**
- * @param name the property <em>URI</em> in string form.
- * @deprecated use {@link #setProperty(URI, Object)} instead.
- */
- void setProperty(String name, Object value);
-
- void setProperty(URI name, Object value);
-
- /**
- * @param name the property <em>URI</em> in string form.
- * @deprecated use {@link #removeProperty(URI, Object)} instead.
- */
- void removeProperty(String name, Object value);
-
- void removeProperty(URI name, Object value);
-
- /**
- * @param name the property <em>URI</em> in string form.
- * @return true if <code>value</code> is associated with the specified property
- * @deprecated use {@link #hasProperty(URI, Object)} instead.
- */
- boolean hasProperty(String name, Object value);
- boolean hasProperty(URI name, Object value);
-
/**
- * @return a (non-null, possibly empty) set of URIs corresponding to property names.
- */
- Set propertyNameSet();
-
- /**
* @OntProperty (uri="http://www.w3.org/2000/01/rdf-schema#comment")
*/
String getComment();
@@ -91,27 +50,6 @@
void setVersionInfo(String versionInfo);
/**
- * @return the <em>local</em> name within {@link #getURI()}'s namespace.
- */
- String getId();
-
- /**
- * @return the full URI for this thing, which is unique within a model.
- */
- URI getURI();
-
- /**
- * @return the declared type of the instance
- */
- URI getDeclaredType();
-
- /**
- * @return a <em>locked</em> {@link ClassInfo} instance
- * representing this thing's interface/declared type.
- */
- ClassInfo getClassInfo();
-
- /**
* @return a <em>locked</em> {@link InterfaceInfo} instance
* representing this thing's interface/declared type.
*/
--- //depot/modules/cordoba/storage/modelstore/src/main/java/com/webify/framework/model/ModelFactory.java 2005/11/21 08:58:32
+++ //depot/modules/cordoba/storage/modelstore/src/main/java/com/webify/framework/model/ModelFactory.java 2005/11/21 10:29:33
@@ -3,8 +3,8 @@
import com.webify.framework.model.changes.ModelChanges;
import com.webify.framework.model.metadata.MetadataRegistry;
import com.webify.framework.support.trackingmap.MultiValueMap;
+import com.webify.framework.triples.TripleStore;
import com.webify.framework.triples.VersionInfo;
-import com.webify.framework.triples.TripleStore;
import java.net.URI;
import java.util.List;
@@ -114,12 +114,6 @@
MultiValueMap getAllProperties(final long version, final URI subject);
- /**
- * Attaches disconnected instances and {@link java.util.Collection}s
- * of {@link IThing}s. Other types of objects are ignored.
- */
- void attachDisconnected(Object disconnected);
-
long getCurrentVersion();
VersionInfo getCurrentVersionInfo();
--- //depot/modules/cordoba/storage/modelstore/src/main/java/com/webify/framework/model/dbstore/HibernateModelFactory.java 2005/11/21 08:58:32
+++ //depot/modules/cordoba/storage/modelstore/src/main/java/com/webify/framework/model/dbstore/HibernateModelFactory.java 2005/11/22 07:34:00
@@ -6,7 +6,6 @@
import com.webify.framework.model.ModelQuery;
import com.webify.framework.model.NotFoundException;
import com.webify.framework.model.proxy.ProxyHandlerContext;
-import com.webify.framework.support.collections.IdentitySet;
import com.webify.framework.support.trackingmap.TrackingMap;
import com.webify.framework.triples.changes.TripleChanges;
import com.webify.wsf.modelstore.impl.ModelAccessImpl;
@@ -168,56 +167,6 @@
return version;
}
- /**
- * @return non-null possibly empty collection
- */
- private Collection getOtherThingsInCloud(final IThing thing) {
- final HibernateInvocationHandler handler = HibernateInvocationHandler.handlerForThing(thing);
- final Collection others = handler.getThingsInCloud();
- others.remove(thing);
- return others;
- }
-
- /**
- * @param disconnected
- * can be an {@link IThing}, a {@link Collection}or regular
- * {@link Object}
- */
- public void attachDisconnected(Object disconnected) {
- HashSet things = new HashSet();
- findAllThingsInClouds(disconnected, new IdentitySet(), things);
- if (GENERAL_LOG.isDebugEnabled()) {
- GENERAL_LOG.debug("Reattaching: " + things);
- }
- for (Iterator i = things.iterator(); i.hasNext();) {
- final IThing thing = (IThing) i.next();
- HibernateInvocationHandler handler = HibernateInvocationHandler.handlerForThing(thing);
- handler.reattach(this);
- }
- }
-
- private void findAllThingsInClouds(final Object disconnected,
- final Set visited,
- final Set target) {
- if (!visited.add(disconnected)) {
- // already seen this object
- return;
- }
-
- if (disconnected instanceof Collection) {
- final Collection collection = (Collection) disconnected;
- for (Iterator i = collection.iterator(); i.hasNext();) {
- findAllThingsInClouds(i.next(), visited, target);
- }
- }
- else if (disconnected instanceof IThing) {
- final IThing thing = (IThing) disconnected;
- // no need to recurse into each because they all have the same cloud
- target.add(thing);
- target.addAll(getOtherThingsInCloud(thing));
- }
- }
-
long getWorkingVersion() {
// TODO implement getWorkingVersion properly.
return ModelFactory.CURRENT_VERSION;
@@ -250,7 +199,7 @@
final HibernateProxyBuilder builder = new HibernateProxyBuilder();
builder.setContext(this);
if (typeUri == null) {
- final TypeComputation tc = new TypeComputation(this, iface, properties);
+ final TypeComputation tc = new TypeComputation(this.getMetadataRegistry(), iface, properties);
builder.setInterface(tc.deriveInterface());
builder.setTypeUri(tc.deriveType());
}
--- //depot/modules/cordoba/storage/modelstore/src/main/java/com/webify/framework/model/dbstore/TypeComputation.java 2005/11/21 08:58:32
+++ //depot/modules/cordoba/storage/modelstore/src/main/java/com/webify/framework/model/dbstore/TypeComputation.java 2005/11/22 07:34:00
@@ -4,7 +4,7 @@
import com.webify.framework.model.IThing;
import com.webify.framework.model.PredicateConstants;
import com.webify.framework.model.metadata.ClassInfo;
-import com.webify.framework.model.proxy.ProxyHandlerContext;
+import com.webify.framework.model.metadata.MetadataRegistry;
import com.webify.framework.support.trackingmap.TrackingMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -21,7 +21,7 @@
* @author dranatunga
* @version $Id$
*/
-class TypeComputation {
+public class TypeComputation {
private static final int NONE = 0;
@@ -44,28 +44,28 @@
private int _ifaceState = NONE;
private int _typeState = NONE;
- private final ProxyHandlerContext _context;
+ private final MetadataRegistry _registry;
private final Class _ifaceIn;
private Class _bestIface;
private URI _bestType;
private final TrackingMap _knowledge;
- TypeComputation(ProxyHandlerContext context, Class ifaceIn, TrackingMap knowledge) {
+ public TypeComputation(MetadataRegistry registry, Class ifaceIn, TrackingMap knowledge) {
// TODO an instance can have more than one type, we need to account for this in our API
- _context = context;
+ _registry = registry;
_ifaceIn = ifaceIn;
_knowledge = knowledge;
_bestIface = ifaceIn;
}
- Class deriveInterface() {
+ public Class deriveInterface() {
determineUsingInstanceAssociation();
// TODO determineUsingClassAssocation
determineUsingTypeNameGuessing();
return _bestIface;
}
- URI deriveType() {
+ public URI deriveType() {
determineUsingInstanceType();
determineUsingMetadataInfo();
return _bestType;
@@ -141,7 +141,7 @@
ClassInfo mostSpecificType = null;
for (Iterator i = _knowledge.getAll(PredicateConstants.TYPE_OF).iterator(); i.hasNext();) {
URI oneDeclaredType = (URI) i.next();
- ClassInfo oneDeclaredInfo = _context.getMetadataRegistry().getClassInfo(oneDeclaredType);
+ ClassInfo oneDeclaredInfo = _registry.getClassInfo(oneDeclaredType);
if ((mostSpecificType == null) || oneDeclaredInfo.getSuperClasses().contains(mostSpecificType)) {
mostSpecificType = oneDeclaredInfo;
}
@@ -163,7 +163,7 @@
if (_typeState >= FOUND_FROM_ANNOTATION) {
return;
}
- final ClassInfo classInfo = _context.getMetadataRegistry().getInterfaceInfo(_ifaceIn).getTypeInfo();
+ final ClassInfo classInfo = _registry.getInterfaceInfo(_ifaceIn).getTypeInfo();
if ((classInfo == null) || (classInfo.getTypeUri() == null)) {
return;
}
--- //depot/modules/cordoba/storage/modelstore/src/test/java/com/webify/framework/model/kowari/KowariModelFactoryTest.java 2005/11/14 14:53:49
+++ //depot/modules/cordoba/storage/modelstore/src/test/java/com/webify/framework/model/kowari/KowariModelFactoryTest.java 2005/11/21 10:29:33
@@ -1,23 +1,22 @@
package com.webify.framework.model.kowari;
+import java.net.URI;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import java.net.URI;
import com.webify.framework.model.IThing;
import com.webify.framework.model.ModelFactory;
import com.webify.framework.model.ModelQuery;
import com.webify.framework.model.metadata.InterfaceInfo;
import com.webify.framework.model.metadata.PropertyInfo;
+import com.webify.framework.support.uri.URIs;
import com.webify.framework.support.uuid.UUID;
-import com.webify.framework.support.uri.URIs;
+import com.webify.framework.test.ConfiguredCoreTest;
+import com.webify.framework.test.ModelExistsCondition;
import com.webify.framework.test.PreTestCondition;
-import com.webify.framework.test.ModelExistsCondition;
-import com.webify.framework.test.ConfiguredCoreTest;
-
import junit.framework.TestSuite;
/**
@@ -52,7 +51,6 @@
ts.addTest(new KowariModelFactoryTest("testModifyKnownSubject"));
ts.addTest(new KowariModelFactoryTest("testListExisting"));
ts.addTest(new KowariModelFactoryTest("testListLiterals"));
- ts.addTest(new KowariModelFactoryTest("testSerializeThing"));
ts.addTest(new KowariModelFactoryTest("testMetadataAccessFromThing"));
return ts;
}
@@ -112,15 +110,6 @@
}
- public void testSerializeThing() {
- final IThing original = getModelFactory().load(IThing.class, EXISTING_THING);
- final byte[] serialized = serialize(original);
- final Object reloaded = deserialize(serialized);
- assertEquals(original, reloaded);
- // TODO lookup something off reloaded that would require it to be connected.
- getModelFactory().attachDisconnected(reloaded);
- }
-
public void testMetadataAccessFromThing() {
final IThing created = getModelFactory().create(SampleCar.class, new UUID().toString());
final InterfaceInfo info = created.getInterfaceInfo();