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

📄 editdataprep.bsh

📁 国外的一套开源CRM
💻 BSH
字号:
/*
 * $Id: editdataprep.bsh,v 1.1 2003/11/04 23:58:06 byersa Exp $
 *
 * Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
 * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;


import org.ofbiz.base.util.*;
import org.ofbiz.entity.*;
import org.ofbiz.security.*;
import org.ofbiz.service.*;
import org.ofbiz.entity.model.*;
import org.ofbiz.content.widget.html.*;
import org.ofbiz.content.widget.form.*;
import org.ofbiz.content.data.DataResourceWorker;



import javax.servlet.*;
import javax.servlet.http.*;
/**
 *
 * @author     <a href="mailto:byersa@automationgroups.com">Al Byers</a>
 * @version    $Revision: 1.1 $
 * @since      2.1

 * This is a crude general script to find entity data based on the primary key.
 * It only works on entities with one primary key field and it relies on that being
 * in the pagedef config file.
 * It could get and interrogate a GenericEntity object
 */

    
security			= request.getAttribute("security");
// Get permission from pagedef config file
String permission		= page.getProperty("permission");
String formDefFile		= page.getProperty("formDefFile");
String singleFormName		= page.getProperty("singleFormName");
String entityName		= page.getProperty("entityName");
String priKeyName		= page.getProperty("priKeyName");
String defaultMapName		= page.getProperty("defaultMapName");
if( defaultMapName == null) defaultMapName	= "currentValue";
String entityOperation		= page.getProperty("entityOperation");
if( entityOperation == null) entityOperation	= "_ADMIN";

dispatcher	= (LocalDispatcher)request.getAttribute("dispatcher");
delegator = (GenericDelegator) request.getAttribute("delegator");


mapIn = new HashMap();
userLogin = session.getAttribute("userLogin");
mapIn.put("userLogin", userLogin);
mapIn.put("entityOperation", entityOperation);


HashMap currentEntityMap = (HashMap)session.getAttribute("currentEntityMap");
if(currentEntityMap == null){
    currentEntityMap     = new HashMap();
    session.setAttribute("currentEntityMap", currentEntityMap);
}

currentPK = currentEntityMap.get(entityName);
    org.ofbiz.base.util.Debug.logInfo("in editdataprep, entityName:" + entityName, null);
    org.ofbiz.base.util.Debug.logInfo("in editdataprep, currentPK:" + currentPK, null);
// currentPK could be GenericValue
GenericValue currentValue = null;
if (currentPK != null) {
    currentValue = delegator.findByPrimaryKey(currentPK.getPrimaryKey()); 
    org.ofbiz.base.util.Debug.logInfo("in editdataprep, currentValue:" + currentValue, null);

}
if (currentValue == null) {
        primaryKeyVal = (String)request.getAttribute("dataResourceId");
    org.ofbiz.base.util.Debug.logInfo("in editdataprep, primaryKeyVal(2):" + primaryKeyVal, null);
        currentValue = delegator.findByPrimaryKey(entityName, UtilMisc.toMap("dataResourceId",primaryKeyVal));
}

if (currentValue == null) {
        primaryKeyVal = (String)request.getParameter("dataResourceId");
    org.ofbiz.base.util.Debug.logInfo("in editdataprep, primaryKeyVal(3):" + primaryKeyVal, null);
        currentValue = delegator.findByPrimaryKey(entityName, UtilMisc.toMap("dataResourceId",primaryKeyVal));
    org.ofbiz.base.util.Debug.logInfo("in editdataprep, currentValue(3):" + currentValue, null);
}

    context.put("hasPermission", Boolean.TRUE);
if (currentValue == null ) {
  request.setAttribute("errorReqMsg", "No current content PK found.");
} else {

        
    HtmlFormWrapper editWrapper = new HtmlFormWrapper(formDefFile, 
    				singleFormName, request, response);
    
    org.ofbiz.base.util.Debug.logInfo("in editdataprep, editWrapper(3):" + editWrapper, null);
    editWrapper.putInContext(defaultMapName, currentValue);
    // The idea here is that by setting the map name here, dependency on the 
            // widget-form config file could be eliminated.
    ModelForm modelForm	= editWrapper.getModelForm();
    modelForm.setDefaultMapName(defaultMapName);
    context.put("editWrapper", editWrapper);
    //context.put(priKeyName, priKeyValue);

    org.ofbiz.base.util.Debug.logInfo("in editdataprep, entityName:" + entityName, null);
    if (entityName != null && entityName.equals("DataResource") ) {
        List dataCategoryTrail = new ArrayList();
        rootNode = new HashMap();
        rootNode.put("id", "ROOT");
        DataResourceWorker.getDataCategoryMap(delegator, 0, rootNode, dataCategoryTrail, true);
        Debug.logInfo(" typelist, rootNode: " + rootNode, "FINDPREP");
        List dataCategoryList = new ArrayList();
        DataResourceWorker.buildList(rootNode, dataCategoryList, 0);
        context.put("dataCategoryList", dataCategoryList);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -