Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit e3a0424

Browse files
committed
Adding new virtual table for Scheduling Properties
1 parent bdebdfd commit e3a0424

File tree

9 files changed

+329
-8
lines changed

9 files changed

+329
-8
lines changed

source/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ The sample consists of the following subfolders:
77
sap.sample.cmsdbdriver.plugin | Java | Custom Plug-in, exposing virtual Table(s)
88
sap.sample.cmsdbdriver.core | Java | Help you to use the CMS Data Access Driver SDK in your plug-in with simple methodes
99
com.sap.sample.boe.services | Java | Help you to use the BOE REST API in your plug-in
10-
sap.sample.deploy | Helper | Export content to LCMBIAR or export Java to JARs
10+
sap.sample.deploy | Helper | Export content to LCMBIAR or export Java to JARs
11+
sap.sample.test | JUnit | Sample test to read the InfoObjects Scheduling properties

source/sap.sample.cmsdbdriver.plugin/.classpath

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
<classpath>
33
<classpathentry kind="src" path="src"/>
44
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
5-
<classpathentry kind="var" path="BOE_HOME"/>
5+
<classpathentry exported="true" kind="var" path="BOE_HOME"/>
66
<classpathentry kind="var" path="BOE_HOME/dataAccess/connectionServer/drivers/java/dbd_sap_java_drivers_sdk.jar"/>
77
<classpathentry kind="var" path="BOE_HOME/dataAccess/connectionServer/drivers/java/dbd_sapbicms.jar"/>
88
<classpathentry kind="var" path="BOE_HOME/java/lib/ConnectionServer.jar"/>
9-
<classpathentry kind="var" path="BOE_HOME/java/lib/cecore.jar"/>
10-
<classpathentry kind="var" path="BOE_HOME/java/lib/celib.jar"/>
9+
<classpathentry exported="true" kind="var" path="BOE_HOME/java/lib/cecore.jar"/>
10+
<classpathentry exported="true" kind="var" path="BOE_HOME/java/lib/celib.jar"/>
1111
<classpathentry kind="var" path="BOE_HOME/dataAccess/connectionServer/drivers/java/cs_sqlparser.jar"/>
12-
<classpathentry kind="var" path="BOE_HOME/java/lib/logging.jar"/>
13-
<classpathentry kind="var" path="BOE_HOME/java/lib/json.jar"/>
14-
<classpathentry combineaccessrules="false" kind="src" path="/sap.sample.cmsdbdriver.core"/>
15-
<classpathentry combineaccessrules="false" kind="src" path="/com.sap.sample.boe.services"/>
12+
<classpathentry exported="true" kind="var" path="BOE_HOME/java/lib/logging.jar"/>
13+
<classpathentry exported="true" kind="var" path="BOE_HOME/java/lib/json.jar"/>
14+
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/sap.sample.cmsdbdriver.core"/>
15+
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/com.sap.sample.boe.services"/>
1616
<classpathentry kind="output" path="bin"/>
1717
</classpath>

source/sap.sample.cmsdbdriver.plugin/src/sap/sample/cmsdbdriver/plugin/custom/Plugin.java

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public Plugin(final CMSDriverConnection connection) {
2121
pluginBase = new PluginBase(connection);
2222
pluginBase.addTable(new TemplateTableResults(pluginBase));
2323
pluginBase.addTable(new RestJSONTableResults(pluginBase));
24+
pluginBase.addTable(new ScheduleInfoTableResults(pluginBase));
2425
}
2526

