Groovy web console

subscribe to the feed Subscribe
to this
site

Published 5 months ago by
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
if ((inputMap."Detailed Description".contains("Reset Password") ) && inputMap."Detailed Description".contains("BSS PROD DB"))
{

def DBuserid2=""
def ruserid2=""
def DBname2=""
def applicationinp2=""


def directWO=inputMap."SRID"
//directWO="SR10"
//def directWO="null"

def customer_email=inputMap."Customer Internet E-mail"
//def customer_email=inputMap."WO Type Field 13"
//def customer_email="null"
//def customer_email="svc_ignio@celcom.com.my"

def a=inputMap."Detailed Description"
def c=a.split('\n')

//Requester User ID
/**
def ruserid=c[(c.findIndexValues {     it.contains("User ID"); })]
ruserid=ruserid[0].split(':')
if(ruserid.size()>1){
ruserid2=ruserid[1]
ruserid2=ruserid2.trim()
}
*/
//def ruseridd="TCS_"+ruserid2   //Adding TCS_


def ruserid=inputMap."Requestor ID"
ruserid2=ruserid.trim()

//Db User ID
def DBuserid=c[(c.findIndexValues {     it.contains("DB User ID"); })]
DBuserid=DBuserid[0].split(':')
if(DBuserid.size()>1){
DBuserid2=DBuserid[1]
DBuserid2=DBuserid2.trim()
}

//Application Name
def applicationinp=c[(c.findIndexValues {     it.contains("Application"); })]
applicationinp=applicationinp[0].split(':')
if(applicationinp.size()>1){
applicationinp2=applicationinp[1]
applicationinp2=applicationinp2.trim()
}



// Mapping DB Name and DB Instance with the help of reference table
def DbMapping2 = { table, identifier1->
def resultSet = RefDataQuery.from(table).select(identifier1).where(RefDataCriteria.exp("ApplicationName").equalTo(applicationinp2)).execute()
def retVal = []
resultSet.each { val ->
retVal << val.get(identifier1)
}
return retVal
}

def var = [];
var=DbMapping2.call("HostnameMapping2","DatabaseInstance")
def temp=var[0];
DBname2=temp.toString();


// Mapping Hostname with the help of reference table
def DbMapping = { table, identifier1->
def resultSet = RefDataQuery.from(table).select(identifier1).where(RefDataCriteria.exp("DatabaseInstance").equalTo(DBname2)).execute()
def retVal = []
resultSet.each { val ->
retVal << val.get(identifier1)
}
return retVal
}

var = [];
var=DbMapping.call("HostnameMapping2","Hostname")
temp=var[0];
def hostname=temp.toString();


def t=".celcom.com.my"
if ((hostname == null || hostname == "null" || hostname == "" || hostname == " ")){
  hostname="null"
}
else if(!(hostname.contains(t))){
hostname=hostname+t
hostname=hostname.trim()
//println(hostname)
}



//Mapping to local variable
inputMap.put("hostnameVar", hostname);
inputMap.put("dbVar", DBname2);
inputMap.put("dbuseridVar", DBuserid2);
inputMap.put("emailVar", customer_email);
inputMap.put("appnameVar", applicationinp2);


//def template=inputMap."TemplateName"
def dbuserupper=DBuserid2.toUpperCase()
def requpper=ruserid2.toUpperCase()

//Checking checks
//if(DBuserid2 == ruseridd && directWO !="null" && DBname2 &&  DBuserid2 && ruserid2 && customer_email !="null" && template=="DB User ID" ){
if(directWO !=null && DBname2 &&  DBuserid2 && customer_email !=null && (dbuserupper.contains(requpper))){
//if(directWO !=null && DBname2 &&  DBuserid2 && customer_email !=null){
//if(directWO !=null && DBname2 &&  DBuserid2){
//inputMap.item = "Unlock_User"
inputMap.item = "Unlock_Reset_User"
}
}

//==================================================================Reset Password END=================================================================


//==================================================================UNLOCK USER======================================================================
else if ((inputMap."Detailed Description".contains("Reactivate") ) && inputMap."Detailed Description".contains("BSS PROD DB"))
{

def DBuserid2=""
def ruserid2=""
def DBname2=""
def applicationinp2=""


def directWO=inputMap."SRID"
//directWO="SR10"
//def directWO="null"

def customer_email=inputMap."Customer Internet E-mail"
//def customer_email=inputMap."WO Type Field 13"
//def customer_email="null"
//def customer_email="svc_ignio@celcom.com.my"

def a=inputMap."Detailed Description"
def c=a.split('\n')

//Requester User ID
/**
def ruserid=c[(c.findIndexValues {     it.contains("User ID"); })]
ruserid=ruserid[0].split(':')
if(ruserid.size()>1){
ruserid2=ruserid[1]
ruserid2=ruserid2.trim()
}
*/
//def ruseridd="TCS_"+ruserid2   //Adding TCS_

def ruserid=inputMap."Requestor ID"
ruserid2=ruserid.trim()


//Db User ID
def DBuserid=c[(c.findIndexValues {     it.contains("DB User ID"); })]
DBuserid=DBuserid[0].split(':')
if(DBuserid.size()>1){
DBuserid2=DBuserid[1]
DBuserid2=DBuserid2.trim()
}


//Application Name
def applicationinp=c[(c.findIndexValues {     it.contains("Application"); })]
applicationinp=applicationinp[0].split(':')
if(applicationinp.size()>1){
applicationinp2=applicationinp[1]
applicationinp2=applicationinp2.trim()
}



// Mapping DB Name and DB Instance with the help of reference table
def DbMapping2 = { table, identifier1->
def resultSet = RefDataQuery.from(table).select(identifier1).where(RefDataCriteria.exp("ApplicationName").equalTo(applicationinp2)).execute()
def retVal = []
resultSet.each { val ->
retVal << val.get(identifier1)
}
return retVal
}

def var = [];
var=DbMapping2.call("HostnameMapping2","DatabaseInstance")
def temp=var[0];
DBname2=temp.toString();


// Mapping Hostname with the help of reference table
def DbMapping = { table, identifier1->
def resultSet = RefDataQuery.from(table).select(identifier1).where(RefDataCriteria.exp("DatabaseInstance").equalTo(DBname2)).execute()
def retVal = []
resultSet.each { val ->
retVal << val.get(identifier1)
}
return retVal
}

var = [];
var=DbMapping.call("HostnameMapping2","Hostname")
temp=var[0];
def hostname=temp.toString();

def t=".celcom.com.my"
if ((hostname == null || hostname == "null" || hostname == "" || hostname == " ")){
  hostname="null"
}
else if(!(hostname.contains(t))){
hostname=hostname+t
hostname=hostname.trim()
//println(hostname)
}




//Mapping to local variable
inputMap.put("hostnameVar", hostname);
inputMap.put("dbVar", DBname2);
inputMap.put("dbuseridVar", DBuserid2);
inputMap.put("emailVar", customer_email);
inputMap.put("appnameVar", applicationinp2);


//def template=inputMap."TemplateName"


def dbuserupper=DBuserid2.toUpperCase()
def requpper=ruserid2.toUpperCase()

//Checking checks
//if(DBuserid2 == ruseridd && directWO !="null" && DBname2 &&  DBuserid2 && ruserid2 && customer_email !="null" && template=="DB User ID" ){
if(directWO !=null && DBname2 &&  DBuserid2 && customer_email !=null && (dbuserupper.contains(requpper))){
//if(directWO !=null && DBname2 &&  DBuserid2 && customer_email !=null){
//if(directWO !=null && DBname2 &&  DBuserid2){
//inputMap.item = "Unlock_User"
inputMap.item = "Unlock_Reset_User"
}
}
//==================================================================UNLOCK USER END===============================================================
//==============================================================START OF RPOS RESET PASSWORD============================================================

//check if Detailed Description contains RPOS or  not
else if ((inputMap."Detailed Description".contains("Reset Password"))  && (inputMap."Detailed Description".contains("Centouch Payments")))
{
// store Detailed Description in variable b
def b=inputMap."Detailed Description"
// store list of Detailed Description in variable d
def d=b.split('\n')

def userid_rpos2=""
def storeid2=""
def empname_rpos2=""
def reqid2=""

def directWO=inputMap."SRID"

// store store id in variable storeid
def storeid=d[(d.findIndexValues {     it.contains("Store ID"); })]
storeid=storeid[0].split(':')
if(storeid.size()>1){
storeid2=storeid[1]
storeid2=storeid2.trim()
//println(storeid)
}
// store login id in variable userid_rpos
def userid_rpos=d[(d.findIndexValues {     it.contains("User ID"); })]
userid_rpos=userid_rpos[0].split(':')
if(userid_rpos.size()>1){
userid_rpos2=userid_rpos[1]
userid_rpos2=userid_rpos2.trim()
//println(userid_rpos)
}
// store emp name in variable empname_rpos
def empname_rpos=d[(d.findIndexValues {     it.contains("Full Name"); })]
empname_rpos=empname_rpos[0].split(':')
if(empname_rpos.size()>1){
empname_rpos2=empname_rpos[1]
empname_rpos2=empname_rpos2.trim()
//println(empname_rpos)
}

// store Requestor ID in variable reqid2
def reqid=inputMap."Requestor ID"
reqid2=reqid.trim()

// Mapping the server, schema and status of respective store id with the help of reference table
def func1 = { table, identifier1->
def resultSet = RefDataQuery.from(table).select(identifier1).where(RefDataCriteria.exp("STORE ID").equalTo(storeid2)).execute()
def retVal = []
resultSet.each { val ->
retVal << val.get(identifier1)
}
return retVal
}
def var4 = [];
def var1 = [];
def var2 = [];
var4=func1.call("CelcomRPOS","SCHEMA NAME")
var1=func1.call("CelcomRPOS","RBO SERVER")
var2=func1.call("CelcomRPOS","STATUS")
def Server1=var1[0];
def Schema1=var4[0];
def Status1=var2[0];
def RBO_Server=Server1.toString();
def RBO_Schema=Schema1.toString();
def RBO_Status=Status1.toString();


// Mapping the hostname of respective dB with the help of reference table
def HostMapping = { table, identifier1->
def resultSet = RefDataQuery.from(table).select(identifier1).where(RefDataCriteria.exp("DB NAME").equalTo(RBO_Server)).execute()
def retVal = []
resultSet.each { val ->
retVal << val.get(identifier1)
}
return retVal
}
def var5 = [];
var5=HostMapping.call("rpos_tc_hostnames","HOSTNAME")
def temp=var5[0];
def hostname=temp.toString();


def t=".celcom.com.my"
if ((hostname == null || hostname == "null" || hostname == "" || hostname == " ")){
  hostname="null"
}
else if(!(hostname.contains(t))){
hostname=hostname+t
hostname=hostname.trim()
//println(hostname)
}


//mapping variables
inputMap.put("loginidvar",userid_rpos2)
inputMap.put("hostnamevar",hostname)
inputMap.put("dbvar",RBO_Server)
inputMap.put("schemavar",RBO_Schema)
//def email1="svc_ignio@celcom.com.my"
def email1=inputMap."Customer Internet E-mail"
inputMap.put("emailvar",email1)

//check if status is active, login id, store id and empname are not null
if(userid_rpos2 !="" && storeid2 !="" && empname_rpos2 !="" && email1 && userid_rpos2.equalsIgnoreCase(reqid2) && directWO !=null)
{
inputMap.item="Pass_rpos"
}
}


//================================================================END OF RPOS RESET PASSWORD============================================================

//===============================================================START OF RPOS REACTIVATE USER============================================================

