⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hello3services.java

📁 本工程实现OFBiz开发的各种配置
💻 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 + -