2627
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
package sap.sample.cmsdbdriver.plugin.custom;
2+
3+
import java.sql.Types;
4+
import java.util.HashMap;
5+
import java.util.List;
6+
import java.util.Map;
7+
import java.util.Set;
8+
9+
import com.crystaldecisions.sdk.occa.infostore.CePropertyID;
10+
import com.crystaldecisions.sdk.occa.infostore.IDestination;
11+
import com.crystaldecisions.sdk.occa.infostore.IDestinations;
12+
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
13+
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
14+
import com.crystaldecisions.sdk.occa.infostore.IProcessingInfo;
15+
import com.crystaldecisions.sdk.occa.infostore.ISchedulingInfo;
16+
import com.crystaldecisions.sdk.properties.IProperties;
17+
import com.crystaldecisions.sdk.properties.IProperty;
18+
import com.sap.connectivity.cs.java.drivers.cms.CMSDBDriverException;
19+
import com.sap.connectivity.cs.java.drivers.cms.api.CustomObject;
20+
import com.sap.connectivity.cs.java.drivers.cms.api.IQueryElement;
21+
import com.sap.connectivity.cs.java.drivers.sdk.datafoundation.IUnvTable;
22+
import com.sap.connectivity.cs.java.drivers.sdk.datafoundation.UnvTableFieldDef;
23+
import com.sap.connectivity.cs.sqlparser.Condition.Operand;
24+
25+
import sap.sample.cmsdbdriver.plugin.core.IResultPlugin;
26+
import sap.sample.cmsdbdriver.plugin.core.IResultTable;
27+
import sap.sample.cmsdbdriver.plugin.core.PluginBase;
28+
29+
public class ScheduleInfoTableResults extends IResultTable implements IUnvTable {
30+
31+
private static final String TABLE_NAME = "ScheduleInfo";
32+
33+
private static final String NO = "no";
34+
private static final String DETAILS = "Details";
35+
private static final String VALUE = "PropertyValue";
36+
private static final String LEVEL = "PropertyLevel";
37+
private static final String PATH = "PropertyPath";
38+
private static final String NAME = "PropertyName";
39+
private static final String IS_CONTAINER = "PropertyIsContainer";
40+
41+
final private PluginBase pluginBase;
42+
43+
final private Map<String, UnvTableFieldDef> columns = new HashMap<String, UnvTableFieldDef>();
44+
private String queryFields;
45+
46+
/**
47+
* Define the list of Fields for the virtual table
48+
*/
49+
public ScheduleInfoTableResults(IResultPlugin plugin) {
50+
super(plugin);
51+
columns.put(NO, new UnvTableFieldDef(NO, Types.INTEGER));
52+
columns.put(DETAILS, new UnvTableFieldDef(DETAILS, Types.VARCHAR));
53+
pluginBase = (PluginBase)plugin;
54+
55+
}
56+
57+
/**
58+
* Returns the name of the virtual table
59+
* @return virtual table name
60+
*/
61+
@Override
62+
public String getName() {
63+
return TABLE_NAME;
64+
}
65+
66+
@Override
67+
/**
68+
* Returns the fields defined for the virtual table
69+
* @return list of table fields
70+
*/
71+
public Map<String, UnvTableFieldDef> getTableFields() {
72+
return this.columns;
73+
}
74+
75+
@Override
76+
/**
77+
* use the getQueryElement() or getIds() to prepare data for setValues()
78+
*/
79+
public void initialize(IQueryElement queryElement, Set<Integer> ids) {
80+
// nothing to initialize/prepare
81+
queryFields = "";
82+
for (int i=0; i<queryElement.getCondition().operands().size(); i++) {
83+
if (queryElement.getCondition().operands().get(i).toString().contentEquals(TABLE_NAME + "." + DETAILS)) {
84+
queryFields = queryElement.getCondition().operands().get(i + 1).toString();
85+
queryFields = queryFields.trim().replaceAll("'", "").replaceAll("\\s+", ",");
86+
}
87+
}
88+
}
89+
90+
91+
@Override
92+
public void setValues(int id) throws CMSDBDriverException {
93+
IInfoObjects infoObjects = pluginBase.getConnection().queryCMS("select si_id, " + queryFields + " from ci_infoobjects where si_id = " + id);
94+
// should not be the case
95+
if (infoObjects == null) return;
96+
if (infoObjects.size() == 0) return;
97+
IInfoObject infoObject = (IInfoObject)infoObjects.get(0);
98+
//IProperties properties = infoObject.properties().getProperties(CePropertyID.SI_DESTINATIONS);
99+
100+
String fields[] = queryFields.split(",");
101+
for (int i=0; i<fields.length; i++) {
102+
fields[i] = fields[i].trim();
103+
String[] subFields = fields[i].split("\\.");
104+
if (subFields[0].equalsIgnoreCase("si_scheduleinfo")) {
105+
ISchedulingInfo sInfo = infoObject.getSchedulingInfo();
106+
if (subFields.length == 1) {
107+
setValues(id, "SchedulingInfo", sInfo.properties(), 0, "");
108+
} else {
109+
IProperty prop = sInfo.properties().getProperty(subFields[1]);
110+
if (prop != null) {
111+
if (prop.isContainer()) {
112+
setValues(id, "SchedulingInfo", (IProperties)prop.getValue(), 1, CePropertyID.idToName(prop.getID()));
113+
} else {
114+
if (getCustomObject() == null) setCustomObject(new CustomObject());
115+
setObjectProperties("SchedulingInfo", 1, "", prop);
116+
addRow(id);
117+
}
118+
}
119+
}
120+
} else if (subFields[0].equalsIgnoreCase("si_processinfo")) {
121+
IProcessingInfo pInfo = infoObject.getProcessingInfo();
122+
if (subFields.length == 1) {
123+
setValues(id, "ProcessingInfo", pInfo.properties(), 0, "");
124+
} else {
125+
IProperty prop = pInfo.properties().getProperty(subFields[1]);
126+
if (prop != null) {
127+
if (prop.isContainer()) {
128+
setValues(id, "ProcessingInfo", (IProperties)prop.getValue(), 1, CePropertyID.idToName(prop.getID()));
129+
} else {
130+
if (getCustomObject() == null) setCustomObject(new CustomObject());
131+
setObjectProperties("ProcessingInfo", 1, "", prop);
132+
addRow(id);
133+
}
134+
}
135+
}
136+
}
137+
}
138+
}
139+
140+
private void setValues(int id, String text, IProperties properties, int level, String path) throws CMSDBDriverException {
141+
String s = "";
142+
Set<Integer> keys = properties.keySet();
143+
for (int key : keys) {
144+
if (getCustomObject() == null) setCustomObject(new CustomObject());
145+
IProperty prop = properties.getProperty(key);
146+
setObjectProperties(text, level, path, prop);
147+
if (prop.isContainer()) {
148+
setValues(id, text, (IProperties)prop.getValue(), level + 1, path + (path.length() > 0 ? "." : "") + CePropertyID.idToName(prop.getID()));
149+
} else {
150+
addRow(id);
151+
}
152+
}
153+
}
154+
155+
private void setObjectProperties(String text, int level, String path, IProperty prop) {
156+
setObjectProperty(TABLE_NAME + "." + ScheduleInfoTableResults.DETAILS,
157+
String.class.getName(), text);
158+
setObjectProperty(TABLE_NAME + "." + ScheduleInfoTableResults.LEVEL,
159+
Integer.class.getName(), level);
160+
setObjectProperty(TABLE_NAME + "." + ScheduleInfoTableResults.PATH,
161+
String.class.getName(), path);
162+
setObjectProperty(TABLE_NAME + "." + ScheduleInfoTableResults.NAME,
163+
String.class.getName(), CePropertyID.idToName(prop.getID()));
164+
setObjectProperty(TABLE_NAME + "." + ScheduleInfoTableResults.IS_CONTAINER,
165+
Boolean.class.getName(), prop.isContainer());
166+
if (prop.isContainer()) return;
167+
setObjectProperty(TABLE_NAME + "." + ScheduleInfoTableResults.VALUE,
168+
String.class.getName(), "" + prop.getValue());
169+
170+
}
171+
}
172+