//check if Detailed Description contains RPOS or  not
else if ((inputMap."Detailed Description".contains("Reactivate"))  && (inputMap."Detailed Description".contains("Centouch Payments")))
{
// store Detailed Description in variable b
def b=inputMap."Detailed Description"
// store list of Detailed Description in variable d
def d=b.split('\n')

def userid_rpos2=""
def storeid2=""
def empname_rpos2=""
def reqid2=""

def directWO=inputMap."SRID"

// store store id in variable storeid
def storeid=d[(d.findIndexValues {     it.contains("Store ID"); })]
storeid=storeid[0].split(':')
if(storeid.size()>1){
storeid2=storeid[1]
storeid2=storeid2.trim()
//println(storeid)
}
// store login id in variable userid_rpos
def userid_rpos=d[(d.findIndexValues {     it.contains("User ID"); })]
userid_rpos=userid_rpos[0].split(':')
if(userid_rpos.size()>1){
userid_rpos2=userid_rpos[1]
userid_rpos2=userid_rpos2.trim()
//println(userid_rpos)
}
// store emp name in variable empname_rpos
def empname_rpos=d[(d.findIndexValues {     it.contains("Full Name"); })]
empname_rpos=empname_rpos[0].split(':')
if(empname_rpos.size()>1){
empname_rpos2=empname_rpos[1]
empname_rpos2=empname_rpos2.trim()
//println(empname_rpos)
}

// store Requestor ID in variable reqid2
def reqid=inputMap."Requestor ID"
reqid2=reqid.trim()

// Mapping the server, schema and status of respective store id with the help of reference table
def func1 = { table, identifier1->
def resultSet = RefDataQuery.from(table).select(identifier1).where(RefDataCriteria.exp("STORE ID").equalTo(storeid2)).execute()
def retVal = []
resultSet.each { val ->
retVal << val.get(identifier1)
}
return retVal
}
def var4 = [];
def var1 = [];
def var2 = [];
var4=func1.call("CelcomRPOS","SCHEMA NAME")
var1=func1.call("CelcomRPOS","RBO SERVER")
var2=func1.call("CelcomRPOS","STATUS")
def Server1=var1[0];
def Schema1=var4[0];
def Status1=var2[0];
def RBO_Server=Server1.toString();
def RBO_Schema=Schema1.toString();
def RBO_Status=Status1.toString();


// Mapping the hostname of respective dB with the help of reference table
def HostMapping = { table, identifier1->
def resultSet = RefDataQuery.from(table).select(identifier1).where(RefDataCriteria.exp("DB NAME").equalTo(RBO_Server)).execute()
def retVal = []
resultSet.each { val ->
retVal << val.get(identifier1)
}
return retVal
}
def var5 = [];
var5=HostMapping.call("rpos_tc_hostnames","HOSTNAME")
def temp=var5[0];
def hostname=temp.toString();


def t=".celcom.com.my"
if ((hostname == null || hostname == "null" || hostname == "" || hostname == " ")){
  hostname="null"
}
else if(!(hostname.contains(t))){
hostname=hostname+t
hostname=hostname.trim()
//println(hostname)
}


//mapping variables
inputMap.put("loginidvar",userid_rpos2)
inputMap.put("hostnamevar",hostname)
inputMap.put("dbvar",RBO_Server)
inputMap.put("schemavar",RBO_Schema)
//def email1="svc_ignio@celcom.com.my"
def email1=inputMap."Customer Internet E-mail"
inputMap.put("emailvar",email1)

//check if status is active, login id, store id and empname are not null
//if(userid_rpos2 !="" && storeid2 !="" && empname_rpos2 !="" && email1 && RBO_Server != null && RBO_Server!="null" && RBO_Server!="" && RBO_Server!=" ")
if(userid_rpos2 !="" && storeid2 !="" && empname_rpos2 !="" && email1 && userid_rpos2.equalsIgnoreCase(reqid2) && directWO !=null)
{
inputMap.item="React_rpos"
}
}


//================================================================END OF RPOS REACTIVATE USER============================================================

//================================================================START OF RPOS NEW USER=================================================================

