📄 hello3services.java
字号:
package org.ofbiz.hello3;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.ServiceUtil;
public class Hello3Services {
public static final String module = Hello3Services.class.getName();
public static Map createHelloPerson(DispatchContext dctx, Map context){
GenericDelegator delegator = dctx.getDelegator();
try {
String helloPersonId = delegator.getNextSeqId("HelloPerson");
Debug.logInfo("helloPersonId = " + helloPersonId, module);
GenericValue helloPerson = delegator.makeValue("HelloPerson",
UtilMisc.toMap("helloPersonId", helloPersonId));
helloPerson.setNonPKFields(context);
delegator.create(helloPerson);
Map result = ServiceUtil.returnSuccess();
result.put("helloPersonId", helloPersonId);
/**
* test view-entity
*/
Debug.logInfo("start to test view-entity", module);
List personHobbyList = delegator.findAll("PersonHobby");
if(personHobbyList != null)
Debug.logInfo("records=" + personHobbyList.size(), module);
Iterator it = personHobbyList.iterator();
while(it.hasNext()){
GenericValue personHobby = (GenericValue)it.next();
Collection c = personHobby.getAllKeys();
Iterator it1 = c.iterator();
while(it1.hasNext()){
String key = (String)it1.next();
Debug.logInfo(key + "=" + personHobby.getString(key), module);
}
}
return result;
}
catch (GenericEntityException e) {
return ServiceUtil.returnError(e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -