BrightSide Workbench Full Report + Source Code
bserp-www/src/main/java/org/turro/erp/sales/logic/CustomerOrderWrapper.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 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 
19 package org.turro.erp.sales.logic;
20 
21 import org.turro.auth.Authentication;
22 import org.turro.command.Command;
23 import org.turro.command.Context;
24 import org.turro.elephant.log.LogType;
25 import org.turro.elephant.util.ZkossUtils;
26 import org.turro.erp.entity.CustomerOrder;
27 import org.turro.zul.frame.Framework;
28 
33 public class CustomerOrderWrapper extends org.turro.erp.workorder.CustomerOrderWrapper {
34 
36  super(entity);
37  }
38 
39  public void delete(final boolean close) {
40  // Check if possible and notify
41  if(canDelete()) {
42  ZkossUtils.confirmDeletion(null, new Command() {
43  @Override
44  public Object execute(Context context) {
45  if(CustomerOrderWrapper.super.delete()) {
46  if(close) Framework.getCurrent().closeSelected();
47  }
48  return null;
49  }
50  });
51  }
52  }
53 
54  @Override
55  public boolean canDelete() {
56  if(entity.getId() == 0) return false;
57 // Dao dao = getDao();
58 // Long count = (Long) dao.getSingleResult(
59 // "select count(*) from Document " +
60 // "where contract = ?",
61 // new Object[] { contract });
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 Framework getCurrent()
Definition: Framework.java:203