BrightSide Workbench Full Report + Source Code
bserp-www/src/main/java/org/turro/erp/workorder/logic/WorkOrderWrapper.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.erp.workorder.logic;
19 
20 import org.turro.auth.Authentication;
21 import org.turro.elephant.context.Application;
22 import org.turro.elephant.log.LogType;
23 import org.turro.erp.entity.OrderReference;
24 import org.turro.erp.entity.WorkOrder;
25 
30 public class WorkOrderWrapper extends org.turro.erp.workorder.WorkOrderWrapper {
31 
33  super(entity);
34  }
35 
36  public String getTabLabel() {
37  return getSelfLabel() + " #" + entity.getId();
38  }
39 
40  public String getSelfLabel() {
41  if(entity.isProductOrder()) {
42  return Application.getString("lProductOrder");
43  } else {
44  return Application.getString("lWorkOrder");
45  }
46  }
47 
48  @Override
49  public boolean canDelete() {
50  if(entity.getId() == 0) return false;
51  for(OrderReference or : entity.getOrderReferences()) {
52  if(!or.getUpdatedTasks().isEmpty()) {
53  return false;
54  }
55  }
56 // Dao dao = getDao();
57 // Long count = (Long) dao.getSingleResult(
58 // "select count(*) from OrderReference as o " +
59 // "where o.workOrder = ? " +
60 // "and o.tasks is not empty",
61 // new Object[] { entity });
62 // if(count == 0) {
63 // count = (Long) dao.getSingleResult(
64 // "select count(*) from DocumentLine " +
65 // "where store = ?",
66 // new Object[] { contract });
67 // }
68 // return count == 0;
69  return true;
70  }
71 
72  @Override
73  protected void logEntity(LogType logType, String path, String action, String data) {
74  Authentication.log(logType, path, action, data);
75  }
76 
77 }
static String getString(String key)