BrightSide Workbench Full Report + Source Code
bserp-www/src/main/java/org/turro/erp/aptitude/logic/AptitudeWrapper.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.aptitude.logic;
19 
20 import org.turro.auth.Authentication;
21 import org.turro.command.Command;
22 import org.turro.command.Context;
23 import org.turro.elephant.log.LogType;
24 import org.turro.elephant.util.ZkossUtils;
25 import org.turro.erp.entity.Aptitude;
26 import org.turro.zul.frame.Framework;
27 
32 public class AptitudeWrapper extends org.turro.hr.aptitude.AptitudeWrapper {
33 
35  super(entity);
36  }
37 
38  public void delete(final boolean close) {
39  // Check if possible and notify
40  if(canDelete()) {
41  ZkossUtils.confirmDeletion(null, new Command() {
42  @Override
43  public Object execute(Context context) {
44  if(AptitudeWrapper.super.delete()) {
45  if(close) Framework.getCurrent().closeSelected();
46  }
47  return null;
48  }
49  });
50  }
51  }
52 
53  public boolean canDelete() {
54  if(entity.getId() == 0) return false;
55 // Dao dao = getDao();
56 // Long count = (Long) dao.getSingleResult(
57 // "select count(*) from Document " +
58 // "where contract = ?",
59 // new Object[] { contract });
60 // if(count == 0) {
61 // count = (Long) dao.getSingleResult(
62 // "select count(*) from DocumentLine " +
63 // "where store = ?",
64 // new Object[] { contract });
65 // }
66 // return count == 0;
67  return true;
68  }
69 
70  @Override
71  protected void logEntity(LogType logType, String path, String action, String data) {
72  Authentication.log(logType, path, action, data);
73  }
74 
75 }
static Framework getCurrent()
Definition: Framework.java:203