|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.irisel.oms.olapi.QuerySave
public class QuerySave
This class is used to make relational queries in 3-tier mode, using a CLBrowser. It is based upon the deprecated class InstanceRetrieval, which was designed for working in 2-tier mode (requiring connectivity with the database server). In contrast, QuerySave uses a CLBrowser (connection-less browser) so it can be used by the J2EE clients too. The intended use is the following: 1) Initialization. The constructor without arguments will use CLGuiomBrowser.getGuiomBrowser() in order to get the browser. Otherwise you can specify an existing CLBrowser. 2A) Adding/Updating Records Add the instances to be saved. You can add individual instances (addInstance) or a set (addInstanceSet). If the OID is zero a new OID will be generated and the record will be inserted. If the OID is different from zero, the record will be updated if exists, otherwise the record will be inserted using that OID. Provide a different branch id (integer type) to identify that instance or instance set that is being added. 2B) Relating Records You can relate records using relateInstances method. To relate to records that you don't want to modify, you need to add those instances in read-only mode (addInstanceRO, addInstanceSetRO). To relate two instances or instance sets you need to provide the branch ids used when calling addInstance(Set) method, you can provide a single integer or an array of integers, and the name of the relation. For OMS-M2M relationships you must specify role names (can be null) and the sense of the relationship (note it is equivalent to use the inverse relationship if you change that boolean too). When relating a set (array) of branches, the behavior for O2O relationship will be to link by pairs, when the relationship is O2M, every element in source list will be linked with all elements in destination array. 3) Performing the operation To perform the operation use the method save(). Alternatively, you can invoke prepareStatements() first, then save(), in order to manage possible exceptions at this point separately from the possible exceptions occuring during the actual save.
Constructor Summary | |
---|---|
QuerySave()
|
|
QuerySave(CLBrowser clb)
|
Method Summary | |
---|---|
void |
addInstance(int id,
Instance i)
Adds a new instance to be created or updated. |
void |
addInstanceRO(int id,
Instance i)
Adds an instance to be referenced by other instances. |
void |
addInstanceSet(int id,
InstanceSet is)
Adds a new InstanceSet to be created or updated The instances will be created or updated in a case-per-case basis, depending on whether the instance's primary key is null or not. |
void |
addInstanceSetRO(int id,
InstanceSet iii)
Adds an instance set to be referenced by other instances. |
void |
clear()
Adds a new instance to be created or updated. |
CLBrowser |
getBrowser()
Getter for property browser. |
void |
prepareStatements()
Set up the instance set to be saved. |
void |
relateInstancesM2O(int[] id1,
int[] id2,
java.lang.String relationName)
Relates two instances or sets by id and relation name. |
void |
relateInstancesM2O(int id1,
int id2,
java.lang.String relationName)
|
void |
relateInstancesO2O(int[] id1,
int[] id2,
java.lang.String relationName)
Relates in a one-to-one basis each instance/set of id1[i] to each instance/set of id2[i]. |
void |
relateInstancesO2O(int id1,
int id2,
java.lang.String relationName)
|
void |
relateInstancesOMS(int[] id1,
int[] id2,
java.lang.String relationName,
java.lang.String role1,
java.lang.String role2,
boolean forward)
Relates two instances or sets by id and relation name (which must be OMS-managed) |
void |
relateInstancesOMS(int id1,
int id2,
java.lang.String relationName,
java.lang.String role1,
java.lang.String role2,
boolean forward)
|
int |
save()
|
void |
setBrowser(CLBrowser browser)
Setter for property browser. |
void |
unrelateInstances(int srcBranchId,
int dstBranchId,
RelationVO rel)
|
void |
unrelateInstances(int srcBranchId,
int dstBranchId,
java.lang.String relname)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public QuerySave() throws QuerySaveException
QuerySaveException
public QuerySave(CLBrowser clb) throws QuerySaveException
QuerySaveException
Method Detail |
---|
public void clear()
id
- is the internal index of the instance to be saved, start
numbering schema at 0, then 1, 2, etc.i
- is the instance to be saved.public void addInstance(int id, Instance i) throws QuerySaveException
id
- is the internal index of the instance to be saved, start
numbering schema at 0, then 1, 2, etc.i
- is the instance to be saved.
QuerySaveException
public void addInstanceRO(int id, Instance i) throws QuerySaveException
id
- is the internal index of the instance to be saved, start
numbering schema at 0, then 1, 2, etc.i
- is the instance to be saved.
QuerySaveException
public void addInstanceSet(int id, InstanceSet is) throws QuerySaveException
id
- is the internal index of the instance to be saved, start
numbering schema at 0, then 1, 2, etc.is
- is the InstanceSet to be saved.
QuerySaveException
public void addInstanceSetRO(int id, InstanceSet iii) throws QuerySaveException
id
- is the internal index of the instance to be saved, start
numbering schema at 0, then 1, 2, etc.iii
- is
- is the InstanceSet to be saved.
QuerySaveException
public void relateInstancesO2O(int[] id1, int[] id2, java.lang.String relationName)
id1
- id2
- relationName
- public void relateInstancesO2O(int id1, int id2, java.lang.String relationName)
public void relateInstancesM2O(int[] id1, int[] id2, java.lang.String relationName)
QuerySave.relateInstancesO2O
.
If relation is One-to-Many, every instance/set of id1 will be related to all instances/sets on id2.
If relation is Many-to-One, every instance/set of id2 will be related to all instances/sets in id1.
If relation is Many-To-Many relationships, use QuerySave.relateInstancesOMS
.
id1
- id2
- relationName
- public void relateInstancesM2O(int id1, int id2, java.lang.String relationName)
public void relateInstancesOMS(int[] id1, int[] id2, java.lang.String relationName, java.lang.String role1, java.lang.String role2, boolean forward)
id1
- id2
- relationName
- role1
- role2
- forward
- public void relateInstancesOMS(int id1, int id2, java.lang.String relationName, java.lang.String role1, java.lang.String role2, boolean forward)
public void unrelateInstances(int srcBranchId, int dstBranchId, java.lang.String relname)
public void unrelateInstances(int srcBranchId, int dstBranchId, RelationVO rel)
public void prepareStatements() throws QuerySaveException
QuerySaveException
public int save() throws QuerySaveException
QuerySaveException
public CLBrowser getBrowser()
public void setBrowser(CLBrowser browser)
browser
- New value of property browser.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |