Hi to all of you, i need help with the following issues regarding with the project that i'm doing right now.
The project is simply, like a "store branches" to "main office" relationship.
3 ADMINS. EACH ADMIN HAS 2 Branches. (ADMIN A - store1,store2 ADMIN B- store3,store4 etc.)
EACH BRANCHES HAS 2 main folders (req A and req B), same as ADMINS.
When "store branches" upload docs (with metadata) , his boss will have that copy (with metadata). In my project the store branches has 2 types of requests, when the store uploads at reqA, his boss will have that copy at reqA too, respectively.
I don't know why at reqB the docs simply copied but not the metadata. but on reqA i completed it.
------------STORE UPLOADS REQ A --------------
I JUST SIMPLY COPY PASTE THEN EDIT SOME DATA.
PLSS HELP ME, SORRY FOR THE MESSY MESSAGE. THANKS A LOT.
The project is simply, like a "store branches" to "main office" relationship.
3 ADMINS. EACH ADMIN HAS 2 Branches. (ADMIN A - store1,store2 ADMIN B- store3,store4 etc.)
EACH BRANCHES HAS 2 main folders (req A and req B), same as ADMINS.
When "store branches" upload docs (with metadata) , his boss will have that copy (with metadata). In my project the store branches has 2 types of requests, when the store uploads at reqA, his boss will have that copy at reqA too, respectively.
I don't know why at reqB the docs simply copied but not the metadata. but on reqA i completed it.
------------STORE UPLOADS REQ A --------------
Code: Select all
--------------STORE REQB----------------------
import com.openkm.dao.*;
import com.openkm.bean.*;
import com.openkm.util.*;
import com.openkm.api.*;
import java.sql.*;
import org.hibernate.*;
import com.openkm.core.*;
import java.sql.ResultSet;
import com.openkm.spring.PrincipalUtils;
import com.openkm.automation.AutomationUtils;
String storeName,returnSlipNo,dateRequest;
String userProfile;
//Connects to the database
Session hbmSession = HibernateUtil.getSessionFactory().openSession();
Connection con = LegacyDAO.getConnection();
Statement st = con.createStatement();
//Variable declaration
String month,day,year,time;
String sql="";
String fileName = "";
String propertyGroup="okg:req",propertyName="okp.reqstore";
//Gets the name of the recently uploaded file from the database
String query = "SELECT * FROM okm_node_base where NBS_UUID='"+uuid+"'";
ResultSet rs = st.executeQuery(query);
rs.next();
fileName = rs.getString("NBS_NAME");
//Specifies the full path of the file
String path = "/okm:personal/"+userId+"/APO_REQUEST/";
path=path+fileName;
returnSlipNo=fileName;
//Gets the Name of the logged in user
query = "SELECT * FROM okm_user WHERE USR_ID='"+userId+"'";
rs = st.executeQuery(query);
rs.next();
storeName = rs.getString("USR_NAME");
//Gets the date when the file was uploaded
query = "SELECT * FROM okm_node_base WHERE NBS_UUID='"+uuid+"'";
rs = st.executeQuery(query);
rs.next();
dateRequest = rs.getString("NBS_CREATED");
//Sets the property group of the file
OKMPropertyGroup.getInstance().addGroup(null, path, "okg:req");
//Sets the Name of the user as the store name
sql = "UPDATE okm_node_property set NPG_VALUE='"+storeName+"' where NPG_NODE='"+uuid+
"' AND NPG_NAME = '"+propertyName+"' AND NPG_GROUP = '"+propertyGroup+"'";
st.executeUpdate(sql);
//Sets the name of the file as the Slip No
propertyName = "okp.reqslip";
sql = "UPDATE okm_node_property set NPG_VALUE='"+returnSlipNo+"' where NPG_NODE='"+uuid+
"' AND NPG_NAME = '"+propertyName+"' AND NPG_GROUP = '"+propertyGroup+"'";
st.executeUpdate(sql);
//Adjusts the format of the date to match the format in the property group
month = dateRequest.substring(5,7);
day = dateRequest.substring(8,10);
year = dateRequest.substring(0,4);
time = "000000";
dateRequest = year+month+day+time;
//Sets the date uploaded as date request
propertyName = "okp.reqdate";
sql = "UPDATE okm_node_property set NPG_VALUE='"+dateRequest+"' where NPG_NODE='"+uuid+
"' AND NPG_NAME = '"+propertyName+"' AND NPG_GROUP = '"+propertyGroup+"'";
st.executeUpdate(sql);
path = OKMDocument.getInstance().getPath(null,uuid);
//Copy to root
OKMDocument.getInstance().copy(null, path, "/okm:root/Main1/APO_FOR_APPROVAL");
//Gets the name of the recently uploaded file from the database
query = "SELECT * FROM okm_node_base where NBS_UUID='"+uuid+"'";
rs = st.executeQuery(query);
rs.next();
fileName = rs.getString("NBS_NAME");
//Gets the UUID of the file in taxonomy
query = "SELECT * FROM okm_node_base WHERE NBS_AUTHOR = '"+userId+"' AND NBS_CONTEXT = 'okm_root' "+
"AND NBS_NAME = '"+fileName+"'";
rs = st.executeQuery(query);
rs.next();
String newUuid = rs.getString("NBS_UUID");
path = OKMDocument.getInstance().getPath(null,newUuid);
OKMPropertyGroup.getInstance().addGroup(null, path, propertyGroup);
sql = "INSERT INTO TEMP_UUID VALUES('"+uuid+"','"+newUuid+"')";
st.executeUpdate(sql);
Code: Select all
import com.openkm.dao.*;
import com.openkm.bean.*;
import com.openkm.util.*;
import com.openkm.api.*;
import java.sql.*;
import org.hibernate.*;
import com.openkm.core.*;
import java.sql.ResultSet;
import com.openkm.spring.PrincipalUtils;
import com.openkm.automation.AutomationUtils;
String storeName,returnSlipNo,dateRequest;
String userProfile;
//Connects to the database
Session hbmSession = HibernateUtil.getSessionFactory().openSession();
Connection con = LegacyDAO.getConnection();
Statement st = con.createStatement();
//Variable declaration
String month,day,year,time;
String sql="";
String fileName = "";
String propertyGroup="okg:reqda",propertyName="okp.dareqstore";
//Gets the name of the recently uploaded file from the database
String query = "SELECT * FROM okm_node_base where NBS_UUID='"+uuid+"'";
ResultSet rs = st.executeQuery(query);
rs.next();
fileName = rs.getString("NBS_NAME");
//Specifies the full path of the file
String path = "/okm:personal/"+userId+"/DA_REQUEST/";
path=path+fileName;
returnSlipNo=fileName;
//Gets the Name of the logged in user
query = "SELECT * FROM okm_user WHERE USR_ID='"+userId+"'";
rs = st.executeQuery(query);
rs.next();
storeName = rs.getString("USR_NAME");
//Gets the date when the file was uploaded
query = "SELECT * FROM okm_node_base WHERE NBS_UUID='"+uuid+"'";
rs = st.executeQuery(query);
rs.next();
dateRequest = rs.getString("NBS_CREATED");
//Sets the property group of the file
OKMPropertyGroup.getInstance().addGroup(null, path, "okg:reqda");
//Sets the Name of the user as the store name
sql = "UPDATE okm_node_property set NPG_VALUE='"+storeName+"' where NPG_NODE='"+uuid+
"' AND NPG_NAME = '"+propertyName+"' AND NPG_GROUP = '"+propertyGroup+"'";
st.executeUpdate(sql);
//Sets the name of the file as the Slip No
propertyName = "okp.darnum";
sql = "UPDATE okm_node_property set NPG_VALUE='"+returnSlipNo+"' where NPG_NODE='"+uuid+
"' AND NPG_NAME = '"+propertyName+"' AND NPG_GROUP = '"+propertyGroup+"'";
st.executeUpdate(sql);
//Adjusts the format of the date to match the format in the property group
month = dateRequest.substring(5,7);
day = dateRequest.substring(8,10);
year = dateRequest.substring(0,4);
time = "000000";
dateRequest = year+month+day+time;
//Sets the date uploaded as date request
propertyName = "okp.dareqdate";
sql = "UPDATE okm_node_property set NPG_VALUE='"+dateRequest+"' where NPG_NODE='"+uuid+
"' AND NPG_NAME = '"+propertyName+"' AND NPG_GROUP = '"+propertyGroup+"'";
st.executeUpdate(sql);
path = OKMDocument.getInstance().getPath(null,uuid);
//Copy to root
OKMDocument.getInstance().copy(null, path, "/okm:root/Main1/DA_FOR_APPROVAL");
//Gets the name of the recently uploaded file from the database
query = "SELECT * FROM okm_node_base where NBS_UUID='"+uuid+"'";
rs = st.executeQuery(query);
rs.next();
fileName = rs.getString("NBS_NAME");
//Gets the UUID of the file in taxonomy
query = "SELECT * FROM okm_node_base WHERE NBS_AUTHOR = '"+userId+"' AND NBS_CONTEXT = 'okm_root' "+"AND NBS_NAME = '"+fileName+"'";
rs = st.executeQuery(query);
rs.next();
String newUuid = rs.getString("NBS_UUID");
path = OKMDocument.getInstance().getPath(null,newUuid);
OKMPropertyGroup.getInstance().addGroup(null, path, propertyGroup);
sql = "INSERT INTO TEMP_UUID VALUES('"+uuid+"','"+newUuid+"')";
st.executeUpdate(sql);
I JUST SIMPLY COPY PASTE THEN EDIT SOME DATA.
PLSS HELP ME, SORRY FOR THE MESSY MESSAGE. THANKS A LOT.