• User will upload docs with metadata, will direct at Admin.

  • OpenKM has many interesting features, but requires some configuration process to show its full potential.
OpenKM has many interesting features, but requires some configuration process to show its full potential.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #43809  by jujustine21
 
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 --------------
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: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);
--------------STORE REQB----------------------
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.
 #43820  by jllort
 
Do small diagram of what you are trying to do ( small and simplified ). With a single sample. Life cycle of document A.
I do not like much you are using database query all the time and we do not suggest doing it from database except in exceptional cases. Almost things can be done with Automation + API combination. But before starting with this big messi, share with us small and simplified diagram and then will try to give you some clues about how doing it.
 #43822  by jujustine21
 
I'm so sorry sir for my recent post.
This is what i have done in my project.

I. The Main Admin as ADMINISTRATOR.
- he has only TAXONOMY and TRASH on his user_profile, let's call it (CDI ADMIN).

download/file.php?mode=view&id=1842

- has a folder named "APPROVED"
- he has an access on other Area Managers.

download/file.php?mode=view&id=1843

II. Area MANAGERS
- he has the same user_profile as MAIN ADMIN, but has limited view on folders, unlike MAIN ADMIN. ex. MAIN1 has only access on MAIN1, MAIN2 to MAIN2, etc.

- has 2 main folders, under each folder has 1 subfolder.

download/file.php?mode=view&id=1844

- has an acces on folder named "APPROVED"
III. STORES
- has a user_profile (below)

download/file.php?mode=view&id=1847

FLOW OF THE PROJECT.
1. REQUESTING (I've done this)
If a STORE wants to request (for supply, for example)(There are two types of requests.) the STORE will upload a file at whether APO or DA REQUEST. And their MANAGERS will have the copy. So in this problem, i found a solution how to do this. I created 3 different profile_name same as the USERNAME of the managers. MY 3 MANAGERS are, MAIN1, MAIN2,and MAIN3. so i created 3 profile named MAIN1, MAIN2, MAIN3. So at automation i created 8 events. (triggered at doc_create)
These are the 8 events.
-STORE APO_REQUEST - in this rule, if the STORE uploads a APO_REQUEST, they will fill up the following metadata.
-STORE DA_REQUEST - if the STORE uploads a DA_REQUEST
-DIRECT_APO_AT_MAIN1 - in this rule, when a REQUEST uploaded, the MANAGER will have that copy (together with metadata) Validations are (1. If the doc is uploaded at APO_FOR_APPROVAL folder and 2. If the USER has profile named MAIN1)
ACTIONS are (THE MANAGER WILL HAVE THE COPY with metadata)
-DIRECT_APO_AT_MAIN2,MAIN3 same as above
-DIRECT_DA_AT_MAIN1,MAIN2,MAIN3 -in this rule, when a REQUEST uploaded, the MANAGER will have that copy (together with metadata) Validations are (1. If the doc is uploaded at DA_FOR_APPROVAL folder and 2. If the USER has profile named MAIN1)
ACTIONS are (THE MANAGER WILL HAVE THE COPY with metadata).

2. APPROVING (THIS IS WHERE I GOT CONFUSED)
When manager will approve the request, he's going to the APPROVED folder then upload a file with a different metadata, same filename as the request, and the STORE who requests will have a copy.

That's why i'm asking about, how can i have the metadata as a string on automation execute scripting so that if i am going to copy the approved file it is going directly to the STORE who requests it.

THANK YOU VERY MUCH, all suggestions will do.
Attachments
5.png
5.png (46.79 KiB) Viewed 3451 times
4.png
4.png (67.02 KiB) Viewed 3451 times
3.png
3.png (54.43 KiB) Viewed 3451 times
2.png
2.png (14.24 KiB) Viewed 3451 times
1.png
1.png (46.87 KiB) Viewed 3451 times
 #43823  by jujustine21
 
Sir I just want to add some questions, what is the best way to create folders automatically each time the admin creates multiple accounts.
For example, if i create a new user, that user will have folders automatically. This is related to my project sir. Is it, automation? workflow? or what?
 #43828  by jujustine21
 
Hi Sir jllort,

I searched all topics that may affect my problems here. I found one, but i can't understand it well. The title of that topic is List<FormElement> by matt81.
I have the same problem, i want to get the property value of a doc as a string. As what i've posted a while ago, if one of the ADMINS will approve, he will upload a file to the APPROVED folder at okm:root, then he's going to fill up the metadata (STORE NAME), then i want to retrieve what the admin wrote on that property group.
Then i will copy the doc using
OKMDocument.getInstance().copy(null, path, "okm:personal/"+propertyValue(STORE's NAME)+"/APO_APPORVED or DA_APPROVED);
 #43850  by jllort
 
I do not know what you understanding for " share with us small and simplified diagram", obviously what you think about it and what I think are not the same. Are several ways to solve what seems a workflow problems, some are more manual ( based in protocol what all users must follow ) and another more automatically. Seems the easiest way for doing it is link your logic with metadata value change.

The main problem is that you want to build something very complex but before it you must expend some time doing small test and understanding at least two things : metadata + automation.

About automation ( actions based in events, like metadata change )
https://docs.openkm.com/kcenter/view/ok ... ation.html
https://docs.openkm.com/kcenter/view/ok ... ction.html

To take some control of API classes:
https://docs.openkm.com/kcenter/view/ok ... ption.html

Also I suggest download the openkm portable environment what comes with a sample based with metadata + catalog ( https://sourceforge.net/projects/openkmportabledev/ ).

I'm not sure if for you the best option should be create your own user interface with SDK4j https://docs.openkm.com/kcenter/view/sdk4j-1.1/ ( PHP or .NET ), seems you want to use OpenKM in a very specific way, usualy in this cases the best option is build your own UI, with few feature but focused in the resolution of your problem.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.