Advertisement
psi_mmobile

Untitled

May 26th, 2020
1,107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.82 KB | None | 0 0
  1.     private void setRemoteUnit(AppModuleImpl am, ViewObject vo, Row fixedUnit) {
  2.         Integer remoteUnitId = (Integer)fixedUnit.getAttribute("RemoteUnitId");
  3.         //Find remote unit
  4.         if (null == remoteUnitId) {
  5.             remoteUnitId = createRemoteUnit(am);
  6.             fixedUnit.setAttribute("RemoteUnitId", remoteUnitId);
  7.         }
  8.  
  9.         vo = am.getRemoteUnitView1();
  10.         vo.setWhereClause("RemoteUnit.REMOTE_UNIT_ID = " + remoteUnitId);
  11.         vo.executeQuery();
  12.     }
  13.    
  14.     protected void prepareThePage(int selectedFixedUnitId) {
  15.         AppModuleImpl am = (AppModuleImpl)ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");
  16.         ViewObject vo = am.getEditFixedUnitView1();
  17.         vo.setWhereClause("FixedUnit.FIXED_UNIT_ID = " + selectedFixedUnitId);
  18.         vo.executeQuery();
  19.         Row fixedUnit = vo.first();
  20.         isLinkedToAddress =
  21.                 (null != fixedUnit.getAttribute("Wgs84Latitude") && null != fixedUnit.getAttribute("Wgs84Latitude"));
  22.         setJSON(new FixedUnitResult(fixedUnit), isLinkedToAddress);
  23.  
  24.         setRemoteUnit(am, vo, fixedUnit);
  25.     }
  26.    
  27.     protected int createRemoteUnit(AppModuleImpl am) {
  28.         ViewObject vo = am.getRemoteUnitView1();
  29.         Row row = vo.createRow();
  30.         row.setNewRowState(Row.STATUS_INITIALIZED);
  31.         row.setAttribute("AdminCenterId", UserBean.getCurrent().getAdminCenterId());
  32.         vo.insertRow(row);
  33.         am.getTransaction().postChanges();
  34.         log.debug("RemoteUnitId? : " + row.getAttribute("RemoteUnitId"));
  35.         int remoteUnitId = (Integer)row.getAttribute("RemoteUnitId");
  36.         System.out.println("REMOTE UNIT ID FROM createRemoteUnit(AppModuleImpl am) IS: " + remoteUnitId);
  37.         vo.setCurrentRow(row);
  38.         return remoteUnitId;
  39.     }
  40.  
  41.     public String editFixedUnit() {
  42.         this.geocodeRes = null;
  43.         int selectedFixedUnitId = ContextBean.getCurrent().getSelectedFixedUnitId();
  44.         log.debug("Edit FixedUnit : " + selectedFixedUnitId);
  45.         if (selectedFixedUnitId == 0) {
  46.             BuildixxUtils.addInfoMessage(JSFUtils.resolveExpressionAsString("#{res.misc_pls_sel_fu_first}"));
  47.  
  48.             return null;
  49.         }
  50.         prepareThePage(selectedFixedUnitId);
  51.  
  52.         return "editFixedUnit";
  53.     }
  54.    
  55.     public String createFixedUnit() {
  56.         log.debug("Create FIXED UNIT");
  57.         ContextBean.getCurrent().setSelectedFixedUnitId(0);
  58.         AppModuleImpl am = (AppModuleImpl)ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");
  59.  
  60.         ViewObject voFixedUnitCategoryView = am.getVoFixedUnitCategoryView1();
  61.         if (!voFixedUnitCategoryView.isExecuted())
  62.             voFixedUnitCategoryView.executeQuery();
  63.         if (voFixedUnitCategoryView.getRowCount() == 0) {
  64.             log.debug("No fixed unit category found in VoFixedUnitCategoryView, Create aborted");
  65.             return "";
  66.         }
  67.         createFixedUnit(am, voFixedUnitCategoryView);
  68.  
  69.         return editFixedUnit();
  70.     }
  71.    
  72.     protected void createFixedUnit(AppModuleImpl am, ViewObject voFixedUnitCategoryView) {
  73.         ViewObject editFixedUnitVo = am.getEditFixedUnitView1();
  74.         Row newFixedUnit = editFixedUnitVo.createRow();
  75.  
  76.         Row currentFixedUnitCategory = voFixedUnitCategoryView.getCurrentRow();
  77.         if (null == currentFixedUnitCategory)
  78.             currentFixedUnitCategory = voFixedUnitCategoryView.first();
  79.  
  80.         newFixedUnit.setAttribute("VehicleOwnerId", currentFixedUnitCategory.getAttribute("VehicleOwnerId"));
  81.         newFixedUnit.setAttribute("VoFixedUnitCategoryId", currentFixedUnitCategory.getAttribute("VoFixedUnitCategoryId"));
  82.         editFixedUnitVo.insertRow(newFixedUnit);
  83.         am.getTransaction().postChanges();
  84.         log.debug("FixedUnitId? : " + newFixedUnit.getAttribute("FixedUnitId"));
  85.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement