You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2014/10/24 10:22:57 UTC
svn commit: r1634024 [3/3] - in
/ofbiz/trunk/applications/content/src/org/ofbiz/content: ./ blog/ cms/
compdoc/ content/ data/ layout/ survey/ view/ webapp/ftl/
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java Fri Oct 24 08:22:56 2014
@@ -22,13 +22,12 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
-import java.io.StringWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
+import java.io.StringWriter;
import java.io.Writer;
import java.nio.ByteBuffer;
import java.sql.Timestamp;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -44,6 +43,7 @@ import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.ModelService;
@@ -137,9 +137,9 @@ public class DataServices {
// get first statusId for content out of the statusItem table if not provided
if (UtilValidate.isEmpty(dataResource.get("statusId"))) {
try {
- List<GenericValue> statusItems = delegator.findByAnd("StatusItem",UtilMisc.toMap("statusTypeId", "CONTENT_STATUS"), UtilMisc.toList("sequenceId"), false);
- if (!UtilValidate.isEmpty(statusItems)) {
- dataResource.put("statusId", statusItems.get(0).getString("statusId"));
+ GenericValue statusItem = EntityQuery.use(delegator).from("StatusItem").where("statusTypeId", "CONTENT_STATUS").orderBy("sequenceId").queryFirst();
+ if (statusItem != null) {
+ dataResource.put("statusId", statusItem.get("statusId"));
}
} catch (GenericEntityException e) {
return ServiceUtil.returnError(e.getMessage());
@@ -312,7 +312,7 @@ public class DataServices {
// If textData exists, then create DataResource and return dataResourceId
String dataResourceId = (String) context.get("dataResourceId");
try {
- dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false);
+ dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne();
} catch (GenericEntityException e) {
Debug.logWarning(e, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentDataResourceNotFound", UtilMisc.toMap("parameters.dataResourceId", dataResourceId), locale));
@@ -366,7 +366,7 @@ public class DataServices {
Debug.logVerbose("in updateElectronicText, textData:" + textData, module);
}
try {
- electronicText = delegator.findOne("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId), false);
+ electronicText = EntityQuery.use(delegator).from("ElectronicText").where("dataResourceId", dataResourceId).queryOne();
if (electronicText != null) {
electronicText.put("textData", textData);
electronicText.store();
@@ -521,7 +521,7 @@ public class DataServices {
if (byteBuffer != null) {
byte[] imageBytes = byteBuffer.array();
try {
- GenericValue imageDataResource = delegator.findOne("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false);
+ GenericValue imageDataResource = EntityQuery.use(delegator).from("ImageDataResource").where("dataResourceId", dataResourceId).queryOne();
if (Debug.infoOn()) {
Debug.logInfo("imageDataResource(U):" + imageDataResource, module);
Debug.logInfo("imageBytes(U):" + imageBytes, module);
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java Fri Oct 24 08:22:56 2014
@@ -44,6 +44,7 @@ import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericPK;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.minilang.MiniLangException;
import org.ofbiz.minilang.SimpleMapProcessor;
import org.ofbiz.service.GenericServiceException;
@@ -136,7 +137,7 @@ public class LayoutEvents {
dispatcher.runSync("deactivateAssocs", context2);
}
- GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false);
+ GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne();
//Debug.logVerbose("in createLayoutImage, dataResource:" + dataResource, module);
// Use objectInfo field to store the name of the file, since there is no
// place in ImageDataResource for it.
@@ -147,7 +148,7 @@ public class LayoutEvents {
}
// See if this needs to be a create or an update procedure
- GenericValue imageDataResource = delegator.findOne("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false);
+ GenericValue imageDataResource = EntityQuery.use(delegator).from("ImageDataResource").where("dataResourceId", dataResourceId).queryOne();
//Debug.logVerbose("in createLayoutImage, imageDataResource(0):" + imageDataResource, module);
if (imageDataResource == null) {
imageDataResource = delegator.makeValue("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
@@ -195,7 +196,7 @@ public class LayoutEvents {
String dataResourceId = (String) context.get("drDataResourceId");
Debug.logVerbose("in createLayoutImage(java), dataResourceId:" + dataResourceId, "");
- GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false);
+ GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne();
Debug.logVerbose("in createLayoutImage(java), dataResource:" + dataResource, "");
// Use objectInfo field to store the name of the file, since there is no
// place in ImageDataResource for it.
@@ -207,7 +208,7 @@ public class LayoutEvents {
}
// See if this needs to be a create or an update procedure
- GenericValue imageDataResource = delegator.findOne("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false);
+ GenericValue imageDataResource = EntityQuery.use(delegator).from("ImageDataResource").where("dataResourceId", dataResourceId).queryOne();
if (imageDataResource == null) {
imageDataResource = delegator.makeValue("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
imageDataResource.set("imageData", byteWrap.array());
@@ -253,10 +254,11 @@ public class LayoutEvents {
if (UtilValidate.isEmpty(contentId)) {
// Look for an existing associated Content
try {
- List lst = delegator.findByAnd("DataResourceContentView ", UtilMisc.toMap("dataResourceId", dataResourceId));
- if (lst.size() > 0) {
- GenericValue dataResourceContentView = (GenericValue) lst.get(0);
- contentId = (String) dataResourceContentView.get("coContentId");
+ GenericValue dataResourceContentView = EntityQuery.use(delegator).from("DataResourceContentView")
+ .where("dataResourceId", dataResourceId)
+ .queryFirst();
+ if (dataResourceContentView != null) {
+ contentId = dataResourceContentView.getString("coContentId");
}
} catch (GenericEntityException e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
@@ -321,7 +323,7 @@ public class LayoutEvents {
String newId = null;
String newDataResourceId = null;
try {
- content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+ content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
Debug.logVerbose("in cloneLayout, content:" + content, "");
if (content == null) {
String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.content_empty", locale);
@@ -334,7 +336,7 @@ public class LayoutEvents {
newId = delegator.getNextSeqId("Content");
newContent.set("contentId", newId);
String dataResourceId = (String) content.get("dataResourceId");
- GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), false);
+ GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne();
if (dataResource != null) {
GenericValue newDataResource = delegator.makeValue("DataResource", dataResource);
Debug.logVerbose("in cloneLayout, newDataResource:" + newDataResource, "");
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java Fri Oct 24 08:22:56 2014
@@ -45,7 +45,7 @@ import org.ofbiz.content.data.DataResour
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
-import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
@@ -214,7 +214,7 @@ public class PdfSurveyServices {
}
pdfStamper.close();
if (UtilValidate.isNotEmpty(contentId)) {
- survey = delegator.findOne("Survey", UtilMisc.toMap("surveyId", surveyId), false);
+ survey = EntityQuery.use(delegator).from("Survey").where("surveyId", surveyId).queryOne();
survey.set("acroFormContentId", contentId);
survey.store();
}
@@ -247,7 +247,7 @@ public class PdfSurveyServices {
//String contentId = (String)context.get("contentId");
surveyResponseId = (String)context.get("surveyResponseId");
if (UtilValidate.isNotEmpty(surveyResponseId)) {
- GenericValue surveyResponse = delegator.findOne("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId), false);
+ GenericValue surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyResponseId", surveyResponseId).queryOne();
if (surveyResponse != null) {
surveyId = surveyResponse.getString("surveyId");
}
@@ -270,13 +270,15 @@ public class PdfSurveyServices {
//AcroFields.Item item = fs.getFieldItem(fieldName);
//int type = fs.getFieldType(fieldName);
String value = fs.getField(fieldName);
- List<GenericValue> questions = delegator.findByAnd("SurveyQuestionAndAppl", UtilMisc.toMap("surveyId", surveyId, "externalFieldRef", fieldName), null, false);
- if (questions.size() == 0) {
+ GenericValue surveyQuestionAndAppl = EntityQuery.use(delegator).from("SurveyQuestionAndAppl")
+ .where("surveyId", surveyId,
+ "externalFieldRef", fieldName)
+ .queryFirst();
+ if (surveyQuestionAndAppl == null) {
Debug.logInfo("No question found for surveyId:" + surveyId + " and externalFieldRef:" + fieldName, module);
continue;
}
- GenericValue surveyQuestionAndAppl = questions.get(0);
String surveyQuestionId = (String)surveyQuestionAndAppl.get("surveyQuestionId");
String surveyQuestionTypeId = (String)surveyQuestionAndAppl.get("surveyQuestionTypeId");
GenericValue surveyResponseAnswer = delegator.makeValue("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId, "surveyQuestionId", surveyQuestionId));
@@ -422,13 +424,13 @@ public class PdfSurveyServices {
Document document = new Document();
try {
if (UtilValidate.isNotEmpty(surveyResponseId)) {
- GenericValue surveyResponse = delegator.findOne("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId), false);
+ GenericValue surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyResponseId", surveyResponseId).queryOne();
if (surveyResponse != null) {
surveyId = surveyResponse.getString("surveyId");
}
}
if (UtilValidate.isNotEmpty(surveyId) && UtilValidate.isEmpty(contentId)) {
- GenericValue survey = delegator.findOne("Survey", UtilMisc.toMap("surveyId", surveyId), false);
+ GenericValue survey = EntityQuery.use(delegator).from("Survey").where("surveyId", surveyId).queryOne();
if (survey != null) {
String acroFormContentId = survey.getString("acroFormContentId");
if (UtilValidate.isNotEmpty(acroFormContentId)) {
@@ -440,11 +442,11 @@ public class PdfSurveyServices {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
- List<GenericValue> responses = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId), null, false);
+ List<GenericValue> responses = EntityQuery.use(delegator).from("SurveyResponseAnswer").where("surveyResponseId", surveyResponseId).queryList();
for (GenericValue surveyResponseAnswer : responses) {
String value = null;
String surveyQuestionId = (String) surveyResponseAnswer.get("surveyQuestionId");
- GenericValue surveyQuestion = delegator.findOne("SurveyQuestion", UtilMisc.toMap("surveyQuestionId", surveyQuestionId), false);
+ GenericValue surveyQuestion = EntityQuery.use(delegator).from("SurveyQuestion").where("surveyQuestionId", surveyQuestionId).queryOne();
String questionType = surveyQuestion.getString("surveyQuestionTypeId");
// DEJ20060227 this isn't used, if needed in the future should get from SurveyQuestionAppl.externalFieldRef String fieldName = surveyQuestion.getString("description");
if ("OPTION".equals(questionType)) {
@@ -489,10 +491,10 @@ public class PdfSurveyServices {
List<Object> qAndA = FastList.newInstance();
try {
- List<GenericValue> responses = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId), null, false);
+ List<GenericValue> responses = EntityQuery.use(delegator).from("SurveyResponseAnswer").where("surveyResponseId", surveyResponseId).queryList();
for (GenericValue surveyResponseAnswer : responses) {
String surveyQuestionId = (String) surveyResponseAnswer.get("surveyQuestionId");
- GenericValue surveyQuestion = delegator.findOne("SurveyQuestion", UtilMisc.toMap("surveyQuestionId", surveyQuestionId), false);
+ GenericValue surveyQuestion = EntityQuery.use(delegator).from("SurveyQuestion").where("surveyQuestionId", surveyQuestionId).queryOne();
qAndA.add(UtilMisc.toMap("question", surveyQuestion, "response", surveyResponseAnswer));
}
results.put("questionsAndAnswers", qAndA);
@@ -517,28 +519,31 @@ public class PdfSurveyServices {
try {
String surveyId = null;
if (UtilValidate.isNotEmpty(surveyResponseId)) {
- GenericValue surveyResponse = delegator.findOne("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId), false);
+ GenericValue surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyResponseId", surveyResponseId).queryOne();
if (surveyResponse != null) {
surveyId = surveyResponse.getString("surveyId");
}
}
if (UtilValidate.isNotEmpty(surveyId)) {
- GenericValue survey = delegator.findOne("Survey", UtilMisc.toMap("surveyId", surveyId), false);
+ GenericValue survey = EntityQuery.use(delegator).from("Survey").where("surveyId", surveyId).queryOne();
if (survey != null) {
acroFormContentId = survey.getString("acroFormContentId");
}
}
- List<GenericValue> responses = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId), null, false);
+ List<GenericValue> responses = EntityQuery.use(delegator).from("SurveyResponseAnswer").where("surveyResponseId", surveyResponseId).queryList();
for (GenericValue surveyResponseAnswer : responses) {
String value = null;
String surveyQuestionId = (String) surveyResponseAnswer.get("surveyQuestionId");
- GenericValue surveyQuestion = delegator.findOne("SurveyQuestion", UtilMisc.toMap("surveyQuestionId", surveyQuestionId), true);
+ GenericValue surveyQuestion = EntityQuery.use(delegator).from("SurveyQuestion").where("surveyQuestionId", surveyQuestionId).cache().queryOne();
- List<GenericValue> surveyQuestionApplList = EntityUtil.filterByDate(delegator.findByAnd("SurveyQuestionAppl", UtilMisc.toMap("surveyId", surveyId, "surveyQuestionId", surveyQuestionId), UtilMisc.toList("-fromDate"), true), false);
- GenericValue surveyQuestionAppl = EntityUtil.getFirst(surveyQuestionApplList);
+ GenericValue surveyQuestionAppl = EntityQuery.use(delegator).from("SurveyQuestionAppl")
+ .where("surveyId", surveyId,
+ "surveyQuestionId", surveyQuestionId)
+ .orderBy("-fromDate")
+ .filterByDate().cache().queryFirst();
String questionType = surveyQuestion.getString("surveyQuestionTypeId");
String fieldName = surveyQuestionAppl.getString("externalFieldRef");
@@ -618,7 +623,7 @@ public class PdfSurveyServices {
String https = (String)context.get("https");
String webSiteId = (String)context.get("webSiteId");
String rootDir = (String)context.get("rootDir");
- GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), true);
+ GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
String dataResourceId = content.getString("dataResourceId");
inputByteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https, webSiteId, locale, rootDir);
} catch (GenericEntityException e) {
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java Fri Oct 24 08:22:56 2014
@@ -47,6 +47,7 @@ import org.ofbiz.entity.condition.Entity
import org.ofbiz.entity.transaction.TransactionUtil;
import org.ofbiz.entity.util.EntityFindOptions;
import org.ofbiz.entity.util.EntityListIterator;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import freemarker.template.Configuration;
@@ -240,7 +241,7 @@ public class SurveyWrapper {
public GenericValue getSurvey() {
GenericValue survey = null;
try {
- survey = delegator.findOne("Survey", UtilMisc.toMap("surveyId", surveyId), true);
+ survey = EntityQuery.use(delegator).from("Survey").where("surveyId", surveyId).cache().queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to get Survey : " + surveyId, module);
}
@@ -286,12 +287,10 @@ public class SurveyWrapper {
List<GenericValue> questions = FastList.newInstance();
try {
- Map<String, Object> fields = UtilMisc.<String, Object>toMap("surveyId", surveyId);
- List<String> order = UtilMisc.toList("sequenceNum", "surveyMultiRespColId");
- questions = delegator.findByAnd("SurveyQuestionAndAppl", fields, order, true);
- if (questions != null) {
- questions = EntityUtil.filterByDate(questions);
- }
+ questions = EntityQuery.use(delegator).from("SurveyQuestionAndAppl")
+ .where("surveyId", surveyId)
+ .orderBy("sequenceNum", "surveyMultiRespColId")
+ .filterByDate().cache().queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to get questions for survey : " + surveyId, module);
}
@@ -312,7 +311,10 @@ public class SurveyWrapper {
String responseId = null;
List<GenericValue> responses = null;
try {
- responses = delegator.findByAnd("SurveyResponse", UtilMisc.toMap("surveyId", surveyId, "partyId", partyId), UtilMisc.toList("-lastModifiedDate"), false);
+ responses = EntityQuery.use(delegator).from("SurveyResponse")
+ .where("surveyId", surveyId, "partyId", partyId)
+ .orderBy("-lastModifiedDate")
+ .queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
@@ -335,7 +337,7 @@ public class SurveyWrapper {
public long getNumberResponses() throws SurveyWrapperException {
long responses = 0;
try {
- responses = delegator.findCountByCondition("SurveyResponse", EntityCondition.makeCondition("surveyId", EntityOperator.EQUALS, surveyId), null, null);
+ responses = EntityQuery.use(delegator).from("SurveyResponse").where("surveyId", surveyId).queryCount();
} catch (GenericEntityException e) {
throw new SurveyWrapperException(e);
}
@@ -345,7 +347,7 @@ public class SurveyWrapper {
public List<GenericValue> getSurveyResponses(GenericValue question) throws SurveyWrapperException {
List<GenericValue> responses = null;
try {
- responses = delegator.findByAnd("SurveyResponse", UtilMisc.toMap("surveyQuestionId", question.getString("surveyQuestionId")), null, false);
+ responses = EntityQuery.use(delegator).from("SurveyResponse").where("surveyQuestionId", question.get("surveyQuestionId")).queryList();
} catch (GenericEntityException e) {
throw new SurveyWrapperException(e);
}
@@ -359,7 +361,7 @@ public class SurveyWrapper {
if (responseId != null) {
List<GenericValue> answers = null;
try {
- answers = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", responseId), null, false);
+ answers = EntityQuery.use(delegator).from("SurveyResponseAnswer").where("surveyResponseId", responseId).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
@@ -658,7 +660,9 @@ public class SurveyWrapper {
long result = 0;
try {
- result = delegator.findCountByCondition("SurveyResponseAndAnswer", makeEliCondition(question), null, null);
+ result = EntityQuery.use(delegator).from("SurveyResponseAndAnswer")
+ .where(makeEliCondition(question))
+ .queryCount();
} catch (GenericEntityException e) {
Debug.logError(e, module);
throw new SurveyWrapperException("Unable to get responses", e);
@@ -724,19 +728,11 @@ public class SurveyWrapper {
}
private EntityListIterator getEli(GenericValue question, int maxRows) throws GenericEntityException {
- EntityFindOptions efo = new EntityFindOptions();
- efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE);
- efo.setResultSetConcurrency(EntityFindOptions.CONCUR_READ_ONLY);
- efo.setSpecifyTypeAndConcur(true);
- efo.setDistinct(false);
- if (maxRows > 0) {
- efo.setMaxRows(maxRows);
- }
-
- EntityListIterator eli = null;
- eli = delegator.find("SurveyResponseAndAnswer", makeEliCondition(question), null, null, null, efo);
-
- return eli;
+ return EntityQuery.use(delegator).from("SurveyResponseAndAnswer")
+ .where(makeEliCondition(question))
+ .cursorScrollInsensitive()
+ .maxRows(maxRows)
+ .queryIterator();
}
@SuppressWarnings("serial")
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java Fri Oct 24 08:22:56 2014
@@ -41,6 +41,7 @@ import org.ofbiz.content.data.DataResour
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.webapp.view.AbstractViewHandler;
import org.ofbiz.webapp.view.ViewHandlerException;
import org.ofbiz.webapp.website.WebSiteWorker;
@@ -83,7 +84,7 @@ public class SimpleContentViewHandler ex
if (UtilValidate.isEmpty(contentRevisionSeqId)) {
if (UtilValidate.isEmpty(mapKey) && UtilValidate.isEmpty(contentAssocTypeId)) {
if (UtilValidate.isNotEmpty(contentId)) {
- GenericValue content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), true);
+ GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
dataResourceId = content.getString("dataResourceId");
}
if (Debug.verboseOn()) Debug.logVerbose("dataResourceId:" + dataResourceId, module);
@@ -105,7 +106,7 @@ public class SimpleContentViewHandler ex
if (Debug.verboseOn()) Debug.logVerbose("dataResourceId:" + dataResourceId, module);
}
} else {
- GenericValue contentRevisionItem = delegator.findOne("ContentRevisionItem", UtilMisc.toMap("contentId", rootContentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId), true);
+ GenericValue contentRevisionItem = EntityQuery.use(delegator).from("ContentRevisionItem").where("contentId", rootContentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId).cache().queryOne();
if (contentRevisionItem == null) {
throw new ViewHandlerException("ContentRevisionItem record not found for contentId=" + rootContentId
+ ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId);
@@ -117,7 +118,7 @@ public class SimpleContentViewHandler ex
}
}
if (UtilValidate.isNotEmpty(dataResourceId)) {
- GenericValue dataResource = delegator.findOne("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId), true);
+ GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne();
// DEJ20080717: why are we rendering the DataResource directly instead of rendering the content?
ByteBuffer byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https, webSiteId, locale, rootDir);
ByteArrayInputStream bais = new ByteArrayInputStream(byteBuffer.array());
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java Fri Oct 24 08:22:56 2014
@@ -35,6 +35,7 @@ import org.ofbiz.content.content.Content
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.LocalDispatcher;
import freemarker.core.Environment;
@@ -135,7 +136,7 @@ public class EditRenderSubContentTransfo
mimeTypeIdTemp = (String) subContentDataResourceView.get("mimeTypeId");
if (UtilValidate.isEmpty(mimeTypeIdTemp) && UtilValidate.isNotEmpty(contentId)) { // will need these below
try {
- parentContent = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+ parentContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
if (parentContent != null) {
mimeTypeIdTemp = (String) parentContent.get("mimeTypeId");
}
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java Fri Oct 24 08:22:56 2014
@@ -37,6 +37,7 @@ import org.ofbiz.content.content.Content
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.webapp.ftl.LoopWriter;
@@ -116,7 +117,7 @@ public class LoopSubContentTransform imp
String parentContentId = (String)ctx.get("contentId");
if (UtilValidate.isEmpty(mimeTypeId) && UtilValidate.isNotEmpty(parentContentId)) { // will need these below
try {
- GenericValue parentContent = delegator.findOne("Content", UtilMisc.toMap("contentId", parentContentId), false);
+ GenericValue parentContent = EntityQuery.use(delegator).from("Content").where("contentId", parentContentId).queryOne();
if (parentContent != null) {
mimeTypeId = (String) parentContent.get("mimeTypeId");
ctx.put("parentContent", parentContent);
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java?rev=1634024&r1=1634023&r2=1634024&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java Fri Oct 24 08:22:56 2014
@@ -39,6 +39,7 @@ import org.ofbiz.content.content.Content
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.webapp.ftl.LoopWriter;
@@ -124,7 +125,7 @@ public class TraverseSubContentTransform
}
if (UtilValidate.isNotEmpty(thisContentId)) {
try {
- view = delegator.findOne("Content", UtilMisc.toMap("contentId", thisContentId), false);
+ view = EntityQuery.use(delegator).from("Content").where("contentId", thisContentId).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Error getting sub-content", module);
throw new RuntimeException(e.getMessage());
@@ -186,7 +187,7 @@ public class TraverseSubContentTransform
/*
if (UtilValidate.isNotEmpty(contentId)) {
try {
- content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+ content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
} catch (GenericEntityException e) {
// TODO: Not sure what to put here.
throw new RuntimeException(e.getMessage());