1 /******************************************************************************
3 * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
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. *
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 Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
20 #include "base/configobject.hpp"
21 #include "base/utility.hpp"
22 #impl_include "icinga/service.hpp"
31 * The type of a service comment.
40 CommentAcknowledgement = 4
43 class CommentNameComposer : public NameComposer
46 virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
47 virtual Dictionary::Ptr ParseName(const String& name) const;
51 class Comment : ConfigObject < CommentNameComposer
56 [config, protected, required, navigation(host)] name(Host) host_name {
58 return Host::GetByName(GetHostName());
61 [config, protected, navigation(service)] String service_name {
63 if (!oldValue.IsEmpty()) {
64 Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
65 DependencyGraph::RemoveDependency(this, service.get());
68 if (!newValue.IsEmpty()) {
69 Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
70 DependencyGraph::AddDependency(this, service.get());
74 if (GetServiceName().IsEmpty())
77 Host::Ptr host = Host::GetByName(GetHostName());
78 return host->GetServiceByShortName(GetServiceName());
82 [config] Timestamp entry_time {
83 default {{{ return Utility::GetTime(); }}}
85 [config, enum] CommentType entry_type {
86 default {{{ return CommentUser; }}}
88 [config, required] String author;
89 [config, required] String text;
90 [config] bool persistent;
91 [config] Timestamp expire_time;
92 [state] int legacy_id;