All things delegator/entity are now generified.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@586848 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adam Heath
2007-10-21 03:52:32 +00:00
parent 9b0735ce53
commit f107f75aed
5 changed files with 28 additions and 40 deletions
@@ -361,17 +361,17 @@ public class ServiceUtil {
// create the conditions to query
EntityCondition pool = new EntityExpr("poolId", EntityOperator.EQUALS, sendPool);
List finExp = UtilMisc.toList(new EntityExpr("finishDateTime", EntityOperator.NOT_EQUAL, null));
List<EntityExpr> finExp = UtilMisc.toList(new EntityExpr("finishDateTime", EntityOperator.NOT_EQUAL, null));
finExp.add(new EntityExpr("finishDateTime", EntityOperator.LESS_THAN, purgeTime));
List canExp = UtilMisc.toList(new EntityExpr("cancelDateTime", EntityOperator.NOT_EQUAL, null));
List<EntityExpr> canExp = UtilMisc.toList(new EntityExpr("cancelDateTime", EntityOperator.NOT_EQUAL, null));
canExp.add(new EntityExpr("cancelDateTime", EntityOperator.LESS_THAN, purgeTime));
EntityCondition cancelled = new EntityConditionList(canExp, EntityOperator.AND);
EntityCondition finished = new EntityConditionList(finExp, EntityOperator.AND);
EntityCondition cancelled = new EntityConditionList<EntityExpr>(canExp, EntityOperator.AND);
EntityCondition finished = new EntityConditionList<EntityExpr>(finExp, EntityOperator.AND);
EntityCondition doneCond = new EntityConditionList(UtilMisc.toList(cancelled, finished), EntityOperator.OR);
EntityCondition mainCond = new EntityConditionList(UtilMisc.toList(doneCond, pool), EntityOperator.AND);
EntityCondition doneCond = new EntityConditionList<EntityCondition>(UtilMisc.toList(cancelled, finished), EntityOperator.OR);
EntityCondition mainCond = new EntityConditionList<EntityCondition>(UtilMisc.toList(doneCond, pool), EntityOperator.AND);
// configure the find options
EntityFindOptions findOptions = new EntityFindOptions();
@@ -391,7 +391,7 @@ public class ServiceUtil {
boolean beganTx1 = false;
while (!noMoreResults) {
// current list of records
List curList = null;
List<GenericValue> curList = null;
try {
// begin this transaction
beganTx1 = TransactionUtil.begin();
@@ -419,11 +419,9 @@ public class ServiceUtil {
// remove each from the list in its own transaction
if (curList != null && curList.size() > 0) {
// list of runtime data IDs to attempt to delete
List runtimeToDelete = FastList.newInstance();
List<String> runtimeToDelete = FastList.newInstance();
Iterator curIter = curList.iterator();
while (curIter.hasNext()) {
GenericValue job = (GenericValue) curIter.next();
for (GenericValue job: curList) {
String runtimeId = job.getString("runtimeDataId");
String jobId = job.getString("jobId");
boolean beganTx2 = false;
@@ -451,9 +449,7 @@ public class ServiceUtil {
// we do this so that the ones which cannot be deleted to not cause
// the entire group to rollback; some may be attached to multiple jobs.
if (runtimeToDelete.size() > 0) {
Iterator delIter = runtimeToDelete.iterator();
while (delIter.hasNext()) {
String runtimeId = (String) delIter.next();
for (String runtimeId: runtimeToDelete) {
boolean beganTx3 = false;
try {
beganTx3 = TransactionUtil.begin();
@@ -507,7 +503,7 @@ public class ServiceUtil {
}
String jobId = (String) context.get("jobId");
Map fields = UtilMisc.toMap("jobId", jobId);
Map<String, Object> fields = UtilMisc.<String, Object>toMap("jobId", jobId);
GenericValue job = null;
try {
@@ -545,7 +541,7 @@ public class ServiceUtil {
}
String jobId = (String) context.get("jobId");
Map fields = UtilMisc.toMap("jobId", jobId);
Map<String, Object> fields = UtilMisc.<String, Object>toMap("jobId", jobId);
GenericValue job = null;
try {
@@ -91,8 +91,7 @@ public abstract class GenericAsyncEngine extends AbstractEngine {
// Create the runtime data
String dataId = dispatcher.getDelegator().getNextSeqId("RuntimeData");
GenericValue runtimeData = dispatcher.getDelegator().makeValue("RuntimeData",
UtilMisc.toMap("runtimeDataId", dataId));
GenericValue runtimeData = dispatcher.getDelegator().makeValue("RuntimeData", "runtimeDataId", dataId);
runtimeData.set("runtimeInfo", XmlSerializer.serialize(context));
runtimeData.create();
@@ -106,20 +106,20 @@ public class JobManager {
public synchronized Iterator poll() {
List poll = FastList.newInstance();
Collection jobEnt = null;
Collection<GenericValue> jobEnt = null;
// sort the results by time
List order = UtilMisc.toList("runTime");
List<String> order = UtilMisc.toList("runTime");
// basic query
List expressions = UtilMisc.toList(new EntityExpr("runTime", EntityOperator.LESS_THAN_EQUAL_TO,
List<EntityExpr> expressions = UtilMisc.toList(new EntityExpr("runTime", EntityOperator.LESS_THAN_EQUAL_TO,
UtilDateTime.nowTimestamp()), new EntityExpr("startDateTime", EntityOperator.EQUALS, null),
new EntityExpr("cancelDateTime", EntityOperator.EQUALS, null),
new EntityExpr("runByInstanceId", EntityOperator.EQUALS, null));
// limit to just defined pools
List pools = ServiceConfigUtil.getRunPools();
List poolsExpr = UtilMisc.toList(new EntityExpr("poolId", EntityOperator.EQUALS, null));
List<EntityExpr> poolsExpr = UtilMisc.toList(new EntityExpr("poolId", EntityOperator.EQUALS, null));
if (pools != null) {
Iterator poolsIter = pools.iterator();
while (poolsIter.hasNext()) {
@@ -129,9 +129,9 @@ public class JobManager {
}
// make the conditions
EntityCondition baseCondition = new EntityConditionList(expressions, EntityOperator.AND);
EntityCondition poolCondition = new EntityConditionList(poolsExpr, EntityOperator.OR);
EntityCondition mainCondition = new EntityConditionList(UtilMisc.toList(baseCondition, poolCondition), EntityOperator.AND);
EntityCondition baseCondition = new EntityConditionList<EntityExpr>(expressions, EntityOperator.AND);
EntityCondition poolCondition = new EntityConditionList<EntityExpr>(poolsExpr, EntityOperator.OR);
EntityCondition mainCondition = new EntityConditionList<EntityCondition>(UtilMisc.toList(baseCondition, poolCondition), EntityOperator.AND);
// we will loop until we have no more to do
boolean pollDone = false;
@@ -156,9 +156,7 @@ public class JobManager {
//jobEnt = delegator.findByCondition("JobSandbox", mainCondition, null, order);
if (jobEnt != null && jobEnt.size() > 0) {
Iterator i = jobEnt.iterator();
while (i.hasNext()) {
GenericValue v = (GenericValue) i.next();
for (GenericValue v: jobEnt) {
DispatchContext dctx = getDispatcher().getDispatchContext();
if (dctx == null) {
Debug.logError("Unable to locate DispatchContext object; not running job!", module);
@@ -204,9 +202,9 @@ public class JobManager {
public synchronized void reloadCrashedJobs() {
String instanceId = UtilProperties.getPropertyValue("general.properties", "unique.instanceId", "ofbiz0");
List crashed = null;
List<GenericValue> crashed = null;
List exprs = UtilMisc.toList(new EntityExpr("finishDateTime", EntityOperator.EQUALS, null));
List<EntityExpr> exprs = UtilMisc.toList(new EntityExpr("finishDateTime", EntityOperator.EQUALS, null));
exprs.add(new EntityExpr("cancelDateTime", EntityOperator.EQUALS, null));
exprs.add(new EntityExpr("runByInstanceId", EntityOperator.EQUALS, instanceId));
try {
@@ -218,9 +216,7 @@ public class JobManager {
if (crashed != null && crashed.size() > 0) {
try {
int rescheduled = 0;
Iterator i = crashed.iterator();
while (i.hasNext()) {
GenericValue job = (GenericValue) i.next();
for (GenericValue job: crashed) {
long runtime = job.getTimestamp("runTime").getTime();
RecurrenceInfo ri = JobManager.getRecurrenceInfo(job);
if (ri != null) {
@@ -401,7 +397,7 @@ public class JobManager {
if (UtilValidate.isEmpty(jobName)) {
jobName = Long.toString((new Date().getTime()));
}
Map jFields = UtilMisc.toMap("jobName", jobName, "runTime", new java.sql.Timestamp(startTime),
Map<String, Object> jFields = UtilMisc.<String, Object>toMap("jobName", jobName, "runTime", new java.sql.Timestamp(startTime),
"serviceName", serviceName, "recurrenceInfoId", infoId, "runtimeDataId", dataId);
// set the pool ID
@@ -268,8 +268,7 @@ public class PersistedServiceJob extends GenericServiceJob {
// gets the job value object
private GenericValue getJob() throws InvalidJobException {
try {
Map fields = UtilMisc.toMap("jobId", getJobId());
GenericValue jobObj = delegator.findByPrimaryKey("JobSandbox", fields);
GenericValue jobObj = delegator.findByPrimaryKey("JobSandbox", "jobId", getJobId());
if (jobObj == null) {
throw new InvalidJobException("Job [" + getJobId() + "] came back null from datasource");
@@ -288,10 +287,9 @@ public class PersistedServiceJob extends GenericServiceJob {
return 0;
}
Map fields = UtilMisc.toMap("parentJobId", pJobId, "statusId", "SERVICE_FAILED");
long count = 0;
try {
count = delegator.findCountByAnd("JobSandbox", fields);
count = delegator.findCountByAnd("JobSandbox", "parentJobId", pJobId, "statusId", "SERVICE_FAILED");
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
@@ -109,8 +109,7 @@ public class ServiceSemaphore {
}
if (semaphore == null) {
Map fields = UtilMisc.toMap("serviceName", model.name, "lockThread", threadName, "lockTime", lockTime);
semaphore = delegator.makeValue("ServiceSemaphore", fields);
semaphore = delegator.makeValue("ServiceSemaphore", "serviceName", model.name, "lockThread", threadName, "lockTime", lockTime);
// use the special method below so we can reuse the unqiue tx functions
dbWrite(semaphore, false);