Class DataModel
java.lang.Object
net.sf.jailer.datamodel.DataModel
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumOrder priority of a column.static classThrown if data model doesn't exist.static classThrown if a table has no primary key.static classHolds XML settings for exportation into XML files. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDataModel(String additionalTablesFile, String additionalAssociationsFile, Map<String, String> sourceSchemaMapping, CsvFile.LineFilter assocFilter, PrimaryKeyFactory primaryKeyFactory, ExecutionContext executionContext, boolean failOnMissingTables) Reads intable.csvandassociation.csvand builds the relational data model.DataModel(String additionalTablesFile, String additionalAssociationsFile, Map<String, String> sourceSchemaMapping, CsvFile.LineFilter assocFilter, PrimaryKeyFactory primaryKeyFactory, ExecutionContext executionContext, boolean failOnMissingTables, KnownIdentifierMap knownIdentifiers) Reads intable.csvandassociation.csvand builds the relational data model.DataModel(String additionalTablesFile, String additionalAssociationsFile, Map<String, String> sourceSchemaMapping, CsvFile.LineFilter assocFilter, ExecutionContext executionContext) Reads intable.csvandassociation.csvand builds the relational data model.DataModel(String additionalTablesFile, String additionalAssociationsFile, PrimaryKeyFactory primaryKeyFactory, ExecutionContext executionContext) Reads intable.csvandassociation.csvand builds the relational data model.DataModel(String additionalTablesFile, String additionalAssociationsFile, ExecutionContext executionContext) Reads intable.csvandassociation.csvand builds the relational data model.DataModel(Map<String, String> sourceSchemaMapping, ExecutionContext executionContext, boolean failOnMissingTables) Reads intable.csvandassociation.csvand builds the relational data model.DataModel(PrimaryKeyFactory primaryKeyFactory, Map<String, String> sourceSchemaMapping, ExecutionContext executionContext) Reads intable.csvandassociation.csvand builds the relational data model.DataModel(ExecutionContext executionContext) Reads intable.csvandassociation.csvand builds the relational data model.DataModel(KnownIdentifierMap knownIdentifiers, ExecutionContext executionContext) Reads intable.csvandassociation.csvand builds the relational data model. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddRestrictedDependencyWithNulledFK(Set<Table> tables) Adds all tables that are part of a restricted dependency with nulled foreign key to the given set of tables.voidAssigns a unique ID to each association.checkForPrimaryKey(Set<Table> subjects, boolean hasRowID) Checks whether all tables in the closure of a given subject have primary keys.voidRemoves all derived filters and renews them.static StringgetAssociationsFile(ExecutionContext executionContext) Gets name of file containing the association definitions.static StringgetColumnsFile(ExecutionContext executionContext) Gets name of file containing the column definitions.getComment(Table table, Column column) Gets the comment for a table or column.static StringgetCommentsFile(ExecutionContext executionContext) Gets name of file containing the comments.static StringgetDatamodelFolder(ExecutionContext executionContext) Gets name of data model folder.getDisplayName(Table table) Gets display name of a tablestatic StringgetDisplayNamesFile(ExecutionContext executionContext) Gets name of file containing the display names.static StringgetExcludeFromDeletionFile(ExecutionContext executionContext) Gets name of file containing the list of tables to be excluded from deletion.Gets export modus, SQL or XML.Gets theFilterTemplates ordered by priority.getIndependentTables(Set<Table> tableSet) Gets all independent tables (i.e.getIndependentTables(Set<Table> tableSet, Set<Association> associations) Gets all independent tables (i.e.Gets time of last modification.GetsgetLastModified()as String.static StringgetModelNameFile(ExecutionContext executionContext) Gets name of file containing the model name.getName()Gets name of the model.getParameters(String subjectCondition, List<ExtractionModel.AdditionalSubject> additionalSubjects) Gets all parameters which occur in subject condition, association restrictions or XML templates.Gets the restriction model.Gets list of tables sorted by name.Gets a table by name.getTableByDisplayName(String displayName) Gets a table by display name.getTableByOrdinal(int ordinal) Gets table byTable.getOrdinal().Gets all tables.static StringgetTablesFile(ExecutionContext executionContext) Gets name of file containing the table definitions.longGets internal version number.static StringgetVersionFile(ExecutionContext executionContext) Gets name of file containing the version number.Gets XML settings for exportation into XML files.Normalizes a set of tables.voidsave(String file, Table stable, SubjectLimitDefinition subjectLimitDefinition, String subjectCondition, ScriptFormat scriptFormat, List<RestrictionDefinition> restrictionDefinitions, Map<String, Map<String, double[]>> positions, List<ExtractionModel.AdditionalSubject> additionalSubjects, String currentModelSubfolder) Saves the data model.voidSaves the order priority of the columns.voidsaveRestrictions(File file, List<RestrictionDefinition> restrictionDefinitions) Saves restrictions only.voidsetExportModus(String modus) Sets export modus, SQL or XML.voidsetRestrictionModel(RestrictionModel restrictionModel) Sets the restriction model.voidsetXmlSettings(DataModel.XmlSettings xmlSettings) Sets XML settings for exportation into XML files.toString()Stringifies the data model.voidTransposes the data-model.
-
Field Details
-
TABLE_CSV_FILE
- See Also:
-
MODELNAME_CSV_FILE
- See Also:
-
namedAssociations
Maps association-names to associations; -
decisionPending
-
columnOrderPrio
Maps normalized column name to order priority. -
version
public long versionInternal version number. Incremented on each modification. -
DEFAULT_NAME
-
-
Constructor Details
-
DataModel
public DataModel(PrimaryKeyFactory primaryKeyFactory, Map<String, String> sourceSchemaMapping, ExecutionContext executionContext) throws IOExceptionReads intable.csvandassociation.csvand builds the relational data model.- Parameters:
primaryKeyFactory- factory for creating primary keyssourceSchemaMapping- mapping of source schema namesexecutionContext- the execution context- Throws:
IOException
-
DataModel
Reads intable.csvandassociation.csvand builds the relational data model.- Parameters:
executionContext- the execution context- Throws:
IOException
-
DataModel
public DataModel(KnownIdentifierMap knownIdentifiers, ExecutionContext executionContext) throws IOException Reads intable.csvandassociation.csvand builds the relational data model.- Parameters:
knownIdentifiers- map of known identifiers for name normalizationexecutionContext- the execution context- Throws:
IOException
-
DataModel
public DataModel(Map<String, String> sourceSchemaMapping, ExecutionContext executionContext, boolean failOnMissingTables) throws IOExceptionReads intable.csvandassociation.csvand builds the relational data model.- Parameters:
sourceSchemaMapping- mapping of source schema namesexecutionContext- the execution contextfailOnMissingTables-trueto throw an exception if the data model files are not found- Throws:
IOException
-
DataModel
public DataModel(String additionalTablesFile, String additionalAssociationsFile, PrimaryKeyFactory primaryKeyFactory, ExecutionContext executionContext) throws IOException Reads intable.csvandassociation.csvand builds the relational data model.- Parameters:
additionalTablesFile- additional table file to read, ornulladditionalAssociationsFile- additional association file to read, ornullprimaryKeyFactory- factory for creating primary keysexecutionContext- the execution context- Throws:
IOException
-
DataModel
public DataModel(String additionalTablesFile, String additionalAssociationsFile, ExecutionContext executionContext) throws IOException Reads intable.csvandassociation.csvand builds the relational data model.- Parameters:
additionalTablesFile- additional table file to read, ornulladditionalAssociationsFile- additional association file to read, ornullexecutionContext- the execution context- Throws:
IOException
-
DataModel
public DataModel(String additionalTablesFile, String additionalAssociationsFile, Map<String, String> sourceSchemaMapping, CsvFile.LineFilter assocFilter, ExecutionContext executionContext) throws IOExceptionReads intable.csvandassociation.csvand builds the relational data model.- Parameters:
additionalTablesFile- additional table file to read, ornulladditionalAssociationsFile- additional association file to read, ornullsourceSchemaMapping- mapping of source schema namesassocFilter- filter for association lines, ornullexecutionContext- the execution context- Throws:
IOException
-
DataModel
public DataModel(String additionalTablesFile, String additionalAssociationsFile, Map<String, String> sourceSchemaMapping, CsvFile.LineFilter assocFilter, PrimaryKeyFactory primaryKeyFactory, ExecutionContext executionContext, boolean failOnMissingTables) throws IOExceptionReads intable.csvandassociation.csvand builds the relational data model.- Parameters:
additionalTablesFile- additional table file to read, ornulladditionalAssociationsFile- additional association file to read, ornullsourceSchemaMapping- mapping of source schema namesassocFilter- filter for association lines, ornullprimaryKeyFactory- factory for creating primary keysexecutionContext- the execution contextfailOnMissingTables-trueto throw an exception if the data model files are not found- Throws:
IOException
-
DataModel
public DataModel(String additionalTablesFile, String additionalAssociationsFile, Map<String, String> sourceSchemaMapping, CsvFile.LineFilter assocFilter, PrimaryKeyFactory primaryKeyFactory, ExecutionContext executionContext, boolean failOnMissingTables, KnownIdentifierMap knownIdentifiers) throws IOExceptionReads intable.csvandassociation.csvand builds the relational data model.- Parameters:
additionalTablesFile- additional table file to read, ornulladditionalAssociationsFile- additional association file to read, ornullsourceSchemaMapping- mapping of source schema namesassocFilter- filter for association lines, ornullprimaryKeyFactory- factory for creating primary keysexecutionContext- the execution contextfailOnMissingTables-trueto throw an exception if the data model files are not foundknownIdentifiers- map of known identifiers for name normalization, ornull- Throws:
IOException
-
-
Method Details
-
getDatamodelFolder
Gets name of data model folder.- Parameters:
executionContext- the execution context- Returns:
- name of the data model folder
-
getTablesFile
Gets name of file containing the table definitions.- Parameters:
executionContext- the execution context- Returns:
- name of the file containing the table definitions
-
getModelNameFile
Gets name of file containing the model name.- Parameters:
executionContext- the execution context- Returns:
- name of the file containing the model name
-
getDisplayNamesFile
Gets name of file containing the display names.- Parameters:
executionContext- the execution context- Returns:
- name of the file containing the display names
-
getColumnsFile
Gets name of file containing the column definitions.- Parameters:
executionContext- the execution context- Returns:
- name of the file containing the column definitions
-
getAssociationsFile
Gets name of file containing the association definitions.- Parameters:
executionContext- the execution context- Returns:
- name of the file containing the association definitions
-
getCommentsFile
Gets name of file containing the comments.- Parameters:
executionContext- the execution context- Returns:
- name of the file containing the comments
-
getExcludeFromDeletionFile
Gets name of file containing the list of tables to be excluded from deletion.- Parameters:
executionContext- the execution context- Returns:
- name of the file containing tables excluded from deletion
-
getVersionFile
Gets name of file containing the version number.- Parameters:
executionContext- the execution context- Returns:
- name of the file containing the version number
-
getTable
-
getTableByDisplayName
-
getName
-
getLastModified
-
getDisplayName
-
getTables
-
getRestrictionModel
Gets the restriction model.- Returns:
- the restriction model
-
setRestrictionModel
Sets the restriction model.- Parameters:
restrictionModel- the restriction model
-
getIndependentTables
-
getIndependentTables
Gets all independent tables (i.e. tables which don't depend on other tables in the set) of a given table-set.- Parameters:
tableSet- the table-setassociations- the associations to consider,nullfor all associations- Returns:
- the sub-set of independent tables of the table-set
-
transpose
public void transpose()Transposes the data-model. -
toString
-
getSortedTables
-
normalize
-
assignAssociationIDs
public void assignAssociationIDs()Assigns a unique ID to each association. -
getExportModus
Gets export modus, SQL or XML. (GUI support).- Returns:
- the export modus
-
setExportModus
Sets export modus, SQL or XML. (GUI support).- Parameters:
modus- the export modus to set
-
getXmlSettings
Gets XML settings for exportation into XML files.- Returns:
- the XML settings
-
setXmlSettings
Sets XML settings for exportation into XML files.- Parameters:
xmlSettings- the XML settings to set
-
getVersion
public long getVersion()Gets internal version number. Incremented on each modification.- Returns:
- internal version number. Incremented on each modification.
-
checkForPrimaryKey
public Set<Table> checkForPrimaryKey(Set<Table> subjects, boolean hasRowID) throws DataModel.NoPrimaryKeyException Checks whether all tables in the closure of a given subject have primary keys.- Parameters:
subjects- the subjectshasRowID-trueif row IDs are available as a substitute for primary keys- Returns:
- the set of all tables in the closure that were checked
- Throws:
DataModel.NoPrimaryKeyException- if a table has no primary key
-
getParameters
public SortedSet<String> getParameters(String subjectCondition, List<ExtractionModel.AdditionalSubject> additionalSubjects) Gets all parameters which occur in subject condition, association restrictions or XML templates.- Parameters:
subjectCondition- the subject conditionadditionalSubjects- additional subjects to scan for parameters- Returns:
- all parameters which occur in subject condition, association restrictions or XML templates
-
getLastModifiedAsString
GetsgetLastModified()as String.- Returns:
getLastModified()as String
-
save
public void save(String file, Table stable, SubjectLimitDefinition subjectLimitDefinition, String subjectCondition, ScriptFormat scriptFormat, List<RestrictionDefinition> restrictionDefinitions, Map<String, Map<String, throws FileNotFoundExceptiondouble[]>> positions, List<ExtractionModel.AdditionalSubject> additionalSubjects, String currentModelSubfolder) Saves the data model.- Parameters:
file- the file namestable- the subject tablesubjectLimitDefinition- limit definition of the subjectsubjectCondition- the subject conditionscriptFormat- the script formatrestrictionDefinitions- the restriction definitions to savepositions- table positions ornulladditionalSubjects- additional subjectscurrentModelSubfolder- the current model subfolder- Throws:
FileNotFoundException
-
saveRestrictions
public void saveRestrictions(File file, List<RestrictionDefinition> restrictionDefinitions) throws FileNotFoundException Saves restrictions only.- Parameters:
file- the file to save restrictions intorestrictionDefinitions- the restriction definitions to save- Throws:
FileNotFoundException
-
saveColumnOrderPrio
Saves the order priority of the columns.- Throws:
FileNotFoundException
-
getTableByOrdinal
Gets table byTable.getOrdinal().- Parameters:
ordinal- the ordinal- Returns:
- the table
-
getFilterTemplates
Gets theFilterTemplates ordered by priority.- Returns:
- template list
-
deriveFilters
public void deriveFilters()Removes all derived filters and renews them. -
addRestrictedDependencyWithNulledFK
-
getComment
-