Author: jleroux
Date: Sun Nov 12 09:02:39 2006 New Revision: 473992 URL: http://svn.apache.org/viewvc?view=rev&rev=473992 Log: A patch from Marco Risaliti : "Migrate Entity Maintenance from JSPs/region to Screen widget" (https://issues.apache.org/jira/browse/OFBIZ-450) Added: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh (with props) incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh (with props) incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh (with props) incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh (with props) incubator/ofbiz/trunk/framework/webtools/webapp/webtools/entity/EntityMaint.ftl (with props) incubator/ofbiz/trunk/framework/webtools/webapp/webtools/entity/FindGeneric.ftl (with props) incubator/ofbiz/trunk/framework/webtools/webapp/webtools/entity/ViewGeneric.ftl (with props) incubator/ofbiz/trunk/framework/webtools/webapp/webtools/entity/ViewRelations.ftl (with props) Modified: incubator/ofbiz/trunk/ (props changed) incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels_it.properties incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/regions.xml incubator/ofbiz/trunk/framework/webtools/webapp/webtools/entity/FindGeneric.jsp incubator/ofbiz/trunk/framework/webtools/webapp/webtools/entity/ViewGeneric.jsp incubator/ofbiz/trunk/framework/webtools/webapp/webtools/entity/ViewRelations.jsp incubator/ofbiz/trunk/framework/webtools/webapp/webtools/entity/entitymaint.jsp incubator/ofbiz/trunk/framework/webtools/widget/EntityScreens.xml Propchange: incubator/ofbiz/trunk/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Sun Nov 12 09:02:39 2006 @@ -1,3 +1,10 @@ -ofbiz.jar -bin -patchDos.bat +ofbiz.jar +bin +patchDos.bat +startofbizScreen.bat +startofbizBoth.bat +startofbizFr.bat +startofbizPos.bat +startofbizPosFr.bat +startofbizPosScreen.bat +ofbizLogo.png Modified: incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties?view=diff&rev=473992&r1=473991&r2=473992 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties (original) +++ incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.properties Sun Nov 12 09:02:39 2006 @@ -43,8 +43,11 @@ WebtoolsAddLoggerFormDescription=This form allows you to enable a logger for a specific package or class. WebtoolsAdjustDebuggingLevels=Adjust Debugging Levels WebtoolsAdministration=Administration +WebtoolsAll=All WebtoolsAsync=ASYNC WebtoolsBackToCacheMaintenance=Back to Cache Maintenance +WebtoolsBackToEntityList=Back To Entity List +WebtoolsBackToFindScreen=Back To Find Screen WebtoolsBytes=Bytes WebtoolsCacheDebugTools=Cache & Debug Tools WebtoolsCacheElementKey=Cache Element Key @@ -59,11 +62,13 @@ WebtoolsConditions=Conditions WebtoolsConditionService=Condition service WebtoolsCount=Count +WebtoolsCreate=Crt WebtoolsCreateDummyFks=Create "Dummy" FKs WebtoolsDataFileTools=Data File Tools WebtoolsDebuggingLevelFormDescription=This form allows you to change application debugging levels. WebtoolsDefaultEntityName=Default Entity Name WebtoolsDeleteFiles=Delete Files Afterwards? +WebtoolsDeleteThisValue=Delete This Value WebtoolsDispatcherName=Dispatcher Name WebtoolsEditCustomTimePeriods=Edit Custom Time Periods WebtoolsElements=Elements @@ -75,6 +80,7 @@ WebtoolsEntityReference=Entity Reference WebtoolsEntitySyncStatus=Entity Sync Status WebtoolsEntityXMLTools=Entity XML Tools +WebtoolsEntityView=View Entity WebtoolsErrorLogLevel=Error WebtoolsErrorLogLevelTooltip=The Error level designates error events that might still allow the application to continue running. WebtoolsEventName=Event name @@ -85,6 +91,14 @@ WebtoolsFatalLogLevel=Fatal WebtoolsFatalLogLevelTooltip=The Fatal level designates very severe error events that will presumably lead the application to abort. WebtoolsFieldName=Field Name +WebtoolsFieldsList=Fields +WebtoolsFieldType=Field Type +WebtoolsFind=Fnd +WebtoolsFindAllRecords=Find All Records +WebtoolsFindRecord=Find Record +WebtoolsFindValues=Find Values +WebtoolsFKName=FK Name +WebtoolsForEntity=For Entity WebtoolsFormat=Format WebtoolsFreeMemory=FREE WebtoolsFrequency=Frequency @@ -108,6 +122,7 @@ WebtoolsIsURL=Is URL? WebtoolsJob=Job WebtoolsJobList=Job List +WebtoolsLeaveAllEntriesBlank=leave all entries blank WebtoolsLHSMapName=LHS map name WebtoolsLHSValueName=LHS value name WebtoolsLimitRowsTo=Limit Rows To @@ -139,6 +154,10 @@ WebtoolsMessage12=Step 2: Service Parameters WebtoolsMessage13=This application is primarily intended for developers and system administrators WebtoolsMessage14=For something interesting make sure you are logged in, try username:admin, password:ofbiz +WebtoolsMessage15=You may create an Entity +WebtoolsMessage16=by entering the values you want, and clicking Create +WebtoolsMessage17=You do not have permission to create a entity +WebtoolsMessage18=_ADMIN, or _CREATE needed. WebtoolsMiscSetupTools=Misc. Setup Tools WebtoolsMisses=Misses/NF/EXP/SR WebtoolsMissesTotal=Misses @@ -151,6 +170,8 @@ WebtoolsNoParametersDefined=No parameters defined WebtoolsNoServicesFound=No services found WebtoolsNote1=NOTE: If you have not already run the installation data loading script, from the ofbiz home directory run "ant run-install" or "java -jar ofbiz.jar install" +WebtoolsNotPresent=NP +WebtoolsNoRecordsFound=No Records found for Entity WebtoolsNoUtilCacheFound=No UtilCache instances found WebtoolsNoUtilCacheElementsFound=No UtilCache elements found WebtoolsNoUtilCacheSpecified=No Cache Name Specified @@ -163,7 +184,12 @@ WebtoolsPerformanceTests=Performance Tests WebtoolsPermissionError=Webtools Permission Error WebtoolsPermissionType=Permission Type +WebtoolsPk=Primary Key WebtoolsPool=Pool +WebtoolsRelatedEntity=Related Entity +WebtoolsRelations=Relations +WebtoolsRelationType=Relation Type +WebtoolsReln=Reln WebtoolsReloadCacheList=Reload Cache List WebtoolsRemoves=removes:H/M WebtoolsRemovesHit=removes:Hit @@ -191,6 +217,8 @@ WebtoolsShowShowWSDL=Show wsdl WebtoolsSize=Size WebtoolsSizeTotal=Size Total +WebtoolsSpecifiedEntity1=Specified Entity +WebtoolsSpecifiedEntity2=was not found WebtoolsStatusInvalid=Invalid Status WebtoolsStatusRunning=Running WebtoolsStatusShuttingDown=Shutting down @@ -210,12 +238,14 @@ WebtoolsTimeoutSeconds=TX Timeout Seconds (for each entity) WebtoolsTimingLogLevel=Timing WebtoolsTimingLogLevelTooltip=The Timing Level designates fine-grained informational events that are most useful to debug an application. +WebtoolsTitle=Title WebtoolsTitle1=The purpose of this Web Tools administration package is to contain all of the WebtoolsTitle2=administration tools that directly relate to the various Core Tool Components. The Core Tool Component layer is WebtoolsTitle3=defined in the architecture documents as the container WebtoolsTitle4=of all entity definitions shared by the vertical applications that WebtoolsTitle5=are built on top of these entity definitions and the tools surrounding them such as the entity, workflow, and rule engines, WebtoolsTitle6=content and knowledge management, data analysis, and so forth +WebtoolsToFindAll=To find ALL of Entity WebtoolsTotalMemory=TOTAL WebtoolsUsedMemory=USED WebtoolsUseFileStore=Use File Store ? @@ -224,8 +254,11 @@ WebtoolsVerboseLogLevel=Verbose WebtoolsVerboseLogLevelTooltip=The Verbose Level designates fine-grained informational events that are most useful to debug an application. WebtoolsViewLog=View Log +WebtoolsViewRelations=View Relations +WebtoolsViewValue=View Value WebtoolsWarningLogLevel=Warning WebtoolsWarningLogLevelTooltip=The Warning level designates potentially harmful situations. +WebtoolsWithPk=With PK WebtoolsWorkflowEngineTools=Workflow Engine Tools WebtoolsWorkflowMonitor=Workflow Monitor WebtoolsWorkWithDataFiles=Work With Data Files Modified: incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels_it.properties URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels_it.properties?view=diff&rev=473992&r1=473991&r2=473992 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels_it.properties (original) +++ incubator/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels_it.properties Sun Nov 12 09:02:39 2006 @@ -39,8 +39,11 @@ WebtoolsAddLoggerFormDescription=Questa form ti permette di abilitare un logger per uno specifico package o classe. WebtoolsAdjustDebuggingLevels=Aggiustamento Livello di Debugging WebtoolsAdministration=Amministra +WebtoolsAll=Tutto WebtoolsAsync=Asincrono WebtoolsBackToCacheMaintenance=Torna Indietro alla Pagina Manutenzione Cache +WebtoolsBackToEntityList=Torna Indietro alla Lista Entit\u00e0 +WebtoolsBackToFindScreen=Torna Indietro alla Ricerca WebtoolsBytes=Bytes WebtoolsCacheDebugTools=Strumenti di Debug e Cache WebtoolsCacheElementKey=Chiave Elemento Cache @@ -55,9 +58,11 @@ WebtoolsConditions=Condizioni WebtoolsConditionService=Condizione servizio WebtoolsCount=Conta +WebtoolsCreate=Crea WebtoolsCreateDummyFks=Creare "Dummy" FKs WebtoolsDataFileTools=Strumenti per File Dati WebtoolsDeleteFiles=Cancellare i Files Successivamente? +WebtoolsDeleteThisValue=Cancella Questo Valore WebtoolsDebuggingLevelFormDescription=Questa form ti permette di cambiare i livelli di debug dell'applicazione. WebtoolsDefaultEntityName=Nome Entit\u00e0 Default WebtoolsDispatcherName=Nome Dispatcher @@ -70,6 +75,7 @@ WebtoolsEntityName=Nome Entit\u00e0 WebtoolsEntitySyncStatus=Stato Sincronizzazioni Entit\u00e0 WebtoolsEntityXMLTools=Strumenti per Entit\u00e0 XML +WebtoolsEntityView=Entit\u00e0 Vista WebtoolsErrorLogLevel=Errore WebtoolsErrorLogLevelTooltip=Il livello Errore designa eventi di errori che potrebbero ancora permettere all'applicazione di continuare l'esecuzione. WebtoolsEventName=Nome Evento @@ -80,6 +86,14 @@ WebtoolsFatalLogLevel=Fatale WebtoolsFatalLogLevelTooltip=Il livello Fatale designa molti eventi di errori che presubibilmente l'applicazione terminer\u00e0. WebtoolsFieldName=Nome Campo +WebtoolsFieldsList=Campi +WebtoolsFieldType=Tipo Campo +WebtoolsFind=Ric +WebtoolsFindAllRecords=Ricerca Tutti i Records +WebtoolsFindRecord=Ricerca Record +WebtoolsFindValues=Ricerca Valori +WebtoolsFKName=Nome Chiave Esterna +WebtoolsForEntity=Per Entit\u00e0 WebtoolsFormat=Formato WebtoolsFreeMemory=LIBERA WebtoolsFrequency=Frequenza @@ -103,6 +117,7 @@ WebtoolsIsURL=E' un URL? WebtoolsJob=Lavoro WebtoolsJobList=Lista Lavori +WebtoolsLeaveAllEntriesBlank=lasciare tutte le voci vuote WebtoolsLHSMapName=Nome mappa LHS WebtoolsLHSValueName=Nome valore LHS WebtoolsLimitRowsTo=Limita Righe A @@ -134,6 +149,10 @@ WebtoolsMessage12=Passo 2: Servizio Parametri WebtoolsMessage13=Questa applicazione \u00e8 progettat per gli sviluppatori e amministratori di sistema WebtoolsMessage14=Se interessato, devi essere autenticato, provare con Nome utente:admin, Password:ofbiz +WebtoolsMessage15=Tu puoi creare una Entit\u00e0 +WebtoolsMessage16=e inserendo i valori che vuoi, e cliccando il tasto Creare +WebtoolsMessage17=Tu non hai il permesso di creare una entit\u00e0 +WebtoolsMessage18=_ADMIN, o _CREATE necessitano. WebtoolsMiscSetupTools=Strumenti Vari di Configurazione WebtoolsMisses=Perse Non Trovate Scadute Pulizia Riferimenti WebtoolsMissesTotal=Perse @@ -146,6 +165,8 @@ WebtoolsNoParametersDefined=Nessun parametro definito WebtoolsNoServicesFound=Nessun servizio trovato WebtoolsNote1=NOTA: Se non hai ancora eseguito lo script di installazione di caricamento dei dati, esegui dalla home directory di ofbiz "ant run-install" o "java -jar ofbiz.jar install" +WebtoolsNotPresent=Non Presente +WebtoolsNoRecordsFound=Nessun Records trovato per l'Entit\u00e0 WebtoolsNoUtilCacheFound=Nessuna istanza di Cache trovata WebtoolsNoUtilCacheElementsFound=Nessun elemento di Cache trovato WebtoolsNoUtilCacheSpecified=Nessun Nome di Cache Specificato @@ -158,7 +179,12 @@ WebtoolsPermissionError=Errore Permesso Strumenti Web WebtoolsPerformanceTests=Test delle Prestazioni WebtoolsPermissionType=Tipo Permesso +WebtoolsPk=Chiave Primaria WebtoolsPool=Pool +WebtoolsRelatedEntity=Entit\u00e0 Relazionata +WebtoolsRelations=Relazioni +WebtoolsRelationType=Tipo Relazione +WebtoolsReln=Rel WebtoolsReloadCacheList=Ricarica Lista Cache WebtoolsRemoves=Rimossi: Colpi Persi WebtoolsRemovesHit=Rimossi: Colpi @@ -186,6 +212,8 @@ WebtoolsShowShowWSDL=Mostra wsdl WebtoolsSize=Ampiezza WebtoolsSizeTotal=Ampiezza Totale +WebtoolsSpecifiedEntity1=Entit\u00e0 specificata +WebtoolsSpecifiedEntity2=non trovata WebtoolsStatusInvalid=Stato Invalido WebtoolsStatusRunning=In Esecuzione WebtoolsStatusShuttingDown=In Chiusura @@ -205,12 +233,14 @@ WebtoolsTimeoutSeconds=TX Timeout in Secondi (per ogni entit\u00e0) WebtoolsTimingLogLevel=Tempo WebtoolsTimingLogLevelTooltip=Il livello Tempo designa eventi informativi che sono utili per il debug dell'applicazione. +WebtoolsTitle=Titolo WebtoolsTitle1=La funzione di questo pacchetto di Strumenti Web di amministrazione \u00e8 di contenere tutti gli WebtoolsTitle2=strumenti di amministrazione che sono direttamente relativi alle varie Componenti Principali. Lo strato dei Componenti Principali \u00e8 WebtoolsTitle3=definito nei documenti architetturali come il container WebtoolsTitle4=di tutte le definizioni delle entit\u00e0 condivise da tuttle le applicazioni che WebtoolsTitle5=sono costruite alla base di queste definizioni di entit\u00e0 e strumenti intorno a questi come entit\u00e0, flussi di lavoro, e engine delle regole, WebtoolsTitle6=gestione contenuti, analisi dati, e cos\u00ec via +WebtoolsToFindAll=Per ricercare TUTTO sull'Entit\u00e0 WebtoolsTotalMemory=TOTALE WebtoolsUsedMemory=USATA WebtoolsUseFileStore=Usa File Memorizzato ? @@ -219,8 +249,11 @@ WebtoolsVerboseLogLevel=Dettaglio WebtoolsVerboseLogLevelTooltip=Il livello Dettaglio designa eventi informativi che sono utili per il debug dell'applicazione. WebtoolsViewLog=Mostra Log +WebtoolsViewRelations=Mostra Relazioni +WebtoolsViewValue=Mostra Valore WebtoolsWarningLogLevel=Avvertimento WebtoolsWarningLogLevelTooltip=Il livello Avvertimento designa potenziali situazioni anomale. +WebtoolsWithPk=Con la Chiave Primaria WebtoolsWorkflowEngineTools=Strumenti per Engine Flussi di Lavoro WebtoolsWorkflowMonitor=Monitor dei Flussi di Lavoro WebtoolsWorkWithDataFiles=Lavora Con i Files di Dati Added: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh?view=auto&rev=473992 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh (added) +++ incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh Sun Nov 12 09:02:39 2006 @@ -0,0 +1,65 @@ +/* + * Copyright 2001-2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.model.ModelReader; +import org.ofbiz.entity.model.ModelEntity; +import org.ofbiz.entity.model.ModelViewEntity; + +delegator = request.getAttribute("delegator"); + +ModelReader reader = delegator.getModelReader(); +Collection ec = reader.getEntityNames(); +TreeSet entities = new TreeSet(ec); +Iterator classNamesIterator = entities.iterator(); + +int colSize = entities.size()/3 + 1; +int kIdx = 0; +List entitiesList = new ArrayList(); +while (classNamesIterator != null && classNamesIterator.hasNext()) { + ModelEntity entity = reader.getModelEntity((String)classNamesIterator.next()); + + String viewEntity = "N"; + if (entity instanceof ModelViewEntity) { + viewEntity = "Y"; + } + + String entityPermissionView = "N"; + if (security.hasEntityPermission("ENTITY_DATA", "_VIEW", session) || security.hasEntityPermission(entity.getPlainTableName(), "_VIEW", session)) { + entityPermissionView = "Y"; + } + + String entityPermissionCreate = "N"; + if (security.hasEntityPermission("ENTITY_DATA", "_CREATE", session) || security.hasEntityPermission(entity.getPlainTableName(), "_CREATE", session)) { + entityPermissionCreate = "Y"; + } + + String changeColumn = "N"; + kIdx++; + if (kIdx >= colSize) { + colSize += colSize; + changeColumn = "Y"; + } + + Map entityMap = new HashMap(); + entityMap.put("entityName", entity.getEntityName()); + entityMap.put("entityPermissionView", entityPermissionView); + entityMap.put("entityPermissionCreate", entityPermissionCreate); + entityMap.put("viewEntity", viewEntity); + entityMap.put("changeColumn", changeColumn); + + entitiesList.add(entityMap); +} +context.put("entitiesList", entitiesList); Propchange: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityMaint.bsh ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh?view=auto&rev=473992 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh (added) +++ incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh Sun Nov 12 09:02:39 2006 @@ -0,0 +1,221 @@ +/* + * Copyright 2001-2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.security.Security; +import org.ofbiz.entity.model.ModelReader; +import org.ofbiz.entity.model.ModelEntity; +import org.ofbiz.entity.model.ModelField; +import org.ofbiz.entity.model.ModelFieldType; +import org.ofbiz.entity.GenericEntity; +import org.ofbiz.base.util.UtilFormatOut; +import org.ofbiz.entity.condition.EntityCondition; +import org.ofbiz.entity.condition.EntityFieldMap; +import org.ofbiz.entity.condition.EntityOperator; +import org.ofbiz.entity.transaction.TransactionUtil; +import org.ofbiz.entity.util.EntityFindOptions; +import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.base.util.Debug; +import java.sql.Timestamp; +import java.sql.Date; +import java.sql.Time; + +delegator = request.getAttribute("delegator"); +security = request.getAttribute("security"); + +String entityName = request.getParameter("entityName"); + +ModelReader reader = delegator.getModelReader(); +ModelEntity modelEntity = reader.getModelEntity(entityName); + +context.put("entityName", modelEntity.getEntityName()); +context.put("plainTableName", modelEntity.getPlainTableName()); + +String hasViewPermission = (security.hasEntityPermission("ENTITY_DATA", "_VIEW", session) || security.hasEntityPermission(modelEntity.getPlainTableName(), "_VIEW", session)) == true ? "Y" : "N"; +String hasCreatePermission = (security.hasEntityPermission("ENTITY_DATA", "_CREATE", session) || security.hasEntityPermission(modelEntity.getPlainTableName(), "_CREATE", session)) == true ? "Y" : "N"; +String hasUpdatePermission = (security.hasEntityPermission("ENTITY_DATA", "_UPDATE", session) || security.hasEntityPermission(modelEntity.getPlainTableName(), "_UPDATE", session)) == true ? "Y" : "N"; +String hasDeletePermission = (security.hasEntityPermission("ENTITY_DATA", "_DELETE", session) || security.hasEntityPermission(modelEntity.getPlainTableName(), "_DELETE", session)) == true ? "Y" : "N"; + +context.put("hasViewPermission", hasViewPermission); +context.put("hasCreatePermission", hasCreatePermission); +context.put("hasUpdatePermission", hasUpdatePermission); +context.put("hasDeletePermission", hasDeletePermission); + +String find = request.getParameter("find"); +if (find == null) { + find = "false"; +} + +String curFindString = "entityName=" + entityName + "&find=" + find; + +GenericEntity findByEntity = delegator.makeValue(entityName, null); +for (int fnum = 0; fnum < modelEntity.getFieldsSize(); fnum++) { + ModelField field = modelEntity.getField(fnum); + String fval = request.getParameter(field.getName()); + if (fval != null) { + if (fval.length() > 0) { + curFindString = curFindString + "&" + field.getName() + "=" + fval; + findByEntity.setString(field.getName(), fval); + } + } +} +curFindString = UtilFormatOut.encodeQuery(curFindString); +context.put("curFindString", curFindString); + +String viewIndexString = (String)request.getParameter("VIEW_INDEX"); +if (viewIndexString == null || viewIndexString.length() == 0) { + viewIndexString = "0"; +} + +int viewIndex = 0; +try { + viewIndex = Integer.valueOf(viewIndexString).intValue(); +} +catch (NumberFormatException nfe) { + viewIndex = 0; +} +context.put("viewIndex", viewIndex); +context.put("viewIndexPrevious", viewIndex-1); +context.put("viewIndexNext", viewIndex+1); + +String viewSizeString = (String)request.getParameter("VIEW_SIZE"); +if (viewSizeString == null || viewSizeString.length() == 0) { + viewSizeString = "10"; +} + +int viewSize = 10; +try { + viewSize = Integer.valueOf(viewSizeString).intValue(); +} +catch (NumberFormatException nfe) { + viewSize = 10; +} +context.put("viewSize", viewSize); + +int lowIndex = viewIndex*viewSize+1; +int highIndex = (viewIndex+1)*viewSize; +context.put("lowIndex", lowIndex); +context.put("highIndex", highIndex); + +int arraySize = 0; +List resultPartialList = null; + +if ("true".equals(find)) { + EntityCondition condition = new EntityFieldMap(findByEntity, EntityOperator.AND); + arraySize = (int) delegator.findCountByCondition(findByEntity.getEntityName(), condition, null); + if (arraySize < highIndex) { + highIndex = arraySize; + } + + if ((highIndex - lowIndex + 1) > 0) { + boolean beganTransaction = false; + try { + beganTransaction = TransactionUtil.begin(); + + EntityFindOptions efo = new EntityFindOptions(); + efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE); + EntityListIterator resultEli = null; + resultEli = delegator.findListIteratorByCondition(findByEntity.getEntityName(), condition, null, null, null, efo); + resultPartialList = resultEli.getPartialList(lowIndex, highIndex - lowIndex + 1); + resultEli.close(); + } + catch (GenericEntityException e) { + Debug.logError(e, "Failure in operation, rolling back transaction", "FindGeneric.bsh"); + try { + // only rollback the transaction if we started one... + TransactionUtil.rollback(beganTransaction, "Error looking up entity values in WebTools Entity Data Maintenance", e); + } + catch (GenericEntityException e2) { + Debug.logError(e2, "Could not rollback transaction: " + e2.toString(), "FindGeneric.bsh"); + } + // after rolling back, rethrow the exception + throw e; + } + finally { + // only commit the transaction if we started one... this will throw an exception if it fails + TransactionUtil.commit(beganTransaction); + } + } +} +context.put("arraySize", arraySize); +context.put("resultPartialList", resultPartialList); + +List fieldList = new ArrayList(); +for (int fnum = 0; fnum < modelEntity.getFieldsSize(); fnum++) { + ModelField field = modelEntity.getField(fnum); + ModelFieldType type = delegator.getEntityFieldType(modelEntity, field.getType()); + + Map fieldMap = new HashMap(); + fieldMap.put("name", field.getName()); + fieldMap.put("isPk", (field.getIsPk() == true) ? "Y" : "N"); + fieldMap.put("javaType", type.getJavaType()); + fieldMap.put("sqlType", type.getSqlType()); + fieldMap.put("param", (request.getParameter(field.getName()) != null ? request.getParameter(field.getName()) : "")); + + fieldList.add(fieldMap); +} +context.put("fieldList", fieldList); +context.put("columnCount", (fieldList.size())+2); + +List records = new ArrayList(); +if (resultPartialList != null) { + Iterator resultPartialIter = resultPartialList.iterator(); + while (resultPartialIter.hasNext()) { + Map record = new HashMap(); + + GenericValue value = (GenericValue)resultPartialIter.next(); + String findString = "entityName=" + entityName; + for (int pknum = 0; pknum < modelEntity.getPksSize(); pknum++) { + ModelField pkField = modelEntity.getPk(pknum); + ModelFieldType type = delegator.getEntityFieldType(modelEntity, pkField.getType()); + findString += "&" + pkField.getName() + "=" + value.get(pkField.getName()); + } + record.put("findString", findString); + + List fields = new ArrayList(); + for (int fnum = 0; fnum < modelEntity.getFieldsSize(); fnum++) { + String fieldValue = ""; + ModelField field = modelEntity.getField(fnum); + ModelFieldType type = delegator.getEntityFieldType(modelEntity, field.getType()); + + if(type.getJavaType().equals("Timestamp") || type.getJavaType().equals("java.sql.Timestamp")) { + Timestamp dtVal = value.getTimestamp(field.getName()); + fieldValue = (dtVal == null) ? "" : dtVal.toString(); + } else if(type.getJavaType().equals("Date") || type.getJavaType().equals("java.sql.Date")) { + Date dateVal = value.getDate(field.getName()); + fieldValue = (dateVal == null) ? "" : dateVal.toString(); + } else if(type.getJavaType().equals("Time") || type.getJavaType().equals("java.sql.Time")) { + Time timeVal = value.getTime(field.getName()); + fieldValue = (timeVal == null) ? "" : timeVal.toString(); + } else if(type.getJavaType().indexOf("Integer") >= 0) { + fieldValue = UtilFormatOut.safeToString((Integer)value.get(field.getName())); + } else if(type.getJavaType().indexOf("Long") >= 0) { + fieldValue = UtilFormatOut.safeToString((Long)value.get(field.getName())); + } else if(type.getJavaType().indexOf("Double") >= 0) { + fieldValue = UtilFormatOut.safeToString((Double)value.get(field.getName())); + } else if(type.getJavaType().indexOf("Float") >= 0) { + fieldValue = UtilFormatOut.safeToString((Float)value.get(field.getName())); + } else if(type.getJavaType().indexOf("String") >= 0) { + fieldValue = UtilFormatOut.checkNull((String)value.get(field.getName())); + } + fields.add(fieldValue); + } + record.put("fields", fields); + records.add(record); + } +} +context.put("records", records); Propchange: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.bsh ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh?view=auto&rev=473992 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh (added) +++ incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh Sun Nov 12 09:02:39 2006 @@ -0,0 +1,438 @@ +/* + * Copyright 2001-2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.GenericPK; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.security.Security; +import org.ofbiz.entity.model.ModelReader; +import org.ofbiz.entity.model.ModelEntity; +import org.ofbiz.entity.model.ModelField; +import org.ofbiz.entity.model.ModelFieldType; +import org.ofbiz.entity.model.ModelRelation; +import org.ofbiz.entity.model.ModelKeyMap; +import org.ofbiz.base.util.UtilFormatOut; +import org.ofbiz.base.util.UtilMisc; +import java.sql.Timestamp; +import java.sql.Date; +import java.sql.Time; + +delegator = request.getAttribute("delegator"); +security = request.getAttribute("security"); + +String entityName = request.getParameter("entityName"); +context.put("entityName", entityName); + +ModelReader reader = delegator.getModelReader(); +ModelEntity entity = reader.getModelEntity(entityName); + +context.put("plainTableName", entity.getPlainTableName()); + +boolean hasAllView = security.hasEntityPermission("ENTITY_DATA", "_VIEW", session); +boolean hasAllCreate = security.hasEntityPermission("ENTITY_DATA", "_CREATE", session); +boolean hasAllUpdate = security.hasEntityPermission("ENTITY_DATA", "_UPDATE", session); +boolean hasAllDelete = security.hasEntityPermission("ENTITY_DATA", "_DELETE", session); +boolean hasViewPermission = hasAllView || security.hasEntityPermission(entity.getPlainTableName(), "_VIEW", session); +boolean hasCreatePermission = hasAllCreate || security.hasEntityPermission(entity.getPlainTableName(), "_CREATE", session); +boolean hasUpdatePermission = hasAllUpdate || security.hasEntityPermission(entity.getPlainTableName(), "_UPDATE", session); +boolean hasDeletePermission = hasAllDelete || security.hasEntityPermission(entity.getPlainTableName(), "_DELETE", session); + +context.put("hasAllView", hasAllView); +context.put("hasAllCreate", hasAllCreate); +context.put("hasAllUpdate", hasAllUpdate); +context.put("hasAllDelete", hasAllDelete); +context.put("hasViewPermission", hasViewPermission); +context.put("hasCreatePermission", hasCreatePermission); +context.put("hasUpdatePermission", hasUpdatePermission); +context.put("hasDeletePermission" , hasDeletePermission); + +boolean useValue = true; +String curFindString = "entityName=" + entityName; +GenericPK findByPK = delegator.makePK(entityName, null); +for(int fnum = 0; fnum < entity.getPksSize(); fnum++) { + ModelField field = entity.getPk(fnum); + ModelFieldType type = delegator.getEntityFieldType(entity, field.getType()); + String fval = request.getParameter(field.getName()); + if (fval != null && fval.length() > 0) { + curFindString = curFindString + "&" + field.getName() + "=" + fval; + findByPK.setString(field.getName(), fval); + } +} +context.put("findByPk", findByPK.toString()); + +curFindString = UtilFormatOut.encodeQuery(curFindString); +context.put("curFindString", curFindString); + +GenericValue value = null; +//only try to find it if this is a valid primary key... +if (findByPK.isPrimaryKey()) { + value = delegator.findByPrimaryKey(findByPK); +} +context.put("value", value); + +if (value == null) { + useValue = false; +} + +List relationList = new ArrayList(); +for(int tabIndex = 0; tabIndex < entity.getRelationsSize(); tabIndex++) { + Map relation = new HashMap(); + + ModelRelation modelRelation = entity.getRelation(tabIndex); + ModelEntity relatedEntity = reader.getModelEntity(modelRelation.getRelEntityName()); + if (hasAllView || security.hasEntityPermission(relatedEntity.getPlainTableName(), "_VIEW", session)) { + relation.put("tab", "tab"+(tabIndex+3)); + relation.put("title", modelRelation.getTitle()); + relation.put("relEntityName", modelRelation.getRelEntityName()); + relation.put("type", modelRelation.getType()); + } + relationList.add(relation); +} +context.put("relations", relationList); + +if (value != null) { + List fieldList = new ArrayList(); + for (int fnum = 0; fnum < entity.getFieldsSize(); fnum++) { + Map mapField = new HashMap(); + + ModelField field = entity.getField(fnum); + ModelFieldType type = delegator.getEntityFieldType(entity, field.getType()); + + String fieldValue = ""; + if (type.getJavaType().equals("Timestamp") || type.getJavaType().equals("java.sql.Timestamp")) { + Timestamp dtVal = value.getTimestamp(field.getName()); + fieldValue = (dtVal == null) ? "" : dtVal.toString(); + } else if (type.getJavaType().equals("Date") || type.getJavaType().equals("java.sql.Date")) { + Date dateVal = value.getDate(field.getName()); + fieldValue = (dateVal == null) ? "" : dateVal.toString(); + } else if (type.getJavaType().equals("Time") || type.getJavaType().equals("java.sql.Time")) { + Time timeVal = value.getTime(field.getName()); + fieldValue = (timeVal == null) ? "" : timeVal.toString(); + } else if (type.getJavaType().indexOf("Integer") >= 0) { + fieldValue = UtilFormatOut.safeToString((Integer)value.get(field.getName())); + } else if (type.getJavaType().indexOf("Long") >= 0) { + fieldValue = UtilFormatOut.safeToString((Long)value.get(field.getName())); + } else if (type.getJavaType().indexOf("Double") >= 0) { + fieldValue = UtilFormatOut.safeToString((Double)value.get(field.getName())); + } else if (type.getJavaType().indexOf("Float") >= 0) { + fieldValue = UtilFormatOut.safeToString((Float)value.get(field.getName())); + } else if (type.getJavaType().indexOf("String") >= 0) { + fieldValue = UtilFormatOut.checkNull((String)value.get(field.getName())); + } + mapField.put("name", field.getName()); + mapField.put("value", fieldValue); + + fieldList.add(mapField); + } + context.put("fields", fieldList); +} + +GenericValue valueSave = value; +boolean pkNotFound = false; +if (value == null && (findByPK.getAllFields().size() > 0)) { + pkNotFound = true; +} +context.put("pkNotFound", pkNotFound); + +String lastUpdateMode = request.getParameter("UPDATE_MODE"); +if ((session.getAttribute("_ERROR_MESSAGE_") != null || request.getAttribute("_ERROR_MESSAGE_") != null) && + lastUpdateMode != null && !lastUpdateMode.equals("DELETE")) { + //if we are updating and there is an error, do not use the entity data for the fields, use parameters to get the old value + useValue = false; +} +context.put("useValue", useValue); + +List newFieldPkList = new ArrayList(); +for (int fnum = 0; fnum < entity.getPksSize();fnum++) { + Map mapField = new HashMap(); + + ModelField field = entity.getPk(fnum); + ModelFieldType type = delegator.getEntityFieldType(entity, field.getType()); + + String fieldValue = ""; + String fieldType = ""; + String stringLength = ""; + if (type.getJavaType().equals("Timestamp") || type.getJavaType().equals("java.sql.Timestamp")) { + String dateTimeString = null; + if (findByPK != null && useValue) { + Timestamp dtVal = findByPK.getTimestamp(field.getName()); + if(dtVal != null) { + dateTimeString = dtVal.toString(); + } + } else if (!useValue) { + dateTimeString = request.getParameter(field.getName()); + } + fieldValue = UtilFormatOut.checkNull(dateTimeString); + fieldType = "DateTime"; + } else if (type.getJavaType().equals("Date") || type.getJavaType().equals("java.sql.Date")) { + String dateString = null; + if (findByPK != null && useValue) { + Date dateVal = findByPK.getDate(field.getName()); + dateString = (dateVal == null) ? "" : dateVal.toString(); + } else if (!useValue) { + dateString = request.getParameter(field.getName()); + } + fieldValue = UtilFormatOut.checkNull(dateString); + fieldType = "Date"; + } else if (type.getJavaType().equals("Time") || type.getJavaType().equals("java.sql.Time")) { + String timeString = null; + if (findByPK != null && useValue) { + Time timeVal = findByPK.getTime(field.getName()); + timeString = (timeVal == null) ? "" : timeVal.toString(); + } else if (!useValue) { + timeString = request.getParameter(field.getName()); + } + fieldValue = UtilFormatOut.checkNull(timeString); + fieldType = "Time"; + } else if (type.getJavaType().indexOf("Integer") >= 0) { + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.safeToString((Integer)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldType = "Integer"; + } else if (type.getJavaType().indexOf("Long") >= 0) { + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.safeToString((Long)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldType = "Long"; + } else if (type.getJavaType().indexOf("Double") >= 0) { + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.safeToString((Double)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldType = "Double"; + } else if (type.getJavaType().indexOf("Float") >= 0) { + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.safeToString((Float)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldType = "Float"; + } else if (type.getJavaType().indexOf("String") >= 0) { + if (type.stringLength() <= 80) { + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.checkNull((String)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldType = "StringOneRow"; + } else if (type.stringLength() <= 255){ + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.checkNull((String)findByPK.get(field.getName())) : (useValue ? "" : UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldType = "String"; + } else { + fieldValue = (findByPK != null && useValue) ? UtilFormatOut.checkNull((String)findByPK.get(field.getName())):(useValue?"":UtilFormatOut.checkNull(request.getParameter(field.getName()))); + fieldType = "Textarea"; + } + stringLength = type.stringLength().toString(); + } + mapField.put("name", field.getName()); + mapField.put("value", fieldValue); + mapField.put("fieldType", fieldType); + mapField.put("stringLength", stringLength); + + newFieldPkList.add(mapField); +} +context.put("newFieldPkList", newFieldPkList); + +List newFieldNoPkList = new ArrayList(); +for (int fnum = 0; fnum < entity.getNopksSize();fnum++) { + Map mapField = new HashMap(); + + ModelField field = entity.getNopk(fnum); + ModelFieldType type = delegator.getEntityFieldType(entity, field.getType()); + + String fieldValue = ""; + String fieldType = ""; + String stringLength = ""; + if (type.getJavaType().equals("Timestamp") || type.getJavaType().equals("java.sql.Timestamp")) { + String dateTimeString = null; + if (value != null && useValue) { + Timestamp dtVal = value.getTimestamp(field.getName()); + if (dtVal != null) { + dateTimeString = dtVal.toString(); + } + } else if (!useValue) { + dateTimeString = request.getParameter(field.getName()); + } + fieldValue = UtilFormatOut.checkNull(dateTimeString); + fieldType = "DateTime"; + } else if (type.getJavaType().equals("Date") || type.getJavaType().equals("java.sql.Date")) { + String dateString = null; + if (value != null && useValue) { + Date dateVal = value.getDate(field.getName()); + dateString = (dateVal == null) ? "" : dateVal.toString(); + } else if (!useValue) { + dateString = request.getParameter(field.getName()); + } + fieldValue = UtilFormatOut.checkNull(dateString); + fieldType = "Date"; + } else if (type.getJavaType().equals("Time") || type.getJavaType().equals("java.sql.Time")) { + String timeString = null; + if (value != null && useValue) { + Time timeVal = value.getTime(field.getName()); + timeString = (timeVal == null) ? "" : timeVal.toString(); + } else if (!useValue) { + timeString = request.getParameter(field.getName()); + } + fieldValue = UtilFormatOut.checkNull(timeString); + fieldType = "Time"; + } else if (type.getJavaType().indexOf("Integer") >= 0) { + fieldValue = (value != null && useValue) ? UtilFormatOut.safeToString((Integer)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldType = "Integer"; + } else if (type.getJavaType().indexOf("Long") >= 0) { + fieldValue = (value != null && useValue) ? UtilFormatOut.safeToString((Long)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldType = "Long"; + } else if (type.getJavaType().indexOf("Double") >= 0) { + fieldValue = (value != null && useValue) ? UtilFormatOut.safeToString((Double)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldType = "Double"; + } else if (type.getJavaType().indexOf("Float") >= 0) { + fieldValue = (value != null && useValue) ? UtilFormatOut.safeToString((Float)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldType = "Float"; + } else if (type.getJavaType().indexOf("String") >= 0) { + if (type.stringLength() <= 80) { + fieldValue = (value != null && useValue) ? UtilFormatOut.checkNull((String)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldType = "StringOneRow"; + } else if (type.stringLength() <= 255) { + fieldValue = (value != null && useValue) ? UtilFormatOut.checkNull((String)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldType = "String"; + } else { + fieldValue = (value != null && useValue) ? UtilFormatOut.checkNull((String)value.get(field.getName())):UtilFormatOut.checkNull(request.getParameter(field.getName())); + fieldType = "Textarea"; + } + stringLength = type.stringLength().toString(); + } + mapField.put("name", field.getName()); + mapField.put("value", fieldValue); + mapField.put("fieldType", fieldType); + mapField.put("stringLength", stringLength); + + newFieldNoPkList.add(mapField); +} +context.put("newFieldNoPkList", newFieldNoPkList); + +List relationFieldList = new ArrayList(); +for (int relIndex = 0; relIndex < entity.getRelationsSize(); relIndex++) { + Map mapRelation = new HashMap(); + + ModelRelation relation = entity.getRelation(relIndex); + ModelEntity relatedEntity = reader.getModelEntity(relation.getRelEntityName()); + + boolean relCreate = false; + if (security.hasEntityPermission(relatedEntity.getPlainTableName(), "_CREATE", session)) { + relCreate = true; + } + + mapRelation.put("relIndex", relIndex + 3); + mapRelation.put("title", relation.getTitle()); + mapRelation.put("relatedTable", relatedEntity.getEntityName()); + mapRelation.put("relCreate", relCreate); + + if ("one".equals(relation.getType()) || "one-nofk".equals(relation.getType())) { + if (value != null) { + if (hasAllView || security.hasEntityPermission(relatedEntity.getPlainTableName(), "_VIEW", session)) { + Iterator tempIter = UtilMisc.toIterator(value.getRelated(relation.getTitle() + relatedEntity.getEntityName())); + GenericValue valueRelated = null; + if (tempIter != null && tempIter.hasNext()) { + valueRelated = (GenericValue) tempIter.next(); + } + + List relatedFieldsList = new ArrayList(); + for (int fnum = 0; fnum < relatedEntity.getFieldsSize(); fnum++) { + Map mapRelatedFields = new HashMap(); + ModelField field = relatedEntity.getField(fnum); + ModelFieldType type = delegator.getEntityFieldType(entity, field.getType()); + + String fieldValue = ""; + String fieldType = ""; + if (type.getJavaType().equals("Timestamp") || type.getJavaType().equals("java.sql.Timestamp")) { + Timestamp dtVal = null; + if (valueRelated != null) { + dtVal = valueRelated.getTimestamp(field.getName()); + } + fieldValue = (dtVal == null) ? "" : dtVal.toString(); + fieldType = "DateTime"; + } else if (type.getJavaType().equals("Date") || type.getJavaType().equals("java.sql.Date")) { + Date dateVal = null; + if (valueRelated != null) { + dateVal = valueRelated.getDate(field.getName()); + } + fieldValue = (dateVal == null) ? "" : dateVal.toString(); + fieldType = "Date"; + } else if (type.getJavaType().equals("Time") || type.getJavaType().equals("java.sql.Time")) { + Time timeVal = null; + if (valueRelated != null) { + timeVal = valueRelated.getTime(field.getName()); + } + fieldValue = (timeVal == null) ? "" : timeVal.toString(); + fieldType = "Time"; + } else if (type.getJavaType().indexOf("Integer") >= 0) { + if (valueRelated != null) { + fieldValue = UtilFormatOut.safeToString((Integer)valueRelated.get(field.getName())); + } + fieldType = "Integer"; + } else if (type.getJavaType().indexOf("Long") >= 0) { + if (valueRelated != null) { + fieldValue = UtilFormatOut.safeToString((Long)valueRelated.get(field.getName())); + } + fieldType = "Long"; + } else if (type.getJavaType().indexOf("Double") >= 0) { + if (valueRelated != null) { + fieldValue = UtilFormatOut.safeToString((Double)valueRelated.get(field.getName())); + } + fieldType = "Double"; + } else if (type.getJavaType().indexOf("Float") >= 0) { + if (valueRelated != null) { + fieldValue = UtilFormatOut.safeToString((Float)valueRelated.get(field.getName())); + } + fieldType = "Float"; + } else if (type.getJavaType().indexOf("String") >= 0) { + if (valueRelated != null) { + fieldValue = UtilFormatOut.checkNull((String)valueRelated.get(field.getName())); + } + fieldType = "String"; + } + + mapRelatedFields.put("name", field.getName()); + mapRelatedFields.put("type", fieldType); + mapRelatedFields.put("value", fieldValue); + relatedFieldsList.add(mapRelatedFields); + } + + mapRelation.put("valueRelated", valueRelated); + if (valueRelated != null) { + mapRelation.put("valueRelatedPk", valueRelated.getPrimaryKey().toString()); + } + mapRelation.put("relatedFieldsList", relatedFieldsList); + mapRelation.put("relType", "one"); + + String findString = "entityName=" + relatedEntity.getEntityName(); + for (int knum = 0; knum < relation.getKeyMapsSize(); knum++) { + ModelKeyMap keyMap = relation.getKeyMap(knum); + if (value.get(keyMap.getFieldName()) != null) { + findString += "&" + keyMap.getRelFieldName() + "=" + value.get(keyMap.getFieldName()); + } + } + String encodeFindString = UtilFormatOut.encodeQuery(findString); + mapRelation.put("encodeRelatedEntityFindString", encodeFindString); + + relationFieldList.add(mapRelation); + } + } + } else if (relation.getType().equalsIgnoreCase("many")) { + if (value != null) { + if (hasAllView || security.hasEntityPermission(relatedEntity.getPlainTableName(), "_VIEW", session)) { + mapRelation.put("relType", "many"); + + String findString = "entityName=" + relatedEntity.getEntityName(); + for (int knum = 0; knum < relation.getKeyMapsSize(); knum++) { + ModelKeyMap keyMap = relation.getKeyMap(knum); + if (value.get(keyMap.getFieldName()) != null) { + findString += "&" + keyMap.getRelFieldName() + "=" + value.get(keyMap.getFieldName()); + } + } + String encodeFindString = UtilFormatOut.encodeQuery(findString); + mapRelation.put("encodeRelatedEntityFindString", encodeFindString); + + relationFieldList.add(mapRelation); + } + } + } +} +context.put("relationFieldList", relationFieldList); +context.put("relSize", relationFieldList.size() + 2); Propchange: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewGeneric.bsh ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh?view=auto&rev=473992 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh (added) +++ incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh Sun Nov 12 09:02:39 2006 @@ -0,0 +1,59 @@ +/* + * Copyright 2001-2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.security.Security; +import org.ofbiz.entity.model.ModelReader; +import org.ofbiz.entity.model.ModelEntity; +import org.ofbiz.entity.model.ModelRelation; +import org.ofbiz.entity.model.ModelKeyMap; + +delegator = request.getAttribute("delegator"); +security = request.getAttribute("security"); + +String entityName = request.getParameter("entityName"); +context.put("entityName", entityName); + +ModelReader reader = delegator.getModelReader(); +ModelEntity modelEntity = reader.getModelEntity(entityName); + +context.put("plainTableName", modelEntity.getPlainTableName()); + +boolean hasViewPermission = security.hasEntityPermission("ENTITY_DATA", "_VIEW", session) || security.hasEntityPermission(modelEntity.getPlainTableName(), "_VIEW", session); +context.put("hasViewPermission", hasViewPermission); + +List relations = new ArrayList(); +for (Iterator rit = modelEntity.getRelationsIterator(); rit.hasNext();) { + Map mapRelation = new HashMap(); + + ModelRelation modelRelation = (ModelRelation) rit.next(); + List relFields = new ArrayList(); + for (Iterator kit = modelRelation.getKeyMapsIterator(); kit.hasNext(); ) { + Map mapFields = new HashMap(); + ModelKeyMap keyMap = (ModelKeyMap) kit.next(); + mapFields.put("fieldName", keyMap.getFieldName()); + mapFields.put("relFieldName", keyMap.getRelFieldName()); + + relFields.add(mapFields); + } + mapRelation.put("relFields", relFields); + mapRelation.put("title", modelRelation.getTitle()); + mapRelation.put("relEntityName", modelRelation.getRelEntityName()); + mapRelation.put("type", modelRelation.getType()); + mapRelation.put("fkName", modelRelation.getFkName()); + + relations.add(mapRelation); +} +context.put("relations", relations); Propchange: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ViewRelations.bsh ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml?view=diff&rev=473992&r1=473991&r2=473992 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml (original) +++ incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml Sun Nov 12 09:02:39 2006 @@ -177,7 +177,7 @@ <security https="true" auth="true"/> <response name="success" type="view" value="ViewGeneric"/> </request-map> - + <request-map uri="UpdateGeneric"> <security https="true" auth="true"/> <event type="java" path="org.ofbiz.webtools.GenericWebEvent" invoke="updateGeneric"/> @@ -495,10 +495,10 @@ <view-map name="entityref_list" page="/entity/entityref_list.jsp"/> <view-map name="entityref_main" page="/entity/entityref_main.jsp"/> - <view-map name="entitymaint" type="region"/> - <view-map name="FindGeneric" type="region"/> - <view-map name="ViewGeneric" type="region"/> - <view-map name="ViewRelations" type="region"/> + <view-map name="entitymaint" type="screen" page="component://webtools/widget/EntityScreens.xml#EntityMaint"/> + <view-map name="FindGeneric" type="screen" page="component://webtools/widget/EntityScreens.xml#FindGeneric"/> + <view-map name="ViewGeneric" type="screen" page="component://webtools/widget/EntityScreens.xml#ViewGeneric"/> + <view-map name="ViewRelations" type="screen" page="component://webtools/widget/EntityScreens.xml#ViewRelations"/> <!-- these are NOT regions because they generate text output that should never be decorated --> <view-map name="tablesMySql" page="/entity/tablesMySql.jsp"/> Modified: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/regions.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/regions.xml?view=diff&rev=473992&r1=473991&r2=473992 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/regions.xml (original) +++ incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/regions.xml Sun Nov 12 09:02:39 2006 @@ -28,24 +28,6 @@ </define> <!-- ====== Start View Specific Regions ====== --> - - <define id="entitymaint" region="MAIN_REGION"> - <put section="title">Entity Data Maintenance</put> - <put section="content" content="/entity/entitymaint.jsp"/> - </define> - <define id="FindGeneric" region="MAIN_REGION"> - <put section="title">Find Entity</put> - <put section="content" content="/entity/FindGeneric.jsp"/> - </define> - <define id="ViewGeneric" region="MAIN_REGION"> - <put section="title">View/Edit Entity</put> - <put section="content" content="/entity/ViewGeneric.jsp"/> - </define> - <define id="ViewRelations" region="MAIN_REGION"> - <put section="title">View Relations for an Entity</put> - <put section="content" content="/entity/ViewRelations.jsp"/> - </define> - <define id="EditEntity" region="MAIN_REGION"> <put section="title">Edit Entity Definition</put> <put section="content" content="/entity/EditEntity.jsp"/> Added: incubator/ofbiz/trunk/framework/webtools/webapp/webtools/entity/EntityMaint.ftl URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/webapp/webtools/entity/EntityMaint.ftl?view=auto&rev=473992 ============================================================================== --- incubator/ofbiz/trunk/framework/webtools/webapp/webtools/entity/EntityMaint.ftl (added) +++ incubator/ofbiz/trunk/framewo |
Free forum by Nabble | Edit this page |