Skip to main content
1-Visitor
July 24, 2012
Question

Disable Container Level OIR's

  • July 24, 2012
  • 13 replies
  • 2058 views

OIR question.


At my current client location, they have a wc10.1 OIR disable at container level issue.


For whatever reason, they have like 50 containers with 10 different OIR's.


They now want to override & disable those 50 or so, with 10 new ORG level
OIR's, that they will loadfromfile create.

Obviously they dont want to manually select disable for 500 OIR's from the interface.


I'll assume that you cant change the container level OIR's to disabled
through loadfronfile, but I could be wrong.


Does anybody know the route to diable those. LoadFromFile, coding, ???


Thanks
L Jett

13 replies

cadjett1-VisitorAuthor
1-Visitor
July 27, 2012

Here is the updated code, so I/others can query the classes/methods later.

I use /**/ instead of tabs (before each line), so its more legible & wont word wrap oddly in your editor:

package ext;

import java.io.*;
import java.text.*;
import java.sql.*;
import java.net.*;
import java.util.*;
import java.lang.*;

import java.sql.PreparedStatement;

import wt.pds.DatabaseInfoUtilities;
import wt.pds.PDSIfc;
import wt.pom.*;

import wt.util.WTException;
import wt.fc.collections.*;

public class OIR_Disable_01 {
/**/public static void main(String args[]) {

/**//**/Statement statement;
/**//**/ResultSet resultset;
/**//**/statement = null;
/**//**/resultset = null;

/**//**/try {
/**//**//**/statement = connection.createStatement();
/**//**//**/String s,s1,s2,s3;
/**//**//**/idStg=";

/**//**//**/for(resultset = statement.executeQuery("Select Name, CLASSNAMEKEYCONTAINERREFEREN, IDA2A2, ENABLEDFLAG from TYPEBASEDRULE WHERE CLASSNAMEKEYCONTAINERREFEREN='wt.inf.container.OrgContainer' AND ENABLEDFLAG='0"); resultset.next();) {
/**//**//**//**/s = resultset.getString("Name");
/**//**//**//**/s1 = resultset.getString("CLASSNAMEKEYCONTAINERREFEREN");
/**//**//**//**/s2 = resultset.getString("IDA2A2");
/**//**//**//**/s3 = resultset.getString("ENABLEDFLAG");

/**//**//**//**/idStg = idStg+s2+",";

/**//**//**//**/System.out.println((new StringBuilder()).append("\nName: ").append(s).append("\n\tContainer: ").append(s1).toString());
/**//**//**//**/System.out.println((new StringBuilder()).append("\tIDA2A2: ").append(s2).append("\n\tENABLEDFLAG: ").append(s3).toString());
/**//**//**/}

/**//**//**/idStgFull = idStg.substring(0,idStg.length()-1);
/**//**//**/System.out.println("idStgFull: "+idStgFull);

/**//**//**/String ps1;

/**//**//**/ps1 = (new StringBuilder()).append("UPDATE TYPEBASEDRULE SET enabledFlag=1 WHERE IDA2A2 in (").append(idStgFull).append(")").toString();

/**//**//**/System.out.println("SQL Update Stg: "+ps1);
/**//**//**/preparedstatement = connection.prepareStatement(ps1);
/**//**//**/preparedstatement.executeUpdate();
/**//**//**/connection.commit();
/**//**/}
/**//**/catch(SQLException sqlexception1) {
/**//**//**/System.out.println("SQLException while executing startQuery: "+sqlexception1);
/**//**//**/sqlexception1.printStackTrace();
/**//**/}

/**//**/try {
/**//**//**/if(resultset != null)
/**//**//**//**/resultset.close();
/**//**//**/if(statement != null)
/**//**//**//**/statement.close();
/**//**//**/if(preparedstatement != null)
/**//**//**//**/preparedstatement.close();
/**//**/}
/**//**/catch(SQLException sqlexception) {
/**//**//**/System.out.println("SQLException while executing startQuery: "+sqlexception);
/**//**//**/sqlexception.printStackTrace();
/**//**/}
}

/**/static Connection connection;
/**/static PreparedStatement preparedstatement;
/**/static String idStgFull, idStg;

/**/static {
/**//**/try {
/**//**//**/connection = DataServicesRegistry.getDefault().getPdsFor("DEFAULT").getDataSource().getConnection();
/**//**/}
/**//**/catch(Throwable throwable) {
/**//**//**/throw new ExceptionInInitializerError(throwable);
/**//**/}
/**/}
}


Basically the sql is:

Select Name, CLASSNAMEKEYCONTAINERREFEREN, IDA2A2, ENABLEDFLAG from TYPEBASEDRULE WHERE CLASSNAMEKEYCONTAINERREFEREN='wt.inf.container.OrgContainer' AND ENABLEDFLAG='0'

Take IDA2A2's into array & use in Update sql.

UPDATE TYPEBASEDRULE SET enabledFlag=1 WHERE IDA2A2 in (0001,0002)

L Jett

cadjett1-VisitorAuthor
1-Visitor
July 28, 2012

The last code was good for testing & printing query before run.

The code below might be a more direct Update sql route, where you dont need to log.

Again using /**/ instead of tab for clarity. Just find/replace /**/ with tabs or ?


package ext;


import java.io.*;
import java.text.*;
import java.sql.*;
import java.net.*;
import java.util.*;
import java.lang.*;


import java.sql.PreparedStatement;


import wt.pds.DatabaseInfoUtilities;
import wt.pds.PDSIfc;
import wt.pom.*;


public class FMCNA_OIR_Disable_02 {
/**/public static void main(String args[]) {
/**//**/try {
/**//**//**/String ps1 = ("UPDATE TYPEBASEDRULE SET enabledFlag=1 WHERE CLASSNAMEKEYCONTAINERREFEREN='wt.inf.container.OrgContainer' AND ENABLEDFLAG='0");


/**//**//**/System.out.println("SQL Update Stg: "+ps1);
/**//**//**/preparedstatement = connection.prepareStatement(ps1);
/**//**//**/preparedstatement.executeUpdate();
/**//**//**/connection.commit();
/**//**/}
/**//**/catch(SQLException sqlexception1) {
/**//**//**/System.out.println("SQLException while executing startQuery: "+sqlexception1);
/**//**//**/sqlexception1.printStackTrace();
/**//**/}


/**//**/try {
/**//**//**/if(preparedstatement != null)
/**//**//**//**/preparedstatement.close();
/**//**/}
/**//**/catch(SQLException sqlexception) {
/**//**//**/System.out.println("SQLException while executing startQuery: "+sqlexception);
/**//**//**/sqlexception.printStackTrace();
/**//**/}
/**/}


/**/static Connection connection;
/**/static PreparedStatement preparedstatement;


/**/static {
/**//**/try {
/**//**//**/connection = DataServicesRegistry.getDefault().getPdsFor("DEFAULT").getDataSource().getConnection();
/**//**/}
/**//**/catch(Throwable throwable) {
/**//**//**/throw new ExceptionInInitializerError(throwable);
/**//**/}
/**/}
}


L Jett

cadjett1-VisitorAuthor
1-Visitor
July 28, 2012

Or straight sql:

UPDATE TYPEBASEDRULE SET enabledFlag=1 WHERE CLASSNAMEKEYCONTAINERREFEREN='wt.inf.container.OrgContainer' AND ENABLEDFLAG='0';
commit;