documentDataList) {
this.documentDataList = documentDataList;
documentDataListLoaded = true;
}
/**
* Sets the db-connection in all related objects.
*
* @param db the db-connection
*/
@Override
public void setDb(Db db) {
super.setDb(db);
Db.applyToCollection(db, documentNodeList);
Db.applyToCollection(db, documentDataList);
}
/**
* Sets the contextDb in all related objects.
*
* @param db the db-connection
*/
@Override
public void setContextDb(ContextDb cd) {
super.setContextDb(cd);
ContextDb.applyToCollection(cd, documentNodeList);
ContextDb.applyToCollection(cd, documentDataList);
}
/**
* Deletes all composite relations from storage.
*
* @return true if deleted, false if failed and rollback required
*/
@Override
public boolean deleteLinkedObjects() {
return isVirgin() ||
super.deleteLinkedObjects() && deleteLinkedObjects(true);
}
/**
* Deletes composite relations.
* This method is invoked from deleteLinkedObjects() or saveLinkedObjects().
* When invoked from saveLinkedObjects() lazy relations not
* already loaded will be considered to be unchanged, i.e.
* need no update or insert.
*
* @param delete is true if invoked from delete()
* @return true if deleted, false if failed and rollback required
*/
private boolean deleteLinkedObjects(boolean delete) {
boolean rv = true;
// composite tracked lazy list of DocumentNode
if (delete) {
rv = rv && deleteList(getDocumentNodeList()) >= 0;
}
else if (documentNodeList != null && documentNodeList.isObjectRemoved()) {
rv = rv && deleteList(documentNodeList.getRemovedObjects()) >= 0;
}
// composite tracked lazy list of DocumentData
if (delete) {
rv = rv && deleteList(getDocumentDataList()) >= 0;
}
else if (documentDataList != null && documentDataList.isObjectRemoved()) {
rv = rv && deleteList(documentDataList.getRemovedObjects()) >= 0;
}
return rv;
}
/**
* Saves composite relations.
*
* @return true if all saved, false if rollback required.
*/
@Override
public boolean saveLinkedObjects() {
if (!super.saveLinkedObjects() ||
!isVirgin() && !deleteLinkedObjects(false)) {
return false;
}
// composite tracked lazy list of DocumentNode
if (documentNodeList != null) {
int ndx = 0;
for (DocumentNode obj: documentNodeList) {
obj.linkToParent(this, ndx);
ndx++;
}
if (saveList(documentNodeList, true) < 0) return false;
}
// composite tracked lazy list of DocumentData
if (documentDataList != null) {
int ndx = 0;
for (DocumentData obj: documentDataList) {
obj.linkToNode(this, ndx);
ndx++;
}
if (saveList(documentDataList, true) < 0) return false;
}
return true;
}
/**
* Checks composite relations for modification recursively.
*
* @return true if this or any composition is modified
*/
@Override
public boolean isModified() {
return super.isModified()
// composite tracked lazy list of DocumentNode
|| isListModified(documentNodeList)
// composite tracked lazy list of DocumentData
|| isListModified(documentDataList)
;
}
/**
* This is a composite object.
*/
@Override
public boolean isComposite() {
return true;
}
/**
* Marks this object and all its composites to be deleted.
*/
@Override
public void markDeleted() {
super.markDeleted();
// composite tracked lazy list of DocumentNode
markListDeleted(getDocumentNodeList());
// composite tracked lazy list of DocumentData
markListDeleted(getDocumentDataList());
}
// End of wurblet generated code.//GEN-END:relations
/**
* Wurblet generates accessor methods to the objects attributes.
*
* @wurblet methods DbMethods $mapping --tracked
*/
// Code generated by wurblet. Do not edit!//GEN-BEGIN:methods
/**
* Overwritten cause of "--tracked".
* @return true = setters check for modification
*/
public boolean isTracked() {
return true; // invoking isModified() is ok
}
/**
*
* get db attribute parentId
*
* @return ID of the parent DocumentNode or DocumentJob
*/
public long getParentId() {
return parentId;
}
/**
*
* set db attribute parentId
*
* @param parentId ID of the parent DocumentNode or DocumentJob
*/
public void setParentId(long parentId) {
if (!isModified()) {
setModified(this.parentId != parentId);
}
this.parentId = parentId;
}
/**
*
* get db attribute parentNdx
*
* @return order within the parent node
*/
public int getParentNdx() {
return parentNdx;
}
/**
*
* set db attribute parentNdx
*
* @param parentNdx order within the parent node
*/
public void setParentNdx(int parentNdx) {
if (!isModified()) {
setModified(this.parentNdx != parentNdx);
}
this.parentNdx = parentNdx;
}
/**
*
* get db attribute nodeName
*
* @return name of the node
*/
public String getNodeName() {
return nodeName;
}
/**
*
* set db attribute nodeName
*
* @param nodeName name of the node
*/
public void setNodeName(String nodeName) {
if (!isModified()) {
setModified(Compare.equals(this.nodeName, nodeName) == false);
}
this.nodeName = nodeName;
}
// End of wurblet generated code.//GEN-END:methods
/**
* Wurblet generates the declarations of the attributes.
*
* @wurblet declare DbDeclare $mapping
*/
// Code generated by wurblet. Do not edit!//GEN-BEGIN:declare
/**
* ID of the parent DocumentNode or DocumentJob
*/
private long parentId;
/**
* order within the parent node
*/
private int parentNdx;
/**
* name of the node
*/
private String nodeName;
// End of wurblet generated code.//GEN-END:declare
/**
* Wurblet generates the fieldnames of the attributes.
*
* @wurblet fieldnames DbFieldNames $mapping
*/
// Code generated by wurblet. Do not edit!//GEN-BEGIN:fieldnames
private static boolean columnsValid; // true if COLUMN_.... are valid for getFields()
public static final String FIELD_PARENTID = "parent_id";
private static int COLUMN_PARENTID;
public static final String FIELD_PARENTNDX = "parent_ndx";
private static int COLUMN_PARENTNDX;
public static final String FIELD_NODENAME = "node_name";
private static int COLUMN_NODENAME;
private static int COLUMN_ID;
private static int COLUMN_SERIAL;
// End of wurblet generated code.//GEN-END:fieldnames
/**
* Wurblet generates the field-lengths of the attributes.
*
* @wurblet fieldlengths DbFieldLengths $mapping
*/
// Code generated by wurblet. Do not edit!//GEN-BEGIN:fieldlengths
public static final int LENGTH_NODENAME = 128;
// End of wurblet generated code.//GEN-END:fieldlengths
}