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

java.lang.Object
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>> extends Object
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 Details

    • prototypeName

      protected String prototypeName
    • prototype

      protected com.sas.metadata.remote.Prototype prototype
    • prototypeProperties

      protected Map<String,com.sas.metadata.remote.Property> prototypeProperties
    • user

      protected UserContextInterface user
    • metadataServer

      protected OMIServer metadataServer
    • repository

      protected RepositoryInterface repository
    • repositoryName

      protected String repositoryName
    • name

      protected String name
    • desc

      protected String desc
    • options

      protected Map<String,String> options
    • OTHER_OPTIONS_PROPERTY

      protected static final String OTHER_OPTIONS_PROPERTY
      See Also:
    • built

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

      protected T extends MetadataInterface builtSmartObject
  • Constructor Details

    • MetadataBuilder

      protected MetadataBuilder(Class<J> metadataType, String publicType, double usageVersion)
  • Method Details

    • name

      public B name(String name)
      Defines object name.
      Parameters:
      name - object name
      Returns:
      builder
      Throws:
      IllegalArgumentException - for invalid names
      NullPointerException
    • desc

      public B desc(String desc)
      Defines descriptive text.
      Parameters:
      desc - description
      Returns:
      builder
      Throws:
      NullPointerException - if desc is null
    • keyword

      public B keyword(String keyword)
      Defines a keyword. May be called multiple times to define multiple keywords.
      Parameters:
      keyword - keyword
      Returns:
      builder
    • option

      public B option(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(String optionName, 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(String name, String value, 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:
      NullPointerException - if name or value is null
    • validate

      public void validate(UserContextInterface user) throws IllegalArgumentException, 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:
      IllegalArgumentException - illegal value was specified to the builder
      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 IllegalArgumentException, IllegalStateException, ItemAlreadyExistsException, ServiceException
      Build the object.
      Parameters:
      user - user context
      Returns:
      the new object
      Throws:
      IllegalArgumentException - illegal value was specified to the builder
      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 RemoteException, com.sas.metadata.remote.MdException, ServiceException
      Throws:
      RemoteException
      com.sas.metadata.remote.MdException
      ServiceException
    • loadPrototypeProperties

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

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

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

      protected final com.sas.metadata.remote.Property createPropertyFromPrototype(com.sas.metadata.remote.Property prototype, String value) throws RemoteException
      Throws:
      RemoteException
    • findMetadataByName

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

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