Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom transformations and Jenkins pipeline changes. #33

Merged
merged 1 commit into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 14 additions & 64 deletions datamodeler/CustomTransformationScripts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,55 +31,6 @@ for (var t = 0; t<tables.length;t++){
}]]>
</script>
</scr>
<scr id="B673F271-4836-DD48-15AC-487DDECCAF49" name="Tables to upper case - JRuby" object="relational" engine="JSR 223 JRuby Engine" var="model" library="" method="" purpose="transformation" >
<script>
<![CDATA[tables =$model.getTableSet().toArray()
for t in 0..tables.length-1
table = tables[t]
name = table.getName().upcase
table.setName(name)
columns = table.getElements()
size = table.getElementsCollection().size()-1
for i in 0..size
column = columns[i]
cname = column.getName().upcase
column.setName(cname)
end
keys = table.getKeys()
for i in 0..keys.length-1
key = keys[i]
kname = key.getName().upcase
key.setName(kname)
end
end]]>
</script>
</scr>
<scr id="3E7C4F9E-9FCB-56C7-086F-F976F9A66384" name="Tables to upper case - JRuby - library usage" object="relational" engine="JSR 223 JRuby Engine" var="model" library="Jruby lib" method="tables_up" purpose="transformation" >
<script>
<![CDATA[def tables_up(model)
tables = model.getTableSet().toArray()
for t in 0..tables.length-1
table = tables[t]
name = table.getName().upcase
table.setName(name)
columns = table.getElements()
size = table.getElementsCollection().size()-1
for i in 0..size
column = columns[i]
cname = column.getName().upcase
column.setName(cname)
end
keys = table.getKeys()
for i in 0..keys.length-1
key = keys[i]
kname = key.getName().upcase
key.setName(kname)
end
end
return true
end]]>
</script>
</scr>
<scr id="E60A5A28-BB9B-3787-10E7-259DF900B9E6" name="Table abbreviation to column" object="relational" engine="Oracle Nashorn" var="model" library="" method="" purpose="transformation" >
<script>
<![CDATA[tables = model.getTableSet().toArray();
Expand Down Expand Up @@ -426,6 +377,7 @@ function copyCommentsInRDBMS(object) {
}
}

model.getAppView().logMessage("Some message...");
entities = model.getEntitySet().toArray();
for (var e = 0; e < entities.length; e++) {
var entity = entities[e]; copyCommentsInRDBMS(entity);
Expand All @@ -443,8 +395,7 @@ for (var e = 0; e < entities.length; e++) {
copyCommentsInRDBMS(key.getFKAssociation());
}
}
}
]]>
}]]>
</script>
</scr>
<scr id="BB4A8D82-E1C4-4D8B-53D1-E075B1FF26AB" name="Copy Preferred Abbreviation to Short Name - custom" object="logical" engine="Oracle Nashorn" var="model" library="" method="" purpose="transformation" >
Expand All @@ -462,24 +413,26 @@ for (var e = 0; e < entities.length; e++) {
entities = model.getEntitySet().toArray();
for (var e = 0; e < entities.length; e++) {
copyPreferredAbbreviation(entities[e]);
}
]]>
}]]>
</script>
</scr>
<scr id="4E709409-3C85-7F34-DFFF-2047EE229EDA" name="Set Relation Name - custom" object="logical" engine="Oracle Nashorn" var="model" library="" method="" purpose="transformation" >
<script>
<![CDATA[function setRelationName(object, name) {
if (!object.getName().equals(name)) {
<![CDATA[function setRelationName(object, sourceShortName, sourceAbbreviation, targetShortName, targetAbbreviation) {
var sourceName = (sourceAbbreviation.equals('') ? sourceShortName : sourceAbbreviation);
var targetName = (targetAbbreviation.equals('') ? targetShortName : targetAbbreviation);
var name = (sourceName.equals('') || targetName.equals('') ? '' : sourceName + '_' + targetName);

if (!name.equals('') && !object.getName().equals(name)) {
object.setName(name);
object.setDirty(true);
}
}

relations = model.getRelationSet().toArray();
for (var r = 0; r < relations.length; r++) {
setRelationName(relations[r], relations[r].getSourceEntity().getPreferredAbbreviation() + '_' + relations[r].getTargetEntity().getPreferredAbbreviation());
}
]]>
setRelationName(relations[r], relations[r].getSourceEntity().getShortName(), relations[r].getSourceEntity().getPreferredAbbreviation(), relations[r].getTargetEntity().getShortName(), relations[r].getTargetEntity().getPreferredAbbreviation());
}]]>
</script>
</scr>
<scr id="96422D7C-70EB-F471-5D92-C8308B44B0F9" name="Copy Comments in RDBMS to Comments (relational) - custom" object="relational" engine="Oracle Nashorn" var="model" library="" method="" purpose="transformation" >
Expand Down Expand Up @@ -515,8 +468,7 @@ for (var t = 0; t < tables.length; t++) {
copyCommentsInRDBMS(key.getFKAssociation());
}
}
}
]]>
}]]>
</script>
</scr>
<scr id="8009F019-4519-4EC8-66B9-4604D766549F" name="Set security options - custom" object="relational" engine="Oracle Nashorn" var="model" library="" method="" purpose="transformation" >
Expand All @@ -533,8 +485,7 @@ for (var t = 0; t < tables.length; t++) {
cols[c].setContainsSensitiveInformation(false); }
}
table.setDirty(true);
}
]]>
}]]>
</script>
</scr>
<scr id="358AEBAC-D32B-E06D-2D12-8C8A48DEFD8C" name="Table names plural - custom" object="relational" engine="Oracle Nashorn" var="model" library="" method="" purpose="transformation" >
Expand All @@ -555,8 +506,7 @@ for (var t = 0; t < tables.length; t++) {
// . -> .S
table.setName(tableName + "S"); table.setDirty(true);
}
}
]]>
}]]>
</script>
</scr>
<scr id="BF61242D-73E3-0133-F1EC-9897745CC516" name="Set Use Domain Constraints - custom" object="relational" engine="Oracle Nashorn" var="model" library="" method="" purpose="transformation" >
Expand Down
34 changes: 21 additions & 13 deletions jenkins/libraries/maven/steps/process.groovy
Original file line number Diff line number Diff line change
@@ -1,42 +1,50 @@
// -*- mode: groovy; coding: utf-8 -*-
void call(app_env){
script {
assert pipelineConfig.scm_branch_oracle_tools != null
assert pipelineConfig.scm_url_oracle_tools != null
assert pipelineConfig.maven != null
assert pipelineConfig.jdk != null
assert pipelineConfig.scm_url_oracle_tools != null
assert pipelineConfig.scm_branch_oracle_tools != null
assert pipelineConfig.scm_url != null
assert pipelineConfig.scm_credentials != null
assert pipelineConfig.scm_username != null
assert pipelineConfig.scm_email != null
assert pipelineConfig.conf_dir != null
assert pipelineConfig.db_dir != null
assert pipelineConfig.apex_dir != null

env.SCM_BRANCH = app_env.scm_branch
assert env.scm_branch != null
assert env.SCM_BRANCH != null
env.SCM_BRANCH_PREV = ( app_env.previous != null ? app_env.previous.scm_branch : '' )
env.SCM_CREDENTIALS = app_env.scm_credentials
env.SCM_CREDENTIALS = ( app_env.scm_credentials != null ? app_env.scm_credentials : pipelineConfig.scm_credentials )
assert env.SCM_CREDENTIALS != null
env.SCM_URL = app_env.scm_url
env.SCM_URL = ( app_env.scm_url != null ? app_env.scm_url : pipelineConfig.scm_url )
assert env.SCM_URL != null
env.SCM_USERNAME = app_env.scm_username
env.SCM_USERNAME = ( app_env.scm_username != null ? app_env.scm_username : pipelineConfig.scm_username )
assert env.SCM_USERNAME != null
env.SCM_EMAIL = app_env.scm_email
env.SCM_EMAIL = ( app_env.scm_email != null ? app_env.scm_email : pipelineConfig.scm_email )
assert env.SCM_EMAIL != null

env.CONF_DIR = app_env.conf_dir
env.CONF_DIR = ( app_env.conf_dir != null ? app_env.conf_dir : pipelineConfig.conf_dir )
assert env.CONF_DIR != null

env.DB = app_env.db
assert env.DB != null
env.DB_CREDENTIALS = app_env.db_credentials
assert env.DB_CREDENTIALS != null
env.DB_DIR = app_env.db_dir
env.DB_DIR = ( app_env.db_dir != null ? app_env.db_dir : pipelineConfig.db_dir )
assert env.DB_DIR != null
env.DB_ACTIONS = app_env.db_actions
assert env.DB_ACTIONS != null
env.DB_USERNAME_PROPERTY = ( app_env.db_username_property != null ? app_env.db_username_property : 'db.proxy.username' )

env.APEX_DIR = app_env.apex_dir
env.APEX_DIR = ( app_env.apex_dir != null ? app_env.apex_dir : pipelineConfig.apex_dir )
assert env.APEX_DIR != null
env.APEX_ACTIONS = app_env.apex_actions
assert env.APEX_ACTIONS != null
}

withCredentials([usernamePassword(credentialsId: app_env.db_credentials, passwordVariable: 'DB_PASSWORD', usernameVariable: 'DB_USERNAME')]) {
withCredentials([usernamePassword(credentialsId: env.DB_CREDENTIALS, passwordVariable: 'DB_PASSWORD', usernameVariable: 'DB_USERNAME')]) {
// Clean before build
cleanWs()

Expand All @@ -52,13 +60,13 @@ void call(app_env){
}

dir('myproject') {
git branch: app_env.scm_branch, credentialsId: app_env.scm_credentials, url: app_env.scm_url
git branch: env.SCM_BRANCH, credentialsId: env.SCM_CREDENTIALS, url: env.SCM_URL

withMaven(maven: pipelineConfig.maven,
options: [artifactsPublisher(disabled: true),
findbugsPublisher(disabled: true),
openTasksPublisher(disabled: true)]) {
sshagent([app_env.scm_credentials]) {
sshagent([env.SCM_CREDENTIALS]) {
sh('''
pwd
unset JAVA_HOME
Expand Down