Login  Register

svn commit: r586848 - in /ofbiz/trunk/framework/service/src/org/ofbiz/service: ServiceUtil.java engine/GenericAsyncEngine.java job/JobManager.java job/PersistedServiceJob.java semaphore/ServiceSemaphore.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

svn commit: r586848 - in /ofbiz/trunk/framework/service/src/org/ofbiz/service: ServiceUtil.java engine/GenericAsyncEngine.java job/JobManager.java job/PersistedServiceJob.java semaphore/ServiceSemaphore.java

doogie-3
2163 posts
Author: doogie
Date: Sat Oct 20 20:52:32 2007
New Revision: 586848

URL: http://svn.apache.org/viewvc?rev=586848&view=rev
Log:
All things delegator/entity are now generified.

Modified:
    ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericAsyncEngine.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/semaphore/ServiceSemaphore.java

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java?rev=586848&r1=586847&r2=586848&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java Sat Oct 20 20:52:32 2007
@@ -361,17 +361,17 @@
         // 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 @@
             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 @@
                 // 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 @@
                     // 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 @@
         }
 
         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 @@
         }
 
         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 {

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericAsyncEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericAsyncEngine.java?rev=586848&r1=586847&r2=586848&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericAsyncEngine.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericAsyncEngine.java Sat Oct 20 20:52:32 2007
@@ -91,8 +91,7 @@
                 // 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();

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java?rev=586848&r1=586847&r2=586848&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java Sat Oct 20 20:52:32 2007
@@ -106,20 +106,20 @@
 
     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 @@
         }
 
         // 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 @@
                 //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 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 @@
         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 @@
         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

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java?rev=586848&r1=586847&r2=586848&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java Sat Oct 20 20:52:32 2007
@@ -268,8 +268,7 @@
     // 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 @@
             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);
         }

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/semaphore/ServiceSemaphore.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/semaphore/ServiceSemaphore.java?rev=586848&r1=586847&r2=586848&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/semaphore/ServiceSemaphore.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/semaphore/ServiceSemaphore.java Sat Oct 20 20:52:32 2007
@@ -109,8 +109,7 @@
         }
 
         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);