Package overit.geocall.platform
Class ScriptPackage
java.lang.Object
overit.geocall.platform.Package
overit.geocall.platform.ScriptPackage
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
FsmAssetsScripts,FsmBundlerScripts,FsmExecutionScripts,FsmForecastCapacityScripts,FsmGPSTrackingScripts,FsmInventoryScripts,FsmLocationsScripts,FsmMaterialsScripts,FsmMobileFormsScripts,FsmOrganizationalStructuressScripts,FsmRoughPlanningScripts,FsmSchedulingScripts,FsmSkillScripts,FsmWorkOrdersScripts,WfmAiScripts,WfmCeeScripts,WfmProjectScripts
This class defines a script package, i.e. a package that containing the sql scripts, used for the definition
of the data model that each layer/module contributes to enriching.
Each layer can contain a script package or, in case it is divided into application modules, it can contain as many script packages as modules.
Each layer/module does not necessarily must have a script package; in case the functionalities do not require to enrich the data model already available, the definition of a script package is not necessary.
When scripts are applied, they are executed in the order defined by the SQL file name; sql files must be named with the following format
However, the life cycle of the modules foresees a progressive advancement of the scripts, and therefore their application must take into account not only the versioning within a single package, but also any dependencies between modules.
For example, if the package A contains the following scripts
Or you can define a script package programmatically by creating a new instance of
Each layer can contain a script package or, in case it is divided into application modules, it can contain as many script packages as modules.
Each layer/module does not necessarily must have a script package; in case the functionalities do not require to enrich the data model already available, the definition of a script package is not necessary.
When scripts are applied, they are executed in the order defined by the SQL file name; sql files must be named with the following format
<major>.<minor>.<patch>.<sequence>.sql
(the sequence is optional). This allows you to run scripts with lower versioning first.However, the life cycle of the modules foresees a progressive advancement of the scripts, and therefore their application must take into account not only the versioning within a single package, but also any dependencies between modules.
For example, if the package A contains the following scripts
1.0.0.sql1.1.0.sql1.1.1.sql
1.0.0.sql1.0.1.sql1.1.0.sql
1.0.0.sql- module A1.0.0.sql- module B1.0.1.sql- module B1.1.0.sql- module A1.1.0.sql- module B1.1.1.sql- module A
ScriptPackage extension indicating a name that
uniquely identify the package within the layer, a list of dependencies from other packages and eventually the
position of the package.
Remember to annotate the class with the @Provider annotation.
package overit.geocallapp.wfm.core.scripts;
{@literal @}Provider
public class CoreScriptPackage extends ScriptPackage {
public CoreScriptPackage() {
super("core");
}
}
The example above shows how to define a package script, called core, whose sql files are placed within the
package overit.geocallapp.wfm.core.scripts.
package overit.geocallapp.wfm.cee.scripts;
{@literal @}Provider
public class CEEScriptPackage extends ScriptPackage {
public CEEScriptPackage() {
super("cee");
addDependency(CoreScriptPackage.class);
}
}
The example above shows the definition of another script package, belonging to the CEE module of the same layer,
which defines a dependency on the script package described in the previous example.Or you can define a script package programmatically by creating a new instance of
ScriptPackage and registering
it by calling the Layer.addScriptPackage(ScriptPackage) method.
ScriptPackage scriptPackage = new ScriptPackage("cee", "overit/geocallapp/wfm/cee/scripts/");
scriptPackage.addDependency(CoreScriptPackage.class);
layer.addScriptPackage(scriptPackage);
The association between ScriptPackage and Layer occurs automatically as long as the class that defines its implementation:
- is positioned within the domain defined by the Layer
- contains the annotation
@Provider
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedScriptPackage(String name) Create a new script package by specifying name.ScriptPackage(String name, String position) Create a new script package by specifying its name and position. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddDependency(Class<? extends ScriptPackage>... dependency) Adds the dependency of the current package to the script package identified by the classes passed as a parameter.final voidaddDependency(String... dependency) Adds the dependency of the current package to the script package identified by the names passed as a parameter.final booleandependsBy(ScriptPackage other) Check if the current script package depends from the one passed as parameterbooleanGet the ordered list of the script packages that this depends fromReturns the name of the layer that this package belongs togetOwner()inthashCode()Get the list with the sql file's name contained inside the current packageprotected voidSet the layer that this package belongs to.Methods inherited from class overit.geocall.platform.Package
getAlias, getName, getPosition, invariant, setAlias, setPosition, validatePosition
-
Field Details
-
owner
-
-
Constructor Details
-
ScriptPackage
Create a new script package by specifying name. This constructor can be called from class extensions, instead ofScriptPackage(String, String), because it is easier to use since the package containing the scripts is automatically calculated according to the subclass package.- Parameters:
name- string that uniquely identifies the package. Null value is not allowed.
-
ScriptPackage
Create a new script package by specifying its name and position. The position directories must be separated with the/character, it must start without the/character and must end with.
The following example shows the definition of a new script package, called core, whose sql file is positioned inside theoverit.geocallapp.wfm.scriptspackageScriptPackage scriptPackage = new ScriptPackage("core", "overit/geocallapp/wfm/scripts/");- Parameters:
name- string that uniquely identifies the package. Null value is not allowed.position- path that identifies the position of the script package, i.e. the directory that contains the sql script files. Null value is not allowed.
-
-
Method Details
-
getOwner
- Returns:
- the layer that this package belongs to or null if the package has not yet been registered to any layer
-
setOwner
Set the layer that this package belongs to.- Parameters:
owner- the owner layer
-
addDependency
Adds the dependency of the current package to the script package identified by the classes passed as a parameter. Any class for which there is no correspondence with any other registered script packages will not be taken into account.- Parameters:
dependency- classes of the script packages towards which to define a dependency
-
addDependency
Adds the dependency of the current package to the script package identified by the names passed as a parameter. Any names for which there is no correspondence with any other registered script packages will not be taken into account.- Parameters:
dependency- names of the script packages towards which to define a dependency
-
getLayerName
Returns the name of the layer that this package belongs to- Returns:
- the name of the layer that this package belongs to. If the layer is the
BasicLayer, returns "geocall"
-
getDependencies
Get the ordered list of the script packages that this depends from- Returns:
- the list of the script packages that this depends from, ordered according to the specified dependencies. If this package has no dependencies, empty set will be returned.
-
dependsBy
Check if the current script package depends from the one passed as parameter- Parameters:
other- the instance of the package with which to check the dependency- Returns:
trueif this package depends from the other;falseotherwise
-
listContent
Get the list with the sql file's name contained inside the current package- Returns:
- the list with the sql file's name contained inside the current package, or an empty set if the folder doesn't contains any file.
-
equals
-
hashCode
public int hashCode()
-