1   /*
2    * Copyright 2003 - 2013 The eFaps Team
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   * Revision:        $Rev$
17   * Last Changed:    $Date$
18   * Last Changed By: $Author$
19   */
20  
21  package org.efaps.admin.ui;
22  
23  import java.util.Collections;
24  import java.util.HashMap;
25  import java.util.HashSet;
26  import java.util.Map;
27  import java.util.Properties;
28  import java.util.Set;
29  import java.util.UUID;
30  
31  import org.efaps.admin.EFapsSystemConfiguration;
32  import org.efaps.admin.KernelSettings;
33  import org.efaps.admin.datamodel.Attribute;
34  import org.efaps.admin.datamodel.Classification;
35  import org.efaps.admin.datamodel.Type;
36  import org.efaps.admin.dbproperty.DBProperties;
37  import org.efaps.admin.user.Role;
38  import org.efaps.ci.CIAdminUserInterface;
39  import org.efaps.util.EFapsException;
40  import org.efaps.util.RequestHandler;
41  import org.efaps.util.cache.CacheReloadException;
42  
43  /**
44   * This class represents the Commands which enable the interaction with a User. <br>
45   * Buttons in the UserInterface a represented by this Class.
46   *
47   * @author The eFaps Team
48   * @version $Id$
49   */
50  public abstract class AbstractCommand
51      extends AbstractUserInterfaceObject
52  {
53  
54      /**
55       * This enum is used to define the Sortdirection of a Field.
56       */
57      public static enum SortDirection {
58          /**
59           * Sortdirection descending.
60           */
61          DESCENDING("desc"),
62          /**
63           * Sortdirection ascending.
64           */
65          ASCENDING("asc"),
66          /**
67           * Sortdirection none.
68           */
69          NONE("");
70  
71          /**
72           * Variable storing the value.
73           */
74          private final String value;
75  
76          /**
77           * Private constructor setting the value for the enum.
78           *
79           * @param _value value
80           */
81          private SortDirection(final String _value)
82          {
83              this.value = _value;
84              AbstractCommand.MAPPER.put(this.value, this);
85          }
86  
87          /**
88           * Getter method for instance variable {@link #value}.
89           *
90           * @return value of instance variable {@link #value}
91           */
92          public String getValue()
93          {
94              return this.value;
95          }
96  
97          /**
98           * Method to get a SortDirection by its value.
99           *
100          * @param _value Value for sort direction
101          * @return SortDirection
102          */
103         public static SortDirection getEnum(final String _value)
104         {
105             return AbstractCommand.MAPPER.get(_value);
106         }
107     }
108 
109     /**
110      * This map is used as a store by the enum SortDirection for the method
111      * getEnum.
112      */
113     private static final Map<String, AbstractCommand.SortDirection> MAPPER
114         = new HashMap<String, AbstractCommand.SortDirection>();
115 
116     /**
117      * This enum id used to define the different Targets a Command can have.
118      */
119     public static enum Target {
120         /** The target of the href is the content frame. */
121         CONTENT,
122         /** The target of the href is the hidden frame. */
123         HIDDEN,
124         /** The target of the href is a Modal Window. */
125         MODAL,
126         /** The target of the href is a new Popup Window. */
127         POPUP,
128         /**
129          * The target of the href is not known. This is maybe, if a javascript
130          * function is directly called.
131          */
132         UNKNOWN;
133     }
134 
135     /**
136      * Needed for serialization.
137      */
138     private static final long serialVersionUID = 1L;
139 
140     /**
141      * The instance variable stores if the execution of the command needs a
142      * confirmation of the user. The default value is <i>false</i>.
143      *
144      * @see #isAskUser
145      * @see #setAskUser
146      */
147     private boolean askUser = false;
148 
149     /**
150      * If the instance variable is set to <i>tree</i>, the command is selected
151      * as default command in the navigation tree.
152      *
153      * @see #isDefaultSelected
154      * @see #setDefaultSelected
155      */
156     private boolean defaultSelected = false;
157 
158     /**
159      * Instance variable to hold the reference to the icon file.
160      *
161      * @see #setIcon
162      * @see #getIcon
163      */
164     private String icon = null;
165 
166     /**
167      * The instance variable stores the label of this command instance. The
168      * default value is set from the constructor to the name plus extension
169      * '.Label'.
170      *
171      * @see #getLabel
172      * @see #setLabel
173      */
174     private String label = null;
175 
176     /**
177      * Instance variable to hold the reference to call.
178      *
179      * @see #setReference
180      * @see #getReference
181      */
182     private String reference = null;
183 
184     /**
185      * If the value is set to <i>true</i>. the commands submits the current form
186      * to the given href url and the given target. The default value is
187      * <i>false</i>.
188      *
189      * @see #isSubmit
190      * @see #setSubmit
191      */
192     private boolean submit = false;
193 
194     /**
195      * Number of rows that must be committed. Special meanings:
196      * <ul>
197      * <li>
198      * 0: the mechanism expects at least one. Default</li>
199      * <li>
200      * -1: the mechanism is deactivated.</li>
201      * <li>
202      * 1, 2, 3 ...: the exact number of selected rows will be checked.</li>
203      * </ul>
204      *
205      */
206     private int submitSelectedRows = 0;
207 
208     /**
209      * The target of the command is the content frame.
210      *
211      * @see #isTargetContent
212      * @see #isTargetPopup
213      * @set #getTarget
214      * @see #setTarget
215      */
216     private Target target = AbstractCommand.Target.UNKNOWN;
217 
218     /**
219      * The instance variable stores the height for the target bottom. Only a is
220      * set, the value is used from the JSP pages.
221      *
222      * @see #getTargetBottomHeight
223      * @see #setTargetBottomHeight
224      */
225     private int targetBottomHeight = 0;
226 
227     /**
228      * The instance variable stores the target connect attribute used for the
229      * connect in a form.
230      */
231     private long targetConnectAttributeId = 0;
232 
233     /**
234      * The instance variable stores the create type for the target user
235      * interface object.
236      */
237     private long targetCreateTypeId = 0;
238 
239     /**
240      * Classifications that will be added to the object on create.
241      */
242     private final Set<Long> targetCreateClassificationIds = new HashSet<Long>();
243 
244     /**
245      * Is the target Menu/Command the default.
246      */
247     private boolean targetDefaultMenu = true;
248 
249     /**
250      * The instance variable stores the target user interface form object which
251      * is shown by the this abstract commmand.
252      *
253      * @see #getTargetForm
254      * @see #setTargetForm
255      */
256     private Form targetForm = null;
257 
258     /**
259      * The instance method stores the complete menu. Default value is a null and
260      * no menu is shown.
261      *
262      * @see #setTargetMenu
263      * @see #getTargetMenu
264      */
265     private Menu targetMenu = null;
266 
267     /**
268      * The instance method stores the command that will be executed after this
269      * command.
270      */
271     private AbstractCommand targetCommand = null;
272 
273     /**
274      * Should the revise/previous button be rendered.
275      */
276     private boolean targetCmdRevise = true;
277 
278     /**
279      * The instance variable stores the mode of the target user interface
280      * object.
281      *
282      * @see #getTargetMode
283      * @see #setTargetMode
284      */
285     private TargetMode targetMode = TargetMode.UNKNOWN;
286 
287     /**
288      * The instance variable stores the search of target user interface object.
289      *
290      * @see #getTargetSearch
291      * @see #setTargetSearch
292      */
293     private Search targetSearch = null;
294 
295     /**
296      * Standard checkboxes for a table must be shown. The checkboxes are used
297      * e.g. to delete selected.
298      *
299      * @see #isTargetShowCheckBoxes
300      */
301     private boolean targetShowCheckBoxes = false;
302 
303     /**
304      * The instance variable stores the target user interface table object which
305      * is shown by the this abstract commmand.
306      *
307      * @see #getTargetTable
308      * @see #setTargetTable
309      */
310     private Table targetTable = null;
311 
312     /**
313      * The instance variable stores for target user interface table object the
314      * default sort direction. The default value is NONE. .
315      *
316      * @see #getTargetTableSortDirection
317      * @see #setTargetTableSortDirection
318      */
319     private SortDirection targetTableSortDirection = AbstractCommand.SortDirection.NONE;
320 
321     /**
322      * The instance variable stores for target user interface table object the
323      * default sort key.
324      *
325      * @see #getTargetTableSortKey
326      * @see #setTargetTableSortKey
327      */
328     private String targetTableSortKey = null;
329 
330     /**
331      * Sets the title of the target window.
332      *
333      * @see #getTargetTitle
334      * @see #setTargetTitle
335      */
336     private String targetTitle = null;
337 
338     /**
339      * The instance variable stores the window height of the popup window (
340      * {@link #target} is set to {@link #TARGET_POPUP}). The default value is
341      * <i>400</i>.
342      *
343      * @see #getWindowHeight
344      * @see #setWindowHeight
345      */
346     private int windowHeight = 400;
347 
348     /**
349      * The instance variable stores the window width of the popup window (
350      * {@link #target} is set to {@link #TARGET_POPUP}). The default value is
351      * <i>600</i>.
352      *
353      * @see #getWindowWidth
354      * @see #setWindowWidth
355      */
356     private int windowWidth = 600;
357 
358     /**
359      * Does the executed esjp return a file that must be shown.
360      */
361     private boolean targetShowFile = false;
362 
363     /**
364      * Must the update after command be deactivated.
365      */
366     private boolean noUpdateAfterCmd;
367 
368     /**
369      * Name of the field the Structurbrowser sits in the target.
370      */
371     private String targetStructurBrowserField;
372 
373     /**
374      * Name of the target wiki.
375      */
376     private String targeHelp;
377 
378     /**
379      * Constructor to set the id and name of the command object. The constructor
380      * also sets the label of the command and the titel of the target.
381      *
382      * @param _id id of the command to set
383      * @param _name name of the command to set
384      * @param _uuid uuid of the command to set
385      * @see #label
386      */
387     protected AbstractCommand(final long _id,
388                               final String _uuid,
389                               final String _name)
390     {
391         super(_id, _uuid, _name);
392         this.label = _name + ".Label";
393         this.targetTitle = _name + ".Title";
394     }
395 
396     /**
397      * Add a new role for access to this command.
398      *
399      * @param _role Role to add
400      * @see #access
401      * @see #getAccess
402      */
403     protected void add(final Role _role)
404     {
405         getAccess().add(_role.getId());
406     }
407 
408     /**
409      * Get the current icon reference value.
410      *
411      * @return the value of the instance variable {@link #icon}.
412      * @see #icon
413      * @see #setIcon
414      */
415     public String getIcon()
416     {
417         return this.icon;
418     }
419 
420     /**
421      * This method returns the Property of the Label and not the name.
422      *
423      * @return String
424      */
425     public String getLabelProperty()
426     {
427         return DBProperties.getProperty(this.label);
428     }
429 
430     /**
431      * This is the setter method for the instance variable {@link #label}.
432      *
433      * @return value of instance variable {@link #label}
434      * @see #label
435      * @see #setLabel
436      */
437     public String getLabel()
438     {
439         return this.label;
440     }
441 
442     /**
443      * Get the current reference value.
444      *
445      * @return the value of the instance variable {@link #reference}.
446      * @see #reference
447      * @see #setReference
448      */
449     public String getReference()
450     {
451         return this.reference;
452     }
453 
454     /**
455      * This is the setter method for the instance variable {@link #target}.
456      *
457      * @return value of instance variable {@link #target}
458      * @see #target
459      * @see #setTarget
460      */
461     public Target getTarget()
462     {
463         return this.target;
464     }
465 
466     /**
467      * This is the setter method for the instance variable
468      * {@link #targetBottomHeight}.
469      *
470      * @return value of instance variable {@link #targetBottomHeight}
471      * @see #targetBottomHeight
472      * @see #setTargetBottomHeight
473      */
474     public int getTargetBottomHeight()
475     {
476         return this.targetBottomHeight;
477     }
478 
479     /**
480      * This is the setter method for the instance variable
481      * {@link #targetConnectAttribute}.
482      *
483      * @return value of instance variable {@link #targetConnectAttribute}
484      * @throws CacheReloadException on error
485      */
486     public Attribute getTargetConnectAttribute()
487         throws CacheReloadException
488     {
489         return Attribute.get(this.targetConnectAttributeId);
490     }
491 
492     /**
493      * This is the setter method for the instance variable
494      * {@link #targetCreateType}.
495      *
496      * @return value of instance variable {@link #targetCreateType}
497      * @throws CacheReloadException on error
498      */
499     public Type getTargetCreateType()
500         throws CacheReloadException
501     {
502         return Type.get(this.targetCreateTypeId);
503     }
504 
505     /**
506      * This is the getter method for the instance variable
507      * {@link #targetDefaultMenu}.
508      *
509      * @return value of instance variable {@link #targetDefaultMenu}
510      */
511     public boolean hasTargetDefaultMenu()
512     {
513         return this.targetDefaultMenu;
514     }
515 
516     /**
517      * This is the setter method for the instance variable {@link #targetForm}.
518      *
519      * @return value of instance variable {@link #targetForm}
520      * @see #targetForm
521      * @see #setTargetForm
522      */
523     public Form getTargetForm()
524     {
525         return this.targetForm;
526     }
527 
528     /**
529      * Getter method for the instance variable {@link #targetMenu}.
530      * Adds the default menus if allowed ({@link #targetDefaultMenu}
531      * defined in an SystemConfiguration.
532      *
533      * @return value of instance variable {@link #targetMenu}
534      * @throws EFapsException on error
535      * @see #targetMenu
536      * @see #setTargetMenu
537      */
538     public Menu getTargetMenu()
539         throws EFapsException
540     {
541         Menu ret = this.targetMenu;
542         if (this.targetDefaultMenu
543                         && EFapsSystemConfiguration.get().getAttributeValue(KernelSettings.DEFAULTMENU) != null) {
544             // reads the Value from "Common_Main_DefaultMenu"
545             if (EFapsSystemConfiguration.get().getAttributeValue(KernelSettings.DEFAULTMENU).equals("none")) {
546                 ret = this.targetMenu;
547             } else {
548                 final Properties prop = EFapsSystemConfiguration.get()
549                                 .getAttributeValueAsProperties(KernelSettings.DEFAULTMENU);
550                 for (int i = 0; i < 99; i++) {
551                     if (prop.getProperty("Menu" + i) != null) {
552                         final String menuname = prop.getProperty("Menu" + i);
553                         if (getTargetTable() != null) {
554                             // if no Enable4TableN property is set or if the
555                             // Enable4TableN is not false the default
556                             // menu will be added
557                             if (prop.getProperty("Enable4Table" + i) == null
558                                             || (prop.getProperty("Enable4Table" + i) != null
559                                             && !"false".equalsIgnoreCase(prop.getProperty("Enable4Table" + i)))) {
560                                 if (this.targetMenu == null && ret == null) {
561                                     ret = Menu.get(menuname);
562                                     break;
563                                 } else {
564                                     this.targetMenu.addAll(Menu.get(menuname));
565                                     ret = this.targetMenu;
566                                 }
567                             }
568                         } else if (getTargetForm() != null) {
569                             // only if a Enabled4FormN property is set to true the menu will be added
570                             if (prop.getProperty("Enable4Form" + i) != null
571                                             && "true".equalsIgnoreCase(prop.getProperty("Enable4Form" + i))) {
572                                 if (this.targetMenu == null && ret == null) {
573                                     ret = Menu.get(menuname);
574                                     break;
575                                 } else {
576                                     this.targetMenu.addAll(Menu.get(menuname));
577                                     ret = this.targetMenu;
578                                 }
579                             }
580                         }
581                     } else {
582                         break;
583                     }
584                 }
585             }
586         }
587         return ret;
588     }
589 
590     /**
591      * Getter method for instance variable {@link #targetCommand}.
592      *
593      * @return value of instance variable {@link #targetCommand}
594      */
595     public AbstractCommand getTargetCommand()
596     {
597         return this.targetCommand;
598     }
599 
600     /**
601      * Getter method for instance variable {@link #targeHelp}.
602      *
603      * @return value of instance variable {@link #targeHelp}
604      */
605     public String getTargetHelp()
606     {
607         return this.targeHelp;
608     }
609 
610     /**
611      * Getter method for instance variable {@link #targetCmdRevise}.
612      *
613      * @return value of instance variable {@link #targetCmdRevise}
614      */
615     public boolean isTargetCmdRevise()
616     {
617         return this.targetCmdRevise;
618     }
619 
620     /**
621      * @param _value comma separated list of classifications
622      * @throws CacheReloadException on error
623      */
624     private void setTargetCreateClassifications(final String _value)
625         throws CacheReloadException
626     {
627         final String[] values = _value.split(";");
628         for (final String value : values) {
629             final Type classification = Type.get(value.trim());
630             if (classification != null) {
631                 this.targetCreateClassificationIds.add(classification.getId());
632             }
633         }
634     }
635 
636     /**
637      * Getter method for instance variable {@link #targetCreateClassification}.
638      *
639      * @return value of instance variable {@link #targetCreateClassification}
640      * @throws CacheReloadException on error
641      */
642     public Set<Classification> getTargetCreateClassification()
643         throws CacheReloadException
644     {
645         final Set<Classification> ret = new HashSet<Classification>();
646         for (final Long id : this.targetCreateClassificationIds) {
647             ret.add(Classification.get(id));
648         }
649         return Collections.unmodifiableSet(ret);
650     }
651 
652     /**
653      * This is the setter method for the instance variable {@link #targetMode}.
654      *
655      * @return value of instance variable {@link #targetMode}
656      * @see #targetMode
657      * @see #setTargetMode
658      */
659     public TargetMode getTargetMode()
660     {
661         return this.targetMode;
662     }
663 
664     /**
665      * This is the setter method for the instance variable {@link #targetSearch}
666      * .
667      *
668      * @return value of instance variable {@link #targetSearch}
669      * @see #targetSearch
670      * @see #setTargetSearch
671      */
672     public Search getTargetSearch()
673     {
674         return this.targetSearch;
675     }
676 
677     /**
678      * This is the setter method for the instance variable {@link #targetTable}.
679      *
680      * @return value of instance variable {@link #targetTable}
681      * @see #targetTable
682      * @see #setTargetTable
683      */
684     public Table getTargetTable()
685     {
686         return this.targetTable;
687     }
688 
689     /**
690      * This is the setter method for the instance variable
691      * {@link #targetTableSortDirection}.
692      *
693      * @return value of instance variable {@link #targetTableSortDirection}
694      * @see #targetTableSortDirection
695      * @see #setTargetTableSortDirection
696      */
697     public SortDirection getTargetTableSortDirection()
698     {
699         return this.targetTableSortDirection;
700     }
701 
702     /**
703      * This is the setter method for the instance variable
704      * {@link #targetTableSortKey}.
705      *
706      * @return value of instance variable {@link #targetTableSortKey}
707      * @see #targetTableSortKey
708      * @see #setTargetTableSortKey
709      */
710     public String getTargetTableSortKey()
711     {
712         return this.targetTableSortKey;
713     }
714 
715     /**
716      * This is the setter method for the instance variable {@link #targetTitle}.
717      *
718      * @return value of instance variable {@link #targetTitle}
719      * @see #targetTitle
720      * @see #setTargetTitle
721      */
722     public String getTargetTitle()
723     {
724         return this.targetTitle;
725     }
726 
727     /**
728      * The instance method returns the label of a command (or also menu). The
729      * instance method looks in the DBProperties, if a property entry with
730      * prefix <i>Command.</i> and name is found. This value is returned. If no
731      * entry is found, the name of the command is returned.
732      *
733      * @return label of the command (or menu)
734      */
735     public String getViewableName()
736     {
737         String name = getName();
738         if (DBProperties.hasProperty("Command." + getName())) {
739             name = DBProperties.getProperty("Command." + getName());
740         }
741         return name;
742     }
743 
744     /**
745      * This is the getter method for the instance variable {@link #windowHeight}
746      * .
747      *
748      * @return value of instance variable {@link #windowHeight}
749      * @see #windowHeight
750      * @see #setWindowHeight
751      */
752     public int getWindowHeight()
753     {
754         return this.windowHeight;
755     }
756 
757     /**
758      * This is the getter method for the instance variable {@link #windowWidth}.
759      *
760      * @return value of instance variable {@link #windowWidth}
761      * @see #windowWidth
762      * @see #setWindowWidth
763      */
764     public int getWindowWidth()
765     {
766         return this.windowWidth;
767     }
768 
769     /**
770      * This is the getter method for the instance variable {@link #askUser}.
771      *
772      * @return value of instance variable {@link #askUser}
773      * @see #askUser
774      * @see #setAskUser
775      */
776     public boolean isAskUser()
777     {
778         return this.askUser;
779     }
780 
781     /**
782      * This is the setter method for the instance variable
783      * {@link #defaultSelected}.
784      *
785      * @return value of instance variable {@link #defaultSelected}
786      * @see #defaultSelected
787      * @see #setDefaultSelected
788      */
789     public boolean isDefaultSelected()
790     {
791         return this.defaultSelected;
792     }
793 
794     /**
795      * This is the setter method for the instance variable {@link #submit}.
796      *
797      * @return value of instance variable {@link #submit}
798      * @see #submit
799      * @see #setSubmit
800      */
801     public boolean isSubmit()
802     {
803         return this.submit;
804     }
805 
806     /**
807      * Getter method for the instance variable {@link #submitSelectedRows}.
808      *
809      * @return value of instance variable {@link #submitSelectedRows}
810      */
811     public int getSubmitSelectedRows()
812     {
813         return this.submitSelectedRows;
814     }
815 
816     /**
817      * Test, if the value of instance variable {@link #target} is equal to
818      * {@link #TARGET_CONTENT}.
819      *
820      * @return <i>true</i> if value is equal, otherwise false
821      * @see #target
822      * @see #getTarget
823      */
824     public boolean isTargetContent()
825     {
826         return getTarget() == AbstractCommand.Target.CONTENT;
827     }
828 
829     /**
830      * Test, if the value of instance variable {@link #target} is equal to
831      * {@link #TARGET_HIDDEN}.
832      *
833      * @return <i>true</i> if value is equal, otherwise false
834      * @see #target
835      * @see #getTarget
836      */
837     public boolean isTargetHidden()
838     {
839         return getTarget() == AbstractCommand.Target.HIDDEN;
840     }
841 
842     /**
843      * Test, if the value of instance variable {@link #target} is equal to
844      * {@link #TARGET_POPUP}.
845      *
846      * @return <i>true</i> if value is equal, otherwise false
847      * @see #target
848      * @see #getTarget
849      */
850     public boolean isTargetPopup()
851     {
852         return getTarget() == AbstractCommand.Target.POPUP;
853     }
854 
855     /**
856      * This is the setter method for the instance variable
857      * {@link #targetShowCheckBoxes}.
858      *
859      * @return value of instance variable {@link #targetShowCheckBoxes}
860      */
861     public boolean isTargetShowCheckBoxes()
862     {
863         return this.targetShowCheckBoxes;
864     }
865 
866     /**
867      * Getter method for instance variable {@link #targetShowFile}.
868      *
869      * @return value of instance variable {@link #targetShowFile}
870      */
871     public boolean isTargetShowFile()
872     {
873         return this.targetShowFile;
874     }
875 
876     /**
877      * Getter method for instance variable {@link #noUpdateAfterCmd}.
878      *
879      * @return value of instance variable {@link #noUpdateAfterCmd}
880      */
881     public boolean isNoUpdateAfterCmd()
882     {
883         return this.noUpdateAfterCmd;
884     }
885 
886     /**
887      * Getter method for instance variable {@link #targetStructurBrowserField}.
888      *
889      * @return value of instance variable {@link #targetStructurBrowserField}
890      */
891     public String getTargetStructurBrowserField()
892     {
893         return this.targetStructurBrowserField;
894     }
895 
896     /**
897      * {@inheritDoc}
898      */
899     @Override
900     protected void setLinkProperty(final UUID _linkTypeUUID,
901                                    final long _toId,
902                                    final UUID _toTypeUUID,
903                                    final String _toName)
904         throws EFapsException
905     {
906         if (_linkTypeUUID.equals(CIAdminUserInterface.LinkIcon.uuid)) {
907             this.icon = RequestHandler.replaceMacrosInUrl(RequestHandler.URL_IMAGE + _toName);
908         } else if (_linkTypeUUID.equals(CIAdminUserInterface.LinkTargetForm.uuid)) {
909             this.targetForm = Form.get(_toId);
910         } else if (_linkTypeUUID.equals(CIAdminUserInterface.LinkTargetMenu.uuid)) {
911             this.targetMenu = Menu.get(_toId);
912         } else if (_linkTypeUUID.equals(CIAdminUserInterface.LinkTargetSearch.uuid)) {
913             this.targetSearch = Search.get(_toId);
914         } else if (_linkTypeUUID.equals(CIAdminUserInterface.LinkTargetTable.uuid)) {
915             this.targetTable = Table.get(_toId);
916         } else if (_linkTypeUUID.equals(CIAdminUserInterface.LinkTargetCommand.uuid)) {
917             this.targetCommand = Command.get(_toId);
918         } else if (_linkTypeUUID.equals(CIAdminUserInterface.LinkTargetHelp.uuid)) {
919             this.targeHelp = _toName;
920         } else {
921             super.setLinkProperty(_linkTypeUUID, _toId, _toTypeUUID, _toName);
922         }
923     }
924 
925     /**
926      * The instance method sets a new property value.
927      *
928      * @param _name name of the property
929      * @param _value value of the property
930      * @throws CacheReloadException on error during reload
931      */
932     @Override
933     protected void setProperty(final String _name,
934                                final String _value)
935         throws CacheReloadException
936     {
937         if ("AskUser".equals(_name)) {
938             this.askUser = "true".equalsIgnoreCase(_value);
939         } else if ("DefaultSelected".equals(_name)) {
940             this.defaultSelected = "true".equalsIgnoreCase(_value);
941         } else if ("HRef".equals(_name)) {
942             this.reference = RequestHandler.replaceMacrosInUrl(_value);
943         } else if ("Label".equals(_name)) {
944             this.label = _value;
945         } else if ("Submit".equals(_name)) {
946             this.submit = "true".equalsIgnoreCase(_value);
947         } else if ("SubmitSelectedRows".equals(_name)) {
948             this.submitSelectedRows = Integer.parseInt(_value);
949         } else if ("Target".equals(_name)) {
950             if ("content".equals(_value)) {
951                 this.target = AbstractCommand.Target.CONTENT;
952             } else if ("hidden".equals(_value)) {
953                 this.target = AbstractCommand.Target.HIDDEN;
954             } else if ("popup".equals(_value)) {
955                 this.target = AbstractCommand.Target.POPUP;
956             } else if ("modal".equals(_value)) {
957                 this.target = AbstractCommand.Target.MODAL;
958             }
959         } else if ("TargetBottomHeight".equals(_name)) {
960             this.targetBottomHeight = Integer.parseInt(_value);
961         } else if ("TargetCmdRevise".equals(_name)) {
962             this.targetCmdRevise = "TRUE".equalsIgnoreCase(_value);
963         } else if ("TargetConnectAttribute".equals(_name)) {
964             final Attribute attr = Attribute.get(_value);
965             this.targetConnectAttributeId = attr == null ? 0 : attr.getId();
966         } else if ("TargetCreateType".equals(_name)) {
967             final Type type = Type.get(_value);
968             this.targetCreateTypeId = type == null ? 0 : type.getId();
969         } else if (_name != null && _name.startsWith("TargetCreateClassifications")) {
970             setTargetCreateClassifications(_value);
971         } else if ("TargetDefaultMenu".equals(_name)) {
972             this.targetDefaultMenu = "none".equalsIgnoreCase(_value);
973         } else if ("TargetMode".equals(_name)) {
974             if ("create".equals(_value)) {
975                 this.targetMode = TargetMode.CREATE;
976             } else if ("edit".equals(_value)) {
977                 this.targetMode = TargetMode.EDIT;
978             } else if ("connect".equals(_value)) {
979                 this.targetMode = TargetMode.CONNECT;
980             } else if ("search".equals(_value)) {
981                 this.targetMode = TargetMode.SEARCH;
982             } else if ("view".equals(_value)) {
983                 this.targetMode = TargetMode.VIEW;
984             }
985         } else if ("TargetShowCheckBoxes".equals(_name)) {
986             this.targetShowCheckBoxes = "true".equalsIgnoreCase(_value);
987         } else if ("TargetTableSortKey".equals(_name)) {
988             this.targetTableSortKey = _value;
989             this.targetTableSortDirection = AbstractCommand.SortDirection.ASCENDING;
990         } else if ("TargetTableSortDirection".equals(_name)) {
991             if (AbstractCommand.SortDirection.DESCENDING.value.equals(_value)) {
992                 this.targetTableSortDirection = AbstractCommand.SortDirection.DESCENDING;
993             } else {
994                 this.targetTableSortDirection = AbstractCommand.SortDirection.ASCENDING;
995             }
996         } else if ("TargetTitle".equals(_name)) {
997             this.targetTitle = _value;
998         } else if ("TargetShowFile".equals(_name)) {
999             this.targetShowFile = "true".equalsIgnoreCase(_value);
1000         } else if ("NoUpdateAfterCOMMAND".equals(_name)) {
1001             this.noUpdateAfterCmd = "true".equalsIgnoreCase(_value);
1002         } else if ("TargetStructurBrowserField".equals(_name)) {
1003             this.targetStructurBrowserField = _value.trim();
1004         } else if ("WindowHeight".equals(_name)) {
1005             this.windowHeight = Integer.parseInt(_value);
1006         } else if ("WindowWidth".equals(_name)) {
1007             this.windowWidth = Integer.parseInt(_value);
1008         } else {
1009             super.setProperty(_name, _value);
1010         }
1011     }
1012 
1013     @Override
1014     public boolean equals(final Object _obj)
1015     {
1016         boolean ret;
1017         if (_obj instanceof AbstractCommand) {
1018             ret = ((AbstractCommand) _obj).getId() == getId();
1019         } else {
1020             ret = super.equals(_obj);
1021         }
1022         return ret;
1023     }
1024 
1025     @Override
1026     public int hashCode()
1027     {
1028         return  Long.valueOf(getId()).intValue();
1029     }
1030 }