public void AutoSelectSinglePath() { // TODO - can we do this for FinishWFT? /*-CONFIG-*/ String m = "AutoSelectSinglePath - "; /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, m + "check for premature Finish Click and single path selection", null, null); // see if the forward paths grid was ever instantiated Datagrid forwardgrid = (Datagrid) getControl(ForwardWorkflowTask.NEXT_TASKS_GRID_CONTROL_NAME); // if not, check how many paths there would be if (null == forwardgrid) { /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, m + "forwardgrid is null, so Finish clicked before selecting a path, see if we can autoselect", null, null); try { /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "get wf task", null, null); IWorkflowTask task = this.getWorkflowTask(); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, m + "get forward activities for task " + task.getActivityName(), null, null); IDfList forwardAct = task.getNextForwardActivities(); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "Get count of next activities", null, null); int count = forwardAct.getCount(); if (1 == count) { /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "only one next activity, so autoselect that one", null, null); // fake it baby IDfTypedObject act = (IDfTypedObject) forwardAct.get(0); String actId = act.getString("r_object_id"); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "id of next activity: " + actId, null, null); String cboxname = "__NEXT_TASKS_CHECKBOX_CONTROL_NAME" + actId; /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, m + "creating fake checkbox for that activity: " + cboxname, null, null); Checkbox cbox = (Checkbox) getControl(cboxname, Checkbox.class); /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, m + "selecting the cbox", null, null); cbox.setValue(true); // dangerous levels of hackitude here... // because the superclass has the "list of next activities" property private and immutable // from this class, I have to resort to this trickery // page == forward forces the superclass to check for selected forward paths. if it's // not forward, it just assumes the list is ready (which its not, and I // can't make it ready since it's frikking PRIVATE. thanks, DCTM /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug( this, m + "set component page to forward so that the super.onCommitChanges call works correcly", null, null); this.setComponentPage("forward"); } } catch (DfException dfe) { throw new RuntimeException("Df Error in single path autoselect", dfe); } } }
public void convert() throws Exception { // select all documents and look for retired and obsolete versions // eff = 3 obs = 4 ret = 6 for NPP // app = 2 for efs? String query = "SELECT r_object_id FROM m_mrcs_efs_central_document WHERE r_current_state = 4 OR r_current_state = 6"; IDfSession session = null; IDfSessionManager sMgr = null; try { IDfClientX clientx = new DfClientX(); IDfClient client = clientx.getLocalClient(); sMgr = client.newSessionManager(); IDfLoginInfo loginInfoObj = clientx.getLoginInfo(); loginInfoObj.setUser("mradmin"); loginInfoObj.setPassword("mr2006"); loginInfoObj.setDomain(null); sMgr.setIdentity("MRCS_Dev", loginInfoObj); } catch (DfException dfe) { dfe.printStackTrace(); } /*-DEBUG-*/ if (DfLogger.isDebugEnabled(this)) DfLogger.debug(this, " ", null, null); // get list of objects that are pdfs... IDfQuery qry = new DfQuery(); qry.setDQL(query); IDfCollection myObj1 = (IDfCollection) qry.execute(session, IDfQuery.DF_READ_QUERY); IDfTypedObject serverConfig = session.getServerConfig(); String aclDomain = serverConfig.getString("operator_name"); IDfACL obsoleteacl = session.getACL(aclDomain, "mrcs_central_archived"); IDfACL retiredacl = session.getACL(aclDomain, "mrcs_central_retired_doc"); while (myObj1.next()) { String curid = myObj1.getString("r_object_id"); // look up object IDfDocument doc = (IDfDocument) session.getObject(new DfId(curid)); // check that it's not a popped off copy (i_folder_id[0] != 'Approved') seems to be the only // indicator of this... IDfFolder folder = (IDfFolder) session.getObject(doc.getFolderId(0)); String foldername = folder.getObjectName(); // don't do this for approved copies... if (!"Approved".equals(foldername)) { // check it's state String statename = doc.getCurrentStateName(); String chronicleid = doc.getChronicleId().getId(); // if In-Progress: simply switch the content type if ("Obsolete".equals(statename)) { String previousquery = "SELECT r_object_id FROM dm_document(all) where i_chronicle_id = '" + chronicleid + "'"; IDfQuery prevqry = new DfQuery(); prevqry.setDQL(previousquery); IDfCollection previousversions = (IDfCollection) prevqry.execute(session, IDfQuery.DF_READ_QUERY); while (previousversions.next()) { String previd = previousversions.getString("r_object_id"); // look up object IDfDocument prevdoc = (IDfDocument) session.getObject(new DfId(previd)); // unlock sMgr.beginTransaction(); try { prevdoc.setString("r_immutable_flag", "FALSE"); prevdoc.save(); prevdoc.fetch(prevdoc.getTypeName()); // necessary? // set flags obsolete = true,retired = false prevdoc.setBoolean("retired", false); prevdoc.setBoolean("obsolete", true); // set acl prevdoc.setACL(obsoleteacl); prevdoc.setString("r_immutable_flag", "TRUE"); prevdoc.save(); } catch (Exception e) { sMgr.abortTransaction(); throw e; } sMgr.commitTransaction(); } previousversions.close(); } if ("Effective".equals(statename)) { String previousquery = "SELECT r_object_id FROM dm_document(all) where i_chronicle_id = '" + chronicleid + "'"; IDfQuery prevqry = new DfQuery(); prevqry.setDQL(query); IDfCollection previousversions = (IDfCollection) qry.execute(session, IDfQuery.DF_READ_QUERY); while (previousversions.next()) { String previd = previousversions.getString("r_object_id"); // look up object IDfDocument prevdoc = (IDfDocument) session.getObject(new DfId(previd)); // unlock String currentstate = prevdoc.getCurrentStateName(); if ("Retired".equals(currentstate)) { sMgr.beginTransaction(); try { prevdoc.setString("r_immutable_flag", "FALSE"); prevdoc.save(); prevdoc.fetch(prevdoc.getTypeName()); // necessary? // set flags obsolete = true,retired = false prevdoc.setBoolean("retired", true); prevdoc.setBoolean("obsolete", false); // set acl prevdoc.setACL(retiredacl); prevdoc.setString("r_immutable_flag", "TRUE"); prevdoc.save(); } catch (Exception e) { sMgr.abortTransaction(); throw e; } sMgr.commitTransaction(); } } previousversions.close(); } } } myObj1.close(); sMgr.release(session); }