com.sas.services.information.metadata
Class MetadataBuilder<T extends MetadataInterface,J extends com.sas.metadata.remote.PrimaryType,B extends MetadataBuilder<T,J,B>>

com.sas.services.information.metadata.MetadataBuilder<T,J,B>
Type Parameters:
T - Information service object class created by this builder
J - Metadata object class used to represent this object
B - Concrete builder class

public abstract class MetadataBuilder<T extends MetadataInterface,J extends com.sas.metadata.remote.PrimaryType,B extends MetadataBuilder<T,J,B>>

Abstract base class for a metadata object builder. The object builder pattern supports defining metadata objects using a simple sequence of methods specifying attributes. See LASRServerUtil for an example of a concrete builder class.


Field Summary
protected  J built
           
protected  T builtSmartObject
           
protected  java.lang.String desc
           
protected  OMIServer metadataServer
           
protected  java.lang.String name
           
protected  java.util.Map<java.lang.String,java.lang.String> options
           
protected static java.lang.String OTHER_OPTIONS_PROPERTY
           
protected  com.sas.metadata.remote.Prototype prototype
           
protected  java.lang.String prototypeName
           
protected  java.util.Map<java.lang.String,com.sas.metadata.remote.Property> prototypeProperties
           
protected  RepositoryInterface repository
           
protected  java.lang.String repositoryName
           
protected  UserContextInterface user
           
 
Constructor Summary
protected MetadataBuilder(java.lang.Class<J> metadataType, java.lang.String publicType, double usageVersion)
           
 
Method Summary
protected  T buildInternal(UserContextInterface user)
          Build the object.
protected  void buildSetup(UserContextInterface user)
           
protected
<M extends com.sas.metadata.remote.Root>
M
createMetadata(java.lang.String name, java.lang.Class<M> type)
           
protected  void createObject()
           
protected  com.sas.metadata.remote.Property createProperty(java.lang.String name, java.lang.String propertyName, java.lang.String delimiter, java.lang.String value)
           
protected  com.sas.metadata.remote.Property createPropertyFromPrototype(com.sas.metadata.remote.Property prototype, java.lang.String value)
           
 B desc(java.lang.String desc)
          Defines descriptive text.
 B extendedAttribute(java.lang.String name, java.lang.String value, java.lang.String description)
          Defines an extended attribute.
protected
<M extends com.sas.metadata.remote.Root>
M
findMetadata(java.lang.String search, java.lang.Class<M> type)
           
protected
<M extends com.sas.metadata.remote.Root>
M
findMetadataByName(java.lang.String name, java.lang.Class<M> type)
           
 B keyword(java.lang.String keyword)
          Defines a keyword.
protected  void loadPrototypeProperties()
           
 B name(java.lang.String name)
          Defines object name.
 B option(java.lang.String optionName)
          Defines a valueless option on the object.
 B option(java.lang.String optionName, java.lang.String optionValue)
          Defines an option on the object.
 void validate(UserContextInterface user)
          Validates the builder state without building the object.
 

Field Detail

prototypeName

protected java.lang.String prototypeName

prototype

protected com.sas.metadata.remote.Prototype prototype

prototypeProperties

protected java.util.Map<java.lang.String,com.sas.metadata.remote.Property> prototypeProperties

user

protected UserContextInterface user

metadataServer

protected OMIServer metadataServer

repository

protected RepositoryInterface repository

repositoryName

protected java.lang.String repositoryName

name

protected java.lang.String name

desc

protected java.lang.String desc

options

protected java.util.Map<java.lang.String,java.lang.String> options

OTHER_OPTIONS_PROPERTY

protected static final java.lang.String OTHER_OPTIONS_PROPERTY
See Also:
Constant Field Values

built

protected J extends com.sas.metadata.remote.PrimaryType built

builtSmartObject

protected T extends MetadataInterface builtSmartObject
Constructor Detail

MetadataBuilder

protected MetadataBuilder(java.lang.Class<J> metadataType,
                          java.lang.String publicType,
                          double usageVersion)
Method Detail

name

public B name(java.lang.String name)
Defines object name.

Parameters:
name - object name
Returns:
builder
Throws:
java.lang.IllegalArgumentException - for invalid names
java.lang.NullPointerException

