public final class SchemaConfig
extends java.lang.Object
Configuration
reading input data from an XML
configuration file. The syntax of that XML file is specified external to this class. The
purpose of this class is to store and provide access to the configuration. How that
configuration is read is not of concern here.
Each database used by an application is configured in an XML element in the configuration file.
That element contains a short name or handle for the database, which matches the logical name
of the database. It also contains a path to the DF file exported from the Progress data
dictionary (the import file from our perspective), as well as the XML file to which the
imported schema information will be written for use in conversion (the schema file). Finally, a
database can be a default database (always loaded into the schema dictionary when parsing
source code), or non-default (only loaded on demand by the Progress parser). All of this
information about a particular database is encoded in an instance of the NsConfig
inner class (which is public
since the external configuration reading process must
create instances of it). Those NsConfig
instances are then added using addNamespace(com.goldencode.p2j.schema.SchemaConfig.NsConfig)
.
One database is designated the "metadata" database. This is the database which contains
metadata about the schema structure used to define all databases in Progress (for a specific
version of Progress). The tables and fields of this database are referenced in source code as
if they were members of every other logical database. Thus, the schema information included in
the metadata database schema is merged with each logical database as it is loaded into the
schema dictionary. The metadata schema configuration is accessible via the getMetadata()
method.
SchemaLoader
,
SchemaDictionary
Modifier and Type | Class and Description |
---|---|
static class |
SchemaConfig.Metadata
Encapsulates information about the project's use of database metadata, including the name of
the metadata schema and the metadata tables used by the application, if any.
|
static class |
SchemaConfig.NsConfig
Encapsulates information about a namespace configuration, including
name, XML file, and whether namespace should be loaded into the schema
dictionary by default.
|
Modifier and Type | Field and Description |
---|---|
private SchemaConfig.Metadata |
metadata
Name of metadata definition applied to every loaded schema
|
private java.util.Map<java.lang.String,SchemaConfig.NsConfig> |
nsConfigs
Map of database names to namespace configuration data
|
Constructor and Description |
---|
SchemaConfig()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addNamespace(SchemaConfig.NsConfig cfg)
Add a namespace configuration object to this configuration.
|
java.util.Iterator<java.lang.String> |
databases()
Get an iterator of configured database names.
|
java.util.Iterator<java.lang.String> |
defaultDatabases()
Get an iterator of names of those databases which have been configured
as default schemas for namespace lookup purposes.
|
java.io.File |
getImportFile(java.lang.String name)
Returns a file object representing the import (DF) file associated with
the specified database schema name.
|
SchemaConfig.Metadata |
getMetadata()
Get the metadata identifier name associated with all schemas.
|
java.lang.String |
getNamespaceParameter(java.lang.String name,
java.lang.String param)
Get the value for the given namespace parameter.
|
java.io.File |
getSchemaFile(java.lang.String name)
Returns a file object representing the XML document associated with the
specified database schema name.
|
java.lang.String |
getSchemaResource(java.lang.String name)
Returns path to the resource representing the XML document associated with the specified
database schema name.
|
java.util.List<java.lang.String> |
getSchemas(boolean omitMeta)
Get a list of schema names, optionally omitting the name of the metadata schema.
|
boolean |
isMetadataActive()
Determine whether metadata is active for the current application.
|
boolean |
isPreferred(java.lang.String name)
Reports whether the database should be preferred in cases where its entities are involved in
ambiguous name conflicts.
|
void |
setMetadata(SchemaConfig.Metadata metadata)
Name of metadata definition applied to every loaded schema.
|
java.lang.String |
toString()
Returns a string representation of this
SchemaConfig 's object graph. |
private SchemaConfig.Metadata metadata
private java.util.Map<java.lang.String,SchemaConfig.NsConfig> nsConfigs
public boolean isMetadataActive()
true
if the application uses metadata, else false
.public SchemaConfig.Metadata getMetadata()
public void setMetadata(SchemaConfig.Metadata metadata)
metadata
- Metadata definition name.public java.util.List<java.lang.String> getSchemas(boolean omitMeta)
omitMeta
- true
to omit the metadata schema, false
to include it.public java.util.Iterator<java.lang.String> databases()
public java.util.Iterator<java.lang.String> defaultDatabases()
SchemaDictionary
object at
construction.public void addNamespace(SchemaConfig.NsConfig cfg)
cfg
- Namespace configuration object.public java.io.File getImportFile(java.lang.String name) throws ConfigurationException
name
- Name of desired namespace configurationConfigurationException
- if environment has not been configured correctly.public java.io.File getSchemaFile(java.lang.String name) throws ConfigurationException
name
- Name of desired namespace configurationConfigurationException
- if environment has not been configured correctly.public java.lang.String getSchemaResource(java.lang.String name)
name
- Name of desired namespace configurationnull
if the resource doesn't exist.public boolean isPreferred(java.lang.String name)
name
- Name of desired namespace configurationtrue
if the database is preferred.public java.lang.String getNamespaceParameter(java.lang.String name, java.lang.String param)
name
- The namespace name.param
- The parameter name or path.null
if name
or param
are
invalid.public java.lang.String toString()
SchemaConfig
's object graph.toString
in class java.lang.Object
Object.toString()