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

📄 uixmlfileutil.java

📁 国外的一套开源CRM
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
			}
	
			////////////////////
			// Write out the SQL for inserting the UI attributes.
			////////////////////
			// Loop through the UI entities.  (Should be only one).
			Iterator uiEntityGVI = uiEntityGVL.iterator();
			List uiAttributeGVL = new LinkedList();
	
			while (uiEntityGVI.hasNext()) {
				GenericValue uiEntityGV = (GenericValue) uiEntityGVI.next();
	
				findHashMap = new HashMap();
				findHashMap.put("entityId", uiEntityGV.getString("entityId"));
				findOrder = new ArrayList();
				findOrder.add("attributeId");
				uiAttributeGVL.addAll(writeSqlInserts("UiAttribute",
						findHashMap, findOrder, delegator, outputFile));
			}
	
			resultString += (String.valueOf(uiAttributeGVL.size()) +
			" UI attributes<BR>\n");
			uiEntityGVI = null;
	
			writeFooter(outputFile);
			outputFile.close();
	
			return resultString;
		} catch (IOException e) {
			Debug.logError(
				"[UISQLFileWriter.writeUiEntitySql]: IO Exception - Error was:", module);
			Debug.logError(e.getMessage(), module);
	
			return e.getMessage();
		} catch (SecurityException se) {
			Debug.logError(
				"[UISQLFileWriter.writeUiEntitySql]: Security Exception - Error was:", module);
			Debug.logError(se.getMessage(), module);
	
			return se.getMessage();
		}
	}
	
	/**
	 * DOCUMENT ME!
	 *
	 * @param delegator 
	 * @param entityId 
	 * @param filePath 
	 *
	 * @return 
	 */
	public String writeAllRecords(GenericDelegator delegator, String entityName, String fileName) 	
	{
		ModelEntity modelEntity = null;
		GenericValue genericValue = null;
		String resultString = "";
		
		try {
			// Open the file, and replace any existing contents.
			FileWriter tempFile = new FileWriter(fileName, false);
			PrintWriter outputFile = new PrintWriter( new BufferedWriter(tempFile));
			writeHeader(outputFile);
		
			////////////////////
			// Write out the SQL for inserting the UI entity.
			////////////////////
			List uiEntityGVL = null;
			uiEntityGVL = writeSqlInserts(entityName, null, null,
					delegator, outputFile);
		
			if (uiEntityGVL.size() <= 0) {
				return "No rows found for \"" + entityName + "\"";
			} else {
				resultString += (String.valueOf(uiEntityGVL.size()) +
				" " + entityName + " records saved<BR>\n");
			}
		
			writeFooter(outputFile);
			outputFile.close();
		
			return resultString;
		} catch (IOException e) {
			Debug.logError(
				"[UISQLFileWriter.writeUiEntitySql]: IO Exception - Error was:", module);
			Debug.logError(e.getMessage(), module);
		
			return e.getMessage();
		} catch (SecurityException se) {
			Debug.logError(
				"[UISQLFileWriter.writeUiEntitySql]: Security Exception - Error was:", module);
			Debug.logError(se.getMessage(), module);
		
			return se.getMessage();
		}
	}
	
	/**
	 * DOCUMENT ME!
	 *
	 * @param delegator 
	 * @param entityId 
	 * @param filePath 
	 *
	 * @return 
	 */
	public String writeLayoutTypeFile(GenericDelegator delegator,
		String layoutTypeId, String filePath) {
		HashMap findHashMap = new HashMap();
		ArrayList findOrder = null;
		ModelEntity modelEntity = null;
		GenericValue genericValue = null;
		String entityName = "";
		String resultString = "";
		
		try {
			// Open the file, and replace any existing contents.
			FileWriter tempFile = new FileWriter(filePath, false);
			PrintWriter outputFile = new PrintWriter( new BufferedWriter(tempFile));
			writeHeader(outputFile);
		
			////////////////////
			// Write out the SQL for inserting the UI entity.
			////////////////////
			List uiEntityGVL = null;
			findHashMap = new HashMap();
			findHashMap.put("layoutTypeId",layoutTypeId);
			findOrder = new ArrayList();
			findOrder.add("layoutTypeId");
			uiEntityGVL = writeSqlInserts("UiLayoutType", findHashMap, findOrder,
					delegator, outputFile);
		
			if (uiEntityGVL.size() <= 0) {
				return "No layoutType found with ID \"" + layoutTypeId + "\"";
			} else {
				resultString += (String.valueOf(uiEntityGVL.size()) +
				" Layout Types<BR>\n");
			}
		
			writeFooter(outputFile);
			outputFile.close();
		
			return resultString;
		} catch (IOException e) {
			Debug.logError(
				"[UISQLFileWriter.writeUiEntitySql]: IO Exception - Error was:", module);
			Debug.logError(e.getMessage(), module);
		
			return e.getMessage();
		} catch (SecurityException se) {
			Debug.logError(
				"[UISQLFileWriter.writeUiEntitySql]: Security Exception - Error was:", module);
			Debug.logError(se.getMessage(), module);
		
			return se.getMessage();
		}
	}

    /**
     * DOCUMENT ME!
     *
     * @param delegator 
     * @param codeTypeId 
     * @param filePath 
     *
     * @return 
     */
    public String writeCodeTypeFile(GenericDelegator delegator,
        String codeTypeId, String filePath) {
        HashMap findHashMap = new HashMap();
        ArrayList findOrder = null;
        ModelEntity modelEntity = null;
        GenericValue genericValue = null;
        String entityName = "";
        String resultString = "";

        try {
            // Open the file, and replace any existing contents.
            FileWriter tempFile = new FileWriter(filePath, false);
            PrintWriter outputFile = new PrintWriter( new BufferedWriter(tempFile));
			writeHeader( outputFile );
			
            ////////////////////
            // Write out the SQL for inserting the Code Type.
            ////////////////////
            List codeTypeGVL = null;
            findHashMap = new HashMap();
            findHashMap.put("codeTypeId", codeTypeId);
            findOrder = new ArrayList();
            findOrder.add("codeTypeId");
            codeTypeGVL = writeSqlInserts("CodeType", findHashMap, findOrder,
                    delegator, outputFile);

            if (codeTypeGVL.size() <= 0) {
                return "No code type found with ID \"" + codeTypeId + "\"";
            } else {
                resultString += (String.valueOf(codeTypeGVL.size()) +
                " Code Types<BR>\n");
            }

            ////////////////////
            // Write out the SQL for inserting the Codes.
            ////////////////////
            // Loop through the UI Code Types.  (Should be only one).
            Iterator codeTypeGVI = codeTypeGVL.iterator();
            List codeGVL = new LinkedList();

            while (codeTypeGVI.hasNext()) {
                GenericValue codeGV = (GenericValue) codeTypeGVI.next();

                findHashMap = new HashMap();
                findHashMap.put("codeTypeId", codeGV.getString("codeTypeId"));
                findOrder = new ArrayList();
                findOrder.add("codeId");
                codeGVL.addAll(writeSqlInserts("Code", findHashMap, findOrder,
                        delegator, outputFile));
            }

            resultString += (String.valueOf(codeGVL.size()) + " Codes<BR>\n");
            codeTypeGVI = null;
	
			writeFooter( outputFile );
            outputFile.close();

            return resultString;
        } catch (IOException e) {
            Debug.logError(
                "[UISQLFileWriter.writeUiEntitySql]: IO Exception - Error was:", module);
            Debug.logError(e.getMessage(), module);

            return e.getMessage();
        } catch (SecurityException se) {
            Debug.logError(
                "[UISQLFileWriter.writeUiEntitySql]: Security Exception - Error was:", module);
            Debug.logError(se.getMessage(), module);

            return se.getMessage();
        }
    }

    /**
     * DOCUMENT ME!
     *
     * @param outputFile 
     * @param outputLine 
     */
    protected void writeLine(BufferedWriter outputFile, String outputLine) {
        try {
            outputFile.write(outputLine);
            outputFile.newLine();
            outputFile.flush();

            return;
        } catch (IOException e) {
            Debug.logError(
                "[UISQLFileWriter.writeUiScreenSql]: IO Exception - Error was:", module);
            Debug.logError(e.getMessage(), module);
        } catch (SecurityException se) {
            Debug.logError(
                "[UISQLFileWriter.writeUiScreenSql]: Security Exception - Error was:", module);
            Debug.logError(se.getMessage(), module);
        }
    }

    /**
     * DOCUMENT ME!
     *
     * @param entityName 
     * @param findHashMap 
     * @param findOrder 
     * @param delegator 
     * @param outputFile 
     *
     * @return 
     */
    public List writeSqlInserts(String entityName, Map findHashMap,
        List findOrder, GenericDelegator delegator,
        PrintWriter outputFile) {
        String fieldName = "";
        String fieldValue = "";
        int fieldCount = 0;
        String outputString = "";
        List genericValueList = null;

        try {
            ModelEntity modelEntity = delegator.getModelEntity(entityName);
            if ( findHashMap == null)
				genericValueList = delegator.findAll(entityName, findOrder);
            else
	            genericValueList = delegator.findByLike(entityName, findHashMap, findOrder);

            Iterator genericValueIterator = genericValueList.iterator();

            while (genericValueIterator.hasNext()) {
                GenericValue genericValue = (GenericValue) genericValueIterator.next();
                
				genericValue.writeXmlText(outputFile, "");
            }

            return genericValueList;
        } catch (GenericEntityException gee) {
            Debug.logError(
                "[UISQLFileWriter.writeSqlInserts]: Generic Entity Exception - Error was:", module);
            Debug.logError(gee.getMessage(), module);

            return genericValueList;
        }
    }

	private void writeHeader(PrintWriter outputFile)
	{    
		outputFile.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
		outputFile.println("<entity-engine-xml>");
	}

	private void writeFooter(PrintWriter outputFile)
	{    
		outputFile.println("</entity-engine-xml>");
	}

}

⌨️ 快捷键说明

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