9a708871773894d17e74c1328035c5614019c579
[public/netxms.git] / src / java / client / netxms-client / src / main / java / org / netxms / client / objects / AbstractObject.java
1 /**
2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2013 Victor Kirhenshtein
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 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 General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 package org.netxms.client.objects;
20
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.HashMap;
24 import java.util.HashSet;
25 import java.util.Iterator;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.Set;
29 import java.util.UUID;
30 import org.netxms.base.GeoLocation;
31 import org.netxms.base.Logger;
32 import org.netxms.base.NXCPCodes;
33 import org.netxms.base.NXCPMessage;
34 import org.netxms.base.NXCommon;
35 import org.netxms.base.PostalAddress;
36 import org.netxms.base.annotations.Internal;
37 import org.netxms.client.AccessListElement;
38 import org.netxms.client.ModuleDataProvider;
39 import org.netxms.client.NXCSession;
40 import org.netxms.client.constants.ObjectStatus;
41 import org.netxms.client.services.ServiceManager;
42
43 /**
44 * Abstract base class for all NetXMS objects (both built-in and provided by extensions)
45 */
46 public abstract class AbstractObject
47 {
48 /** Entire network */
49 public static final int NETWORK = 1;
50 /** Infrastructure Services */
51 public static final int SERVICEROOT = 2;
52 /** Templates */
53 public static final int TEMPLATEROOT = 3;
54 /** Default zone */
55 public static final int ZONE0 = 4;
56 /** Configuration Policies */
57 public static final int POLICYROOT = 5;
58 /** Network Maps */
59 public static final int NETWORKMAPROOT = 6;
60 /** Dashboards */
61 public static final int DASHBOARDROOT = 7;
62 /** Reports */
63 public static final int REPORTROOT = 8;
64 /** Business Services */
65 public static final int BUSINESSSERVICEROOT = 9;
66
67 // Object classes
68 public static final int OBJECT_GENERIC = 0;
69 public static final int OBJECT_SUBNET = 1;
70 public static final int OBJECT_NODE = 2;
71 public static final int OBJECT_INTERFACE = 3;
72 public static final int OBJECT_NETWORK = 4;
73 public static final int OBJECT_CONTAINER = 5;
74 public static final int OBJECT_ZONE = 6;
75 public static final int OBJECT_SERVICEROOT = 7;
76 public static final int OBJECT_TEMPLATE = 8;
77 public static final int OBJECT_TEMPLATEGROUP = 9;
78 public static final int OBJECT_TEMPLATEROOT = 10;
79 public static final int OBJECT_NETWORKSERVICE = 11;
80 public static final int OBJECT_VPNCONNECTOR = 12;
81 public static final int OBJECT_CONDITION = 13;
82 public static final int OBJECT_CLUSTER = 14;
83 public static final int OBJECT_POLICYGROUP = 15;
84 public static final int OBJECT_POLICYROOT = 16;
85 public static final int OBJECT_AGENTPOLICY = 17;
86 public static final int OBJECT_AGENTPOLICY_CONFIG = 18;
87 public static final int OBJECT_NETWORKMAPROOT = 19;
88 public static final int OBJECT_NETWORKMAPGROUP = 20;
89 public static final int OBJECT_NETWORKMAP = 21;
90 public static final int OBJECT_DASHBOARDROOT = 22;
91 public static final int OBJECT_DASHBOARD = 23;
92 public static final int OBJECT_BUSINESSSERVICEROOT = 27;
93 public static final int OBJECT_BUSINESSSERVICE = 28;
94 public static final int OBJECT_NODELINK = 29;
95 public static final int OBJECT_SLMCHECK = 30;
96 public static final int OBJECT_MOBILEDEVICE = 31;
97 public static final int OBJECT_RACK = 32;
98 public static final int OBJECT_ACCESSPOINT = 33;
99 public static final int OBJECT_AGENTPOLICY_LOGPARSER = 34;
100 public static final int OBJECT_CHASSIS = 35;
101 public static final int OBJECT_CUSTOM = 10000;
102
103 // Status calculation methods
104 public static final int CALCULATE_DEFAULT = 0;
105 public static final int CALCULATE_MOST_CRITICAL = 1;
106 public static final int CALCULATE_SINGLE_THRESHOLD = 2;
107 public static final int CALCULATE_MULTIPLE_THRESHOLDS = 3;
108
109 // Status propagation methods
110 public static final int PROPAGATE_DEFAULT = 0;
111 public static final int PROPAGATE_UNCHANGED = 1;
112 public static final int PROPAGATE_FIXED = 2;
113 public static final int PROPAGATE_RELATIVE = 3;
114 public static final int PROPAGATE_TRANSLATED = 4;
115
116 @Internal protected NXCSession session = null;
117 protected long objectId = 0;
118 protected UUID guid;
119 protected String objectName;
120 protected int objectClass;
121 protected ObjectStatus status = ObjectStatus.UNKNOWN;
122 protected boolean isDeleted = false;
123 protected boolean inMaintenanceMode = false;
124 protected String comments;
125 protected GeoLocation geolocation;
126 protected PostalAddress postalAddress;
127 protected UUID image;
128 protected long drillDownObjectId;
129 protected final HashSet<Long> trustedNodes = new HashSet<Long>(0);
130 protected boolean inheritAccessRights = true;
131 protected HashSet<AccessListElement> accessList = new HashSet<AccessListElement>(0);
132 protected int statusCalculationMethod;
133 protected int statusPropagationMethod;
134 protected ObjectStatus fixedPropagatedStatus;
135 protected int statusShift;
136 protected ObjectStatus[] statusTransformation;
137 protected int statusSingleThreshold;
138 protected int[] statusThresholds;
139 protected final HashSet<Long> parents = new HashSet<Long>(0);
140 protected final HashSet<Long> children = new HashSet<Long>(0);
141 protected final List<Long> dashboards = new ArrayList<Long>(0);
142 protected final Map<String, String> customAttributes = new HashMap<String, String>(0);
143 protected Map<String, Object> moduleData = null;
144
145 @Internal private int effectiveRights = 0;
146 @Internal private boolean effectiveRightsCached = false;
147
148 /**
149 * Create dummy object of GENERIC class
150 *
151 * @param id object ID to set
152 * @param session associated session
153 */
154 protected AbstractObject(final long id, final NXCSession session)
155 {
156 objectId = id;
157 this.session = session;
158 guid = UUID.randomUUID();
159 objectName = "unknown";
160 objectClass = OBJECT_GENERIC;
161 comments = "";
162 geolocation = new GeoLocation(false);
163 postalAddress = new PostalAddress();
164 image = NXCommon.EMPTY_GUID;
165
166 statusCalculationMethod = CALCULATE_DEFAULT;
167 statusPropagationMethod = PROPAGATE_DEFAULT;
168 fixedPropagatedStatus = ObjectStatus.NORMAL;
169 statusShift = 0;
170 statusTransformation = new ObjectStatus[4];
171 statusTransformation[0] = ObjectStatus.WARNING;
172 statusTransformation[1] = ObjectStatus.MINOR;
173 statusTransformation[2] = ObjectStatus.MAJOR;
174 statusTransformation[3] = ObjectStatus.CRITICAL;
175 statusSingleThreshold = 75;
176 statusThresholds = new int[4];
177 statusThresholds[0] = 75;
178 statusThresholds[1] = 75;
179 statusThresholds[2] = 75;
180 statusThresholds[3] = 75;
181 }
182
183 /**
184 * Create object from NXCP message
185 * @param msg Message to create object from
186 * @param session Associated client session
187 */
188 public AbstractObject(final NXCPMessage msg, final NXCSession session)
189 {
190 int i, count;
191 long id, id2;
192
193 this.session = session;
194
195 objectId = msg.getFieldAsInt32(NXCPCodes.VID_OBJECT_ID);
196 guid = msg.getFieldAsUUID(NXCPCodes.VID_GUID);
197 objectName = msg.getFieldAsString(NXCPCodes.VID_OBJECT_NAME);
198 objectClass = msg.getFieldAsInt32(NXCPCodes.VID_OBJECT_CLASS);
199 isDeleted = msg.getFieldAsBoolean(NXCPCodes.VID_IS_DELETED);
200 status = ObjectStatus.getByValue(msg.getFieldAsInt32(NXCPCodes.VID_OBJECT_STATUS));
201 inMaintenanceMode = msg.getFieldAsBoolean(NXCPCodes.VID_MAINTENANCE_MODE);
202 comments = msg.getFieldAsString(NXCPCodes.VID_COMMENTS);
203 geolocation = new GeoLocation(msg);
204 postalAddress = new PostalAddress(msg);
205 image = msg.getFieldAsUUID(NXCPCodes.VID_IMAGE);
206 drillDownObjectId = msg.getFieldAsInt64(NXCPCodes.VID_DRILL_DOWN_OBJECT_ID);
207 if (image == null)
208 image = NXCommon.EMPTY_GUID;
209
210 statusCalculationMethod = msg.getFieldAsInt32(NXCPCodes.VID_STATUS_CALCULATION_ALG);
211 statusPropagationMethod = msg.getFieldAsInt32(NXCPCodes.VID_STATUS_PROPAGATION_ALG);
212 fixedPropagatedStatus = ObjectStatus.getByValue(msg.getFieldAsInt32(NXCPCodes.VID_FIXED_STATUS));
213 statusShift = msg.getFieldAsInt32(NXCPCodes.VID_STATUS_SHIFT);
214 statusTransformation = new ObjectStatus[4];
215 statusTransformation[0] = ObjectStatus.getByValue(msg.getFieldAsInt32(NXCPCodes.VID_STATUS_TRANSLATION_1));
216 statusTransformation[1] = ObjectStatus.getByValue(msg.getFieldAsInt32(NXCPCodes.VID_STATUS_TRANSLATION_2));
217 statusTransformation[2] = ObjectStatus.getByValue(msg.getFieldAsInt32(NXCPCodes.VID_STATUS_TRANSLATION_3));
218 statusTransformation[3] = ObjectStatus.getByValue(msg.getFieldAsInt32(NXCPCodes.VID_STATUS_TRANSLATION_4));
219 statusSingleThreshold = msg.getFieldAsInt32(NXCPCodes.VID_STATUS_SINGLE_THRESHOLD);
220 statusThresholds = new int[4];
221 statusThresholds[0] = msg.getFieldAsInt32(NXCPCodes.VID_STATUS_THRESHOLD_1);
222 statusThresholds[1] = msg.getFieldAsInt32(NXCPCodes.VID_STATUS_THRESHOLD_2);
223 statusThresholds[2] = msg.getFieldAsInt32(NXCPCodes.VID_STATUS_THRESHOLD_3);
224 statusThresholds[3] = msg.getFieldAsInt32(NXCPCodes.VID_STATUS_THRESHOLD_4);
225
226 // Status shift can be negative, but all int16 values read from message
227 // as unsigned, so we need to convert shift value
228 if (statusShift > 32767)
229 statusShift = statusShift - 65536;
230
231 // Parents
232 count = msg.getFieldAsInt32(NXCPCodes.VID_PARENT_CNT);
233 for(i = 0, id = NXCPCodes.VID_PARENT_ID_BASE; i < count; i++, id++)
234 {
235 parents.add(msg.getFieldAsInt64(id));
236 }
237
238 // Children
239 count = msg.getFieldAsInt32(NXCPCodes.VID_CHILD_CNT);
240 for(i = 0, id = NXCPCodes.VID_CHILD_ID_BASE; i < count; i++, id++)
241 {
242 children.add(msg.getFieldAsInt64(id));
243 }
244
245 // Trusted nodes
246 count = msg.getFieldAsInt32(NXCPCodes.VID_NUM_TRUSTED_NODES);
247 if (count > 0)
248 {
249 Long[] nodes = msg.getFieldAsUInt32ArrayEx(NXCPCodes.VID_TRUSTED_NODES);
250 trustedNodes.addAll(Arrays.asList(nodes));
251 }
252
253 // Dashboards
254 Long[] d = msg.getFieldAsUInt32ArrayEx(NXCPCodes.VID_DASHBOARDS);
255 if ((d != null) && (d.length > 0))
256 dashboards.addAll(Arrays.asList(d));
257
258 // Custom attributes
259 count = msg.getFieldAsInt32(NXCPCodes.VID_NUM_CUSTOM_ATTRIBUTES);
260 for(i = 0, id = NXCPCodes.VID_CUSTOM_ATTRIBUTES_BASE; i < count; i++, id += 2)
261 {
262 customAttributes.put(msg.getFieldAsString(id), msg.getFieldAsString(id + 1));
263 }
264
265 // Access list
266 inheritAccessRights = msg.getFieldAsBoolean(NXCPCodes.VID_INHERIT_RIGHTS);
267 count = msg.getFieldAsInt32(NXCPCodes.VID_ACL_SIZE);
268 for(i = 0, id = NXCPCodes.VID_ACL_USER_BASE, id2 = NXCPCodes.VID_ACL_RIGHTS_BASE; i < count; i++, id++, id2++)
269 {
270 accessList.add(new AccessListElement(msg.getFieldAsInt64(id), msg.getFieldAsInt32(id2)));
271 }
272
273 // Module-specific data
274 count = msg.getFieldAsInt32(NXCPCodes.VID_MODULE_DATA_COUNT);
275 if (count > 0)
276 {
277 moduleData = new HashMap<String, Object>(count);
278 for(i = 0, id = NXCPCodes.VID_MODULE_DATA_BASE; i < count; i++, id += 0x100000)
279 {
280 String module = msg.getFieldAsString(id);
281 ModuleDataProvider p = (ModuleDataProvider)ServiceManager.getServiceHandler(module, ModuleDataProvider.class);
282 if (p != null)
283 {
284 moduleData.put(module, p.createModuleData(msg, id + 1));
285 }
286 else
287 {
288 Logger.error("AbstractObject", "Unable to find data provider for module " + module);
289 }
290 }
291 }
292 }
293
294 /**
295 * Check if object should be represented by class default image
296 *
297 * @return true if default image should be used
298 */
299 public boolean isDefaultImage()
300 {
301 return image.equals(NXCommon.EMPTY_GUID);
302 }
303
304 /**
305 * Get number of parent objects
306 *
307 * @return number of parent objects
308 */
309 public int getParentCount()
310 {
311 return parents.size();
312 }
313
314 /**
315 * @return Iterator for list of parent objects
316 */
317 public Iterator<Long> getParents()
318 {
319 return parents.iterator();
320 }
321
322 /**
323 * @return Iterator for list of child objects
324 */
325 public Iterator<Long> getChildren()
326 {
327 return children.iterator();
328 }
329
330 /**
331 * @return Access list
332 */
333 public AccessListElement[] getAccessList()
334 {
335 return accessList.toArray(new AccessListElement[accessList.size()]);
336 }
337
338 /**
339 * @return the comments
340 */
341 public String getComments()
342 {
343 return comments;
344 }
345
346 /**
347 * @return the objectId
348 */
349 public long getObjectId()
350 {
351 return objectId;
352 }
353
354 /**
355 * @return the objectName
356 */
357 public String getObjectName()
358 {
359 return objectName;
360 }
361
362 /**
363 * @return the status
364 */
365 public ObjectStatus getStatus()
366 {
367 return status;
368 }
369
370 /**
371 * @return the isDeleted
372 */
373 public boolean isDeleted()
374 {
375 return isDeleted;
376 }
377
378 /**
379 * @return the inheritAccessRights
380 */
381 public boolean isInheritAccessRights()
382 {
383 return inheritAccessRights;
384 }
385
386 /**
387 * Check if given object is direct or indirect parent
388 *
389 * @param objectId ID of object to check
390 */
391 public boolean isChildOf(final long objectId)
392 {
393 boolean rc = false;
394
395 synchronized(parents)
396 {
397 for (Long id : parents)
398 {
399 if (id == objectId)
400 {
401 // Direct parent
402 rc = true;
403 break;
404 }
405 AbstractObject object = session.findObjectById(id);
406 if (object != null)
407 {
408 if (object.isChildOf(objectId))
409 {
410 rc = true;
411 break;
412 }
413 }
414 }
415 }
416 return rc;
417 }
418
419 /**
420 * Check if at least one of given objects is direct or indirect parent
421 * @param objects List of object ID to check
422 */
423 public boolean isChildOf(final long[] objects)
424 {
425 for (long object : objects)
426 {
427 if (isChildOf(object))
428 {
429 return true;
430 }
431 }
432 return false;
433 }
434
435 /**
436 * Check if given object is direct parent
437 *
438 * @param objectId ID of object to check
439 */
440 public boolean isDirectChildOf(final long objectId)
441 {
442 boolean rc = false;
443
444 synchronized(parents)
445 {
446 for (Long id : parents)
447 {
448 if (id == objectId)
449 {
450 // Direct parent
451 rc = true;
452 break;
453 }
454 }
455 }
456 return rc;
457 }
458
459 /**
460 * @return List of parent objects
461 */
462 public AbstractObject[] getParentsAsArray()
463 {
464 final Set<AbstractObject> list;
465 synchronized(parents)
466 {
467 list = new HashSet<AbstractObject>(children.size());
468 for (Long parent : parents)
469 {
470 AbstractObject obj = session.findObjectById(parent);
471 if (obj != null)
472 {
473 list.add(obj);
474 }
475 }
476 }
477 return list.toArray(new AbstractObject[list.size()]);
478 }
479
480 /**
481 * @return List of child objects
482 */
483 public AbstractObject[] getChildsAsArray()
484 {
485 final Set<AbstractObject> list;
486 synchronized(children)
487 {
488 list = new HashSet<AbstractObject>(children.size());
489 for (Long aChildren : children)
490 {
491 AbstractObject obj = session.findObjectById(aChildren);
492 if (obj != null)
493 {
494 list.add(obj);
495 }
496 }
497 }
498 return list.toArray(new AbstractObject[list.size()]);
499 }
500
501 /**
502 * Return identifiers of all child objects
503 *
504 * @return list of children
505 */
506 public long[] getChildIdList()
507 {
508 long[] list;
509 synchronized(children)
510 {
511 list = new long[children.size()];
512 int i = 0;
513 for(Long id : children)
514 list[i++] = id;
515 }
516 return list;
517 }
518
519 /**
520 * Return identifiers of all parent objects
521 *
522 * @return list of object parents
523 */
524 public long[] getParentIdList()
525 {
526 long[] list;
527 synchronized(parents)
528 {
529 list = new long[parents.size()];
530 int i = 0;
531 for(Long id : parents)
532 list[i++] = id;
533 }
534 return list;
535 }
536
537 /**
538 * Internal worker function for getAllChilds
539 * @param classFilter class filter
540 * @param set result set
541 */
542 private void getAllChildsInternal(int[] classFilter, Set<AbstractObject> set)
543 {
544 synchronized(children)
545 {
546 for (Long child : children) {
547 AbstractObject obj = session.findObjectById(child);
548 if (obj != null) {
549 if (matchClassFilter(classFilter, obj.getObjectClass())) {
550 set.add(obj);
551 }
552 obj.getAllChildsInternal(classFilter, set);
553 }
554 }
555 }
556 }
557
558 private boolean matchClassFilter(int[] classFilter, int objectClass)
559 {
560 if (classFilter == null)
561 {
562 return true;
563 }
564 for (int filter : classFilter) {
565 if (objectClass == filter)
566 {
567 return true;
568 }
569 }
570 return false;
571 }
572
573 /**
574 * Get all child objects, direct and indirect
575 *
576 * @param classFilter -1 to get all childs, or NetXMS class id to retrieve objects of given class
577 * @return set of child objects
578 */
579 public Set<AbstractObject> getAllChilds(int classFilter)
580 {
581 Set<AbstractObject> result = new HashSet<AbstractObject>();
582 getAllChildsInternal((classFilter < 0) ? null : new int[] { classFilter }, result);
583 return result;
584 }
585
586 /**
587 * Get all child objects, direct and indirect
588 *
589 * @param classFilter null to get all childs, or NetXMS class id(s) to retrieve objects of given class(es)
590 * @return set of child objects
591 */
592 public Set<AbstractObject> getAllChilds(int[] classFilter)
593 {
594 Set<AbstractObject> result = new HashSet<AbstractObject>();
595 getAllChildsInternal(classFilter, result);
596 return result;
597 }
598
599 /**
600 * Internal worker function for getAllParents
601 * @param classFilter class filter
602 * @param set result set
603 */
604 private void getAllParentsInternal(int[] classFilter, Set<AbstractObject> set)
605 {
606 synchronized(parents)
607 {
608 for (Long parent : parents) {
609 AbstractObject obj = session.findObjectById(parent);
610 if (obj != null)
611 {
612 if (matchClassFilter(classFilter, obj.getObjectClass()))
613 {
614 set.add(obj);
615 }
616 obj.getAllParentsInternal(classFilter, set);
617 }
618 }
619 }
620 }
621
622 /**
623 * Get all parent objects, direct and indirect
624 *
625 * @param classFilter -1 to get all parents, or NetXMS class id to retrieve objects of given class
626 * @return set of parent objects
627 */
628 public Set<AbstractObject> getAllParents(int classFilter)
629 {
630 Set<AbstractObject> result = new HashSet<AbstractObject>();
631 getAllParentsInternal((classFilter < 0) ? null : new int[] { classFilter }, result);
632 return result;
633 }
634
635 /**
636 * Get all parent objects, direct and indirect
637 *
638 * @param classFilter null to get all parents, or NetXMS class id(s) to retrieve objects of given class(es)
639 * @return set of parent objects
640 */
641 public Set<AbstractObject> getAllParents(int[] classFilter)
642 {
643 Set<AbstractObject> result = new HashSet<AbstractObject>();
644 getAllParentsInternal(classFilter, result);
645 return result;
646 }
647
648 /**
649 * @return List of trusted nodes
650 */
651 public AbstractObject[] getTrustedNodes()
652 {
653 synchronized(trustedNodes)
654 {
655 final AbstractObject[] list = new AbstractObject[trustedNodes.size()];
656 final Iterator<Long> it = trustedNodes.iterator();
657 for(int i = 0; it.hasNext(); i++)
658 {
659 long id = it.next();
660 AbstractObject o = session.findObjectById(id);
661 if (o != null)
662 list[i] = o;
663 else
664 list[i] = new UnknownObject(id, session);
665 }
666 return list;
667 }
668 }
669
670 /**
671 * Get list of associated dashboards
672 *
673 * @param accessibleOnly if set to true, only accessible dashboards will be returned
674 * @return list of the dashboard objects
675 */
676 public List<AbstractObject> getDashboards(boolean accessibleOnly)
677 {
678 synchronized(dashboards)
679 {
680 final List<AbstractObject> list = new ArrayList<AbstractObject>();
681 for(Long id : dashboards)
682 {
683 AbstractObject o = session.findObjectById(id);
684 if (o != null)
685 list.add(o);
686 else if (!accessibleOnly)
687 list.add(new UnknownObject(id, session));
688 }
689 return list;
690 }
691 }
692
693 /**
694 * @return true if object has parents
695 */
696 public boolean hasParents()
697 {
698 return parents.size() > 0;
699 }
700
701 /**
702 * @return true if object has children
703 */
704 public boolean hasChildren()
705 {
706 return children.size() > 0;
707 }
708
709 /**
710 * @return true if object has children accessible by this session
711 */
712 public boolean hasAccessibleChildren()
713 {
714 for(Long id : children)
715 if (session.findObjectById(id) != null)
716 return true;
717 return false;
718 }
719
720 /**
721 * If this method returns true object is allowed to be on custom network map.
722 * Default implementation always returns false.
723 *
724 * @return true if object is allowed to be on custom network map
725 */
726 public boolean isAllowedOnMap()
727 {
728 return false;
729 }
730
731 /**
732 * If this method returns true object can have visible alarms.
733 * Default implementation always returns false.
734 *
735 * @return true if object can contain visible alarms
736 */
737 public boolean isAlarmsVisible()
738 {
739 return false;
740 }
741
742 /**
743 * @return the objectClass
744 */
745 public int getObjectClass()
746 {
747 return objectClass;
748 }
749
750 /**
751 * @return Name of NetXMS object's class
752 */
753 public String getObjectClassName()
754 {
755 return "Class " + Integer.toString(objectClass);
756 }
757
758 /**
759 * Get object's custom attributes
760 */
761 public Map<String, String> getCustomAttributes()
762 {
763 return customAttributes;
764 }
765
766 /**
767 * @return the geolocation
768 */
769 public GeoLocation getGeolocation()
770 {
771 return geolocation;
772 }
773
774 @Override
775 public int hashCode()
776 {
777 return (int)objectId;
778 }
779
780 /**
781 * @return the guid
782 */
783 public UUID getGuid()
784 {
785 return guid;
786 }
787
788 /**
789 * @return the image
790 */
791 public UUID getImage()
792 {
793 return image;
794 }
795
796 /**
797 * @return the submapId
798 */
799 public long getDrillDownObjectId()
800 {
801 return drillDownObjectId;
802 }
803
804 /**
805 * @return the statusCalculationMethod
806 */
807 public int getStatusCalculationMethod()
808 {
809 return statusCalculationMethod;
810 }
811
812 /**
813 * @return the statusPropagationMethod
814 */
815 public int getStatusPropagationMethod()
816 {
817 return statusPropagationMethod;
818 }
819
820 /**
821 * @return the fixedPropagatedStatus
822 */
823 public ObjectStatus getFixedPropagatedStatus()
824 {
825 return fixedPropagatedStatus;
826 }
827
828 /**
829 * @return the statusShift
830 */
831 public int getStatusShift()
832 {
833 return statusShift;
834 }
835
836 /**
837 * @return the statusTransformation
838 */
839 public ObjectStatus[] getStatusTransformation()
840 {
841 return statusTransformation;
842 }
843
844 /**
845 * @return the statusSingleThreshold
846 */
847 public int getStatusSingleThreshold()
848 {
849 return statusSingleThreshold;
850 }
851
852 /**
853 * @return the statusThresholds
854 */
855 public int[] getStatusThresholds()
856 {
857 return statusThresholds;
858 }
859
860 /**
861 * Update internal session reference during session handover. This method should not be called directly!
862 *
863 * @param session new session object
864 */
865 public final void setSession(NXCSession session)
866 {
867 this.session = session;
868 }
869
870 /**
871 * Get effective rights for this object. On first call this method
872 * will do request to server, and on all subsequent calls
873 * will return cached value obtained at first call.
874 *
875 * @return effective user rights on this object
876 */
877 public int getEffectiveRights()
878 {
879 if (effectiveRightsCached)
880 return effectiveRights;
881
882 try
883 {
884 effectiveRights = session.getEffectiveRights(objectId);
885 effectiveRightsCached = true;
886 }
887 catch(Exception e)
888 {
889 effectiveRights = 0;
890 }
891 return effectiveRights;
892 }
893
894 /**
895 * Get module-specific data
896 *
897 * @param module module name
898 * @return custom data in module-specific format
899 */
900 public Object getModuleData(String module)
901 {
902 return (moduleData != null) ? moduleData.get(module) : null;
903 }
904
905 /**
906 * @return the postalAddress
907 */
908 public PostalAddress getPostalAddress()
909 {
910 return postalAddress;
911 }
912
913 /**
914 * @return the inMaintenanceMode
915 */
916 public boolean isInMaintenanceMode()
917 {
918 return inMaintenanceMode;
919 }
920 }