desc

public B desc(java.lang.String desc)
Defines descriptive text.

Parameters:
desc - description
Returns:
builder
Throws:
java.lang.NullPointerException - if desc is null

keyword

public B keyword(java.lang.String keyword)
Defines a keyword. May be called multiple times to define multiple keywords.

Parameters:
keyword - keyword
Returns:
builder

option

public B option(java.lang.String optionName)
Defines a valueless option on the object. May be called multiple times to define multiple options

Parameters:
optionName - option name
Returns:
builder

option

public B option(java.lang.String optionName,
                java.lang.String optionValue)
Defines an option on the object. May be called multiple times to define multiple options

Parameters:
optionName - option name
optionValue - option value
Returns:
builder

extendedAttribute

public B extendedAttribute(java.lang.String name,
                           java.lang.String value,
                           java.lang.String description)
Defines an extended attribute. May be called multiple times to define multiple attributes.

Parameters:
name - attribute name
value - attribute value
description - optional attribute description
Returns:
builder
Throws:
java.lang.NullPointerException - if name or value is null

validate

public void validate(UserContextInterface user)
              throws java.lang.IllegalArgumentException,
                     java.lang.IllegalStateException,
                     ItemAlreadyExistsException,
                     ServiceException
Validates the builder state without building the object. Throws an exception if the builder is not ready to create a valid object. This method is called by #build(UserContextInterface) before attempting to create the object. This method is typically overridden by any concrete builder class.

Parameters:
user - user context
Throws:
java.lang.IllegalArgumentException - illegal value was specified to the builder
java.lang.IllegalStateException - the builder has conflicting or missing definitions
ItemAlreadyExistsException - an object with the same name or path already exists
ServiceException

buildInternal

protected T buildInternal(UserContextInterface user)
                                             throws java.lang.IllegalArgumentException,
                                                    java.lang.IllegalStateException,
                                                    ItemAlreadyExistsException,
                                                    ServiceException
Build the object.

Parameters:
user - user context
Returns:
the new object
Throws:
java.lang.IllegalArgumentException - illegal value was specified to the builder
java.lang.IllegalStateException - the builder has conflicting or missing definitions
ItemAlreadyExistsException - an object with the same name or path already exists
ServiceException

buildSetup

protected final void buildSetup(UserContextInterface user)
                         throws ServiceException
Throws:
ServiceException

createObject

protected void createObject()
                     throws java.rmi.RemoteException,
                            com.sas.metadata.remote.MdException,
                            ServiceException
Throws:
java.rmi.RemoteException
com.sas.metadata.remote.MdException
ServiceException

loadPrototypeProperties

protected void loadPrototypeProperties()
                                throws java.rmi.RemoteException,
                                       com.sas.metadata.remote.MdException
Throws:
java.rmi.RemoteException
com.sas.metadata.remote.MdException

createMetadata

protected final <M extends com.sas.metadata.remote.Root> M createMetadata(java.lang.String name,
                                                                          java.lang.Class<M> type)
                                                               throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

createProperty

protected final com.sas.metadata.remote.Property createProperty(java.lang.String name,
                                                                java.lang.String propertyName,
                                                                java.lang.String delimiter,
                                                                java.lang.String value)
                                                         throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

createPropertyFromPrototype

protected final com.sas.metadata.remote.Property createPropertyFromPrototype(com.sas.metadata.remote.Property prototype,
                                                                             java.lang.String value)
                                                                      throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

findMetadataByName

protected final <M extends com.sas.metadata.remote.Root> M findMetadataByName(java.lang.String name,
                                                                              java.lang.Class<M> type)
                                                                   throws java.rmi.RemoteException,
                                                                          com.sas.metadata.remote.MdException
Throws:
java.rmi.RemoteException
com.sas.metadata.remote.MdException

findMetadata

protected final <M extends com.sas.metadata.remote.Root> M findMetadata(java.lang.String search,
                                                                        java.lang.Class<M> type)
                                                             throws java.rmi.RemoteException,
                                                                    com.sas.metadata.remote.MdException
Throws:
java.rmi.RemoteException
com.sas.metadata.remote.MdException



Copyright © 2009 SAS Institute Inc. All Rights Reserved.