Class Grain

    • Method Detail

      • getElements

        public <T extends GrainElementMap<String,​T> getElements​(Class<T> classOfElement)
        Returns a set of elements of specified type defined in the grain.
        Type Parameters:
        T - class of element
        Parameters:
        classOfElement - class of elements from the set
      • getIndices

        public Map<String,​Index> getIndices()
        Returns a set of indices defined in the grain.
      • getMaterializedViews

        public Map<String,​MaterializedView> getMaterializedViews()
        Returns a set of materialized views defined in the grain.
      • getParameterizedViews

        public Map<String,​ParameterizedView> getParameterizedViews()
        Returns a set of parameterized views defined in the grain.
      • getTables

        public Map<String,​BasicTable> getTables()
        Returns a set of tables defined in the grain.
      • getTables

        public <T extends BasicTableMap<String,​T> getTables​(Class<T> tableClass)
        Returns a set of tables defined in the grain by a table class.
        Type Parameters:
        T - table type (e.g. Table or ReadOnlyTable)
        Parameters:
        tableClass - Table class
      • getViews

        public Map<String,​View> getViews()
        Returns a set of views defined in the grain.
      • getElement

        public <T extends GrainElement> T getElement​(String name,
                                                     Class<T> classOfElement)
                                              throws ParseException
        Returns an element by its name and class or throws an exception with the message that element is not found.
        Type Parameters:
        T - class of element
        Parameters:
        name - element name
        classOfElement - element class
        Throws:
        ParseException - if element with such name and class is not found in the grain
      • addIndex

        public void addIndex​(Index index)
                      throws ParseException
        Adds an index.
        Parameters:
        index - new index of the grain.
        Throws:
        ParseException - In case if an index with the same name already exists.
      • getScore

        public AbstractScore getScore()
        Returns model that the grain belongs to.
      • isAutoupdate

        public boolean isAutoupdate()
        Value false indicates that grain was created with option WITH NO AUTOUPDATE, and won't be updated. Default value is true.
      • setAutoupdate

        public void setAutoupdate​(boolean autoupdate)
        Sets autoupdate option. Default value is true.
        Parameters:
        autoupdate - autoupdate flag
      • getVersion

        public VersionString getVersion()
        Returns the grain version.
      • setVersion

        public void setVersion​(String version)
                        throws ParseException
        Sets the grain version.
        Parameters:
        version - Quoted-string. In course of processing single and double quotes are removed.
        Throws:
        ParseException - in case if format of quoted string is incorrect.
      • getLength

        public int getLength()
        Returns length of the script file that the grain was created from.
      • getChecksum

        public int getChecksum()
        Returns checksum of the script file that the grain was created from. Coincidence of version, length and checksum is considered to be a sufficient solution for skipping the reading and update of the database structure.
      • isParsingComplete

        public boolean isParsingComplete()
        Indicates that the grain parsing from file is completed.
      • getDependencyOrder

        public int getDependencyOrder()
        If a grain has a higher number than the other grain then it means that it can depend from the first one.
      • finalizeParsing

        public void finalizeParsing()
                             throws ParseException
        Indicates that the grain parsing is completed. A system method.
        Throws:
        ParseException - thrown when there are tables with illegal names.
      • isModified

        public boolean isModified()
        Returns a flag of grain modification (true if parts of grain were modified in the runtime).
      • getView

        public View getView​(String name)
                     throws ParseException
        Returns a view by its name or an exception with a message that the view was not found.
        Parameters:
        name - View name
        Throws:
        ParseException - If view with that name was not found in the grain.
      • getMaterializedView

        public MaterializedView getMaterializedView​(String name)
                                             throws ParseException
        Returns a materialized view by its name or an exception with a message that the view was not found.
        Parameters:
        name - Materialized view name
        Throws:
        ParseException - If materialized view with that name was not found in the grain.
      • getParameterizedView

        public ParameterizedView getParameterizedView​(String name)
                                               throws ParseException
        Returns a parameterized view by its name or an exception with a message that the view was not found.
        Parameters:
        name - Parameterized view name
        Throws:
        ParseException - If parameterized view with that name was not found in the grain.
      • getTable

        public BasicTable getTable​(String name)
                            throws ParseException
        Returns a table by its name or an exception with a message that the table was not found.
        Parameters:
        name - Table name
        Throws:
        ParseException - If table with that name was not found in the grain.
      • getTable

        public <T extends BasicTable> T getTable​(String name,
                                                 Class<T> tableClass)
                                          throws ParseException
        Returns a table by its name and a table class.
        Type Parameters:
        T - table type (e.g. Table or ReadOnlyTable)
        Parameters:
        name - Table name
        tableClass - Table class
        Throws:
        ParseException - If table with that name was not found in the grain.
      • getGrainParts

        public Set<GrainPart> getGrainParts()
        Returns grain parts that this grain consists of.
      • getNamespace

        public Namespace getNamespace()
        Returns namespace of the grain.
      • setNamespace

        public void setNamespace​(Namespace namespace)
        Sets namespace of the grain.
        Parameters:
        namespace - namespace