source/sap.sample.test/.classpath

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4+
<classpathentry kind="src" path="src"/>
5+
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
6+
<classpathentry combineaccessrules="false" kind="src" path="/sap.sample.cmsdbdriver.plugin"/>
7+
<classpathentry kind="output" path="bin"/>
8+
</classpath>

source/sap.sample.test/.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>sap.sample.test</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/org.eclipse.jdt.core.prefs

source/sap.sample.test/bin/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Test/
+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package Test;
2+
3+
import java.util.Set;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
import com.crystaldecisions.sdk.exception.SDKException;
8+
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
9+
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
10+
import com.crystaldecisions.sdk.framework.ISessionMgr;
11+
import com.crystaldecisions.sdk.occa.infostore.CePropertyID;
12+
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
13+
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
14+
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
15+
import com.crystaldecisions.sdk.occa.infostore.IProcessingInfo;
16+
import com.crystaldecisions.sdk.occa.infostore.ISchedulingInfo;
17+
import com.crystaldecisions.sdk.plugin.authentication.enterprise.IsecEnterpriseBase;
18+
import com.crystaldecisions.sdk.properties.IProperties;
19+
import com.crystaldecisions.sdk.properties.IProperty;
20+
21+
class test {
22+
23+
private static String USER = "administrator";
24+
private static String PASSWORD = "Password1";
25+
private static String CMS = "localhost";
26+
//private static String CMS = "AURORA42-CONS";
27+
28+
private static ISessionMgr sessionMgr = null;
29+
private static IEnterpriseSession eSession = null;
30+
private IInfoStore infoStore;
31+
32+
@Test
33+
void test() throws SDKException {
34+
sessionMgr = CrystalEnterprise.getSessionMgr();
35+
eSession = sessionMgr.logon(USER, PASSWORD, CMS, IsecEnterpriseBase.PROGID);
36+
infoStore = (IInfoStore)eSession.getService("InfoStore");
37+
query(8555, "si_scheduleinfo.si_destinations si_scheduleInfo.si_name si_processinfo");
38+
eSession.logoff();
39+
}
40+
41+
private void workOn(IProperties properties, int level, String path) {
42+
String s = "";
43+
Set<Integer> keys = properties.keySet();
44+
for (int key : keys) {
45+
IProperty prop = properties.getProperty(key);
46+
// System.out.println(prop.isContainer() + ": " + prop.toString());
47+
if (prop.isContainer()) {
48+
System.out.println(level + " - true - " + path + " - " + CePropertyID.idToName(prop.getID()));
49+
workOn((IProperties)prop.getValue(), level + 1, path + (path.length() > 0 ? "\\" : "") + CePropertyID.idToName(prop.getID()));
50+
} else {
51+
System.out.println(level + " - false - " + path + " - " + CePropertyID.idToName(prop.getID()) + ": " + prop.getValue());
52+
}
53+
}
54+
55+
/* for (int i=0; i<properties.size(); i++) {
56+
s = CePropertyID.idToName(prop.getID()) + " : " + prop.isContainer();
57+
}
58+
*/ }
59+
60+
private void query(int id, String field) throws SDKException {
61+
62+
String[] condFields = field.split(" ");
63+
field = field.trim().replaceAll("'", "").replaceAll("\\s+", ",");
64+
65+
//IInfoObjects infoObjects = infoStore.query("select si_id, si_scheduleinfo.si_destinations from ci_infoobjects where si_id = " + id);
66+
IInfoObjects infoObjects = infoStore.query("select si_id, " + field + " from ci_infoobjects where si_id = " + id);
67+
// should not be the case
68+
if (infoObjects == null) return;
69+
if (infoObjects.size() == 0) return;
70+
IInfoObject infoObject = (IInfoObject)infoObjects.get(0);
71+
//IProperties properties = infoObject.properties().getProperties(CePropertyID.SI_DESTINATIONS);
72+
73+
//properties = properties.getProperties("si_destinations");
74+
String s = "";
75+
outProperties("query", infoObject.properties());
76+
IProperty prop = infoObject.properties().getProperty("si_scheduleInfo");
77+
78+
String fields[] = field.split(",");
79+
for (int i=0; i<fields.length; i++) {
80+
fields[i] = fields[i].trim();
81+
String[] subFields = fields[i].split("\\.");
82+
if (subFields[0].equalsIgnoreCase("si_scheduleinfo")) {
83+
ISchedulingInfo sInfo = infoObject.getSchedulingInfo();
84+
if (subFields.length == 1) {
85+
outProperties("SchedulingInfo", sInfo.properties());
86+
} else {
87+
prop = sInfo.properties().getProperty(subFields[1]);
88+
if (prop.isContainer()) {
89+
outProperties("ScheduleInfo." + CePropertyID.idToName(prop.getID()), (IProperties)prop.getValue());
90+
} else {
91+
System.out.println(CePropertyID.idToName(prop.getID()) + " = " + prop.getValue());
92+
}
93+
}
94+
} else if (subFields[0].equalsIgnoreCase("si_processinfo")) {
95+
IProcessingInfo pInfo = infoObject.getProcessingInfo();
96+
if (subFields.length == 1) {
97+
outProperties("ProcessingInfo", pInfo.properties());
98+
} else {
99+
prop = pInfo.properties().getProperty(subFields[1]);
100+
if (prop.isContainer()) {
101+
outProperties("ProcessingInfo." + CePropertyID.idToName(prop.getID()), (IProperties)prop.getValue());
102+
} else {
103+
System.out.println(CePropertyID.idToName(prop.getID()) + " = " + prop.getValue());
104+
}
105+
}
106+
107+
}
108+
}
109+
}
110+
111+
112+
private void outProperties(String text, IProperties properties) {
113+
System.out.println("---> " + text);
114+
Set<Integer> keys = properties.keySet();
115+
for (int key : keys) {
116+
System.out.println(CePropertyID.idToName(key));
117+
}
118+
119+
}
120+
}

0 commit comments

Comments
 (0)