else if ((inputMap.'Detailed Description'.contains("New ID") && inputMap.'Detailed Description'.contains("Centouch Payments") ))
{
// store Detailed Description in variable b
def b=inputMap."Detailed Description"
// store list of Detailed Description in variable d
def d=b.split('\n')

def userid_rpos2=""
def storeid2=""
def empname_rpos2=""
def fempname_rpos2=""
def lempname_rpos2="."
def work_group_id="10"
def role2=""
def reqid2=""

def directWO=inputMap."SRID"

// store store id in variable storeid
def storeid=d[(d.findIndexValues {     it.contains("Store ID"); })]
storeid=storeid[0].split(':')
if(storeid.size()>1){
storeid2=storeid[1]
storeid2=storeid2.trim()
//println(storeid)
}

 

// store login id in variable userid_rpos
def userid_rpos=d[(d.findIndexValues {     it.contains("User ID"); })]
userid_rpos=userid_rpos[0].split(':')
if(userid_rpos.size()>1){
userid_rpos2=userid_rpos[1]
userid_rpos2=userid_rpos2.trim()
//println(userid_rpos)
}

 

// store emp name in variable empname_rpos
def empname_rpos=d[(d.findIndexValues {     it.contains("Full Name"); })]
empname_rpos=empname_rpos[0].split(':')
if(empname_rpos.size()>1){
empname_rpos2=empname_rpos[1]
empname_rpos2=empname_rpos2.trim()
//println(empname_rpos)
}

 

//firstname is same as fullname
fempname_rpos2=empname_rpos2

 

//role mapping
def role=d[(d.findIndexValues {     it.contains("Role/Permission"); })]
role=role[0].split(':')
if(role.size()>1){
role2=role[1]
role2=role2.trim()
}
if(role2=="HQ/Corporate Manager"){
work_group_id="4"
}
else if(role2=="Store Manager"){
work_group_id="5"
}
else if(role2=="Store Supervisor"){
work_group_id="6"
}
else if(role2=="Staff/Sales Associates"){
work_group_id="7"
}
else if(role2==""){
work_group_id="50"
}
else{
work_group_id="10"
}
//print(work_group_id)}
//print(role)

// store Requestor ID in variable reqid2
def reqid=inputMap."Requestor ID"
reqid2=reqid.trim()
 

// Mapping the server, schema and status of respective store id with the help of reference table
def func1 = { table, identifier1->
def resultSet = RefDataQuery.from(table).select(identifier1).where(RefDataCriteria.exp("STORE ID").equalTo(storeid2)).execute()
def retVal = []
resultSet.each { val ->
retVal << val.get(identifier1)
}
return retVal
}
def var4 = [];
def var1 = [];
def var2 = [];
var4=func1.call("CelcomRPOS","SCHEMA NAME")
var1=func1.call("CelcomRPOS","RBO SERVER")
var2=func1.call("CelcomRPOS","STATUS")
def Server1=var1[0];
def Schema1=var4[0];
def Status1=var2[0];
def RBO_Server=Server1.toString();
def RBO_Schema=Schema1.toString();
def RBO_Status=Status1.toString();

 


// Mapping the hostname of respective dB with the help of reference table
def HostMapping = { table, identifier1->
def resultSet = RefDataQuery.from(table).select(identifier1).where(RefDataCriteria.exp("DB NAME").equalTo(RBO_Server)).execute()
def retVal = []
resultSet.each { val ->
retVal << val.get(identifier1)
}
return retVal
}
def var5 = [];
var5=HostMapping.call("rpos_tc_hostnames","HOSTNAME")
def temp=var5[0];
def hostname=temp.toString();

 
def t=".celcom.com.my"
if ((hostname == null || hostname == "null" || hostname == "" || hostname == " ")){
  hostname="null"
}
else if(!(hostname.contains(t))){
hostname=hostname+t
hostname=hostname.trim()
//println(hostname)
}




//mapping variables
inputMap.put("loginidvar",userid_rpos2)
inputMap.put("hostnamevar",hostname)
inputMap.put("dbvar",RBO_Server)
inputMap.put("schemavar",RBO_Schema)
inputMap.put("empnamevar",empname_rpos2)
inputMap.put("fempnamevar",fempname_rpos2)
inputMap.put("lempnamevar",lempname_rpos2)
inputMap.put("workgroupidvar",work_group_id)
inputMap.put("storeidvar",storeid2)
//def email1="svc_ignio@celcom.com.my"
def email1=inputMap."Customer Internet E-mail"
inputMap.put("emailvar",email1)
//check if status is active, login id, store id and empname are not null
//if(userid_rpos2 !="" && storeid2 !="" && empname_rpos2 !="" && work_group_id !="10" && work_group_id !="50" && email1 && RBO_Server != null && RBO_Server!="null" && RBO_Server!="" && RBO_Server!=" ")
if(userid_rpos2 !="" && storeid2 !="" && empname_rpos2 !="" && work_group_id !="10" && work_group_id !="50" && email1 && userid_rpos2.equalsIgnoreCase(reqid2) && directWO !=null)
{
inputMap.item="NewID_rpos"
}
}
//================================================================ENDOF RPOS NEW USER=================================================================

else{
inputMap.item = "XYZZ"
}