ch.agent.crnickl.mongodb
Class WriteMethodsForSchema

java.lang.Object
  extended by ch.agent.crnickl.impl.DatabaseMethodsImpl
      extended by ch.agent.crnickl.mongodb.MongoDatabaseMethods
          extended by ch.agent.crnickl.mongodb.ReadMethodsForSchema
              extended by ch.agent.crnickl.mongodb.WriteMethodsForSchema
All Implemented Interfaces:
ch.agent.crnickl.impl.DatabaseMethods, ch.agent.crnickl.impl.PermissionChecker

public class WriteMethodsForSchema
extends ReadMethodsForSchema

A stateless object with methods providing write access to schemas.

A schema in MongoDB is stored as:

 
 { _id : OID,
   name : STRING, 
   base? : OID,
   attribs : [
     {
       number : NUMBER,
       erasing? : BOOLEAN
       prop? : OID,
       value? : STRING 
     }, ... 
   ]
   series : [
     {
       number : NUMBER,
       erasing? : BOOLEAN
       description? : STRING, 
       attribs : [
         ...
       ]
     }, ...
   ] 
 }
 
 
Note that attribute and series definitions are not keyed, because they do not always have a name (erasing). The position inside the array is independent of number. When erasing is present, it is true, and all other fields except number are absent. When erasing is absent, the presence of other fields denotes overriding behavior. When present, the base field identifies the base schema. The attribs and series arrays can be empty but are present.

Author:
Jean-Paul Vetterli

Nested Class Summary
 
Nested classes/interfaces inherited from class ch.agent.crnickl.mongodb.MongoDatabaseMethods
MongoDatabaseMethods.Operator
 
Constructor Summary
WriteMethodsForSchema()
           
 
Method Summary
 void createSchema(ch.agent.crnickl.api.UpdatableSchema schema)
          Create an empty schema in the database.
 void deleteSchema(ch.agent.crnickl.api.UpdatableSchema schema, ch.agent.crnickl.impl.SchemaUpdatePolicy policy)
          Delete a schema from the database.
 ch.agent.crnickl.api.Surrogate findChronicle(ch.agent.crnickl.api.Property<?> property, ch.agent.crnickl.api.Schema schema)
          Find a chronicle with an explicit attribute value for a given property and schemas.
 ch.agent.crnickl.api.Surrogate findChronicle(ch.agent.crnickl.api.Schema schema)
          Find a chronicle referencing one of the schemas.
 ch.agent.crnickl.api.Surrogate findChronicle(ch.agent.crnickl.api.SeriesDefinition ss, ch.agent.crnickl.api.Schema schema)
          Find a chronicle with a given series in a collection of schemas.
 boolean updateSchema(ch.agent.crnickl.api.UpdatableSchema schema, ch.agent.crnickl.impl.SchemaUpdatePolicy policy)
          Update the basic schema setup in the database.
 
Methods inherited from class ch.agent.crnickl.mongodb.ReadMethodsForSchema
getSchema, getSchemaSurrogateList
 
Methods inherited from class ch.agent.crnickl.mongodb.MongoDatabaseMethods
addOperation, asQuery, compositeName, extractRegexp, getId, getId, getIdOrZero, getMongoDB, getMongoDB, getMongoDB, getObject, getObjectId, makeSurrogate, mongoObject, operation
 
Methods inherited from class ch.agent.crnickl.impl.DatabaseMethodsImpl
check, check, check, check, checkIntegrity, makeSurrogate, makeSurrogate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WriteMethodsForSchema

public WriteMethodsForSchema()
Method Detail

createSchema

public void createSchema(ch.agent.crnickl.api.UpdatableSchema schema)
                  throws ch.agent.crnickl.T2DBException
Create an empty schema in the database. Throw an exception if the operation cannot be done.

Parameters:
schema - a schema
Throws:
ch.agent.crnickl.T2DBException

deleteSchema

public void deleteSchema(ch.agent.crnickl.api.UpdatableSchema schema,
                         ch.agent.crnickl.impl.SchemaUpdatePolicy policy)
                  throws ch.agent.crnickl.T2DBException
Delete a schema from the database. Throw an exception if the operation cannot be done.

Parameters:
schema - a schema
policy - a schema udpdating policy
Throws:
ch.agent.crnickl.T2DBException

updateSchema

public boolean updateSchema(ch.agent.crnickl.api.UpdatableSchema schema,
                            ch.agent.crnickl.impl.SchemaUpdatePolicy policy)
                     throws ch.agent.crnickl.T2DBException
Update the basic schema setup in the database. Throw an exception if the operation cannot be done.

Parameters:
schema - a schema
policy -
Returns:
true if the schema was updated
Throws:
ch.agent.crnickl.T2DBException

findChronicle

public ch.agent.crnickl.api.Surrogate findChronicle(ch.agent.crnickl.api.Schema schema)
                                             throws ch.agent.crnickl.T2DBException
Find a chronicle referencing one of the schemas. This looks like a "reading" method but is used in the context of schema updating.

Parameters:
schema - a schema
Returns:
a surrogate or null
Throws:
ch.agent.crnickl.T2DBException

findChronicle

public ch.agent.crnickl.api.Surrogate findChronicle(ch.agent.crnickl.api.Property<?> property,
                                                    ch.agent.crnickl.api.Schema schema)
                                             throws ch.agent.crnickl.T2DBException
Find a chronicle with an explicit attribute value for a given property and schemas. This looks like a "reading" method but is used in the context of schema updating.

Parameters:
property - a property
schema - a schema
Returns:
a surrogate or null
Throws:
ch.agent.crnickl.T2DBException

findChronicle

public ch.agent.crnickl.api.Surrogate findChronicle(ch.agent.crnickl.api.SeriesDefinition ss,
                                                    ch.agent.crnickl.api.Schema schema)
                                             throws ch.agent.crnickl.T2DBException
Find a chronicle with a given series in a collection of schemas. This looks like a "reading" method but is used in the context of schema updating.

Parameters:
ss - a series definition
schema - a schema
Returns:
a surrogate or null
Throws:
ch.agent.crnickl.T2DBException


Copyright © 2013. All Rights Reserved.