BrightSide Workbench Full Report + Source Code
ErpCommand.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.command;
20 
21 //import org.turro.annotation.ElephantCommand;
22 //import org.turro.command.LabelControl;
23 //import org.turro.elephant.command.CommandFactory;
24 //import org.turro.elephant.command.CommandResolver;
25 //import org.turro.elephant.command.Plugins;
26 //import org.turro.elephant.context.Application;
27 //import org.turro.erp.db.ErpPU;
28 //import org.turro.erp.entity.*;
29 //import org.turro.erp.menu.ErpMenu;
30 //import org.turro.path.Path;
31 //import org.turro.elephant.zkoss.ElLabel;
32 
37 //@ElephantCommand
38 public class ErpCommand /*extends CommandResolver implements Plugins*/ {
39 
40 // @Override
41 // protected Object loadEntity(Path path) {
42 // if(path.getSize() == 2) {
43 // if("workorder".equals(path.getRoot())) {
44 // return new ErpPU().find(WorkOrder.class, Long.valueOf(path.getNode(1)));
45 // } else if("orderref".equals(path.getRoot())) {
46 // return new ErpPU().find(OrderReference.class, Long.valueOf(path.getNode(1)));
47 // } else if("task".equals(path.getRoot())) {
48 // return new ErpPU().find(Task.class, Long.valueOf(path.getNode(1)));
49 // } else if("aptitude".equals(path.getRoot())) {
50 // return new ErpPU().find(Aptitude.class, Long.valueOf(path.getNode(1)));
51 // } else if("resource".equals(path.getRoot())) {
52 // return new ErpPU().find(Resource.class, Long.valueOf(path.getNode(1)));
53 // } else if("humanres".equals(path.getRoot())) {
54 // return new ErpPU().find(HumanResource.class, Long.valueOf(path.getNode(1)));
55 // }
56 // }
57 // return null;
58 // }
59 //
60 // @Override
61 // protected Object getCtrl(String type) {
62 // return new LabelControl(entity);
63 // }
64 //
65 // @Override
66 // protected Object getCtrl(Path path, String type) {
67 // return null;
68 // }
69 //
70 // @Override
71 // protected String getImage(String type) {
72 // if(entity instanceof WorkOrder) {
73 // if(((WorkOrder) entity).getProductId() > 0) {
74 // return "/_zul/images/productorder.png";
75 // } else {
76 // return "/_zul/images/workorder.png";
77 // }
78 // } else if(entity instanceof OrderReference) {
79 // return "/_zul/images/reference.png";
80 // } else if(entity instanceof Task) {
81 // return "/_zul/images/task.png";
82 // } else if(entity instanceof Aptitude) {
83 // return "/_zul/images/aptitude.png";
84 // } else if(entity instanceof Resource) {
85 // return "/_zul/images/resource.png";
86 // } else if(entity instanceof HumanResource) {
87 // return "/_zul/images/operator.png";
88 // }
89 // return null;
90 // }
91 //
92 // @Override
93 // protected String getImage(Path path, String type) {
94 // if("workorder".equals(path.getRoot())) {
95 // return "/_zul/images/workorder.png";
96 // } else if("orderref".equals(path.getRoot())) {
97 // return "/_zul/images/reference.png";
98 // } else if("task".equals(path.getRoot())) {
99 // return "/_zul/images/task.png";
100 // } else if("aptitude".equals(path.getRoot())) {
101 // return "/_zul/images/aptitude.png";
102 // } else if("resource".equals(path.getRoot())) {
103 // return "/_zul/images/resource.png";
104 // } else if("humanres".equals(path.getRoot())) {
105 // return "/_zul/images/operator.png";
106 // }
107 // return null;
108 // }
109 //
110 // @Override
111 // protected String getPath() {
112 // return ErpPU.getObjectPath(entity);
113 // }
114 //
115 // @Override
116 // protected String getExtendedPath() {
117 // return ErpPU.getObjectExtendedPath(entity);
118 // }
119 //
120 // @Override
121 // protected String getDescription() {
122 // if(entity instanceof WorkOrder) {
123 // return ((WorkOrder) entity).getDescription();
124 // } else if(entity instanceof Task) {
125 // return ((Task) entity).getDescription();
126 // }
127 // return null;
128 // }
129 //
130 // @Override
131 // protected String getName() {
132 // if(entity instanceof WorkOrder) {
133 // return ((WorkOrder) entity).getFullDescription();
134 // } else if(entity instanceof OrderReference) {
135 // return ((OrderReference) entity).getSomeDescription();
136 // } else if(entity instanceof Task) {
137 // return ((Task) entity).getName();
138 // } else if(entity instanceof Aptitude) {
139 // return ((Aptitude) entity).getName();
140 // } else if(entity instanceof Resource) {
141 // return ((Resource) entity).getName();
142 // } else if(entity instanceof HumanResource) {
143 // return ((HumanResource) entity).getName();
144 // }
145 // return null;
146 // }
147 //
148 // @Override
149 // protected String getName(Path path) {
150 // if(path.isRoot()) {
151 // if("workorder".equals(path.getRoot())) {
152 // return Application.getString("lWorkOrder");
153 // } else if("orderref".equals(path.getRoot())) {
154 // return Application.getString("lReference");
155 // } else if("task".equals(path.getRoot())) {
156 // return Application.getString("lTask");
157 // } else if("aptitude".equals(path.getRoot())) {
158 // return Application.getString("lAptitude");
159 // } else if("resource".equals(path.getRoot())) {
160 // return Application.getString("lResource");
161 // } else if("humanres".equals(path.getRoot())) {
162 // return Application.getString("lHumanResource");
163 // }
164 // }
165 // return null;
166 // }
167 //
168 // @Override
169 // protected Boolean showEntity() {
170 // if(entity instanceof WorkOrder) {
171 // ErpMenu.showWorkOrder(((WorkOrder) entity).getId());
172 // return true;
173 // } else if(entity instanceof Task) {
174 // ErpMenu.showTaskDetail(((Task) entity).getId(), true);
175 // return true;
176 // } else if(entity instanceof Aptitude) {
177 // ErpMenu.showAptitude(((Aptitude) entity).getId());
178 // return true;
179 // } else if(entity instanceof Resource) {
180 // ErpMenu.showResource(((Resource) entity).getId());
181 // return true;
182 // } else if(entity instanceof HumanResource) {
183 // ErpMenu.showHumanResource(((HumanResource) entity).getId());
184 // return true;
185 // }
186 // return null;
187 // }
188 //
189 // @Override
190 // protected Boolean canShow() {
191 // if(entity instanceof WorkOrder) {
192 // return Application.getApplication().isInRole("erp-workorder:edit");
193 // } else if(entity instanceof OrderReference) {
194 // return false;
195 // } else if(entity instanceof Task) {
196 // return Application.getApplication().isInRole("erp-task:edit");
197 // } else if(entity instanceof Aptitude) {
198 // return Application.getApplication().isInRole("erp-config:edit");
199 // } else if(entity instanceof Resource) {
200 // return Application.getApplication().isInRole("erp-config:edit");
201 // } else if(entity instanceof HumanResource) {
202 // return Application.getApplication().isInRole("erp-config:edit");
203 // }
204 // return null;
205 // }
206 //
207 // @Override
208 // public void addPlugins() {
209 // CommandFactory.addPlugin(Application.getApplication(), new ErpCustomerSummary());
210 // }
211 
212 }