itop.business.class.inc.php 96 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629
  1. <?php
  2. require_once('../application/cmdbabstract.class.inc.php');
  3. require_once('../application/template.class.inc.php');
  4. /**
  5. * itop.business.class.inc.php
  6. * User defined objects, implements the business need
  7. *
  8. * @package iTopBizModelSamples
  9. * @author Romain Quetiez <romainquetiez@yahoo.fr>
  10. * @author Denis Flaven <denisflave@free.fr>
  11. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  12. * @link www.itop.com
  13. * @since 1.0
  14. * @version 1.1.1.1 $
  15. */
  16. /**
  17. * Possible values for the statuses of objects
  18. */
  19. $oAllowedStatuses = new ValueSetEnum('production,implementation,obsolete');
  20. /**
  21. * Relation graphs
  22. */
  23. MetaModel::RegisterRelation("impacts", array("description"=>"objects being functionaly impacted", "verb_down"=>"impacts", "verb_up"=>"is impacted by"));
  24. ////////////////////////////////////////////////////////////////////////////////////
  25. /**
  26. * An organization that owns some objects
  27. *
  28. * An organization "owns" some persons (its employees) but also some other objects
  29. * (its assets) like buildings, computers, furniture...
  30. * the services that they provides, the contracts/OLA they have signed as customer
  31. *
  32. * Organization ownership might be used to manage the R/W access to the object
  33. */
  34. ////////////////////////////////////////////////////////////////////////////////////
  35. /**
  36. * itop.business.class.inc.php
  37. * User defined objects, implements the business need
  38. *
  39. * @package iTopBizModelSamples
  40. * @author Erwan Taloc <taloche@yahoo.fr>
  41. * @author Denis Flaven <denisflave@free.fr>
  42. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  43. * @link www.itop.com
  44. * @since 1.0
  45. * @version 1.1.1.1 $
  46. */
  47. class bizOrganization extends cmdbAbstractObject
  48. {
  49. public static function Init()
  50. {
  51. global $oAllowedStatuses;
  52. $aParams = array
  53. (
  54. "category" => "bizmodel,searchable",
  55. "name" => "Organization",
  56. "description" => "Organizational structure: can be Company and/or Department",
  57. "key_type" => "autoincrement",
  58. "key_label" => "id",
  59. "name_attcode" => "name",
  60. "state_attcode" => "",
  61. "reconc_keys" => array("name"),
  62. "db_table" => "organizations",
  63. "db_key_field" => "id",
  64. "db_finalclass_field" => "",
  65. "display_template" => "../business/templates/default.html",
  66. );
  67. MetaModel::Init_Params($aParams);
  68. MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"Common name", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array() )));
  69. MetaModel::Init_AddAttribute(new AttributeString("code", array("label"=>"Code", "description"=>"Organization code (Siret, DUNS,...)", "allowed_values"=>null, "sql"=>"code", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array() )));
  70. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Lifecycle status", "allowed_values"=>$oAllowedStatuses, "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
  71. MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_id", array("targetclass"=>"bizOrganization", "label"=>"Parent Id", "description"=>"Parent organization", "allowed_values"=>null, "sql"=>"parent_id", "is_null_allowed"=>true, "depends_on"=>array())));
  72. MetaModel::Init_AddAttribute(new AttributeExternalField("parent_name", array("label"=>"Parent Name", "description"=>"Name of the parent organization", "allowed_values"=>null, "extkey_attcode"=> 'parent_id', "target_attcode"=>"name")));
  73. MetaModel::Init_AddFilterFromAttribute("name");
  74. MetaModel::Init_AddFilterFromAttribute("code");
  75. MetaModel::Init_AddFilterFromAttribute("status");
  76. // Display lists
  77. MetaModel::Init_SetZListItems('details', array('name', 'code', 'status', 'parent_id')); // Attributes to be displayed for the complete details
  78. MetaModel::Init_SetZListItems('list', array('name', 'status', 'parent_id')); // Attributes to be displayed for a list
  79. // Search criteria
  80. MetaModel::Init_SetZListItems('standard_search', array('name', 'code', 'status')); // Criteria of the std search form
  81. MetaModel::Init_SetZListItems('advanced_search', array('name', 'code', 'status')); // Criteria of the advanced search form
  82. }
  83. public function Generate(cmdbDataGenerator $oGenerator)
  84. {
  85. //$this->SetKey($oGenerator->GetOrganizationCode());
  86. $this->Set('name', $oGenerator->GetOrganizationName());
  87. $this->Set('code', $oGenerator->GetOrganizationCode());
  88. $this->Set('status', 'implementation');
  89. $this->Set('parent_id', 1);
  90. }
  91. }
  92. ////////////////////////////////////////////////////////////////////////////////////
  93. /**
  94. * Class of objects owned by some organization
  95. *
  96. * This is the root class of all the objects that can be "owned" by an organization
  97. *
  98. * A Real Object
  99. * can be supported by Contacts, having a specific role (same contact with multiple roles?)
  100. * can be documented by Documents
  101. */
  102. ////////////////////////////////////////////////////////////////////////////////////
  103. /**
  104. * itop.business.class.inc.php
  105. * User defined objects, implements the business need
  106. *
  107. * @package iTopBizModelSamples
  108. * @author Erwan Taloc <taloche@yahoo.fr>
  109. * @author Denis Flaven <denisflave@free.fr>
  110. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  111. * @link www.itop.com
  112. * @since 1.0
  113. * @version 1.1.1.1 $
  114. */
  115. class logRealObject extends cmdbAbstractObject
  116. {
  117. public static function Init()
  118. {
  119. global $oAllowedStatuses;
  120. $aParams = array
  121. (
  122. "category" => "bizmodel,searchable",
  123. "name" => "Object",
  124. "description" => "Any CMDB object",
  125. "key_type" => "autoincrement",
  126. "key_label" => "id",
  127. "name_attcode" => "name",
  128. "state_attcode" => "",
  129. "reconc_keys" => array("name"),
  130. "db_table" => "objects",
  131. "db_key_field" => "id",
  132. "db_finalclass_field" => "obj_class",
  133. "display_template" => "../business/templates/default.html",
  134. );
  135. MetaModel::Init_Params($aParams);
  136. MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"Common name", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  137. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Lifecycle status", "allowed_values"=>$oAllowedStatuses, "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
  138. MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"bizOrganization", "label"=>"Organization Id", "description"=>"ID of the object owner organization", "allowed_values"=>new ValueSetObjects("bizOrganization: status Contains 'implementation'", 'name', array('name'=>true)), "sql"=>"org_id", "is_null_allowed"=>false, "depends_on"=>array())));
  139. MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("label"=>"Organization", "description"=>"Company / Department owning this object", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
  140. MetaModel::Init_AddFilterFromAttribute("name");
  141. MetaModel::Init_AddFilterFromAttribute("status");
  142. MetaModel::Init_AddFilterFromAttribute("org_id");
  143. MetaModel::Init_AddFilterFromAttribute("org_name");
  144. // Display lists
  145. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id')); // Attributes to be displayed for the complete details
  146. MetaModel::Init_SetZListItems('list', array('finalclass', 'name', 'status', 'org_id')); // Attributes to be displayed for a list
  147. // Search criteria
  148. MetaModel::Init_SetZListItems('standard_search', array('name', 'status')); // Criteria of the std search form
  149. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'org_id')); // Criteria of the advanced search form
  150. }
  151. public function Generate(cmdbDataGenerator $oGenerator)
  152. {
  153. $this->Set('org_id', $oGenerator->GetOrganizationId());
  154. $this->Set('name', "<overload in derived class>");
  155. $this->Set('status', $oGenerator->GenerateString("enum(implementation,production)"));
  156. }
  157. }
  158. ////////////////////////////////////////////////////////////////////////////////////
  159. /**
  160. * Any kind of thing that can be contacted (person, team, hotline...)
  161. * A contact can:
  162. * be linked to any Real Object with a role
  163. * be part of a GroupContact
  164. */
  165. ////////////////////////////////////////////////////////////////////////////////////
  166. class bizContact extends logRealObject
  167. {
  168. public static function Init()
  169. {
  170. $aParams = array
  171. (
  172. "category" => "bizmodel,searchable",
  173. "name" => "Contact",
  174. "description" => "Contact",
  175. "key_type" => "",
  176. "key_label" => "id",
  177. "name_attcode" => "name",
  178. "state_attcode" => "",
  179. "reconc_keys" => array("org_name", "name"), // inherited attributes
  180. "db_table" => "contacts",
  181. "db_key_field" => "id",
  182. "db_finalclass_field" => "",
  183. "display_template" => "../business/templates/default.html",
  184. );
  185. MetaModel::Init_Params($aParams);
  186. MetaModel::Init_InheritAttributes();
  187. MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("label"=>"Organization", "description"=>"Company / Department of the contact", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
  188. MetaModel::Init_AddAttribute(new AttributeString("email", array("label"=>"eMail", "description"=>"Email address", "allowed_values"=>null, "sql"=>"email", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  189. MetaModel::Init_AddAttribute(new AttributeString("phone", array("label"=>"Phone", "description"=>"Telephone", "allowed_values"=>null, "sql"=>"telephone", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  190. MetaModel::Init_AddAttribute(new AttributeExternalKey("location_id", array("targetclass"=>"bizLocation", "label"=>"Location Id", "description"=>"Id of the location where the contact is located", "allowed_values"=>null, "sql"=>"location_id", "is_null_allowed"=>true, "depends_on"=>array())));
  191. MetaModel::Init_AddAttribute(new AttributeExternalField("location_name", array("label"=>"Location Name", "description"=>"Name of the location where the contact is located", "allowed_values"=>null, "extkey_attcode"=> 'location_id', "target_attcode"=>"name")));
  192. MetaModel::Init_InheritFilters();
  193. MetaModel::Init_AddFilterFromAttribute("org_name");
  194. MetaModel::Init_AddFilterFromAttribute("email");
  195. MetaModel::Init_AddFilterFromAttribute("phone");
  196. MetaModel::Init_AddFilterFromAttribute("location_id");
  197. MetaModel::Init_AddFilterFromAttribute("location_name");
  198. // Display lists
  199. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'email', 'location_id', 'phone')); // Attributes to be displayed for the complete details
  200. MetaModel::Init_SetZListItems('list', array('finalclass', 'name', 'status', 'org_id', 'email', 'location_id', 'phone')); // Attributes to be displayed for a list
  201. // Search criteria
  202. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'email', 'location_id', 'phone')); // Criteria of the std search form
  203. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'org_id')); // Criteria of the advanced search form
  204. }
  205. public function Generate(cmdbDataGenerator $oGenerator)
  206. {
  207. $this->Set('org_id', $oGenerator->GetOrganizationId());
  208. $this->Set('name', "<overload in derived classes>");
  209. $this->Set('email', "<overload in derived classes>");
  210. $this->Set('phone', $oGenerator->GenerateString("enum(+1,+33,+44,+49,+421)| |number(100-999)| |number(000-999)"));
  211. $this->Set('location_id', $oGenerator->GenerateKey("bizLocation", array('org_id' =>$oGenerator->GetOrganizationId() )));
  212. }
  213. }
  214. ////////////////////////////////////////////////////////////////////////////////////
  215. /**
  216. * Physical person only
  217. */
  218. ////////////////////////////////////////////////////////////////////////////////////
  219. class bizPerson extends bizContact
  220. {
  221. public static function Init()
  222. {
  223. $aParams = array
  224. (
  225. "category" => "bizmodel,searchable",
  226. "name" => "Person",
  227. "description" => "Person",
  228. "key_type" => "",
  229. "key_label" => "id",
  230. "name_attcode" => "name",
  231. "state_attcode" => "",
  232. "reconc_keys" => array("org_name", "first_name", "name"), // comment en définir plusieurs
  233. // "reconc_keys" => array("org_name", "employe_number"),
  234. "db_table" => "persons", // Can it use the same physical DB table as any contact ?
  235. "db_key_field" => "id",
  236. "db_finalclass_field" => "",
  237. "display_template" => "../business/templates/person.html",
  238. );
  239. MetaModel::Init_Params($aParams);
  240. MetaModel::Init_InheritAttributes();
  241. MetaModel::Init_AddAttribute(new AttributeString("first_name", array("label"=>"first Name", "description"=>"First name", "allowed_values"=>null, "sql"=>"first_name", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  242. MetaModel::Init_AddAttribute(new AttributeString("employe_number", array("label"=>"Employe Number", "description"=>"employe number", "allowed_values"=>null, "sql"=>"employe_number", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  243. MetaModel::Init_InheritFilters();
  244. MetaModel::Init_AddFilterFromAttribute("first_name");
  245. MetaModel::Init_AddFilterFromAttribute("employe_number");
  246. // Display lists
  247. MetaModel::Init_SetZListItems('details', array('first_name', 'name', 'status', 'org_id', 'email', 'location_id', 'phone', 'employe_number')); // Attributes to be displayed for the complete details
  248. MetaModel::Init_SetZListItems('list', array('first_name', 'name', 'status', 'org_id', 'email', 'location_id', 'phone')); // Attributes to be displayed for a list
  249. // Search criteria
  250. MetaModel::Init_SetZListItems('standard_search', array('first_name', 'name', 'status', 'email', 'location_id', 'phone', 'employe_number')); // Criteria of the std search form
  251. MetaModel::Init_SetZListItems('advanced_search', array('first_name', 'name', 'status', 'email', 'location_id', 'phone', 'employe_number')); // Criteria of the advanced search form
  252. }
  253. public function Generate(cmdbDataGenerator $oGenerator)
  254. {
  255. parent::Generate($oGenerator);
  256. $this->Set('name', $oGenerator->GenerateLastName());
  257. $this->Set('first_name', $oGenerator->GenerateFirstName());
  258. $this->Set('email', $oGenerator->GenerateEmail($this->Get('first_name'), $this->Get('name')));
  259. $this->Set('phone', $oGenerator->GenerateString("enum(+1,+33,+44,+49,+421)| |number(100-999)| |number(000-999)"));
  260. }
  261. }
  262. ////////////////////////////////////////////////////////////////////////////////////
  263. /**
  264. * A team is basically a contact which is also a group of contacts
  265. * (and thus a team can contain other teams)
  266. */
  267. ////////////////////////////////////////////////////////////////////////////////////
  268. class bizTeam extends bizContact
  269. {
  270. public static function Init()
  271. {
  272. $aParams = array
  273. (
  274. "category" => "bizmodel,searchable",
  275. "name" => "Team",
  276. "description" => "A group of contacts",
  277. "key_type" => "",
  278. "key_label" => "id",
  279. "name_attcode" => "name",
  280. "state_attcode" => "",
  281. "reconc_keys" => array("org_name", "name"), // inherited attributes
  282. "db_table" => "teams",
  283. "db_key_field" => "id",
  284. "db_finalclass_field" => "",
  285. "display_template" => "../business/templates/team.html",
  286. );
  287. MetaModel::Init_Params($aParams);
  288. MetaModel::Init_InheritAttributes();
  289. MetaModel::Init_InheritFilters();
  290. // Display lists
  291. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'email', 'location_id', 'phone')); // Attributes to be displayed for the complete details
  292. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'email', 'location_id', 'phone')); // Attributes to be displayed for a list
  293. // Search criteria
  294. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'email', 'location_id', 'phone')); // Criteria of the std search form
  295. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'org_id')); // Criteria of the advanced search form
  296. }
  297. }
  298. ////////////////////////////////////////////////////////////////////////////////////
  299. /**
  300. * An electronic document, with version tracking
  301. */
  302. ////////////////////////////////////////////////////////////////////////////////////
  303. class bizDocument extends logRealObject
  304. {
  305. public static function Init()
  306. {
  307. $aParams = array
  308. (
  309. "category" => "bizmodel,searchable",
  310. "name" => "Document",
  311. "description" => "Document",
  312. "key_type" => "",
  313. "key_label" => "id",
  314. "name_attcode" => "name",
  315. "state_attcode" => "",
  316. "reconc_keys" => array("org_name", "name"), // inherited attributes
  317. "db_table" => "documents",
  318. "db_key_field" => "id",
  319. "db_finalclass_field" => "",
  320. "display_template" => "../business/templates/document.html",
  321. );
  322. MetaModel::Init_Params($aParams);
  323. MetaModel::Init_InheritAttributes();
  324. MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("label"=>"Organization", "description"=>"Company / Department owning the document", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
  325. MetaModel::Init_AddAttribute(new AttributeEnum("scope", array("label"=>"scope", "description"=>"Scope of this document", "allowed_values"=>new ValueSetEnum("organization,hardware support"), "sql"=>"scope", "default_value"=>"organization", "is_null_allowed"=>false, "depends_on"=>array())));
  326. MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Description", "description"=>"Service Description", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  327. MetaModel::Init_InheritFilters();
  328. MetaModel::Init_AddFilterFromAttribute("scope");
  329. MetaModel::Init_AddFilterFromAttribute("description");
  330. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'scope','description')); // Attributes to be displayed for the complete details
  331. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'scope')); // Attributes to be displayed for a list
  332. // Search criteria
  333. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'scope')); // Criteria of the std search form
  334. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'scope')); // Criteria of the advanced search form
  335. }
  336. }
  337. ////////////////////////////////////////////////////////////////////////////////////
  338. /**
  339. * A version of an electronic document
  340. */
  341. ////////////////////////////////////////////////////////////////////////////////////
  342. class bizDocVersion extends cmdbAbstractObject
  343. {
  344. public static function Init()
  345. {
  346. global $oAllowedStatuses;
  347. $aParams = array
  348. (
  349. "category" => "bizmodel,searchable",
  350. "name" => "DocumentVersion",
  351. "description" => "A version of a document",
  352. "key_type" => "autoincrement",
  353. "key_label" => "id",
  354. "name_attcode" => "version_number",
  355. "state_attcode" => "",
  356. "reconc_keys" => array("docname", "version_number"),
  357. "db_table" => "document_versions",
  358. "db_key_field" => "id",
  359. "db_finalclass_field" => "",
  360. "display_template" => "../business/templates/document.html",
  361. );
  362. MetaModel::Init_Params($aParams);
  363. MetaModel::Init_AddAttribute(new AttributeExternalKey("document", array("targetclass"=>"bizDocument", "label"=>"document", "description"=>"The main document", "allowed_values"=>null, "sql"=>"document_id", "is_null_allowed"=>false, "depends_on"=>array())));
  364. MetaModel::Init_AddAttribute(new AttributeExternalField("docname", array("label"=>"document name", "description"=>"name of the document", "allowed_values"=>null, "extkey_attcode"=> 'document', "target_attcode"=>"name")));
  365. MetaModel::Init_AddAttribute(new AttributeString("version_number", array("label"=>"version number", "description"=>"Service name", "allowed_values"=>null, "sql"=>"version_number", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  366. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"status", "description"=>"Status", "allowed_values"=>$oAllowedStatuses, "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
  367. MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"type", "description"=>"Type", "allowed_values"=>new ValueSetEnum("local,draft"), "sql"=>"type", "default_value"=>"local", "is_null_allowed"=>false, "depends_on"=>array())));
  368. MetaModel::Init_AddAttribute(new AttributeURL("url", array("label"=>"URL", "description"=>"Hyperlink to the version", "allowed_values"=>null, "target"=>"_blank", "sql"=>"url", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  369. MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Description", "description"=>"Service Description", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  370. MetaModel::Init_AddFilterFromAttribute("document");
  371. MetaModel::Init_AddFilterFromAttribute("docname");
  372. MetaModel::Init_AddFilterFromAttribute("version_number");
  373. MetaModel::Init_AddFilterFromAttribute("status");
  374. MetaModel::Init_AddFilterFromAttribute("type");
  375. MetaModel::Init_AddFilterFromAttribute("description");
  376. MetaModel::Init_SetZListItems('details', array('docname', 'status', 'version_number', 'type','url','description')); // Attributes to be displayed for the complete details
  377. MetaModel::Init_SetZListItems('list', array('version_number', 'status', 'type', 'url')); // Attributes to be displayed for a list
  378. // Search criteria
  379. MetaModel::Init_SetZListItems('standard_search', array('docname', 'type')); // Criteria of the std search form
  380. MetaModel::Init_SetZListItems('advanced_search', array('docname', 'type')); // Criteria o
  381. }
  382. }
  383. ////////////////////////////////////////////////////////////////////////////////////
  384. /**
  385. * n-n link between any Object and a Document
  386. */
  387. ////////////////////////////////////////////////////////////////////////////////////
  388. class lnkDocumentRealObject extends cmdbAbstractObject
  389. {
  390. public static function Init()
  391. {
  392. $aParams = array
  393. (
  394. "category" => "bizmodel,searchable",
  395. "name" => "DocumentsLinks",
  396. "description" => "A link between a document and another object",
  397. "key_type" => "autoincrement",
  398. "key_label" => "link_id",
  399. "name_attcode" => "link_type",
  400. "state_attcode" => "",
  401. "reconc_keys" => array("doc_name", "object_name"),
  402. "db_table" => "documents_links",
  403. "db_key_field" => "link_id",
  404. "db_finalclass_field" => "",
  405. "display_template" => "../business/templates/default.html",
  406. );
  407. MetaModel::Init_Params($aParams);
  408. MetaModel::Init_AddAttribute(new AttributeExternalKey("doc_id", array("targetclass"=>"bizDocument", "label"=>"Document Name", "description"=>"id of the Document", "allowed_values"=>null, "sql"=>"doc_id", "is_null_allowed"=>false, "depends_on"=>array())));
  409. MetaModel::Init_AddAttribute(new AttributeExternalField("doc_name", array("label"=>"Document", "description"=>"name of the document", "allowed_values"=>null, "extkey_attcode"=> 'doc_id', "target_attcode"=>"name")));
  410. MetaModel::Init_AddAttribute(new AttributeExternalKey("object_id", array("targetclass"=>"logRealObject", "label"=>"object", "description"=>"Object linked", "allowed_values"=>null, "sql"=>"object_id", "is_null_allowed"=>false, "depends_on"=>array())));
  411. MetaModel::Init_AddAttribute(new AttributeExternalField("object_name", array("label"=>"object name", "description"=>"name of the linked object", "allowed_values"=>null, "extkey_attcode"=> 'object_id', "target_attcode"=>"name")));
  412. MetaModel::Init_AddAttribute(new AttributeString("link_type", array("label"=>"link_type", "description"=>"Type of the link", "allowed_values"=>null, "sql"=>"link_type", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  413. MetaModel::Init_AddFilterFromAttribute("doc_id");
  414. MetaModel::Init_AddFilterFromAttribute("doc_name");
  415. MetaModel::Init_AddFilterFromAttribute("object_id");
  416. MetaModel::Init_AddFilterFromAttribute("object_name");
  417. MetaModel::Init_AddFilterFromAttribute("link_type");
  418. // Display lists
  419. MetaModel::Init_SetZListItems('details', array('doc_id', 'object_name', 'link_type')); // Attributes to be displayed for the complete details
  420. MetaModel::Init_SetZListItems('list', array('doc_id', 'object_name', 'link_type')); // Attributes to be displayed for a list
  421. }
  422. }
  423. ////////////////////////////////////////////////////////////////////////////////////
  424. /**
  425. * n-n link between any Object and a contact
  426. */
  427. ////////////////////////////////////////////////////////////////////////////////////
  428. class lnkContactRealObject extends cmdbAbstractObject
  429. {
  430. public static function Init()
  431. {
  432. $aParams = array
  433. (
  434. "category" => "bizmodel,searchable",
  435. "name" => "ContactsLinks",
  436. "description" => "A link between a contact and another object",
  437. "key_type" => "autoincrement",
  438. "key_label" => "link_id",
  439. "name_attcode" => "role",
  440. "state_attcode" => "",
  441. "reconc_keys" => array("contact_name", "object_name"),
  442. "db_table" => "contacts_links",
  443. "db_key_field" => "link_id",
  444. "db_finalclass_field" => "",
  445. "display_template" => "../business/templates/default.html",
  446. );
  447. MetaModel::Init_Params($aParams);
  448. MetaModel::Init_AddAttribute(new AttributeExternalKey("contact_id", array("targetclass"=>"bizContact", "label"=>"Contact", "description"=>"The contact", "allowed_values"=>null, "sql"=>"contact_id", "is_null_allowed"=>false, "depends_on"=>array())));
  449. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_name", array("label"=>"Contact name", "description"=>"name of the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"name")));
  450. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_phone", array("label"=>"Phone", "description"=>"Phone number of the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"phone")));
  451. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_email", array("label"=>"eMail", "description"=>"eMail address of the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"email")));
  452. MetaModel::Init_AddAttribute(new AttributeExternalKey("object_id", array("targetclass"=>"logRealObject", "label"=>"object", "description"=>"Object linked", "allowed_values"=>null, "sql"=>"object_id", "is_null_allowed"=>false, "depends_on"=>array())));
  453. MetaModel::Init_AddAttribute(new AttributeExternalField("object_name", array("label"=>"Object name", "description"=>"name of the linked object", "allowed_values"=>null, "extkey_attcode"=> 'object_id', "target_attcode"=>"name")));
  454. MetaModel::Init_AddAttribute(new AttributeString("role", array("label"=>"Role", "description"=>"Role of the contact", "allowed_values"=>null, "sql"=>"role", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  455. MetaModel::Init_AddFilterFromAttribute("contact_id");
  456. MetaModel::Init_AddFilterFromAttribute("contact_name");
  457. MetaModel::Init_AddFilterFromAttribute("object_id");
  458. MetaModel::Init_AddFilterFromAttribute("object_name");
  459. MetaModel::Init_AddFilterFromAttribute("role");
  460. // Display lists
  461. MetaModel::Init_SetZListItems('details', array('contact_id', 'contact_phone', 'contact_email', 'object_id', 'role')); // Attributes to be displayed for the complete details
  462. MetaModel::Init_SetZListItems('list', array('contact_id', 'contact_phone', 'contact_email', 'object_id', 'role')); // Attributes to be displayed for a list
  463. }
  464. }
  465. ////////////////////////////////////////////////////////////////////////////////////
  466. /**
  467. * Any Infrastructure object (bizLocation, bizDevice, bizApplication, bizCircuit, bizInterface)
  468. * An infrastructure object:
  469. * can be covered by an OLA
  470. * can support the delivery of a Service
  471. * can be part of an GroupInfra
  472. */
  473. ////////////////////////////////////////////////////////////////////////////////////
  474. class logInfra extends logRealObject
  475. {
  476. public static function Init()
  477. {
  478. $aParams = array
  479. (
  480. "category" => "bizmodel,searchable",
  481. "name" => "Infra",
  482. "description" => "Infrastructure real object",
  483. "key_type" => "",
  484. "key_label" => "id",
  485. "name_attcode" => "name",
  486. "state_attcode" => "",
  487. "reconc_keys" => array("org_name", "name"), // inherited attributes
  488. "db_table" => "infra",
  489. "db_key_field" => "id",
  490. "db_finalclass_field" => "",
  491. "display_template" => "../business/templates/default.html",
  492. );
  493. MetaModel::Init_Params($aParams);
  494. MetaModel::Init_InheritAttributes();
  495. MetaModel::Init_AddAttribute(new AttributeEnum("severity", array("label"=>"Severity", "description"=>"Severity for this infrastructure", "allowed_values"=>new ValueSetEnum("high,medium,low"), "sql"=>"severity", "default_value"=>"low", "is_null_allowed"=>false, "depends_on"=>array())));
  496. MetaModel::Init_InheritFilters();
  497. MetaModel::Init_AddFilterFromAttribute("severity");
  498. }
  499. }
  500. ////////////////////////////////////////////////////////////////////////////////////
  501. /**
  502. * bizLocation (Region, Country, City, Site, Building, Floor, Room, Rack,...)
  503. * pourrait être mis en plusieurs sous objects, puisqu'une adresse sur region n'a pas trop de sens
  504. *
  505. */
  506. ////////////////////////////////////////////////////////////////////////////////////
  507. class bizLocation extends logInfra
  508. {
  509. public static function Init()
  510. {
  511. $aParams = array
  512. (
  513. "category" => "bizmodel,searchable",
  514. "name" => "Location",
  515. "description" => "Any type of location: Region, Country, City, Site, Building, Floor, Room, Rack,...",
  516. "key_type" => "",
  517. "key_label" => "id",
  518. "name_attcode" => "name",
  519. "state_attcode" => "",
  520. "reconc_keys" => array("org_name", "name"), // inherited attributes
  521. "db_table" => "location",
  522. "db_key_field" => "id",
  523. "db_finalclass_field" => "",
  524. "display_template" => "../business/templates/location.html",
  525. );
  526. MetaModel::Init_Params($aParams);
  527. MetaModel::Init_InheritAttributes();
  528. MetaModel::Init_AddAttribute(new AttributeText("address", array("label"=>"Address", "description"=>"The postal address of the location", "allowed_values"=>null, "sql"=>"address", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  529. MetaModel::Init_AddAttribute(new AttributeString("country", array("label"=>"Country", "description"=>"Country of the location", "allowed_values"=>null, "sql"=>"country", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  530. MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_location_id", array("targetclass"=>"bizLocation", "label"=>"Parent Location", "description"=>"where is the real object physically located", "allowed_values"=>null, "sql"=>"parent_location_id", "is_null_allowed"=>true, "depends_on"=>array())));
  531. MetaModel::Init_AddAttribute(new AttributeExternalField("parent_location_name", array("label"=>"Parent location (Name)", "description"=>"name of the parent location", "allowed_values"=>null, "extkey_attcode"=> 'parent_location_id', "target_attcode"=>"name")));
  532. // on veut pouvoir rechercher une location qui soit un descendant (pas obligatoirement direct) d'une Location, on fait comment ?
  533. MetaModel::Init_InheritFilters();
  534. MetaModel::Init_AddFilterFromAttribute("country");
  535. MetaModel::Init_AddFilterFromAttribute("address");
  536. MetaModel::Init_AddFilterFromAttribute("parent_location_id");
  537. MetaModel::Init_AddFilterFromAttribute("parent_location_name");
  538. // Display lists
  539. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'address', 'country', 'parent_location_id')); // Attributes to be displayed for the complete details
  540. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'country')); // Attributes to be displayed for a list
  541. // Search criteria
  542. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'country', 'parent_location_name')); // Criteria of the std search form
  543. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'address', 'country', 'parent_location_id', 'org_id')); // Criteria of the advanced search form
  544. }
  545. public function ComputeValues()
  546. {
  547. /*
  548. $this->Set("location_id", $this->GetKey());
  549. // Houston, I've got an issue, as this field is calculated, I should reload the object... ?
  550. $this->Set("location_name", "abc (to be finalized)");
  551. */
  552. }
  553. function DisplayDetails(web_page $oPage)
  554. {
  555. parent::DisplayDetails($oPage);
  556. /*
  557. parent::DisplayDetails($oPage);
  558. $oSearchFilter = new CMDBSearchFilter('bizServer');
  559. $oSearchFilter->AddCondition('location_id', $this->GetKey(), '=');
  560. $oSet = new CMDBObjectSet($oSearchFilter);
  561. $count = $oSet->Count();
  562. if ($count > 0)
  563. {
  564. $oPage->SetCurrentTab("Servers");
  565. $oPage->p("$count server(s) at this location:");
  566. $this->DisplaySet($oPage, $oSet);
  567. }
  568. $oSearchFilter = new CMDBSearchFilter('bizNetworkDevice');
  569. $oSearchFilter->AddCondition('location_id', $this->GetKey(), '=');
  570. $oSet = new CMDBObjectSet($oSearchFilter);
  571. $count = $oSet->Count();
  572. if ($count > 0)
  573. {
  574. $oPage->SetCurrentTab("Network Devices");
  575. $oPage->p("$count Network Device(s) at this location:");
  576. $this->DisplaySet($oPage, $oSet);
  577. }
  578. $oSearchFilter = new CMDBSearchFilter('bizPC');
  579. $oSearchFilter->AddCondition('location_id', $this->GetKey(), '=');
  580. $oSet = new CMDBObjectSet($oSearchFilter);
  581. $count = $oSet->Count();
  582. if ($count > 0)
  583. {
  584. $oPage->SetCurrentTab("PCs");
  585. $oPage->p("$count PC(s) at this location:");
  586. $this->DisplaySet($oPage, $oSet);
  587. }
  588. $oSearchFilter = new CMDBSearchFilter('bizPerson');
  589. $oSearchFilter->AddCondition('location_id', $this->GetKey(), '=');
  590. $oSet = new CMDBObjectSet($oSearchFilter);
  591. $count = $oSet->Count();
  592. if ($count > 0)
  593. {
  594. $oPage->SetCurrentTab("Contacts");
  595. $oPage->p("$count person(s) located to this location:");
  596. $this->DisplaySet($oPage, $oSet);
  597. }
  598. $oSearchFilter = new CMDBSearchFilter('lnkDocumentRealObject');
  599. $oSearchFilter->AddCondition('object_id', $this->GetKey(), '=');
  600. $oSet = new CMDBObjectSet($oSearchFilter);
  601. $count = $oSet->Count();
  602. if ($count > 0)
  603. {
  604. $oPage->SetCurrentTab("Details");
  605. $oPage->p("$count Document(s) linked to this location:");
  606. $this->DisplaySet($oPage, $oSet);
  607. }
  608. */
  609. }
  610. public function Generate(cmdbDataGenerator $oGenerator)
  611. {
  612. parent::Generate($oGenerator);
  613. $sLastName = $oGenerator->GenerateLastName();
  614. $sCityName = $oGenerator->GenerateCityName();
  615. $this->Set('name', $sCityName);
  616. $this->Set('country', $oGenerator->GenerateCountryName());
  617. $this->Set('address', $oGenerator->GenerateString("number(1-999)| |enum(rue,rue,rue,place,avenue,av.,route de)| |$sLastName| |number(0000-9999)|0 |$sCityName"));
  618. $this->Set('parent_location_id', 1);
  619. }
  620. }
  621. ////////////////////////////////////////////////////////////////////////////////////
  622. /**
  623. * Circuit (one end only)
  624. */
  625. ////////////////////////////////////////////////////////////////////////////////////
  626. class bizCircuit extends logInfra
  627. {
  628. public static function Init()
  629. {
  630. $aParams = array
  631. (
  632. "category" => "bizmodel,searchable",
  633. "name" => "Circuit",
  634. "description" => "Any type of circuit",
  635. "key_type" => "",
  636. "key_label" => "id",
  637. "name_attcode" => "name",
  638. "state_attcode" => "",
  639. "reconc_keys" => array("org_name", "carrier_name", "carrier_ref", "name"), // inherited attributes
  640. "db_table" => "circuits",
  641. "db_key_field" => "id",
  642. "db_finalclass_field" => "",
  643. "display_template" => "../business/templates/Circuits.html",
  644. );
  645. MetaModel::Init_Params($aParams);
  646. MetaModel::Init_InheritAttributes();
  647. MetaModel::Init_AddAttribute(new AttributeString("speed", array("label"=>"speed", "description"=>"speed of the circuit", "allowed_values"=>null, "sql"=>"speed", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  648. MetaModel::Init_AddAttribute(new AttributeExternalKey("location_id", array("targetclass"=>"bizLocation", "label"=>"Location ID", "description"=>"Id of the location", "allowed_values"=>null, "sql"=>"location_id", "is_null_allowed"=>false, "depends_on"=>array())));
  649. MetaModel::Init_AddAttribute(new AttributeExternalField("location_name", array("label"=>"Location", "description"=>"Name of the location", "allowed_values"=>null, "extkey_attcode"=> 'location_id', "target_attcode"=>"name")));
  650. MetaModel::Init_AddAttribute(new AttributeExternalKey("interface_id", array("targetclass"=>"bizInterface", "label"=>"Interface Id", "description"=>"id of the interface", "allowed_values"=>null, "sql"=>"interface_id", "is_null_allowed"=>false, "depends_on"=>array())));
  651. MetaModel::Init_AddAttribute(new AttributeExternalField("interface_name", array("label"=>"Interface", "description"=>"Name of the interface", "allowed_values"=>null, "extkey_attcode"=> 'interface_id', "target_attcode"=>"name")));
  652. MetaModel::Init_AddAttribute(new AttributeExternalKey("provider_id", array("targetclass"=>"bizOrganization", "label"=>"Carrier ID", "description"=>"Organization ID of the provider of the Circuit", "allowed_values"=>null, "sql"=>"provider_id", "is_null_allowed"=>false, "depends_on"=>array())));
  653. MetaModel::Init_AddAttribute(new AttributeExternalField("carrier_name", array("label"=>"Carrier", "description"=>"Name of the carrier", "allowed_values"=>null, "extkey_attcode"=> 'provider_id', "target_attcode"=>"name")));
  654. MetaModel::Init_AddAttribute(new AttributeString("carrier_ref", array("label"=>"Carrier reference", "description"=>"reference of the circuit used by the carrier", "allowed_values"=>null, "sql"=>"carrier_ref", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  655. MetaModel::Init_InheritFilters();
  656. MetaModel::Init_AddFilterFromAttribute("speed");
  657. MetaModel::Init_AddFilterFromAttribute("location_id");
  658. MetaModel::Init_AddFilterFromAttribute("location_name");
  659. MetaModel::Init_AddFilterFromAttribute("interface_id");
  660. MetaModel::Init_AddFilterFromAttribute("provider_id");
  661. MetaModel::Init_AddFilterFromAttribute("carrier_ref");
  662. // Display lists
  663. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'speed', 'provider_id', 'carrier_ref', 'location_id')); // Attributes to be displayed for the complete details
  664. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'provider_id', 'carrier_ref', 'speed')); // Attributes to be displayed for a list
  665. // Search criteria
  666. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'carrier_ref', 'speed', 'provider_id')); // Criteria of the std search form
  667. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'carrier_ref', 'speed', 'provider_id')); // Criteria of the advanced search form
  668. }
  669. public function ComputeValues()
  670. {
  671. /*
  672. $oLocatedObject = MetaModel::GetObject("Located Object", $this->Get("located_object_id"));
  673. $this->Set("location_id", $oLocatedObject->Get("location_id"));
  674. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  675. $this->Set("location_name", "abc (to be finalized)");
  676. $this->Set("device_id", $oLocatedObject->Get("device_id"));
  677. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  678. $this->Set("device_name", "abc (to be finalized)");
  679. $this->Set("interface_id", $oLocatedObject->Get("interface_id"));
  680. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  681. $this->Set("interface_name", "abc (to be finalized)");
  682. */
  683. }
  684. }
  685. ////////////////////////////////////////////////////////////////////////////////////
  686. /**
  687. * Any Device Network Interface
  688. */
  689. ////////////////////////////////////////////////////////////////////////////////////
  690. class bizInterface extends logInfra
  691. {
  692. public static function Init()
  693. {
  694. $aParams = array
  695. (
  696. "category" => "bizmodel,searchable",
  697. "name" => "Interface",
  698. "description" => "Interface",
  699. "key_type" => "",
  700. "key_label" => "id",
  701. "name_attcode" => "name",
  702. "state_attcode" => "",
  703. "reconc_keys" => array("org_name", "device_name", "name"),
  704. "db_table" => "interfaces",
  705. "db_key_field" => "id",
  706. "db_finalclass_field" => "",
  707. "display_template" => "../business/templates/interface.html",
  708. );
  709. MetaModel::Init_Params($aParams);
  710. MetaModel::Init_InheritAttributes();
  711. MetaModel::Init_AddAttribute(new AttributeExternalKey("device_id", array("targetclass"=>"bizDevice", "label"=>"Device", "description"=>"Device on which the interface is physically located", "allowed_values"=>null, "sql"=>"device_id", "is_null_allowed"=>false, "depends_on"=>array())));
  712. MetaModel::Init_AddAttribute(new AttributeExternalField("device_name", array("label"=>"Device", "description"=>"name of the device on which the interface is located", "allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"name")));
  713. MetaModel::Init_AddAttribute(new AttributeExternalField("device_location_id", array("label"=>"Device location", "description"=>"location of the device on which the interface is located", "allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"location_id")));
  714. MetaModel::Init_AddAttribute(new AttributeExternalField("device_location_name", array("label"=>"Device location", "description"=>"name of the location of the device on which the interface is located", "allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"location_name")));
  715. MetaModel::Init_AddAttribute(new AttributeEnum("logical_type", array("label"=>"Logical type", "description"=>"Logical type of interface", "allowed_values"=>new ValueSetEnum("primary,secondary,backup,port,logical"), "sql"=>"logical_type", "default_value"=>"port", "is_null_allowed"=>false, "depends_on"=>array())));
  716. MetaModel::Init_AddAttribute(new AttributeEnum("physical_type", array("label"=>"Physical type", "description"=>"Physical type of interface", "allowed_values"=>new ValueSetEnum("ethernet,framerelay,atm,vlan"), "sql"=>"physical_type", "default_value"=>"ethernet", "is_null_allowed"=>false, "depends_on"=>array())));
  717. MetaModel::Init_AddAttribute(new AttributeString("ip_address", array("label"=>"IP address", "description"=>"address IP for this interface", "allowed_values"=>null, "sql"=>"ip_address", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  718. MetaModel::Init_AddAttribute(new AttributeString("mask", array("label"=>"Subnet Mask", "description"=>"Subnet mask for this interface", "allowed_values"=>null, "sql"=>"mask", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  719. MetaModel::Init_AddAttribute(new AttributeString("mac", array("label"=>"MAC address", "description"=>"MAC address for this interface", "allowed_values"=>null, "sql"=>"mac", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  720. MetaModel::Init_AddAttribute(new AttributeString("speed", array("label"=>"Speed (Kb/s)", "description"=>"speed of this interface", "allowed_values"=>null, "sql"=>"speed", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  721. MetaModel::Init_AddAttribute(new AttributeEnum("duplex", array("label"=>"Duplex", "description"=>"Duplex configured for this interface", "allowed_values"=>new ValueSetEnum("half,full,unknown"), "sql"=>"duplex", "default_value"=>"unknown", "is_null_allowed"=>true, "depends_on"=>array())));
  722. MetaModel::Init_InheritFilters();
  723. MetaModel::Init_AddFilterFromAttribute("device_id");
  724. MetaModel::Init_AddFilterFromAttribute("device_name");
  725. MetaModel::Init_AddFilterFromAttribute("device_location_id");
  726. MetaModel::Init_AddFilterFromAttribute("logical_type");
  727. MetaModel::Init_AddFilterFromAttribute("physical_type");
  728. MetaModel::Init_AddFilterFromAttribute("ip_address");
  729. MetaModel::Init_AddFilterFromAttribute("mac");
  730. // Display lists
  731. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'device_id', 'device_location_id','severity','logical_type','physical_type','ip_address','mask','mac','speed','duplex')); // Attributes to be displayed for the complete details
  732. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'device_id','severity')); // Attributes to be displayed for a list
  733. // Search criteria
  734. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'ip_address','mac','device_id')); // Criteria of the std search form
  735. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'device_id', 'org_id')); // Criteria of the advanced search form
  736. }
  737. function DisplayDetails(web_page $oPage)
  738. {
  739. parent::DisplayDetails($oPage);
  740. /*
  741. $oSearchFilter = new CMDBSearchFilter('lnkInterfaces');
  742. $oSearchFilter->AddCondition('interface1_id', $this->GetKey(), '=');
  743. $oSet = new CMDBObjectSet($oSearchFilter);
  744. $count = $oSet->Count();
  745. if ($count > 0)
  746. {
  747. $oPage->SetCurrentTab("Connected interfaces");
  748. $oPage->p("$count interface(s) connected to this device:");
  749. $this->DisplaySet($oPage, $oSet);
  750. }
  751. */
  752. }
  753. public function ComputeValues()
  754. {
  755. /*
  756. // my location is the location of my device
  757. $oDevice = MetaModel::GetObject("bizDevice", $this->Get("device_id"));
  758. $this->Set("location_id", $oDevice->Get("location_id"));
  759. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  760. $this->Set("location_name", "abc (to be finalized)");
  761. // my device is given by my Creator
  762. // my interface is myself
  763. $this->Set("interface_id", $this->GetKey());
  764. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  765. $this->Set("interface_name", "abc (to be finalized)");
  766. */
  767. }
  768. }
  769. ////////////////////////////////////////////////////////////////////////////////////
  770. /**
  771. * n-n link between any Interfaces
  772. */
  773. ////////////////////////////////////////////////////////////////////////////////////
  774. class lnkInterfaces extends cmdbAbstractObject
  775. {
  776. public static function Init()
  777. {
  778. $aParams = array
  779. (
  780. "category" => "bizmodel,searchable",
  781. "name" => "InterfacesLinks",
  782. "description" => "A link between two interfaces",
  783. "key_type" => "autoincrement",
  784. "key_label" => "link_id",
  785. "name_attcode" => "link_type",
  786. "state_attcode" => "",
  787. "reconc_keys" => array("interface1_id", "interface2_id"),
  788. "db_table" => "interfaces_links",
  789. "db_key_field" => "link_id",
  790. "db_finalclass_field" => "",
  791. "display_template" => "../business/templates/default.html",
  792. );
  793. MetaModel::Init_Params($aParams);
  794. MetaModel::Init_AddAttribute(new AttributeExternalKey("interface1_id", array("targetclass"=>"bizInterface", "label"=>"Interface1", "description"=>"The interface1", "sql"=>"interface1_id", "allowed_values"=> null, "is_null_allowed"=>false, "depends_on"=>array())));
  795. MetaModel::Init_AddAttribute(new AttributeExternalField("interface1_name", array("label"=>"Interface1 name", "description"=>"name of the interface1", "extkey_attcode"=> 'interface1_id', "allowed_values"=> null, "target_attcode"=>"name")));
  796. MetaModel::Init_AddAttribute(new AttributeExternalKey("interface2_id", array("targetclass"=>"bizInterface", "label"=>"Interface2", "description"=>"The interface2", "sql"=>"interface2_id", "allowed_values"=> null, "is_null_allowed"=>false, "depends_on"=>array())));
  797. MetaModel::Init_AddAttribute(new AttributeExternalField("interface2_name", array("label"=>"Interface2 name", "description"=>"name of the interface2", "extkey_attcode"=> 'interface2_id', "allowed_values"=> null, "target_attcode"=>"name")));
  798. MetaModel::Init_AddAttribute(new AttributeExternalField("interface1_device_id", array("label"=>"Device1", "description"=>"device", "extkey_attcode"=> 'interface1_id', "allowed_values"=> null, "target_attcode"=>"device_id")));
  799. MetaModel::Init_AddAttribute(new AttributeExternalField("interface1_device_name", array("label"=>"Device name", "description"=>"name of the device", "extkey_attcode"=> 'interface1_id', "allowed_values"=> null, "target_attcode"=>"device_name")));
  800. MetaModel::Init_AddAttribute(new AttributeExternalField("interface2_device_id", array("label"=>"Device2", "description"=>"device", "extkey_attcode"=> 'interface2_id', "allowed_values"=> null, "target_attcode"=>"device_id")));
  801. MetaModel::Init_AddAttribute(new AttributeExternalField("interface2_device_name", array("label"=>"Device name", "description"=>"name of the device", "extkey_attcode"=> 'interface2_id', "allowed_values"=> null, "target_attcode"=>"device_name")));
  802. MetaModel::Init_AddAttribute(new AttributeString("link_type", array("label"=>"link type", "description"=>" Definition of the link", "sql"=>"link_type", "default_value"=>"", "allowed_values"=> null, "is_null_allowed"=>false, "depends_on"=>array())));
  803. MetaModel::Init_AddFilterFromAttribute("interface1_id");
  804. MetaModel::Init_AddFilterFromAttribute("interface1_name");
  805. MetaModel::Init_AddFilterFromAttribute("interface2_id");
  806. MetaModel::Init_AddFilterFromAttribute("interface2_name");
  807. MetaModel::Init_AddFilterFromAttribute("interface2_device_name");
  808. MetaModel::Init_AddFilterFromAttribute("link_type");
  809. // Display lists
  810. MetaModel::Init_SetZListItems('details', array('interface1_id', 'interface2_id', 'link_type')); // Attributes to be displayed for the complete details
  811. MetaModel::Init_SetZListItems('list', array('interface1_id', 'interface1_device_id', 'interface2_id', 'interface2_device_id', 'link_type')); // Attributes to be displayed for the complete details
  812. }
  813. }
  814. ////////////////////////////////////////////////////////////////////////////////////
  815. /**
  816. * Any electronic device
  817. */
  818. ////////////////////////////////////////////////////////////////////////////////////
  819. class bizDevice extends logInfra
  820. {
  821. public static function Init()
  822. {
  823. $aParams = array
  824. (
  825. "category" => "bizmodel,searchable",
  826. "name" => "Device",
  827. "description" => "Electronic devices",
  828. "key_type" => "",
  829. "key_label" => "id",
  830. "name_attcode" => "name",
  831. "state_attcode" => "",
  832. "reconc_keys" => array("org_name", "name"), // inherited attributes
  833. "db_table" => "devices",
  834. "db_key_field" => "id",
  835. "db_finalclass_field" => "",
  836. "display_template" => "../business/templates/default.html",
  837. );
  838. MetaModel::Init_Params($aParams);
  839. MetaModel::Init_InheritAttributes();
  840. MetaModel::Init_AddAttribute(new AttributeExternalKey("location_id", array("targetclass"=>"bizLocation", "label"=>"Location", "description"=>"where is the located object physically located", "allowed_values"=>null, "sql"=>"location_id", "is_null_allowed"=>false, "depends_on"=>array())));
  841. MetaModel::Init_AddAttribute(new AttributeExternalField("location_name", array("label"=>"Location name", "description"=>"name of the location", "allowed_values"=>null, "extkey_attcode"=> 'location_id', "target_attcode"=>"name")));
  842. MetaModel::Init_AddAttribute(new AttributeExternalField("country", array("label"=>"Country", "description"=>"country where the device is located", "allowed_values"=>null, "extkey_attcode"=> 'location_id', "target_attcode"=>"country")));
  843. MetaModel::Init_AddAttribute(new AttributeString("brand", array("label"=>"Brand", "description"=>"The manufacturer of the device", "allowed_values"=>null, "sql"=>"brand", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  844. MetaModel::Init_AddAttribute(new AttributeString("model", array("label"=>"Model", "description"=>"The model number of the device", "allowed_values"=>null, "sql"=>"model", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  845. MetaModel::Init_AddAttribute(new AttributeString("serial_number", array("label"=>"Serial Number", "description"=>"The serial number of the device", "allowed_values"=>null, "sql"=>"serial_number", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  846. MetaModel::Init_InheritFilters();
  847. MetaModel::Init_AddFilterFromAttribute("location_id");
  848. MetaModel::Init_AddFilterFromAttribute("country");
  849. MetaModel::Init_AddFilterFromAttribute("brand");
  850. MetaModel::Init_AddFilterFromAttribute("model");
  851. MetaModel::Init_AddFilterFromAttribute("serial_number");
  852. }
  853. public static function GetRelationQueries($sRelCode)
  854. {
  855. switch ($sRelCode)
  856. {
  857. case "impacts":
  858. $aRels = array(
  859. "connected device" => array("sQuery"=>"bizDevice: PKEY IS device_id IN (bizInterface: PKEY IS interface2_id IN (lnkInterfaces: interface1_id IN (bizInterface: device_id = \$[this.pkey::])))", "bPropagate"=>true, "iDistance"=>3),
  860. "hosted app" => array("sQuery"=>"bizApplication: infra_id = \$[this.pkey::]", "bPropagate"=>true, "iDistance"=>3),
  861. );
  862. return array_merge($aRels, parent::GetRelationQueries($sRelCode));
  863. }
  864. }
  865. public function ComputeValues()
  866. {
  867. /*
  868. // my location is the location of my device (external field)
  869. $this->Set("location_id", $this->Get("device_location_id"));
  870. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  871. $this->Set("location_name", "abc (to be finalized)");
  872. // my device is myself
  873. $this->Set("device_id", $this->GetKey());
  874. // my interface is "nothing"
  875. $this->Set("interface_id", null);
  876. */
  877. }
  878. }
  879. ////////////////////////////////////////////////////////////////////////////////////
  880. /**
  881. * A personal computer
  882. */
  883. ////////////////////////////////////////////////////////////////////////////////////
  884. class bizPC extends bizDevice
  885. {
  886. public static function Init()
  887. {
  888. $aParams = array
  889. (
  890. "category" => "bizmodel,searchable",
  891. "name" => "PC",
  892. "description" => "Personal Computers",
  893. "key_type" => "",
  894. "key_label" => "id",
  895. "name_attcode" => "name",
  896. "state_attcode" => "",
  897. "reconc_keys" => array("org_name", "name"), // inherited attributes
  898. "db_table" => "pcs",
  899. "db_key_field" => "id",
  900. "db_finalclass_field" => "",
  901. "display_template" => "../business/templates/pc.html",
  902. );
  903. MetaModel::Init_Params($aParams);
  904. MetaModel::Init_InheritAttributes();
  905. MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of computer", "allowed_values"=>new ValueSetEnum("desktop PC,laptop"), "sql"=>"type", "default_value"=>"desktop PC", "is_null_allowed"=>false, "depends_on"=>array())));
  906. MetaModel::Init_AddAttribute(new AttributeString("memory_size", array("label"=>"Memory Size", "description"=>"Size of the memory", "allowed_values"=>null, "sql"=>"memory_size", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  907. MetaModel::Init_AddAttribute(new AttributeString("cpu", array("label"=>"CPU", "description"=>"CPU type", "allowed_values"=>null, "sql"=>"cpu_type", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  908. MetaModel::Init_AddAttribute(new AttributeString("hdd_size", array("label"=>"HDD Size", "description"=>"Size of the hard drive", "allowed_values"=>null, "sql"=>"hdd_size", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  909. MetaModel::Init_AddAttribute(new AttributeString("os_family", array("label"=>"OS Family", "description"=>"Type of operating system", "allowed_values"=>null, "sql"=>"os_family", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  910. MetaModel::Init_AddAttribute(new AttributeString("os_version", array("label"=>"OS Version", "description"=>"Detailed version number of the operating system", "allowed_values"=>null, "sql"=>"os_version", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  911. MetaModel::Init_AddAttribute(new AttributeString("shipment_number", array("label"=>"Shipment number", "description"=>"Number for tracking shipment", "allowed_values"=>null, "sql"=>"shipment_number", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  912. MetaModel::Init_AddAttribute(new AttributeString("mgmt_ip", array("label"=>"Mgmt IP", "description"=>"Management IP", "allowed_values"=>null, "sql"=>"mgmt_ip", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  913. MetaModel::Init_AddAttribute(new AttributeString("default_gateway", array("label"=>"Default Gateway", "description"=>"Default Gateway for this device", "allowed_values"=>null, "sql"=>"default_gateway", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  914. MetaModel::Init_InheritFilters();
  915. MetaModel::Init_AddFilterFromAttribute("type");
  916. MetaModel::Init_AddFilterFromAttribute("memory_size");
  917. MetaModel::Init_AddFilterFromAttribute("cpu");
  918. MetaModel::Init_AddFilterFromAttribute("hdd_size");
  919. MetaModel::Init_AddFilterFromAttribute("os_family");
  920. MetaModel::Init_AddFilterFromAttribute("os_version");
  921. MetaModel::Init_AddFilterFromAttribute("mgmt_ip");
  922. // Display lists
  923. MetaModel::Init_SetZListItems('details', array('name', 'status','severity', 'org_id', 'location_id', 'brand', 'model','os_family','os_version','mgmt_ip','default_gateway','shipment_number','serial_number', 'type', 'cpu', 'memory_size', 'hdd_size')); // Attributes to be displayed for the complete details
  924. MetaModel::Init_SetZListItems('list', array('name', 'status', 'severity', 'org_id', 'location_id', 'brand', 'model', 'type')); // Attributes to be displayed for a list
  925. // Search criteria
  926. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'severity','type', 'brand', 'model','os_family','mgmt_ip')); // Criteria of the std search form
  927. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'type', 'brand', 'model', 'cpu', 'memory_size', 'hdd_size')); // Criteria of the advanced search form
  928. }
  929. function DisplayDetails(web_page $oPage)
  930. {
  931. parent::DisplayDetails($oPage);
  932. /*
  933. parent::DisplayDetails($oPage);
  934. $oSearchFilter = new CMDBSearchFilter('lnkContactRealObject');
  935. $oSearchFilter->AddCondition('object_id', $this->GetKey(), '=');
  936. $oSet = new CMDBObjectSet($oSearchFilter);
  937. $count = $oSet->Count();
  938. if ($count > 0)
  939. {
  940. $oPage->SetCurrentTab("Contacts");
  941. $oPage->p("$count contact(s) linked to this PC:");
  942. $this->DisplaySet($oPage, $oSet);
  943. }
  944. $oSearchFilter = new CMDBSearchFilter('bizInterface');
  945. $oSearchFilter->AddCondition('device_id', $this->GetKey(), '=');
  946. $oSet = new CMDBObjectSet($oSearchFilter);
  947. $count = $oSet->Count();
  948. if ($count > 0)
  949. {
  950. $oPage->SetCurrentTab("Interfaces");
  951. $oPage->p("$count interface(s) for this device:");
  952. $this->DisplaySet($oPage, $oSet);
  953. }
  954. */
  955. }
  956. public function Generate(cmdbDataGenerator $oGenerator)
  957. {
  958. $this->Set('org_id', $oGenerator->GetOrganizationId());
  959. $this->Set('location_id', $oGenerator->GenerateKey("bizLocation", array('org_id' =>$oGenerator->GetOrganizationId() )));
  960. $this->Set('name', $oGenerator->GenerateString("enum(pc,pc,pc,pc,pc,win,redhat,linux,srv,workstation)|number(000-999)|.|domain()"));
  961. $this->Set('brand', $oGenerator->GenerateString("enum(Hewlett-Packard,Dell,Compaq,Siemens,Packard Bell,IBM,Gateway,Medion,Sony)"));
  962. $this->Set('model', $oGenerator->GenerateString("enum(Vectra,Deskpro,Dimension,Optiplex,Latitude,Precision,Vaio)"));
  963. $this->Set('serial_number', $oGenerator->GenerateString("enum(FR,US,TW,CH)|number(000000-999999)"));
  964. $this->Set('memory_size', $oGenerator->GenerateString("enum(128,256,384,512,768,1024,1536,2048)"));
  965. $this->Set('cpu', $oGenerator->GenerateString("enum(Pentium III,Pentium 4, Pentium M,Core Duo,Core 2 Duo,Celeron,Opteron,Thurion,Athlon)"));
  966. $this->Set('hdd_size', $oGenerator->GenerateString("enum(40,60,80,120,200,300)"));
  967. }
  968. }
  969. ////////////////////////////////////////////////////////////////////////////////////
  970. /**
  971. * A server
  972. */
  973. ////////////////////////////////////////////////////////////////////////////////////
  974. class bizServer extends bizDevice
  975. {
  976. public static function Init()
  977. {
  978. $aParams = array
  979. (
  980. "category" => "bizmodel,searchable",
  981. "name" => "Server",
  982. "description" => "Computer Servers",
  983. "key_type" => "",
  984. "key_label" => "id",
  985. "name_attcode" => "name",
  986. "state_attcode" => "status",
  987. "reconc_keys" => array("org_name", "name"), // inherited attributes
  988. "db_table" => "servers",
  989. "db_key_field" => "id",
  990. "db_finalclass_field" => "",
  991. "display_template" => "../business/templates/server.html",
  992. );
  993. MetaModel::Init_Params($aParams);
  994. MetaModel::Init_InheritAttributes();
  995. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Status of the server", "allowed_values"=>new ValueSetEnum("In Store,Shipped,Plugged,Production Candidate,In Production,In Change,Being Deconfigured,Obsolete"), "sql"=>"status", "default_value"=>"In Store", "is_null_allowed"=>false, "depends_on"=>array())));
  996. MetaModel::Init_AddAttribute(new AttributeString("memory_size", array("label"=>"Memory Size", "description"=>"Size of the memory", "allowed_values"=>null, "sql"=>"memory_size", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  997. MetaModel::Init_AddAttribute(new AttributeString("cpu", array("label"=>"Model", "description"=>"CPU type", "allowed_values"=>null, "sql"=>"cpu_type", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  998. MetaModel::Init_AddAttribute(new AttributeString("number_of_cpus", array("label"=>"Number of CPUs", "description"=>"Number of CPUs", "allowed_values"=>null, "sql"=>"number_of_cpus", "default_value"=>"1", "is_null_allowed"=>false, "depends_on"=>array())));
  999. MetaModel::Init_AddAttribute(new AttributeString("hdd_size", array("label"=>"HDD Size", "description"=>"Size of the hard drive", "allowed_values"=>null, "sql"=>"hdd_size", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1000. MetaModel::Init_AddAttribute(new AttributeString("hdd_free_size", array("label"=>"Free HDD Size", "description"=>"Size of the free space on the hard drive(s)", "allowed_values"=>null, "sql"=>"hdd_free_size", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1001. MetaModel::Init_AddAttribute(new AttributeString("os_family", array("label"=>"OS Family", "description"=>"Type of operating system", "allowed_values"=>null, "sql"=>"os_family", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1002. MetaModel::Init_AddAttribute(new AttributeString("os_version", array("label"=>"OS Version", "description"=>"Detailed version number of the operating system", "allowed_values"=>null, "sql"=>"os_version", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1003. MetaModel::Init_AddAttribute(new AttributeString("shipment_number", array("label"=>"Shipment number", "description"=>"Number for tracking shipment", "allowed_values"=>null, "sql"=>"shipment_number", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1004. MetaModel::Init_AddAttribute(new AttributeString("mgmt_ip", array("label"=>"Mgmt IP", "description"=>"Management IP", "allowed_values"=>null, "sql"=>"mgmt_ip", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1005. MetaModel::Init_AddAttribute(new AttributeString("default_gateway", array("label"=>"Default Gateway", "description"=>"Default Gateway for this device", "allowed_values"=>null, "sql"=>"default_gateway", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1006. MetaModel::Init_InheritFilters();
  1007. MetaModel::Init_AddFilterFromAttribute("memory_size");
  1008. MetaModel::Init_AddFilterFromAttribute("cpu");
  1009. MetaModel::Init_AddFilterFromAttribute("number_of_cpus");
  1010. MetaModel::Init_AddFilterFromAttribute("hdd_size");
  1011. MetaModel::Init_AddFilterFromAttribute("hdd_free_size");
  1012. MetaModel::Init_AddFilterFromAttribute("os_family");
  1013. MetaModel::Init_AddFilterFromAttribute("os_version");
  1014. // Life cycle
  1015. MetaModel::Init_DefineState("In Store", array("label"=>"InStore", "description"=>"Device in store", "attribute_inherit"=>null,
  1016. "attribute_list"=>array()));
  1017. MetaModel::Init_DefineState("Shipped", array("label"=>"Shipped", "description"=>"The device had been shipped to future location", "attribute_inherit"=>null,
  1018. "attribute_list"=>array("location_id"=>OPT_ATT_MANDATORY,"serial_number"=>OPT_ATT_MANDATORY,"shipment_number"=>OPT_ATT_MANDATORY)));
  1019. MetaModel::Init_DefineState("Plugged", array("label"=>"Plugged", "description"=>"The device is connected to the network", "attribute_inherit"=>null,
  1020. "attribute_list"=>array("location_id"=>OPT_ATT_MANDATORY,"mgmt_ip"=>OPT_ATT_MANDATORY,"name"=>OPT_ATT_MANDATORY)));
  1021. MetaModel::Init_DefineState("Production Candidate", array("label"=>"Pre-Production", "description"=>"The device is ready to be move to production", "attribute_inherit"=>null,
  1022. "attribute_list"=>array()));
  1023. MetaModel::Init_DefineState("In Production", array("label"=>"Production", "description"=>"The device is on production", "attribute_inherit"=>null,
  1024. "attribute_list"=>array()));
  1025. MetaModel::Init_DefineState("In Change", array("label"=>"InChange", "description"=>"A change is being performed on the device", "attribute_inherit"=>null,
  1026. "attribute_list"=>array()));
  1027. MetaModel::Init_DefineState("Being Deconfigured", array("label"=>"BeingDeconfigured", "description"=>"The device is about to be removed from is current location", "attribute_inherit"=>null,
  1028. "attribute_list"=>array()));
  1029. MetaModel::Init_DefineState("Obsolete", array("label"=>"Obsolete", "description"=>"The device is no more used", "attribute_inherit"=>null,
  1030. "attribute_list"=>array()));
  1031. MetaModel::Init_DefineStimulus("ev_store", new StimulusUserAction(array("label"=>"Store this server", "description"=>"This server is move to storage")));
  1032. MetaModel::Init_DefineStimulus("ev_ship", new StimulusUserAction(array("label"=>"Ship this server", "description"=>"This server is shipped to futur location")));
  1033. MetaModel::Init_DefineStimulus("ev_plug", new StimulusUserAction(array("label"=>"Plug this server", "description"=>"The server is pluuged on the network")));
  1034. MetaModel::Init_DefineStimulus("ev_configuration_finished", new StimulusUserAction(array("label"=>"Configuration finished", "description"=>"The device is ready to move to production evaluation")));
  1035. MetaModel::Init_DefineStimulus("ev_val_failed", new StimulusUserAction(array("label"=>"Review configuration", "description"=>"The configuration for this server is not completed")));
  1036. MetaModel::Init_DefineStimulus("ev_mtp", new StimulusUserAction(array("label"=>"Move to Production", "description"=>"The server is moved to production")));
  1037. MetaModel::Init_DefineStimulus("ev_start_change", new StimulusUserAction(array("label"=>"Change Start [No Click]", "description"=>"A change starts for this server")));
  1038. MetaModel::Init_DefineStimulus("ev_end_change", new StimulusUserAction(array("label"=>"End Change [No Click]", "description"=>"No more change running for this server")));
  1039. MetaModel::Init_DefineStimulus("ev_decommission", new StimulusUserAction(array("label"=>"Decommission", "description"=>"The server is being decommissioned")));
  1040. MetaModel::Init_DefineStimulus("ev_obsolete", new StimulusUserAction(array("label"=>"Obsolete", "description"=>"The server is no more used")));
  1041. MetaModel::Init_DefineStimulus("ev_recycle", new StimulusUserAction(array("label"=>"Recycle this server", "description"=>"The server is move back to deconfiguration")));
  1042. MetaModel::Init_DefineTransition("In Store", "ev_ship", array("target_state"=>"Shipped", "actions"=>array(), "user_restriction"=>null));
  1043. MetaModel::Init_DefineTransition("In Store", "ev_plug", array("target_state"=>"Plugged", "actions"=>array(), "user_restriction"=>null));
  1044. MetaModel::Init_DefineTransition("Shipped", "ev_store", array("target_state"=>"In Store", "actions"=>array(), "user_restriction"=>null));
  1045. MetaModel::Init_DefineTransition("Shipped", "ev_plug", array("target_state"=>"Plugged", "actions"=>array(), "user_restriction"=>null));
  1046. MetaModel::Init_DefineTransition("Plugged", "ev_ship", array("target_state"=>"Shipped", "actions"=>array(), "user_restriction"=>null));
  1047. MetaModel::Init_DefineTransition("Plugged", "ev_store", array("target_state"=>"In Store", "actions"=>array(), "user_restriction"=>null));
  1048. MetaModel::Init_DefineTransition("Plugged", "ev_configuration_finished", array("target_state"=>"Production Candidate", "actions"=>array(), "user_restriction"=>null));
  1049. MetaModel::Init_DefineTransition("Production Candidate", "ev_val_failed", array("target_state"=>"Plugged", "actions"=>array(), "user_restriction"=>null));
  1050. MetaModel::Init_DefineTransition("Production Candidate", "ev_mtp", array("target_state"=>"In Production", "actions"=>array(), "user_restriction"=>null));
  1051. MetaModel::Init_DefineTransition("In Production", "ev_start_change", array("target_state"=>"In Change", "actions"=>array(), "user_restriction"=>null));
  1052. MetaModel::Init_DefineTransition("In Production", "ev_obsolete", array("target_state"=>"Obsolete", "actions"=>array(), "user_restriction"=>null));
  1053. MetaModel::Init_DefineTransition("In Production", "ev_decommission", array("target_state"=>"Being Deconfigured", "actions"=>array(), "user_restriction"=>null));
  1054. MetaModel::Init_DefineTransition("In Change", "ev_end_change", array("target_state"=>"In Production", "actions"=>array(), "user_restriction"=>null));
  1055. MetaModel::Init_DefineTransition("Being Deconfigured", "ev_ship", array("target_state"=>"Shipped", "actions"=>array(), "user_restriction"=>null));
  1056. MetaModel::Init_DefineTransition("Being Deconfigured", "ev_plug", array("target_state"=>"Plugged", "actions"=>array(), "user_restriction"=>null));
  1057. MetaModel::Init_DefineTransition("Being Deconfigured", "ev_store", array("target_state"=>"In Store", "actions"=>array(), "user_restriction"=>null));
  1058. MetaModel::Init_DefineTransition("Being Deconfigured", "ev_obsolete", array("target_state"=>"Obsolete", "actions"=>array(), "user_restriction"=>null));
  1059. MetaModel::Init_DefineTransition("Obsolete", "ev_recycle", array("target_state"=>"Being Deconfigured", "actions"=>array(), "user_restriction"=>null));
  1060. // Display lists
  1061. MetaModel::Init_SetZListItems('details', array('name', 'mgmt_ip','default_gateway','status', 'severity','org_id', 'location_id', 'brand', 'model', 'os_family', 'os_version','serial_number','shipment_number', 'cpu', 'number_of_cpus', 'memory_size', 'hdd_size', 'hdd_free_size')); // Attributes to be displayed for the complete details
  1062. MetaModel::Init_SetZListItems('list', array('name', 'status','severity', 'org_id', 'location_id', 'brand', 'model', 'os_family', 'os_version')); // Attributes to be displayed for a list
  1063. // Search criteria
  1064. MetaModel::Init_SetZListItems('standard_search', array('name', 'status','severity', 'brand', 'model', 'os_family', 'location_id')); // Criteria of the std search form
  1065. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status','brand', 'model', 'os_family', 'os_version', 'location_id', 'cpu', 'number_of_cpus', 'memory_size', 'hdd_size', 'hdd_free_size')); // Criteria of the advanced search form
  1066. }
  1067. function DisplayDetails(web_page $oPage)
  1068. {
  1069. parent::DisplayDetails($oPage);
  1070. /*
  1071. parent::DisplayDetails($oPage);
  1072. $oSearchFilter = new CMDBSearchFilter('lnkContactRealObject');
  1073. $oSearchFilter->AddCondition('object_id', $this->GetKey(), '=');
  1074. $oSet = new CMDBObjectSet($oSearchFilter);
  1075. $count = $oSet->Count();
  1076. if ($count > 0)
  1077. {
  1078. $oPage->SetCurrentTab("Contacts");
  1079. $oPage->p("$count contact(s) for this server:");
  1080. $this->DisplaySet($oPage, $oSet);
  1081. }
  1082. $oSearchFilter = new CMDBSearchFilter('bizInterface');
  1083. $oSearchFilter->AddCondition('device_id', $this->GetKey(), '=');
  1084. $oSet = new CMDBObjectSet($oSearchFilter);
  1085. $count = $oSet->Count();
  1086. if ($count > 0)
  1087. {
  1088. $oPage->SetCurrentTab("Interfaces");
  1089. $oPage->p("$count interface(s) for this server:");
  1090. $this->DisplaySet($oPage, $oSet);
  1091. }
  1092. $oSearchFilter = new CMDBSearchFilter('Application');
  1093. $oSearchFilter->AddCondition('infra_id', $this->GetKey(), '=');
  1094. $oSet = new CMDBObjectSet($oSearchFilter);
  1095. $count = $oSet->Count();
  1096. if ($count > 0)
  1097. {
  1098. $oPage->SetCurrentTab("Installed applications");
  1099. $oPage->p("$count application(s) installed on this server:");
  1100. $this->DisplaySet($oPage, $oSet);
  1101. }
  1102. $oSearchFilter = new CMDBSearchFilter('bizPatch');
  1103. $oSearchFilter->AddCondition('infra_id', $this->GetKey(), '=');
  1104. $oSet = new CMDBObjectSet($oSearchFilter);
  1105. $count = $oSet->Count();
  1106. if ($count > 0)
  1107. {
  1108. $oPage->SetCurrentTab("Installed patches");
  1109. $oPage->p("$count patch(s) installed on this server:");
  1110. $this->DisplaySet($oPage, $oSet);
  1111. }
  1112. */
  1113. }
  1114. public function Generate(cmdbDataGenerator $oGenerator)
  1115. {
  1116. $this->Set('org_id', $oGenerator->GetOrganizationId());
  1117. $this->Set('location_id', $oGenerator->GenerateKey("bizLocation", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1118. $this->Set('name', $oGenerator->GenerateString("enum(pc,pc,pc,pc,pc,win,redhat,linux,srv,workstation)|number(000-999)|.|domain()"));
  1119. $this->Set('brand', $oGenerator->GenerateString("enum(Hewlett-Packard,Dell,Compaq,Siemens,Packard Bell,IBM,Gateway,Medion,Sony)"));
  1120. $this->Set('model', $oGenerator->GenerateString("enum(Vectra,Deskpro,Dimension,Optiplex,Latitude,Precision,Vaio)"));
  1121. $this->Set('serial_number', $oGenerator->GenerateString("enum(FR,US,TW,CH)|number(000000-999999)"));
  1122. $this->Set('memory_size', $oGenerator->GenerateString("enum(512,1024,2048,4096,2048,4096,8192,8192,8192,16384,32768)"));
  1123. $this->Set('cpu', $oGenerator->GenerateString("enum(Pentium III,Pentium 4,Pentium M,Core Duo,Core 2 Duo,Celeron,Opteron,Thurion,Athlon)"));
  1124. $this->Set('number_of_cpu', $oGenerator->GenerateString("enum(1,1,2,2,2,2,2,4,4,8)"));
  1125. $this->Set('hdd_size', $oGenerator->GenerateString("enum(500,1024,500,1024,500,1024,2048)"));
  1126. $this->Set('hdd_free_size', $this->Get('hdd_size')*$oGenerator->GenerateString("number(20-80)"));
  1127. $this->Set('os_family', $oGenerator->GenerateString("enum(Windows,Windows,Windows,Linux,Windows,Linux,Windows,Linux,Linux,HP-UX,Solaris,AIX)"));
  1128. $this->Set('os_version', $oGenerator->GenerateString("enum(XP,XP,XP,RH EL 4,RH EL 5,SuSE 10.3,SuSE 10.4,11.11,11.11i)"));
  1129. }
  1130. }
  1131. ////////////////////////////////////////////////////////////////////////////////////
  1132. /**
  1133. * A network device
  1134. */
  1135. ////////////////////////////////////////////////////////////////////////////////////
  1136. class bizNetworkDevice extends bizDevice
  1137. {
  1138. public static function Init()
  1139. {
  1140. $aParams = array
  1141. (
  1142. "category" => "bizmodel,searchable",
  1143. "name" => "Network Device",
  1144. "description" => "A network device",
  1145. "key_type" => "",
  1146. "key_label" => "id",
  1147. "name_attcode" => "name",
  1148. "state_attcode" => "",
  1149. "reconc_keys" => array("org_name", "name"), // inherited attributes
  1150. "db_table" => "network_devices",
  1151. "db_key_field" => "id",
  1152. "db_finalclass_field" => "",
  1153. "display_template" => "../business/templates/network.device.html",
  1154. );
  1155. MetaModel::Init_Params($aParams);
  1156. MetaModel::Init_InheritAttributes();
  1157. MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of device", "allowed_values"=>new ValueSetEnum("switch,router,firewall,load balancer,hub,WAN accelerator"), "sql"=>"type", "default_value"=>"switch", "is_null_allowed"=>false, "depends_on"=>array())));
  1158. MetaModel::Init_AddAttribute(new AttributeString("ip_address", array("label"=>"Mgmt IP", "description"=>"Management IP address", "allowed_values"=>null, "sql"=>"ip_address", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1159. MetaModel::Init_AddAttribute(new AttributeString("default_gateway", array("label"=>"Default Gateway", "description"=>"Default Gateway for this device", "allowed_values"=>null, "sql"=>"default_gateway", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1160. MetaModel::Init_AddAttribute(new AttributeString("ios_version", array("label"=>"IOS version", "description"=>"IOS (software) version", "allowed_values"=>null, "sql"=>"ios_version", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1161. MetaModel::Init_AddAttribute(new AttributeString("memory", array("label"=>"Memory", "description"=>"Memory description", "allowed_values"=>null, "sql"=>"memory", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1162. MetaModel::Init_AddAttribute(new AttributeString("snmp_read", array("label"=>"SNMP Community (Read)", "description"=>"SNMP Read Community String", "allowed_values"=>null, "sql"=>"snmp_read", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1163. MetaModel::Init_AddAttribute(new AttributeString("snmp_write", array("label"=>"SNMP Community (Write)", "description"=>"SNMP Write Community String", "allowed_values"=>null, "sql"=>"snmp_write", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1164. MetaModel::Init_InheritFilters();
  1165. MetaModel::Init_AddFilterFromAttribute("type");
  1166. MetaModel::Init_AddFilterFromAttribute("ip_address");
  1167. MetaModel::Init_AddFilterFromAttribute("ios_version");
  1168. // Display lists
  1169. MetaModel::Init_SetZListItems('details', array('name', 'status','severity','org_id', 'location_id', 'brand','model','type','ip_address','default_gateway','serial_number','ios_version','memory','snmp_read','snmp_write')); // Attributes to be displayed for the complete details
  1170. MetaModel::Init_SetZListItems('list', array('name', 'status','brand','model','type','ip_address')); // Attributes to be displayed for a list
  1171. // Search criteria
  1172. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'location_id', 'brand','model','type','ip_address')); // Criteria of the std search form
  1173. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'org_id', 'location_id', 'brand','model','type','ip_address','serial_number','ios_version','snmp_read','snmp_write')); // Criteria of the advanced search form
  1174. }
  1175. public function Generate(cmdbDataGenerator $oGenerator)
  1176. {
  1177. $this->Set('org_id', $oGenerator->GetOrganizationId());
  1178. $this->Set('location_id', $oGenerator->GenerateKey("bizLocation", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1179. $this->Set('name', $oGenerator->GenerateString("enum(sw,swi,switch,rout,rtr,gw)|number(000-999)|.|domain()"));
  1180. $this->Set('brand', $oGenerator->GenerateString("enum(Hewlett-Packard,Cisco,3Com,Avaya,Alcatel,Cabletron,Extrem Networks,Juniper,Netgear,Synopitcs,Xylan)"));
  1181. $this->Set('model', $oGenerator->GenerateString("enum(Procurve ,Catalyst ,Multiswitch ,C)|enum(25,26,36,40,65)|enum(00,09,10,50)"));
  1182. $this->Set('serial_number', $oGenerator->GenerateString("enum(FAA,AGA,PAD,COB,DFE)|number(0000-9999)|enum(M,X,L)"));
  1183. $this->Set('ip_address', $oGenerator->GenerateString("number(10-248)|.|number(1-254)|.|number(1-254)|.|number(1-254)"));
  1184. $this->Set('ios_version', $oGenerator->GenerateString("enum(9,10,12)|.|enum(0,1,2)|enum(,,,,XP,.5.1)"));
  1185. $this->Set('snmp_read', $oGenerator->GenerateString("enum(Ew,+0,**,Ps)|number(00-99)|enum(+,=,],;, )|enum(Aze,Vbn,Bbn,+9+,-9-,#)"));
  1186. $this->Set('snmp_write', $oGenerator->GenerateString("enum(M3,l3,$,*,Zz,Ks,jh)|number(00-99)|enum(A*e,V%n,Bbn,+,-,#)|number(0-9)"));
  1187. }
  1188. }
  1189. ////////////////////////////////////////////////////////////////////////////////////
  1190. /**
  1191. * A "Solution"
  1192. */
  1193. ////////////////////////////////////////////////////////////////////////////////////
  1194. class bizInfraGroup extends logInfra
  1195. {
  1196. public static function Init()
  1197. {
  1198. $aParams = array
  1199. (
  1200. "category" => "bizmodel,searchable",
  1201. "name" => "Infra Group",
  1202. "description" => "A group of infrastructure elements",
  1203. "key_type" => "",
  1204. "key_label" => "id",
  1205. "name_attcode" => "name",
  1206. "state_attcode" => "",
  1207. "reconc_keys" => array("org_name", "name"), // inherited attributes
  1208. "db_table" => "infra_group",
  1209. "db_key_field" => "id",
  1210. "db_finalclass_field" => "",
  1211. "display_template" => "../business/templates/group.html",
  1212. );
  1213. MetaModel::Init_Params($aParams);
  1214. MetaModel::Init_InheritAttributes();
  1215. MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of groupe", "allowed_values"=>new ValueSetEnum("Monitoring,Reporting,list"), "sql"=>"type", "default_value"=>"list", "is_null_allowed"=>true, "depends_on"=>array())));
  1216. MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Description", "description"=>"usage of the Group", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1217. MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_group_id", array("targetclass"=>"bizInfraGroup", "label"=>"Parent Group", "description"=>"including group", "allowed_values"=>null, "sql"=>"parent_group_id", "is_null_allowed"=>true, "depends_on"=>array())));
  1218. MetaModel::Init_AddAttribute(new AttributeExternalField("parent_group_name", array("label"=>"Parent Group (Name)", "description"=>"name of the parent group", "allowed_values"=>null, "extkey_attcode"=> 'parent_group_id', "target_attcode"=>"name")));
  1219. MetaModel::Init_InheritFilters();
  1220. MetaModel::Init_AddFilterFromAttribute("type");
  1221. MetaModel::Init_AddFilterFromAttribute("parent_group_id");
  1222. MetaModel::Init_AddFilterFromAttribute("parent_group_name");
  1223. // Display lists
  1224. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'type', 'description','parent_group_id')); // Attributes to be displayed for a list
  1225. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'type', 'description')); // Attributes to be displayed for a list
  1226. // Search criteria
  1227. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'type')); // Criteria of the std search form
  1228. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'type', 'description', 'org_id')); // Criteria of the advanced search form
  1229. }
  1230. function DisplayDetails(web_page $oPage)
  1231. {
  1232. parent::DisplayDetails($oPage);
  1233. /*
  1234. $oSearchFilter = new CMDBSearchFilter('lnkInfraGrouping');
  1235. $oSearchFilter->AddCondition('infra_group_id', $this->GetKey(), '=');
  1236. $oSet = new CMDBObjectSet($oSearchFilter);
  1237. $count = $oSet->Count();
  1238. if ($count > 0)
  1239. {
  1240. $oPage->SetCurrentTab("RelatedInfrastructure");
  1241. $oPage->p("Infrastructure Link to this group:");
  1242. $this->DisplaySet($oPage, $oSet);
  1243. }
  1244. $oSearchFilter = new CMDBSearchFilter('lnkContactRealObject');
  1245. $oSearchFilter->AddCondition('object_id', $this->GetKey(), '=');
  1246. $oSet = new CMDBObjectSet($oSearchFilter);
  1247. $count = $oSet->Count();
  1248. if ($count > 0)
  1249. {
  1250. $oPage->SetCurrentTab("TeamLinks");
  1251. $oPage->p("People concerned by this group:");
  1252. $this->DisplaySet($oPage, $oSet);
  1253. }
  1254. */
  1255. }
  1256. public function Generate(cmdbDataGenerator $oGenerator)
  1257. {
  1258. $this->Set('org_id', $oGenerator->GetOrganizationId());
  1259. $this->Set('name', $oGenerator->GenerateString("enum(ov_nnm_,ovpi_,vitalnet_,datacenter_,web_farm_)|number(000-999)"));
  1260. $this->Set('type', $oGenerator->GenerateString("enum(Application,Infrastructure)"));
  1261. }
  1262. }
  1263. ////////////////////////////////////////////////////////////////////////////////////
  1264. //**
  1265. //* An application is an instance of a software install on a PC or Server
  1266. //*
  1267. ////////////////////////////////////////////////////////////////////////////////////
  1268. class bizApplication extends logInfra
  1269. {
  1270. public static function Init()
  1271. {
  1272. $aParams = array
  1273. (
  1274. "category" => "bizmodel,searchable",
  1275. "name" => "Application",
  1276. "description" => "General application",
  1277. "key_type" => "",
  1278. "key_label" => "id",
  1279. "name_attcode" => "name",
  1280. "state_attcode" => "",
  1281. "reconc_keys" => array("device_name", "name"), // inherited attributes
  1282. "db_table" => "applications",
  1283. "db_key_field" => "id",
  1284. "db_finalclass_field" => "",
  1285. "display_template" => "../business/templates/application.html",
  1286. );
  1287. MetaModel::Init_Params($aParams);
  1288. MetaModel::Init_InheritAttributes();
  1289. MetaModel::Init_AddAttribute(new AttributeExternalKey("device_id", array("targetclass"=>"bizDevice", "jointype"=> '', "label"=>"Hosting device", "description"=>"The device where application is installed", "allowed_values"=>null, "sql"=>"device_id", "is_null_allowed"=>false, "depends_on"=>array())));
  1290. MetaModel::Init_AddAttribute(new AttributeExternalField("device_name", array("label"=>"Hosting device", "description"=>"Name of the device where application is installed", "allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"name")));
  1291. MetaModel::Init_AddAttribute(new AttributeDate("install_date", array("label"=>"Installed date", "description"=>"Date when application was installed", "allowed_values"=>null, "sql"=>"install_date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1292. MetaModel::Init_AddAttribute(new AttributeString("version", array("label"=>"Version", "description"=>"Application version", "allowed_values"=>null, "sql"=>"version", "default_value"=>"undefined", "is_null_allowed"=>false, "depends_on"=>array())));
  1293. MetaModel::Init_AddAttribute(new AttributeString("function", array("label"=>"Function", "description"=>"Function provided by this application", "allowed_values"=>null, "sql"=>"function", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1294. MetaModel::Init_InheritFilters();
  1295. MetaModel::Init_AddFilterFromAttribute("function");
  1296. MetaModel::Init_AddFilterFromAttribute("version");
  1297. MetaModel::Init_AddFilterFromAttribute("device_id");
  1298. // Display lists
  1299. MetaModel::Init_SetZListItems('details', array('name','device_id','org_id','status','install_date', 'version','function')); // Attributes to be displayed for the complete details
  1300. MetaModel::Init_SetZListItems('list', array('name','device_id', 'version', 'function')); // Attributes to be displayed for a list
  1301. // Search criteria
  1302. MetaModel::Init_SetZListItems('standard_search', array('name', 'device_id','version','function')); // Criteria of the std search form
  1303. MetaModel::Init_SetZListItems('advanced_search', array('name', 'device_id','version','function')); // Criteria of the advanced search form
  1304. }
  1305. public static function GetRelationQueries($sRelCode)
  1306. {
  1307. switch ($sRelCode)
  1308. {
  1309. case "impacts":
  1310. $aRels = array(
  1311. "client app" => array("sQuery"=>"bizApplication: PKEY IS client_id IN (lnkClientServer: server_id = \$[this.pkey::])", "bPropagate"=>true, "iDistance"=>3),
  1312. );
  1313. return array_merge($aRels, parent::GetRelationQueries($sRelCode));
  1314. }
  1315. }
  1316. function DisplayDetails(web_page $oPage)
  1317. {
  1318. parent::DisplayDetails($oPage);
  1319. /*
  1320. $oSearchFilter = new CMDBSearchFilter('lnkClientServer');
  1321. $oSearchFilter->AddCondition('server_id', $this->GetKey(), '=');
  1322. $oSet = new CMDBObjectSet($oSearchFilter);
  1323. $count = $oSet->Count();
  1324. if ($count > 0)
  1325. {
  1326. $oPage->SetCurrentTab("Connected clients");
  1327. $oPage->p("Client applications impacted when down:");
  1328. $this->DisplaySet($oPage, $oSet);
  1329. }
  1330. */
  1331. }
  1332. }
  1333. ////////////////////////////////////////////////////////////////////////////////////
  1334. /**
  1335. * n-n link between any Infra and a Group
  1336. */
  1337. ////////////////////////////////////////////////////////////////////////////////////
  1338. class lnkInfraGrouping extends cmdbAbstractObject
  1339. {
  1340. public static function Init()
  1341. {
  1342. $aParams = array
  1343. (
  1344. "category" => "bizmodel,searchable",
  1345. "name" => "Infra Grouping",
  1346. "description" => "Infra part of an Infra Group",
  1347. "key_type" => "autoincrement",
  1348. "key_label" => "link_id",
  1349. "name_attcode" => "impact",
  1350. "state_attcode" => "",
  1351. "reconc_keys" => array(""),
  1352. "db_table" => "infra_grouping",
  1353. "db_key_field" => "link_id",
  1354. "db_finalclass_field" => "",
  1355. "display_template" => "../business/templates/default.html",
  1356. );
  1357. MetaModel::Init_Params($aParams);
  1358. MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_id", array("targetclass"=>"logInfra", "jointype"=> '', "label"=>"Infrastructure", "description"=>"Infrastructure part of the group", "allowed_values"=>null, "sql"=>"infra_id", "is_null_allowed"=>false, "depends_on"=>array())));
  1359. MetaModel::Init_AddAttribute(new AttributeExternalField("infra_name", array("label"=>"Infrastructure name", "description"=>"Name of the impacted infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"name")));
  1360. MetaModel::Init_AddAttribute(new AttributeExternalField("infra_status", array("label"=>"Status", "description"=>"Status of the impacted infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"status")));
  1361. MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_group_id", array("targetclass"=>"bizInfraGroup", "jointype"=> '', "label"=>"Group Name", "description"=>"Name of the group", "allowed_values"=>null, "sql"=>"infra_group_id", "is_null_allowed"=>false, "depends_on"=>array())));
  1362. MetaModel::Init_AddAttribute(new AttributeExternalField("group_name", array("label"=>"Group name", "description"=>"Name of the group containing infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_group_id', "target_attcode"=>"name")));
  1363. MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Relation", "description"=>"Relation between this group and infra", "allowed_values"=>null, "sql"=>"impact", "default_value"=>"none", "is_null_allowed"=>true, "depends_on"=>array())));
  1364. // impact should modelized: enum (eg: if the group si dead when infra is dead)
  1365. MetaModel::Init_AddFilterFromAttribute("infra_id");
  1366. MetaModel::Init_AddFilterFromAttribute("infra_group_id");
  1367. MetaModel::Init_AddFilterFromAttribute("impact");
  1368. // Display lists
  1369. MetaModel::Init_SetZListItems('details', array('infra_id','infra_status', 'impact', 'infra_group_id')); // Attributes to be displayed for a list
  1370. MetaModel::Init_SetZListItems('list', array('infra_id','infra_status', 'impact', 'infra_group_id')); // Attributes to be displayed for a list
  1371. // Search criteria
  1372. MetaModel::Init_SetZListItems('standard_search', array('infra_id', 'infra_group_id', 'impact')); // Criteria of the std search form
  1373. MetaModel::Init_SetZListItems('advanced_search', array('infra_id', 'infra_group_id', 'impact')); // Criteria of the advanced search form
  1374. }
  1375. public function Generate(cmdbDataGenerator $oGenerator)
  1376. {
  1377. $this->Set('infra_id', $oGenerator->GenerateKey("logInfra", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1378. $this->Set('infra_group_id', $oGenerator->GenerateKey("bizInfraGroup", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1379. $this->Set('impact', $oGenerator->GenerateString("enum(none,mandatory,partial)"));
  1380. }
  1381. }
  1382. ////////////////////////////////////////////////////////////////////////////////////
  1383. /**
  1384. * n-n link between two applications, one is the server side and the scond one the client*/
  1385. ////////////////////////////////////////////////////////////////////////////////////
  1386. class lnkClientServer extends logRealObject
  1387. {
  1388. public static function Init()
  1389. {
  1390. $aParams = array
  1391. (
  1392. "category" => "bizmodel,searchable",
  1393. "name" => "ClientServerLinks",
  1394. "description" => "Link between client server application",
  1395. "key_type" => "autoincrement",
  1396. "key_label" => "link_id",
  1397. "name_attcode" => "relation", // ????
  1398. "state_attcode" => "",
  1399. "reconc_keys" => array("relation"), // ????
  1400. "db_table" => "clientserver_links",
  1401. "db_key_field" => "link_id",
  1402. "db_finalclass_field" => "",
  1403. );
  1404. MetaModel::Init_Params($aParams);
  1405. MetaModel::Init_AddAttribute(new AttributeExternalKey("client_id", array("targetclass"=>"bizApplication", "jointype"=> '', "label"=>"Client", "description"=>"The client part of the link", "allowed_values"=>null, "sql"=>"client_id", "is_null_allowed"=>false, "depends_on"=>array())));
  1406. MetaModel::Init_AddAttribute(new AttributeExternalField("client_name", array("label"=>"Client", "description"=>"Name of the client", "allowed_values"=>null, "extkey_attcode"=> 'client_id', "target_attcode"=>"name")));
  1407. MetaModel::Init_AddAttribute(new AttributeExternalKey("server_id", array("targetclass"=>"bizApplication", "jointype"=> '', "label"=>"Server", "description"=>"the server part of the link", "allowed_values"=>null, "sql"=>"server_id", "is_null_allowed"=>false, "depends_on"=>array())));
  1408. MetaModel::Init_AddAttribute(new AttributeExternalField("server_name", array("label"=>"Server", "description"=>"Name of the server", "allowed_values"=>null, "extkey_attcode"=> 'server_id', "target_attcode"=>"name")));
  1409. MetaModel::Init_AddAttribute(new AttributeString("relation", array("label"=>"Relation", "description"=>"Type of relation between both application", "allowed_values"=>null, "sql"=>"relation", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1410. MetaModel::Init_AddFilterFromAttribute("client_id");
  1411. MetaModel::Init_AddFilterFromAttribute("server_id");
  1412. // Display lists
  1413. MetaModel::Init_SetZListItems('details', array('client_id', 'server_id', 'relation')); // Attributes to be displayed for a list
  1414. MetaModel::Init_SetZListItems('list', array('client_id', 'server_id', 'relation')); // Attributes to be displayed for a list
  1415. // Search criteria
  1416. MetaModel::Init_SetZListItems('standard_search', array('client_id', 'server_id')); // Criteria of the std search form
  1417. MetaModel::Init_SetZListItems('advanced_search', array('client_id', 'server_id')); // Criteria of the advanced search form
  1418. }
  1419. }
  1420. ////////////////////////////////////////////////////////////////////////////////////
  1421. //**
  1422. //* A patch is an application or OS fixe for an infrastructure
  1423. //*
  1424. ////////////////////////////////////////////////////////////////////////////////////
  1425. class bizPatch extends logRealObject
  1426. {
  1427. public static function Init()
  1428. {
  1429. $aParams = array
  1430. (
  1431. "category" => "bizmodel,searchable",
  1432. "name" => "Patch",
  1433. "description" => "Patch installed on infrastucture",
  1434. "key_type" => "",
  1435. "key_label" => "id",
  1436. "name_attcode" => "name",
  1437. "state_attcode" => "",
  1438. "reconc_keys" => array("device_name", "name"), // inherited attributes
  1439. "db_table" => "patches",
  1440. "db_key_field" => "id",
  1441. "db_finalclass_field" => "",
  1442. "display_template" => "../business/templates/default.html",
  1443. );
  1444. MetaModel::Init_Params($aParams);
  1445. MetaModel::Init_InheritAttributes();
  1446. MetaModel::Init_AddAttribute(new AttributeExternalKey("device_id", array("targetclass"=>"bizDevice", "jointype"=> '', "label"=>"Device", "description"=>"The Device where patch is installed", "allowed_values"=>null, "sql"=>"device_id", "is_null_allowed"=>false, "depends_on"=>array())));
  1447. MetaModel::Init_AddAttribute(new AttributeExternalField("device_name", array("label"=>"Device name", "description"=>"Name of the impacted device", "allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"name")));
  1448. MetaModel::Init_AddAttribute(new AttributeDate("install_date", array("label"=>"Installed date", "description"=>"Date when application was installed", "allowed_values"=>null, "sql"=>"install_date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1449. MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Description", "description"=>"description du patch", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1450. MetaModel::Init_AddAttribute(new AttributeString("patch_type", array("label"=>"Type", "description"=>"type de patch", "allowed_values"=>new ValueSetEnum("OS,Application"), "sql"=>"patch_type", "default_value"=>"OS", "is_null_allowed"=>false, "depends_on"=>array())));
  1451. MetaModel::Init_InheritFilters();
  1452. MetaModel::Init_AddFilterFromAttribute("patch_type");
  1453. MetaModel::Init_AddFilterFromAttribute("device_id");
  1454. // Display lists
  1455. MetaModel::Init_SetZListItems('details', array('name','device_id', 'install_date', 'patch_type','description')); // Attributes to be displayed for the complete details
  1456. MetaModel::Init_SetZListItems('list', array('name','device_id', 'patch_type','install_date')); // Attributes to be displayed for a list
  1457. // Search criteria
  1458. MetaModel::Init_SetZListItems('standard_search', array('name', 'device_id','patch_type')); // Criteria of the std search form
  1459. MetaModel::Init_SetZListItems('advanced_search', array('name', 'device_id','patch_type')); // Criteria of the advanced search form
  1460. }
  1461. }
  1462. /*** Insert here all modules requires for ITOP application ***/
  1463. require_once('incident.business.php');
  1464. require_once('ServiceMgmt.business.php');
  1465. require_once('ChangeMgmt.php');
  1466. require_once('KEDB.php')
  1467. ?>