[Join-cvs] join1/src/main/org/figure8/join/control/action DeliverableActions.java, 1.1, 1.2 Physic
Brought to you by:
lbroudoux
|
From: Laurent B. <lbr...@us...> - 2007-04-08 18:40:44
|
Update of /cvsroot/join/join1/src/main/org/figure8/join/control/action In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21949/control/action Modified Files: DeliverableActions.java PhysicalEnvironmentActions.java Log Message: Adding getting configuration at date feature + fixing Checkstyle errors Index: PhysicalEnvironmentActions.java =================================================================== RCS file: /cvsroot/join/join1/src/main/org/figure8/join/control/action/PhysicalEnvironmentActions.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PhysicalEnvironmentActions.java 9 Oct 2006 20:21:22 -0000 1.2 --- PhysicalEnvironmentActions.java 8 Apr 2007 18:40:38 -0000 1.3 *************** *** 19,22 **** --- 19,24 ---- import org.figure8.join.core.DuplicateEntityException; import org.figure8.join.businessobjects.environment.PhysicalEnvironment; + import org.figure8.join.businessobjects.environment.LogicalEnvironment; + import org.figure8.join.businessobjects.environment.EnvironmentMapping; import org.figure8.join.businessfacades.environment.EnvironmentManager; import org.figure8.join.view.PhysicalEnvironmentTrackingView; *************** *** 32,35 **** --- 34,39 ---- import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + + import java.util.Calendar; /** * Struts action used for managing physical environments within Join application. *************** *** 70,73 **** --- 74,82 ---- public static final String ENVIRONMENT_KEY = "environment"; /** + * The request scope attribute under which the LogicalENvironment object + * selected is stored. + */ + public static final String LOGICAL_ENVIRONMENT_KEY = "logicalEnvironment"; + /** * The request scope attribute under which the retrieved PhysicalEnvironments * list is stored. *************** *** 75,78 **** --- 84,92 ---- public static final String ENVIRONMENTS_KEY = "environments"; /** + * The request scope attribute under which the date corresponding + * to environment configuration view is stored. + */ + public static final String VIEW_DATE_KEY = "viewDate"; + /** * The request scope attribute under which the configuration changes view * for a tracking period is stored. *************** *** 119,123 **** * @throws Exception such as InfraStructureExceptions ... */ ! public ActionForward doExecute(String operation, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{ // Trace operation to execute. log.debug("doExecute() called for '" + operation + "' operation"); --- 133,138 ---- * @throws Exception such as InfraStructureExceptions ... */ ! public ActionForward doExecute(String operation, ActionMapping mapping, ActionForm form, ! HttpServletRequest request, HttpServletResponse response) throws Exception{ // Trace operation to execute. log.debug("doExecute() called for '" + operation + "' operation"); *************** *** 133,137 **** } else if (CONFIG_OP.equals(operation)){ ! return null; } else if (CHANGES_OP.equals(operation)){ --- 148,152 ---- } else if (CONFIG_OP.equals(operation)){ ! return getEnvironmentConfigAtDate(mapping, form, request, response); } else if (CHANGES_OP.equals(operation)){ *************** *** 158,164 **** * @return A forward to the next view to render and display */ ! protected ActionForward loadEnvironment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) ! throws Exception{ ! if (form instanceof PhysicalEnvironmentForm){ // Get the requested environment from manager. --- 173,178 ---- * @return A forward to the next view to render and display */ ! protected ActionForward loadEnvironment(ActionMapping mapping, ActionForm form, ! HttpServletRequest request, HttpServletResponse response) throws Exception{ if (form instanceof PhysicalEnvironmentForm){ // Get the requested environment from manager. *************** *** 185,191 **** * @return A forward to the next view to render and display */ ! protected ActionForward saveEnvironment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) ! throws Exception{ ! if (form instanceof PhysicalEnvironmentForm){ // Get the environment form. --- 199,204 ---- * @return A forward to the next view to render and display */ ! protected ActionForward saveEnvironment(ActionMapping mapping, ActionForm form, ! HttpServletRequest request, HttpServletResponse response) throws Exception{ if (form instanceof PhysicalEnvironmentForm){ // Get the environment form. *************** *** 202,206 **** } else{ ! log.info("Update of existing PhysicalEnvironemnt having key: " + envForm.getKey()); PropertyUtils.copyProperties(environment, envForm); } --- 215,219 ---- } else{ ! log.info("Update of existing PhysicalEnvironment having key: " + envForm.getKey()); PropertyUtils.copyProperties(environment, envForm); } *************** *** 230,244 **** * @return A forward to the next view to render and display */ ! protected ActionForward getEnvironmentDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) ! throws Exception{ ! if (form instanceof PhysicalEnvironmentForm){ // Get the requested environment from manager. PhysicalEnvironmentForm envForm = (PhysicalEnvironmentForm)form; ! PhysicalEnvironment environment = environmentManager.getPhysicalEnvironment(envForm.getId()); // Load the environments list and forward. request.setAttribute(ENVIRONMENT_KEY, environment); - request.setAttribute(ENVIRONMENTS_KEY, environmentManager.getPhysicalEnvironments()); return mapping.findForward("EnvironmentViews"); } --- 243,268 ---- * @return A forward to the next view to render and display */ ! protected ActionForward getEnvironmentDetails(ActionMapping mapping, ActionForm form, ! HttpServletRequest request, HttpServletResponse response) ! throws Exception{ if (form instanceof PhysicalEnvironmentForm){ // Get the requested environment from manager. + PhysicalEnvironment environment = null; PhysicalEnvironmentForm envForm = (PhysicalEnvironmentForm)form; ! ! if (!envForm.isFromLogical()){ ! log.debug("Getting environment details for PhysicalEnvironment '" + envForm.getId() + "'"); ! environment = environmentManager.getPhysicalEnvironment(envForm.getId()); ! request.setAttribute(ENVIRONMENTS_KEY, environmentManager.getPhysicalEnvironments()); ! } ! else{ ! log.debug("Getting environment details for LogicalEnvironment '" + envForm.getId() + "'"); ! LogicalEnvironment logicalEnvironment = environmentManager.getLogicalEnvironment(envForm.getId()); ! environment = logicalEnvironment.getActiveEnvironmentMapping().getPhysicalEnvironment(); ! request.setAttribute(LOGICAL_ENVIRONMENT_KEY, logicalEnvironment); ! } // Load the environments list and forward. request.setAttribute(ENVIRONMENT_KEY, environment); return mapping.findForward("EnvironmentViews"); } *************** *** 248,258 **** /** * Load a specified physical environment from datastore and get its configuration * changes during specified period (use startDate and endDate from form). * @return A forward to the next view to render and display */ ! protected ActionForward getEnvironmentChanges(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) ! throws Exception{ ! if (form instanceof PhysicalEnvironmentForm){ // Get the requested environment tracking view from manager. --- 272,332 ---- /** + * Load a specified physical environmnet from datastore ad get its configuration + * a precise datetime (use startDate, startHour and startMin from form). + * @return A forward to the new view to render and display + */ + protected ActionForward getEnvironmentConfigAtDate(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) + throws Exception{ + if (form instanceof PhysicalEnvironmentForm){ + // Get the requested environment view at date from manager. + PhysicalEnvironmentForm envForm = (PhysicalEnvironmentForm)form; + + // Build correct datetime from form and request locale. + Calendar date = Calendar.getInstance(request.getLocale()); + date.setTime(envForm.getStartDate()); + date.set(Calendar.HOUR_OF_DAY, envForm.getStartHour()); + date.set(Calendar.MINUTE, envForm.getStartMin()); + + // Get configuration view. + PhysicalEnvironment view = null; + if (!envForm.isFromLogical()){ + log.debug("Getting environment coniguration for PhysicalEnvironment '" + envForm.getKey() + "'"); + view = environmentManager.getPhysicalEnvironmentAtDate(envForm.getKey(), date.getTime()); + request.setAttribute(ENVIRONMENTS_KEY, environmentManager.getPhysicalEnvironments()); + } + else{ + log.debug("Getting environment configuration for LogicalEnvironment '" + envForm.getKey() + "'"); + // Retrieve mapping active at wanted date. + LogicalEnvironment logicalEnvironment = environmentManager.getLogicalEnvironment(envForm.getKey()); + EnvironmentMapping envMapping = environmentManager.getEnvironmentMappingAtDate(logicalEnvironment, + date.getTime()); + // If no mapping, set an empty environemnt. + if (envMapping != null) + view = environmentManager.getPhysicalEnvironmentAtDate(envMapping.getPhysicalEnvironment().getKey(), + date.getTime()); + else view = new PhysicalEnvironment(); + + request.setAttribute(LOGICAL_ENVIRONMENT_KEY, logicalEnvironment); + } + + // Store configuration view, date and forward. + request.setAttribute(ENVIRONMENT_KEY, view); + request.setAttribute(VIEW_DATE_KEY, date.getTime()); + return mapping.findForward("EnvironmentViews"); + } + // This should not happen... + return null; + } + + + /** * Load a specified physical environment from datastore and get its configuration * changes during specified period (use startDate and endDate from form). * @return A forward to the next view to render and display */ ! protected ActionForward getEnvironmentChanges(ActionMapping mapping, ActionForm form, ! HttpServletRequest request, HttpServletResponse response) ! throws Exception{ if (form instanceof PhysicalEnvironmentForm){ // Get the requested environment tracking view from manager. Index: DeliverableActions.java =================================================================== RCS file: /cvsroot/join/join1/src/main/org/figure8/join/control/action/DeliverableActions.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DeliverableActions.java 7 Jul 2006 22:20:46 -0000 1.1 --- DeliverableActions.java 8 Apr 2007 18:40:38 -0000 1.2 *************** *** 124,129 **** * @throws Exception such as InfraStructureExceptions ... */ ! public ActionForward doExecute(String operation, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) ! throws Exception{ // Trace operation to execute. log.debug("doExecute() called for '" + operation + "' operation"); --- 124,129 ---- * @throws Exception such as InfraStructureExceptions ... */ ! public ActionForward doExecute(String operation, ActionMapping mapping, ActionForm form, ! HttpServletRequest request, HttpServletResponse response) throws Exception{ // Trace operation to execute. log.debug("doExecute() called for '" + operation + "' operation"); *************** *** 161,167 **** * @return A forward to the next view to render and display */ ! protected ActionForward loadDeliverable(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) ! throws Exception{ ! if (form instanceof DeliverableForm){ // Get the requested deliverable from manager --- 161,166 ---- * @return A forward to the next view to render and display */ ! protected ActionForward loadDeliverable(ActionMapping mapping, ActionForm form, ! HttpServletRequest request, HttpServletResponse response) throws Exception{ if (form instanceof DeliverableForm){ // Get the requested deliverable from manager *************** *** 188,194 **** * @return A forward to the next view to render and display */ ! protected ActionForward showDeliverableForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) ! throws Exception{ ! if (form instanceof DeliverableForm){ DeliverableForm dForm = (DeliverableForm)form; --- 187,193 ---- * @return A forward to the next view to render and display */ ! protected ActionForward showDeliverableForm(ActionMapping mapping, ActionForm form, ! HttpServletRequest request, HttpServletResponse response) ! throws Exception{ if (form instanceof DeliverableForm){ DeliverableForm dForm = (DeliverableForm)form; *************** *** 211,217 **** * @return A forward to the next view to render and display */ ! protected ActionForward saveDeliverable(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) ! throws Exception{ ! if (form instanceof DeliverableForm){ DeliverableForm dForm = (DeliverableForm)form; --- 210,215 ---- * @return A forward to the next view to render and display */ ! protected ActionForward saveDeliverable(ActionMapping mapping, ActionForm form, ! HttpServletRequest request, HttpServletResponse response) throws Exception{ if (form instanceof DeliverableForm){ DeliverableForm dForm = (DeliverableForm)form; *************** *** 241,247 **** * @return A forward to the next view to render and display */ ! protected ActionForward createDeliverable(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) ! throws Exception{ ! if (form instanceof DeliverableForm){ DeliverableForm dForm = (DeliverableForm)form; --- 239,244 ---- * @return A forward to the next view to render and display */ ! protected ActionForward createDeliverable(ActionMapping mapping, ActionForm form, ! HttpServletRequest request, HttpServletResponse response) throws Exception{ if (form instanceof DeliverableForm){ DeliverableForm dForm = (DeliverableForm)form; *************** *** 253,257 **** // Create deliverable and register it using manager. ! Deliverable deliverable = new Deliverable(dForm.getVersionInfo(), dForm.getComments(), supplierId, release, type); log.info("Creation of a new Deliverable with key: " + deliverable.getKey()); --- 250,255 ---- // Create deliverable and register it using manager. ! Deliverable deliverable = new Deliverable(dForm.getVersionInfo(), dForm.getComments(), ! supplierId, release, type); log.info("Creation of a new Deliverable with key: " + deliverable.getKey()); *************** *** 274,280 **** * @return A forward to the next view to render and display */ ! protected ActionForward searchDeliverables(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) ! throws Exception{ ! if (form instanceof DeliverableForm){ // Get the deliverable form. --- 272,278 ---- * @return A forward to the next view to render and display */ ! protected ActionForward searchDeliverables(ActionMapping mapping, ActionForm form, ! HttpServletRequest request, HttpServletResponse response) ! throws Exception{ if (form instanceof DeliverableForm){ // Get the deliverable form. *************** *** 301,307 **** * @return A forward to the next view to render and display */ ! protected ActionForward getDeliverableDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) ! throws Exception{ ! if (form instanceof DeliverableForm){ // Get the requested deliverable from manager --- 299,305 ---- * @return A forward to the next view to render and display */ ! protected ActionForward getDeliverableDetails(ActionMapping mapping, ActionForm form, ! HttpServletRequest request, HttpServletResponse response) ! throws Exception{ if (form instanceof DeliverableForm){ // Get the requested deliverable from manager *************** *** 322,324 **** return null; } ! } --- 320,322 ---- return null; } ! } \ No newline at end of file |