BrightSide Workbench Full Report + Source Code
bserp-core/src/main/java/org/turro/erp/workorder/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;
19 
20 import org.turro.string.Strings;
21 import org.turro.auth.Authentication;
22 import org.turro.elephant.log.LogType;
23 import org.turro.erp.db.ErpPU;
24 import org.turro.erp.entity.WorkOrder;
25 import org.turro.jpa.Dao;
26 import org.turro.jpa.entity.DaoEntity;
27 import org.turro.plugin.PluginChecker;
28 import org.turro.plugin.dossier.ICategory;
29 import org.turro.plugin.dossier.IDossier;
30 
35 public class WorkOrderWrapper extends DaoEntity<WorkOrder, Long> {
36 
38  super(entity);
39  }
40 
41  @Override
42  public WorkOrder save() {
43  entity.prepareForSaving();
44  return super.save();
45  }
46 
47  @Override
48  protected Dao createDao() {
49  return new ErpPU();
50  }
51 
52  @Override
53  protected void logEntity(LogType logType, String path, String action, String data) {
54  Authentication.log(logType, path, action, data);
55  }
56 
57  public IDossier getDossier() {
58  if(entity.getId() > 0) {
59  IDossier dossier = (IDossier) PluginChecker.get("dossier");
60  ICategory cat = dossier.addCategory();
61  cat.setDescription("Resource Planning");
62  cat.setId(8000);
63  cat = dossier.addCategory();
64  cat.setDescription("WorkOrders");
65  cat.setId(8001);
66  cat.setParentId(8000);
67  dossier.setDescription(entity.getWorkOrderId() + " " + Strings.truncateAndWarn(entity.getSomeDescription(), 50));
68  dossier.setIdCategory(cat.getId());
70  if(!entity.isProductOrder()) {
71  dossier.setSubject(entity.getContract().getIContractor());
72  }
73  return dossier;
74  }
75  return null;
76  }
77 
78  @Override
79  protected boolean shouldLog() {
80  return false;
81  }
82 
83 }
static String getObjectPath(Object object)
Definition: ErpPU.java:50
void logEntity(LogType logType, String path, String action, String data)
static Object get(String key)
void setDescription(String description)
void setSubject(IContact subject)
void setIdCategory(Long idCategory)
void setDescription(String description)