com.bowstreet.factory.model
Class SourceModelManager

java.lang.Object
  extended by com.bowstreet.factory.model.SourceModelManager
All Implemented Interfaces:
com.bowstreet.servlet.ObjectLifeCycleHandler.ShutdownAwareObject

public abstract class SourceModelManager
extends java.lang.Object
implements com.bowstreet.servlet.ObjectLifeCycleHandler.ShutdownAwareObject

Config settings bowstreet.settings.sourcemodelmanager.implenetationclass a java class name which extends com.bowstrret.factory.model.SourceModelManager defaults to com.bowstreet.factory.model.implementation.FileModelManager bowstreet.settings.sourcemodelmanager.modelprocessors a comma-delimited list of java class names which implement com.bowstrret.factory.model.ModelProcessor defaults to


Method Summary
static java.lang.String cleanUpModelID(java.lang.String modelID)
           
abstract  SourceModel createEmptyModel()
           
 java.lang.String createRelativeModelID(SourceModel src, java.lang.String absoluteID)
          Change an absolute ModelID into a relative one.
static java.lang.String createRelativeModelID(java.lang.String srcID, java.lang.String absoluteID)
           
 boolean delete(java.lang.String modelID)
           
 void deleteFromStore(java.lang.String modelID)
           
abstract  java.util.SortedSet getAllModelIDs()
           
 java.util.Collection getDerivableStartingTemplates()
          Will return a list of Strings, where the Strings are the ModelID's of Template Models (i.e. the ones to use as sources of new Models).
static ExternalModelProperties getExternalModelProperties()
           
static SourceModelManager getManager()
           
 SourceModel load(java.lang.String modelID, java.lang.String referenceModel)
          Load a SourceModel
 boolean modelExists(java.lang.String modelID)
           
 void processModel(java.lang.String modelID)
           
static java.lang.String resolveRelativeModelID(java.lang.String srcID, java.lang.String relativeID)
          Change a relative ModelID into an absolute one.
 void save(SourceModel src)
           
 SourceModel saveAs(SourceModel src, java.lang.String modelID)
           
 void shutdown()
          Shutdown a shutdown-aware object.
abstract  java.lang.String translateFilenameToModelID(java.lang.String filename, boolean shouldExist)
          Will return the ModelID that is equivalent to this filename.
abstract  java.lang.String translateModelIDToFilename(java.lang.String modelID, boolean shouldExist)
          Will return the filename that is equivalent to this modelID.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cleanUpModelID

public static java.lang.String cleanUpModelID(java.lang.String modelID)

createEmptyModel

public abstract SourceModel createEmptyModel()

createRelativeModelID

public java.lang.String createRelativeModelID(SourceModel src,
                                              java.lang.String absoluteID)
Change an absolute ModelID into a relative one.

Parameters:
src - The SourceModel from which the ID should be evaluated
absoluteID - The absolute ModelID to convert
Returns:
a relative ModelID.

createRelativeModelID

public static java.lang.String createRelativeModelID(java.lang.String srcID,
                                                     java.lang.String absoluteID)
Parameters:
srcID -
absoluteID -
Returns:

delete

public boolean delete(java.lang.String modelID)
               throws java.lang.SecurityException,
                      java.io.IOException
Throws:
java.lang.SecurityException
java.io.IOException

deleteFromStore

public void deleteFromStore(java.lang.String modelID)
                     throws java.lang.SecurityException,
                            java.io.IOException
Throws:
java.lang.SecurityException
java.io.IOException

getAllModelIDs

public abstract java.util.SortedSet getAllModelIDs()

getDerivableStartingTemplates

public java.util.Collection getDerivableStartingTemplates()
Will return a list of Strings, where the Strings are the ModelID's of Template Models (i.e. the ones to use as sources of new Models). This can be overridden by the child class, if it makes sense.

Returns:
A List of String objects identifying models from which new models may be derived. These are modelID's, not Filenames!

getExternalModelProperties

public static ExternalModelProperties getExternalModelProperties()

getManager

public static SourceModelManager getManager()

load

public SourceModel load(java.lang.String modelID,
                        java.lang.String referenceModel)
Load a SourceModel

Parameters:
modelID - The relative reference to resolve and load.
referenceModel - is used as a starting point from which the relativeModelID should be evaluated. Can be null if the model reference isn't relative.

modelExists

public boolean modelExists(java.lang.String modelID)

processModel

public void processModel(java.lang.String modelID)

resolveRelativeModelID

public static java.lang.String resolveRelativeModelID(java.lang.String srcID,
                                                      java.lang.String relativeID)
Change a relative ModelID into an absolute one.

Parameters:
srcID - The Model from which the ID should be evaluated
relativeID - The relative ModelID to convert
Returns:
an absolute ModelID, suitable for passing to the load method, for example.

save

public void save(SourceModel src)
          throws java.io.IOException
Throws:
java.io.IOException

saveAs

public SourceModel saveAs(SourceModel src,
                          java.lang.String modelID)
                   throws java.io.IOException
Throws:
java.io.IOException

shutdown

public void shutdown()
Shutdown a shutdown-aware object. If the shutdown cannot be completed for some reason, then an exception can be thrown.

Specified by:
shutdown in interface com.bowstreet.servlet.ObjectLifeCycleHandler.ShutdownAwareObject
Throws:
java.lang.Exception - when shutdown cannot be completed.

translateFilenameToModelID

public abstract java.lang.String translateFilenameToModelID(java.lang.String filename,
                                                            boolean shouldExist)
Will return the ModelID that is equivalent to this filename.

Parameters:
filename - The filename to translate
shouldExist - If true, will confirm that file exists
Returns:
equivalent ModelID -- null if can't be converted or if shouldExist is true and it doesn't exist

translateModelIDToFilename

public abstract java.lang.String translateModelIDToFilename(java.lang.String modelID,
                                                            boolean shouldExist)
Will return the filename that is equivalent to this modelID.

Parameters:
modelID - The modelID to translate
shouldExist - If true, will confirm that model exists
Returns:
equivalent filename -- null if can't be converted or if shouldExist is true and it doesn't exist


Copyright © 2009 IBM. All Rights Reserved.