itop.business.class.inc.php 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716
  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. define('STANDARD_STATUSES', '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("allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array() )));
  69. MetaModel::Init_AddAttribute(new AttributeString("code", array("allowed_values"=>null, "sql"=>"code", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array() )));
  70. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values"=>new ValueSetEnum(STANDARD_STATUSES), "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
  71. MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_id", array("targetclass"=>"bizOrganization", "allowed_values"=>null, "sql"=>"parent_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  72. MetaModel::Init_AddAttribute(new AttributeExternalField("parent_name", array("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. $aParams = array
  120. (
  121. "category" => "bizmodel,searchable",
  122. "name" => "Object",
  123. "description" => "Any CMDB object",
  124. "key_type" => "autoincrement",
  125. "key_label" => "id",
  126. "name_attcode" => "name",
  127. "state_attcode" => "",
  128. "reconc_keys" => array("name"),
  129. "db_table" => "objects",
  130. "db_key_field" => "id",
  131. "db_finalclass_field" => "obj_class",
  132. "display_template" => "../business/templates/default.html",
  133. );
  134. MetaModel::Init_Params($aParams);
  135. MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  136. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values"=>new ValueSetEnum('production,implementation,obsolete,off,left company,available'), "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
  137. MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"bizOrganization", "allowed_values"=>null, "sql"=>"org_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  138. MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
  139. MetaModel::Init_AddFilterFromAttribute("name");
  140. MetaModel::Init_AddFilterFromAttribute("status");
  141. MetaModel::Init_AddFilterFromAttribute("org_id");
  142. MetaModel::Init_AddFilterFromAttribute("org_name");
  143. // Display lists
  144. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id')); // Attributes to be displayed for the complete details
  145. MetaModel::Init_SetZListItems('list', array('finalclass', 'name', 'status', 'org_id')); // Attributes to be displayed for a list
  146. // Search criteria
  147. MetaModel::Init_SetZListItems('standard_search', array('name', 'status')); // Criteria of the std search form
  148. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'org_id')); // Criteria of the advanced search form
  149. }
  150. public function Generate(cmdbDataGenerator $oGenerator)
  151. {
  152. $this->Set('org_id', $oGenerator->GetOrganizationId());
  153. $this->Set('name', "<overload in derived class>");
  154. $this->Set('status', $oGenerator->GenerateString("enum(implementation,production)"));
  155. }
  156. }
  157. ////////////////////////////////////////////////////////////////////////////////////
  158. /**
  159. * Any kind of thing that can be contacted (person, team, hotline...)
  160. * A contact can:
  161. * be linked to any Real Object with a role
  162. * be part of a GroupContact
  163. */
  164. ////////////////////////////////////////////////////////////////////////////////////
  165. class bizContact extends logRealObject
  166. {
  167. public static function Init()
  168. {
  169. $aParams = array
  170. (
  171. "category" => "bizmodel,searchable",
  172. "name" => "Contact",
  173. "description" => "Contact",
  174. "key_type" => "",
  175. "key_label" => "id",
  176. "name_attcode" => "name",
  177. "state_attcode" => "",
  178. "reconc_keys" => array("org_id", "name"), // inherited attributes
  179. "db_table" => "contacts",
  180. "db_key_field" => "id",
  181. "db_finalclass_field" => "",
  182. "display_template" => "../business/templates/default.html",
  183. );
  184. MetaModel::Init_Params($aParams);
  185. MetaModel::Init_InheritAttributes();
  186. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values"=>new ValueSetEnum('off,left company,available'), "sql"=>"status", "default_value"=>"available", "is_null_allowed"=>false, "depends_on"=>array())));
  187. MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
  188. MetaModel::Init_AddAttribute(new AttributeEmailAddress("email", array("allowed_values"=>null, "sql"=>"email", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  189. MetaModel::Init_AddAttribute(new AttributeString("phone", array("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", "allowed_values"=>new ValueSetObjects('SELECT bizLocation AS p WHERE p.org_id = :this->org_id'), "sql"=>"location_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("org_id"))));
  191. MetaModel::Init_AddAttribute(new AttributeExternalField("location_name", array("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_id", "first_name", "name"), // comment en définir plusieurs
  233. // "reconc_keys" => array("org_id", "employee_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("allowed_values"=>null, "sql"=>"first_name", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  242. MetaModel::Init_AddAttribute(new AttributeString("employee_number", array("allowed_values"=>null, "sql"=>"employee_number", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  243. MetaModel::Init_InheritFilters();
  244. MetaModel::Init_AddFilterFromAttribute("first_name");
  245. MetaModel::Init_AddFilterFromAttribute("employee_number");
  246. // Display lists
  247. MetaModel::Init_SetZListItems('details', array('first_name', 'name', 'status', 'org_id', 'email', 'location_id', 'phone', 'employee_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', 'employee_number')); // Criteria of the std search form
  251. MetaModel::Init_SetZListItems('advanced_search', array('first_name', 'name', 'status', 'email', 'location_id', 'phone', 'employee_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_id", "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. * n-n link between any Object and a contact
  301. */
  302. ////////////////////////////////////////////////////////////////////////////////////
  303. class lnkContactTeam extends cmdbAbstractObject
  304. {
  305. public static function Init()
  306. {
  307. $aParams = array
  308. (
  309. "category" => "bizmodel,searchable",
  310. "name" => "TeamsLinks",
  311. "description" => "A link between a contact and a Team",
  312. "key_type" => "autoincrement",
  313. "key_label" => "link_id",
  314. "name_attcode" => "role",
  315. "state_attcode" => "",
  316. "reconc_keys" => array("contact_id", "team_name"),
  317. "db_table" => "teams_links",
  318. "db_key_field" => "link_id",
  319. "db_finalclass_field" => "",
  320. "display_template" => "../business/templates/default.html",
  321. );
  322. MetaModel::Init_Params($aParams);
  323. MetaModel::Init_AddAttribute(new AttributeExternalKey("contact_id", array("targetclass"=>"bizPerson", "allowed_values"=>null, "sql"=>"contact_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  324. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_name", array("allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"name")));
  325. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_phone", array("allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"phone")));
  326. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_email", array("allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"email")));
  327. MetaModel::Init_AddAttribute(new AttributeExternalKey("team_id", array("targetclass"=>"bizTeam", "allowed_values"=>null, "sql"=>"team_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  328. MetaModel::Init_AddAttribute(new AttributeExternalField("team_name", array("allowed_values"=>null, "extkey_attcode"=> 'team_id', "target_attcode"=>"name")));
  329. MetaModel::Init_AddAttribute(new AttributeString("role", array("allowed_values"=>null, "sql"=>"role", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  330. MetaModel::Init_AddFilterFromAttribute("contact_id");
  331. MetaModel::Init_AddFilterFromAttribute("contact_name");
  332. MetaModel::Init_AddFilterFromAttribute("team_id");
  333. MetaModel::Init_AddFilterFromAttribute("team_name");
  334. MetaModel::Init_AddFilterFromAttribute("role");
  335. // Display lists
  336. MetaModel::Init_SetZListItems('details', array('contact_id', 'contact_phone', 'contact_email', 'team_id', 'role')); // Attributes to be displayed for the complete details
  337. MetaModel::Init_SetZListItems('list', array('contact_id', 'contact_phone', 'contact_email', 'team_id', 'role')); // Attributes to be displayed for a list
  338. }
  339. }
  340. ////////////////////////////////////////////////////////////////////////////////////
  341. /**
  342. * An electronic document, with version tracking
  343. */
  344. ////////////////////////////////////////////////////////////////////////////////////
  345. class bizDocument extends logRealObject
  346. {
  347. public static function Init()
  348. {
  349. $aParams = array
  350. (
  351. "category" => "bizmodel,searchable",
  352. "name" => "Document",
  353. "description" => "Document",
  354. "key_type" => "",
  355. "key_label" => "id",
  356. "name_attcode" => "name",
  357. "state_attcode" => "",
  358. "reconc_keys" => array("org_id", "name"), // inherited attributes
  359. "db_table" => "documents",
  360. "db_key_field" => "id",
  361. "db_finalclass_field" => "",
  362. "display_template" => "../business/templates/document.html",
  363. );
  364. MetaModel::Init_Params($aParams);
  365. MetaModel::Init_InheritAttributes();
  366. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values"=>new ValueSetEnum('production,implementation,obsolete'), "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
  367. MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
  368. MetaModel::Init_AddAttribute(new AttributeEnum("type", array("allowed_values"=>new ValueSetEnum("documentation,contract,working instructions,network map,white paper,presentation,training"), "sql"=>"type", "default_value"=>"documentation", "is_null_allowed"=>false, "depends_on"=>array())));
  369. MetaModel::Init_AddAttribute(new AttributeText("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  370. MetaModel::Init_AddAttribute(new AttributeBlob("contents", array("depends_on"=>array())));
  371. MetaModel::Init_InheritFilters();
  372. MetaModel::Init_AddFilterFromAttribute("type");
  373. MetaModel::Init_AddFilterFromAttribute("description");
  374. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'type', 'description', 'contents')); // Attributes to be displayed for the complete details
  375. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'type', 'contents')); // Attributes to be displayed for a list
  376. // Search criteria
  377. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'type')); // Criteria of the std search form
  378. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'type')); // Criteria of the advanced search form
  379. }
  380. }
  381. ////////////////////////////////////////////////////////////////////////////////////
  382. /**
  383. * n-n link between any Object and a Document
  384. */
  385. ////////////////////////////////////////////////////////////////////////////////////
  386. class lnkDocumentRealObject extends cmdbAbstractObject
  387. {
  388. public static function Init()
  389. {
  390. $aParams = array
  391. (
  392. "category" => "bizmodel,searchable",
  393. "name" => "DocumentsLinks",
  394. "description" => "A link between a document and another object",
  395. "key_type" => "autoincrement",
  396. "key_label" => "link_id",
  397. "name_attcode" => "link_type",
  398. "state_attcode" => "",
  399. "reconc_keys" => array("doc_id", "object_name"),
  400. "db_table" => "documents_links",
  401. "db_key_field" => "link_id",
  402. "db_finalclass_field" => "",
  403. "display_template" => "../business/templates/default.html",
  404. );
  405. MetaModel::Init_Params($aParams);
  406. MetaModel::Init_AddAttribute(new AttributeExternalKey("doc_id", array("targetclass"=>"bizDocument", "allowed_values"=>null, "sql"=>"doc_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  407. MetaModel::Init_AddAttribute(new AttributeExternalField("doc_name", array("allowed_values"=>null, "extkey_attcode"=> 'doc_id', "target_attcode"=>"name")));
  408. MetaModel::Init_AddAttribute(new AttributeExternalKey("object_id", array("targetclass"=>"logRealObject", "allowed_values"=>null, "sql"=>"object_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  409. MetaModel::Init_AddAttribute(new AttributeExternalField("object_name", array("allowed_values"=>null, "extkey_attcode"=> 'object_id', "target_attcode"=>"name")));
  410. MetaModel::Init_AddAttribute(new AttributeString("link_type", array("allowed_values"=>null, "sql"=>"link_type", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  411. MetaModel::Init_AddFilterFromAttribute("doc_id");
  412. MetaModel::Init_AddFilterFromAttribute("doc_name");
  413. MetaModel::Init_AddFilterFromAttribute("object_id");
  414. MetaModel::Init_AddFilterFromAttribute("object_name");
  415. MetaModel::Init_AddFilterFromAttribute("link_type");
  416. // Display lists
  417. MetaModel::Init_SetZListItems('details', array('doc_id', 'object_id', 'link_type')); // Attributes to be displayed for the complete details
  418. MetaModel::Init_SetZListItems('list', array('doc_id', 'object_id', 'link_type')); // Attributes to be displayed for a list
  419. }
  420. }
  421. ////////////////////////////////////////////////////////////////////////////////////
  422. /**
  423. * n-n link between any Object and a contact
  424. */
  425. ////////////////////////////////////////////////////////////////////////////////////
  426. class lnkContactRealObject extends cmdbAbstractObject
  427. {
  428. public static function Init()
  429. {
  430. $aParams = array
  431. (
  432. "category" => "bizmodel,searchable",
  433. "name" => "ContactsLinks",
  434. "description" => "A link between a contact and another object",
  435. "key_type" => "autoincrement",
  436. "key_label" => "link_id",
  437. "name_attcode" => "role",
  438. "state_attcode" => "",
  439. "reconc_keys" => array("contact_id", "object_name"),
  440. "db_table" => "contacts_links",
  441. "db_key_field" => "link_id",
  442. "db_finalclass_field" => "",
  443. "display_template" => "../business/templates/default.html",
  444. );
  445. MetaModel::Init_Params($aParams);
  446. MetaModel::Init_AddAttribute(new AttributeExternalKey("contact_id", array("targetclass"=>"bizContact", "allowed_values"=>null, "sql"=>"contact_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  447. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_name", array("allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"name")));
  448. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_phone", array("allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"phone")));
  449. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_email", array("allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"email")));
  450. MetaModel::Init_AddAttribute(new AttributeExternalKey("object_id", array("targetclass"=>"logRealObject", "allowed_values"=>null, "sql"=>"object_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  451. MetaModel::Init_AddAttribute(new AttributeExternalField("object_name", array("allowed_values"=>null, "extkey_attcode"=> 'object_id', "target_attcode"=>"name")));
  452. MetaModel::Init_AddAttribute(new AttributeString("role", array("allowed_values"=>null, "sql"=>"role", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  453. MetaModel::Init_AddFilterFromAttribute("contact_id");
  454. MetaModel::Init_AddFilterFromAttribute("contact_name");
  455. MetaModel::Init_AddFilterFromAttribute("object_id");
  456. MetaModel::Init_AddFilterFromAttribute("object_name");
  457. MetaModel::Init_AddFilterFromAttribute("role");
  458. // Display lists
  459. MetaModel::Init_SetZListItems('details', array('contact_id', 'contact_phone', 'contact_email', 'object_id', 'role')); // Attributes to be displayed for the complete details
  460. MetaModel::Init_SetZListItems('list', array('contact_id', 'contact_phone', 'contact_email', 'object_id', 'role')); // Attributes to be displayed for a list
  461. }
  462. }
  463. ////////////////////////////////////////////////////////////////////////////////////
  464. /**
  465. * Any Infrastructure object (bizLocation, bizDevice, bizApplication, bizCircuit, bizInterface)
  466. * An infrastructure object:
  467. * can be covered by an OLA
  468. * can support the delivery of a Service
  469. * can be part of an GroupInfra
  470. */
  471. ////////////////////////////////////////////////////////////////////////////////////
  472. class logInfra extends logRealObject
  473. {
  474. public static function Init()
  475. {
  476. $aParams = array
  477. (
  478. "category" => "bizmodel,searchable",
  479. "name" => "Infra",
  480. "description" => "Infrastructure real object",
  481. "key_type" => "",
  482. "key_label" => "id",
  483. "name_attcode" => "name",
  484. "state_attcode" => "",
  485. "reconc_keys" => array("org_id", "name"), // inherited attributes
  486. "db_table" => "infra",
  487. "db_key_field" => "id",
  488. "db_finalclass_field" => "",
  489. "display_template" => "../business/templates/default.html",
  490. );
  491. MetaModel::Init_Params($aParams);
  492. MetaModel::Init_InheritAttributes();
  493. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values"=>new ValueSetEnum('production,implementation,obsolete'), "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
  494. MetaModel::Init_AddAttribute(new AttributeEnum("severity", array("allowed_values"=>new ValueSetEnum("high,medium,low"), "sql"=>"severity", "default_value"=>"low", "is_null_allowed"=>false, "depends_on"=>array())));
  495. MetaModel::Init_InheritFilters();
  496. MetaModel::Init_AddFilterFromAttribute("severity");
  497. }
  498. }
  499. ////////////////////////////////////////////////////////////////////////////////////
  500. /**
  501. * n-n link between any Object and a contact
  502. */
  503. ////////////////////////////////////////////////////////////////////////////////////
  504. class lnkContactInfra extends cmdbAbstractObject
  505. {
  506. public static function Init()
  507. {
  508. $aParams = array
  509. (
  510. "category" => "bizmodel,searchable",
  511. "name" => "ContactsInfraLinks",
  512. "description" => "A link between a contact and an infrastructure",
  513. "key_type" => "autoincrement",
  514. "key_label" => "link_id",
  515. "name_attcode" => "role",
  516. "state_attcode" => "",
  517. "reconc_keys" => array("contact_id", "infra_id"),
  518. "db_table" => "contacts_infra_links",
  519. "db_key_field" => "link_id",
  520. "db_finalclass_field" => "",
  521. "display_template" => "../business/templates/default.html",
  522. );
  523. MetaModel::Init_Params($aParams);
  524. MetaModel::Init_AddAttribute(new AttributeExternalKey("contact_id", array("targetclass"=>"bizContact", "allowed_values"=>null, "sql"=>"contact_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  525. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_name", array("allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"name")));
  526. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_phone", array("allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"phone")));
  527. MetaModel::Init_AddAttribute(new AttributeExternalField("contact_email", array("allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"email")));
  528. MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_id", array("targetclass"=>"logInfra", "allowed_values"=>null, "sql"=>"infra_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  529. MetaModel::Init_AddAttribute(new AttributeExternalField("infra_name", array("allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"name")));
  530. MetaModel::Init_AddAttribute(new AttributeString("role", array("allowed_values"=>null, "sql"=>"role", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  531. MetaModel::Init_AddFilterFromAttribute("contact_id");
  532. MetaModel::Init_AddFilterFromAttribute("contact_name");
  533. MetaModel::Init_AddFilterFromAttribute("infra_id");
  534. MetaModel::Init_AddFilterFromAttribute("infra_name");
  535. MetaModel::Init_AddFilterFromAttribute("role");
  536. // Display lists
  537. MetaModel::Init_SetZListItems('details', array('contact_id', 'contact_phone', 'contact_email', 'infra_id', 'role')); // Attributes to be displayed for the complete details
  538. MetaModel::Init_SetZListItems('list', array('contact_id', 'contact_phone', 'contact_email', 'infra_id', 'role')); // Attributes to be displayed for a list
  539. }
  540. }
  541. ////////////////////////////////////////////////////////////////////////////////////
  542. /**
  543. * bizLocation (Region, Country, City, Site, Building, Floor, Room, Rack,...)
  544. * pourrait être mis en plusieurs sous objects, puisqu'une adresse sur region n'a pas trop de sens
  545. *
  546. */
  547. ////////////////////////////////////////////////////////////////////////////////////
  548. class bizLocation extends logInfra
  549. {
  550. public static function Init()
  551. {
  552. $aParams = array
  553. (
  554. "category" => "bizmodel,searchable",
  555. "name" => "Location",
  556. "description" => "Any type of location: Region, Country, City, Site, Building, Floor, Room, Rack,...",
  557. "key_type" => "",
  558. "key_label" => "id",
  559. "name_attcode" => "name",
  560. "state_attcode" => "",
  561. "reconc_keys" => array("org_id", "name"), // inherited attributes
  562. "db_table" => "location",
  563. "db_key_field" => "id",
  564. "db_finalclass_field" => "",
  565. "display_template" => "../business/templates/location.html",
  566. );
  567. MetaModel::Init_Params($aParams);
  568. MetaModel::Init_InheritAttributes();
  569. MetaModel::Init_AddAttribute(new AttributeText("address", array("allowed_values"=>null, "sql"=>"address", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  570. MetaModel::Init_AddAttribute(new AttributeString("country", array("allowed_values"=>null, "sql"=>"country", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  571. MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_location_id", array("targetclass"=>"bizLocation", "allowed_values"=>null, "sql"=>"parent_location_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  572. MetaModel::Init_AddAttribute(new AttributeExternalField("parent_location_name", array("allowed_values"=>null, "extkey_attcode"=> 'parent_location_id', "target_attcode"=>"name")));
  573. // on veut pouvoir rechercher une location qui soit un descendant (pas obligatoirement direct) d'une Location, on fait comment ?
  574. MetaModel::Init_InheritFilters();
  575. MetaModel::Init_AddFilterFromAttribute("country");
  576. MetaModel::Init_AddFilterFromAttribute("address");
  577. MetaModel::Init_AddFilterFromAttribute("parent_location_id");
  578. MetaModel::Init_AddFilterFromAttribute("parent_location_name");
  579. // Display lists
  580. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'address', 'country', 'parent_location_id')); // Attributes to be displayed for the complete details
  581. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'country')); // Attributes to be displayed for a list
  582. // Search criteria
  583. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'country', 'parent_location_name')); // Criteria of the std search form
  584. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'address', 'country', 'parent_location_id', 'org_id')); // Criteria of the advanced search form
  585. }
  586. public function ComputeValues()
  587. {
  588. /*
  589. $this->Set("location_id", $this->GetKey());
  590. // Houston, I've got an issue, as this field is calculated, I should reload the object... ?
  591. $this->Set("location_name", "abc (to be finalized)");
  592. */
  593. }
  594. function DisplayDetails(WebPage $oPage)
  595. {
  596. parent::DisplayDetails($oPage);
  597. /*
  598. parent::DisplayDetails($oPage);
  599. $oSearchFilter = new CMDBSearchFilter('bizServer');
  600. $oSearchFilter->AddCondition('location_id', $this->GetKey(), '=');
  601. $oSet = new CMDBObjectSet($oSearchFilter);
  602. $count = $oSet->Count();
  603. if ($count > 0)
  604. {
  605. $oPage->SetCurrentTab("Servers");
  606. $oPage->p("$count server(s) at this location:");
  607. $this->DisplaySet($oPage, $oSet);
  608. }
  609. $oSearchFilter = new CMDBSearchFilter('bizNetworkDevice');
  610. $oSearchFilter->AddCondition('location_id', $this->GetKey(), '=');
  611. $oSet = new CMDBObjectSet($oSearchFilter);
  612. $count = $oSet->Count();
  613. if ($count > 0)
  614. {
  615. $oPage->SetCurrentTab("Network Devices");
  616. $oPage->p("$count Network Device(s) at this location:");
  617. $this->DisplaySet($oPage, $oSet);
  618. }
  619. $oSearchFilter = new CMDBSearchFilter('bizPC');
  620. $oSearchFilter->AddCondition('location_id', $this->GetKey(), '=');
  621. $oSet = new CMDBObjectSet($oSearchFilter);
  622. $count = $oSet->Count();
  623. if ($count > 0)
  624. {
  625. $oPage->SetCurrentTab("PCs");
  626. $oPage->p("$count PC(s) at this location:");
  627. $this->DisplaySet($oPage, $oSet);
  628. }
  629. $oSearchFilter = new CMDBSearchFilter('bizPerson');
  630. $oSearchFilter->AddCondition('location_id', $this->GetKey(), '=');
  631. $oSet = new CMDBObjectSet($oSearchFilter);
  632. $count = $oSet->Count();
  633. if ($count > 0)
  634. {
  635. $oPage->SetCurrentTab("Contacts");
  636. $oPage->p("$count person(s) located to this location:");
  637. $this->DisplaySet($oPage, $oSet);
  638. }
  639. $oSearchFilter = new CMDBSearchFilter('lnkDocumentRealObject');
  640. $oSearchFilter->AddCondition('object_id', $this->GetKey(), '=');
  641. $oSet = new CMDBObjectSet($oSearchFilter);
  642. $count = $oSet->Count();
  643. if ($count > 0)
  644. {
  645. $oPage->SetCurrentTab("Details");
  646. $oPage->p("$count Document(s) linked to this location:");
  647. $this->DisplaySet($oPage, $oSet);
  648. }
  649. */
  650. }
  651. public function Generate(cmdbDataGenerator $oGenerator)
  652. {
  653. parent::Generate($oGenerator);
  654. $sLastName = $oGenerator->GenerateLastName();
  655. $sCityName = $oGenerator->GenerateCityName();
  656. $this->Set('name', $sCityName);
  657. $this->Set('country', $oGenerator->GenerateCountryName());
  658. $this->Set('address', $oGenerator->GenerateString("number(1-999)| |enum(rue,rue,rue,place,avenue,av.,route de)| |$sLastName| |number(0000-9999)|0 |$sCityName"));
  659. $this->Set('parent_location_id', 1);
  660. }
  661. }
  662. ////////////////////////////////////////////////////////////////////////////////////
  663. /**
  664. * Circuit (one end only)
  665. */
  666. ////////////////////////////////////////////////////////////////////////////////////
  667. class bizCircuit extends logInfra
  668. {
  669. public static function Init()
  670. {
  671. $aParams = array
  672. (
  673. "category" => "bizmodel,searchable",
  674. "name" => "Circuit",
  675. "description" => "Any type of circuit",
  676. "key_type" => "",
  677. "key_label" => "id",
  678. "name_attcode" => "name",
  679. "state_attcode" => "",
  680. "reconc_keys" => array("org_id", "provider_id", "carrier_ref", "name"), // inherited attributes
  681. "db_table" => "circuits",
  682. "db_key_field" => "id",
  683. "db_finalclass_field" => "",
  684. "display_template" => "../business/templates/circuit.html",
  685. );
  686. MetaModel::Init_Params($aParams);
  687. MetaModel::Init_InheritAttributes();
  688. MetaModel::Init_AddAttribute(new AttributeString("speed", array("allowed_values"=>null, "sql"=>"speed", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  689. MetaModel::Init_AddAttribute(new AttributeExternalKey("location1_id", array("targetclass"=>"bizLocation", "allowed_values"=>new ValueSetObjects('SELECT bizLocation AS p WHERE p.org_id = :this->org_id'), "sql"=>"location1_id", "is_null_allowed"=>false,"on_target_delete"=>DEL_MANUAL, "depends_on"=>array("org_id"))));
  690. MetaModel::Init_AddAttribute(new AttributeExternalField("location1_name", array("allowed_values"=>null, "extkey_attcode"=> 'location1_id', "target_attcode"=>"name")));
  691. MetaModel::Init_AddAttribute(new AttributeExternalKey("location2_id", array("targetclass"=>"bizLocation", "allowed_values"=>new ValueSetObjects('SELECT bizLocation AS p WHERE p.org_id = :this->org_id'), "sql"=>"location2_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL,"depends_on"=>array("org_id"))));
  692. MetaModel::Init_AddAttribute(new AttributeExternalField("location2_name", array("allowed_values"=>null, "extkey_attcode"=> 'location2_id', "target_attcode"=>"name")));
  693. MetaModel::Init_AddAttribute(new AttributeExternalKey("interface1_id", array("targetclass"=>"bizInterface", "allowed_values"=>new ValueSetObjects('SELECT bizInterface AS Intf JOIN bizDevice AS Dev ON Intf.device_id = Dev.id WHERE Intf.org_id = :this->org_id AND Dev.location_id = :this->location1_id'), "sql"=>"interface1_id", "is_null_allowed"=>false,"on_target_delete"=>DEL_MANUAL, "depends_on"=>array("org_id", "location1_id"))));
  694. MetaModel::Init_AddAttribute(new AttributeExternalField("interface1_name", array("allowed_values"=>null, "extkey_attcode"=> 'interface1_id', "target_attcode"=>"name")));
  695. MetaModel::Init_AddAttribute(new AttributeExternalField("device1_name", array("allowed_values"=>null, "extkey_attcode"=> 'interface1_id', "target_attcode"=>"device_name")));
  696. MetaModel::Init_AddAttribute(new AttributeExternalKey("interface2_id", array("targetclass"=>"bizInterface", "allowed_values"=>new ValueSetObjects('SELECT bizInterface AS Intf JOIN bizDevice AS Dev ON Intf.device_id = Dev.id WHERE Intf.org_id = :this->org_id AND Dev.location_id = :this->location2_id'), "sql"=>"interface2_id", "is_null_allowed"=>false,"on_target_delete"=>DEL_MANUAL, "depends_on"=>array("org_id", "location2_id"))));
  697. MetaModel::Init_AddAttribute(new AttributeExternalField("interface2_name", array("allowed_values"=>null, "extkey_attcode"=> 'interface2_id', "target_attcode"=>"name")));
  698. MetaModel::Init_AddAttribute(new AttributeExternalField("device2_name", array("allowed_values"=>null, "extkey_attcode"=> 'interface2_id', "target_attcode"=>"device_name")));
  699. MetaModel::Init_AddAttribute(new AttributeExternalKey("provider_id", array("targetclass"=>"bizOrganization", "allowed_values"=>null, "sql"=>"provider_id", "is_null_allowed"=>false,"on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  700. MetaModel::Init_AddAttribute(new AttributeExternalField("carrier_name", array("allowed_values"=>null, "extkey_attcode"=> 'provider_id', "target_attcode"=>"name")));
  701. MetaModel::Init_AddAttribute(new AttributeString("carrier_ref", array("allowed_values"=>null, "sql"=>"carrier_ref", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  702. MetaModel::Init_InheritFilters();
  703. MetaModel::Init_AddFilterFromAttribute("speed");
  704. MetaModel::Init_AddFilterFromAttribute("location1_id");
  705. MetaModel::Init_AddFilterFromAttribute("location2_id");
  706. MetaModel::Init_AddFilterFromAttribute("interface1_id");
  707. MetaModel::Init_AddFilterFromAttribute("interface2_id");
  708. MetaModel::Init_AddFilterFromAttribute("provider_id");
  709. MetaModel::Init_AddFilterFromAttribute("carrier_ref");
  710. // Display lists
  711. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'speed', 'location1_id','interface1_id','device1_name','location2_id','interface2_id','device2_name','provider_id', 'carrier_ref')); // Attributes to be displayed for the complete details
  712. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'provider_id', 'carrier_ref', 'speed')); // Attributes to be displayed for a list
  713. // Search criteria
  714. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'location1_id','location2_id','carrier_ref', 'speed', 'provider_id')); // Criteria of the std search form
  715. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'location1_id','location2_id','carrier_ref', 'speed', 'provider_id')); // Criteria of the advanced search form
  716. }
  717. public function ComputeValues()
  718. {
  719. /*
  720. $oLocatedObject = MetaModel::GetObject("Located Object", $this->Get("located_object_id"));
  721. $this->Set("location_id", $oLocatedObject->Get("location_id"));
  722. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  723. $this->Set("location_name", "abc (to be finalized)");
  724. $this->Set("device_id", $oLocatedObject->Get("device_id"));
  725. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  726. $this->Set("device_name", "abc (to be finalized)");
  727. $this->Set("interface_id", $oLocatedObject->Get("interface_id"));
  728. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  729. $this->Set("interface_name", "abc (to be finalized)");
  730. */
  731. }
  732. }
  733. ////////////////////////////////////////////////////////////////////////////////////
  734. /**
  735. * Any Device Network Interface
  736. */
  737. ////////////////////////////////////////////////////////////////////////////////////
  738. class bizInterface extends logInfra
  739. {
  740. public static function Init()
  741. {
  742. $aParams = array
  743. (
  744. "category" => "bizmodel,searchable",
  745. "name" => "Interface",
  746. "description" => "Interface",
  747. "key_type" => "",
  748. "key_label" => "id",
  749. "name_attcode" => "name",
  750. "state_attcode" => "",
  751. "reconc_keys" => array("org_id", "device_id", "name"),
  752. "db_table" => "interfaces",
  753. "db_key_field" => "id",
  754. "db_finalclass_field" => "",
  755. "display_template" => "../business/templates/interface.html",
  756. );
  757. MetaModel::Init_Params($aParams);
  758. MetaModel::Init_InheritAttributes();
  759. MetaModel::Init_AddAttribute(new AttributeExternalKey("device_id", array("targetclass"=>"bizDevice", "allowed_values"=>null, "sql"=>"device_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  760. MetaModel::Init_AddAttribute(new AttributeExternalField("device_name", array("allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"name")));
  761. MetaModel::Init_AddAttribute(new AttributeExternalField("device_location_id", array("allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"location_id")));
  762. MetaModel::Init_AddAttribute(new AttributeExternalField("device_location_name", array("allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"location_name")));
  763. MetaModel::Init_AddAttribute(new AttributeEnum("logical_type", array("allowed_values"=>new ValueSetEnum("primary,secondary,backup,port,logical"), "sql"=>"logical_type", "default_value"=>"port", "is_null_allowed"=>false, "depends_on"=>array())));
  764. MetaModel::Init_AddAttribute(new AttributeEnum("physical_type", array("allowed_values"=>new ValueSetEnum("ethernet,framerelay,atm,vlan"), "sql"=>"physical_type", "default_value"=>"ethernet", "is_null_allowed"=>false, "depends_on"=>array())));
  765. MetaModel::Init_AddAttribute(new AttributeString("ip_address", array("allowed_values"=>null, "sql"=>"ip_address", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  766. MetaModel::Init_AddAttribute(new AttributeString("mask", array("allowed_values"=>null, "sql"=>"mask", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  767. MetaModel::Init_AddAttribute(new AttributeString("mac", array("allowed_values"=>null, "sql"=>"mac", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  768. MetaModel::Init_AddAttribute(new AttributeString("speed", array("allowed_values"=>null, "sql"=>"speed", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  769. MetaModel::Init_AddAttribute(new AttributeEnum("duplex", array("allowed_values"=>new ValueSetEnum("half,full,unknown"), "sql"=>"duplex", "default_value"=>"unknown", "is_null_allowed"=>true, "depends_on"=>array())));
  770. MetaModel::Init_AddAttribute(new AttributeExternalKey("if_connected_id", array("targetclass"=>"bizInterface", "allowed_values"=>null, "sql"=>"ext_if_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  771. MetaModel::Init_AddAttribute(new AttributeExternalField("if_connected_name", array("allowed_values"=>null, "extkey_attcode"=> 'if_connected_id', "target_attcode"=>"name")));
  772. MetaModel::Init_AddAttribute(new AttributeExternalField("if_connected_device", array("allowed_values"=>null, "extkey_attcode"=> 'if_connected_id', "target_attcode"=>"device_name")));
  773. MetaModel::Init_InheritFilters();
  774. MetaModel::Init_AddFilterFromAttribute("device_id");
  775. MetaModel::Init_AddFilterFromAttribute("device_name");
  776. MetaModel::Init_AddFilterFromAttribute("device_location_id");
  777. MetaModel::Init_AddFilterFromAttribute("logical_type");
  778. MetaModel::Init_AddFilterFromAttribute("physical_type");
  779. MetaModel::Init_AddFilterFromAttribute("ip_address");
  780. MetaModel::Init_AddFilterFromAttribute("mac");
  781. MetaModel::Init_AddFilterFromAttribute("if_connected_id");
  782. // Display lists
  783. 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','if_connected_name','if_connected_device')); // Attributes to be displayed for the complete details
  784. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'device_id','severity')); // Attributes to be displayed for a list
  785. // Search criteria
  786. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'ip_address','mac','device_id')); // Criteria of the std search form
  787. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'device_id', 'org_id')); // Criteria of the advanced search form
  788. }
  789. function DisplayDetails(WebPage $oPage)
  790. {
  791. parent::DisplayDetails($oPage);
  792. /*
  793. $oSearchFilter = new CMDBSearchFilter('lnkInterfaces');
  794. $oSearchFilter->AddCondition('interface1_id', $this->GetKey(), '=');
  795. $oSet = new CMDBObjectSet($oSearchFilter);
  796. $count = $oSet->Count();
  797. if ($count > 0)
  798. {
  799. $oPage->SetCurrentTab("Connected interfaces");
  800. $oPage->p("$count interface(s) connected to this device:");
  801. $this->DisplaySet($oPage, $oSet);
  802. }
  803. */
  804. }
  805. public function ComputeValues()
  806. {
  807. /*
  808. // my location is the location of my device
  809. $oDevice = MetaModel::GetObject("bizDevice", $this->Get("device_id"));
  810. $this->Set("location_id", $oDevice->Get("location_id"));
  811. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  812. $this->Set("location_name", "abc (to be finalized)");
  813. // my device is given by my Creator
  814. // my interface is myself
  815. $this->Set("interface_id", $this->GetKey());
  816. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  817. $this->Set("interface_name", "abc (to be finalized)");
  818. */
  819. }
  820. }
  821. ////////////////////////////////////////////////////////////////////////////////////
  822. /**
  823. * A subnet
  824. */
  825. ////////////////////////////////////////////////////////////////////////////////////
  826. class bizSubnet extends logInfra
  827. {
  828. public static function Init()
  829. {
  830. $aParams = array
  831. (
  832. "category" => "bizmodel,searchable",
  833. "name" => "Subnet",
  834. "description" => "Logical or physical subnet",
  835. "key_type" => "",
  836. "key_label" => "id",
  837. "name_attcode" => "name",
  838. "state_attcode" => "",
  839. "reconc_keys" => array("org_id", "name"), // inherited attributes
  840. "db_table" => "subnets",
  841. "db_key_field" => "id",
  842. "db_finalclass_field" => "",
  843. "display_template" => "",
  844. );
  845. MetaModel::Init_Params($aParams);
  846. MetaModel::Init_InheritAttributes();
  847. MetaModel::Init_AddAttribute(new AttributeString("ip", array("allowed_values"=>null, "sql"=>"ip", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  848. MetaModel::Init_AddAttribute(new AttributeString("mask", array("allowed_values"=>null, "sql"=>"mask", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  849. MetaModel::Init_InheritFilters();
  850. MetaModel::Init_AddFilterFromAttribute("ip");
  851. MetaModel::Init_AddFilterFromAttribute("mask");
  852. // Display lists
  853. MetaModel::Init_SetZListItems('details', array('name', 'ip','mask')); // Attributes to be displayed for the complete details
  854. MetaModel::Init_SetZListItems('list', array('name', 'ip', 'mask')); // Attributes to be displayed for a list
  855. // Search criteria
  856. MetaModel::Init_SetZListItems('standard_search', array('name', 'ip','mask')); // Criteria of the std search form
  857. MetaModel::Init_SetZListItems('advanced_search', array('name', 'ip','mask')); // Criteria of the advanced search form
  858. }
  859. function DisplayBareRelations(WebPage $oPage)
  860. {
  861. parent::DisplayBareRelations($oPage);
  862. $oPage->SetCurrentTabContainer('Related Objects');
  863. $oPage->SetCurrentTab('IP Usage');
  864. $bit_ip = ip2long($this->Get('ip'));
  865. $bit_mask = ip2long($this->Get('mask'));
  866. $sIPMin = long2ip($bit_ip & $bit_mask);
  867. $sIPMax = long2ip(($bit_ip | (~$bit_mask)) - 1);
  868. $oPage->p("Interfaces having an IP in the range: <em>$sIPMin</em> to <em>$sIPMax</em>");
  869. $oIfSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT bizInterface AS if WHERE INET_ATON(if.ip_address) >= INET_ATON('$sIPMin') AND INET_ATON(if.ip_address) <= INET_ATON('$sIPMax')"));
  870. self::DisplaySet($oPage, $oIfSet);
  871. $iCountUsed = $oIfSet->Count();
  872. $iCountRange = ip2long($sIPMax) - ip2long($sIPMin);
  873. $iFreeCount = $iCountRange - $iCountUsed;
  874. $oPage->SetCurrentTab('Free IPs');
  875. $oPage->p("Free IPs: $iFreeCount");
  876. $oPage->p("Here is an extract of 10 free IP addresses");
  877. $aUsedIPs = $oIfSet->GetColumnAsArray('ip_address', false);
  878. $i = 0;
  879. while ($i < min($iFreeCount, 10))
  880. {
  881. $i++;
  882. $iAnIP = ip2long($sIPMin) + $i;
  883. if (in_array($iAnIP, $aUsedIPs)) continue;
  884. $sAnIP = long2ip($iAnIP);
  885. $oPage->p($sAnIP);
  886. }
  887. }
  888. }
  889. ////////////////////////////////////////////////////////////////////////////////////
  890. /**
  891. * Any electronic device
  892. */
  893. ////////////////////////////////////////////////////////////////////////////////////
  894. class bizDevice extends logInfra
  895. {
  896. public static function Init()
  897. {
  898. $aParams = array
  899. (
  900. "category" => "bizmodel,searchable",
  901. "name" => "Device",
  902. "description" => "Electronic devices",
  903. "key_type" => "",
  904. "key_label" => "id",
  905. "name_attcode" => "name",
  906. "state_attcode" => "",
  907. "reconc_keys" => array("org_id", "name"), // inherited attributes
  908. "db_table" => "devices",
  909. "db_key_field" => "id",
  910. "db_finalclass_field" => "",
  911. "display_template" => "../business/templates/default.html",
  912. );
  913. MetaModel::Init_Params($aParams);
  914. MetaModel::Init_InheritAttributes();
  915. MetaModel::Init_AddAttribute(new AttributeExternalKey("location_id", array("targetclass"=>"bizLocation", "allowed_values"=>new ValueSetObjects('SELECT bizLocation AS p WHERE p.org_id = :this->org_id'), "sql"=>"location_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("org_id"))));
  916. MetaModel::Init_AddAttribute(new AttributeExternalField("location_name", array("allowed_values"=>null, "extkey_attcode"=> 'location_id', "target_attcode"=>"name")));
  917. MetaModel::Init_AddAttribute(new AttributeExternalField("country", array("allowed_values"=>null, "extkey_attcode"=> 'location_id', "target_attcode"=>"country")));
  918. MetaModel::Init_AddAttribute(new AttributeString("brand", array("allowed_values"=>null, "sql"=>"brand", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  919. MetaModel::Init_AddAttribute(new AttributeString("model", array("allowed_values"=>null, "sql"=>"model", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  920. MetaModel::Init_AddAttribute(new AttributeString("serial_number", array("allowed_values"=>null, "sql"=>"serial_number", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  921. MetaModel::Init_AddAttribute(new AttributeString("mgmt_ip", array("allowed_values"=>null, "sql"=>"mgmt_ip", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  922. MetaModel::Init_InheritFilters();
  923. MetaModel::Init_AddFilterFromAttribute("location_id");
  924. MetaModel::Init_AddFilterFromAttribute("country");
  925. MetaModel::Init_AddFilterFromAttribute("brand");
  926. MetaModel::Init_AddFilterFromAttribute("model");
  927. MetaModel::Init_AddFilterFromAttribute("serial_number");
  928. MetaModel::Init_AddFilterFromAttribute("mgmt_ip");
  929. }
  930. public static function GetRelationQueries($sRelCode)
  931. {
  932. switch ($sRelCode)
  933. {
  934. case "impacts":
  935. $aRels = array(
  936. );
  937. return array_merge($aRels, parent::GetRelationQueries($sRelCode));
  938. }
  939. }
  940. public function ComputeValues()
  941. {
  942. /*
  943. // my location is the location of my device (external field)
  944. $this->Set("location_id", $this->Get("device_location_id"));
  945. // Houston, I've got an issue, as this field is calculated, I should reload the object...
  946. $this->Set("location_name", "abc (to be finalized)");
  947. // my device is myself
  948. $this->Set("device_id", $this->GetKey());
  949. // my interface is "nothing"
  950. $this->Set("interface_id", null);
  951. */
  952. }
  953. }
  954. ////////////////////////////////////////////////////////////////////////////////////
  955. /**
  956. * A personal computer
  957. */
  958. ////////////////////////////////////////////////////////////////////////////////////
  959. class bizPC extends bizDevice
  960. {
  961. public static function Init()
  962. {
  963. $aParams = array
  964. (
  965. "category" => "bizmodel,searchable",
  966. "name" => "PC",
  967. "description" => "Personal Computers",
  968. "key_type" => "",
  969. "key_label" => "id",
  970. "name_attcode" => "name",
  971. "state_attcode" => "",
  972. "reconc_keys" => array("org_id", "name"), // inherited attributes
  973. "db_table" => "pcs",
  974. "db_key_field" => "id",
  975. "db_finalclass_field" => "",
  976. "display_template" => "../business/templates/pc.html",
  977. );
  978. MetaModel::Init_Params($aParams);
  979. MetaModel::Init_InheritAttributes();
  980. MetaModel::Init_AddAttribute(new AttributeEnum("type", array("allowed_values"=>new ValueSetEnum("desktop PC,laptop"), "sql"=>"type", "default_value"=>"desktop PC", "is_null_allowed"=>false, "depends_on"=>array())));
  981. MetaModel::Init_AddAttribute(new AttributeString("memory_size", array("allowed_values"=>null, "sql"=>"memory_size", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  982. MetaModel::Init_AddAttribute(new AttributeString("cpu", array("allowed_values"=>null, "sql"=>"cpu_type", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  983. MetaModel::Init_AddAttribute(new AttributeString("hdd_size", array("allowed_values"=>null, "sql"=>"hdd_size", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  984. MetaModel::Init_AddAttribute(new AttributeString("os_family", array("allowed_values"=>null, "sql"=>"os_family", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  985. MetaModel::Init_AddAttribute(new AttributeString("os_version", array("allowed_values"=>null, "sql"=>"os_version", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  986. MetaModel::Init_AddAttribute(new AttributeString("shipment_number", array("allowed_values"=>null, "sql"=>"shipment_number", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  987. MetaModel::Init_AddAttribute(new AttributeString("default_gateway", array("allowed_values"=>null, "sql"=>"default_gateway", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  988. MetaModel::Init_InheritFilters();
  989. MetaModel::Init_AddFilterFromAttribute("type");
  990. MetaModel::Init_AddFilterFromAttribute("memory_size");
  991. MetaModel::Init_AddFilterFromAttribute("cpu");
  992. MetaModel::Init_AddFilterFromAttribute("hdd_size");
  993. MetaModel::Init_AddFilterFromAttribute("os_family");
  994. MetaModel::Init_AddFilterFromAttribute("os_version");
  995. // Display lists
  996. 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
  997. MetaModel::Init_SetZListItems('list', array('name', 'status', 'severity', 'org_id', 'location_id', 'brand', 'model', 'type')); // Attributes to be displayed for a list
  998. // Search criteria
  999. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'severity','type', 'brand', 'model','os_family','mgmt_ip')); // Criteria of the std search form
  1000. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'type', 'brand', 'model', 'cpu', 'memory_size', 'hdd_size')); // Criteria of the advanced search form
  1001. }
  1002. function DisplayDetails(WebPage $oPage)
  1003. {
  1004. parent::DisplayDetails($oPage);
  1005. /*
  1006. parent::DisplayDetails($oPage);
  1007. $oSearchFilter = new CMDBSearchFilter('lnkContactRealObject');
  1008. $oSearchFilter->AddCondition('object_id', $this->GetKey(), '=');
  1009. $oSet = new CMDBObjectSet($oSearchFilter);
  1010. $count = $oSet->Count();
  1011. if ($count > 0)
  1012. {
  1013. $oPage->SetCurrentTab("Contacts");
  1014. $oPage->p("$count contact(s) linked to this PC:");
  1015. $this->DisplaySet($oPage, $oSet);
  1016. }
  1017. $oSearchFilter = new CMDBSearchFilter('bizInterface');
  1018. $oSearchFilter->AddCondition('device_id', $this->GetKey(), '=');
  1019. $oSet = new CMDBObjectSet($oSearchFilter);
  1020. $count = $oSet->Count();
  1021. if ($count > 0)
  1022. {
  1023. $oPage->SetCurrentTab("Interfaces");
  1024. $oPage->p("$count interface(s) for this device:");
  1025. $this->DisplaySet($oPage, $oSet);
  1026. }
  1027. */
  1028. }
  1029. public function Generate(cmdbDataGenerator $oGenerator)
  1030. {
  1031. $this->Set('org_id', $oGenerator->GetOrganizationId());
  1032. $this->Set('location_id', $oGenerator->GenerateKey("bizLocation", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1033. $this->Set('name', $oGenerator->GenerateString("enum(pc,pc,pc,pc,pc,win,redhat,linux,srv,workstation)|number(000-999)|.|domain()"));
  1034. $this->Set('brand', $oGenerator->GenerateString("enum(Hewlett-Packard,Dell,Compaq,Siemens,Packard Bell,IBM,Gateway,Medion,Sony)"));
  1035. $this->Set('model', $oGenerator->GenerateString("enum(Vectra,Deskpro,Dimension,Optiplex,Latitude,Precision,Vaio)"));
  1036. $this->Set('serial_number', $oGenerator->GenerateString("enum(FR,US,TW,CH)|number(000000-999999)"));
  1037. $this->Set('memory_size', $oGenerator->GenerateString("enum(128,256,384,512,768,1024,1536,2048)"));
  1038. $this->Set('cpu', $oGenerator->GenerateString("enum(Pentium III,Pentium 4, Pentium M,Core Duo,Core 2 Duo,Celeron,Opteron,Thurion,Athlon)"));
  1039. $this->Set('hdd_size', $oGenerator->GenerateString("enum(40,60,80,120,200,300)"));
  1040. }
  1041. }
  1042. ////////////////////////////////////////////////////////////////////////////////////
  1043. /**
  1044. * A server
  1045. */
  1046. ////////////////////////////////////////////////////////////////////////////////////
  1047. class bizServer extends bizDevice
  1048. {
  1049. public static function Init()
  1050. {
  1051. $aParams = array
  1052. (
  1053. "category" => "bizmodel,searchable",
  1054. "name" => "Server",
  1055. "description" => "Computer Servers",
  1056. "key_type" => "",
  1057. "key_label" => "id",
  1058. "name_attcode" => "name",
  1059. //"state_attcode" => "status",
  1060. "state_attcode" => "",
  1061. "reconc_keys" => array("org_id", "name"), // inherited attributes
  1062. "db_table" => "servers",
  1063. "db_key_field" => "id",
  1064. "db_finalclass_field" => "",
  1065. "display_template" => "../business/templates/server.html",
  1066. );
  1067. MetaModel::Init_Params($aParams);
  1068. MetaModel::Init_InheritAttributes();
  1069. // MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values"=>new ValueSetEnum("InStore,Shipped,Plugged,ProductionCandidate,InProduction,BeingDeconfigured,Obsolete"), "sql"=>"status", "default_value"=>"InStore", "is_null_allowed"=>false, "depends_on"=>array())));
  1070. MetaModel::Init_AddAttribute(new AttributeString("memory_size", array("allowed_values"=>null, "sql"=>"memory_size", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1071. MetaModel::Init_AddAttribute(new AttributeString("cpu", array("allowed_values"=>null, "sql"=>"cpu_type", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1072. MetaModel::Init_AddAttribute(new AttributeString("number_of_cpus", array("allowed_values"=>null, "sql"=>"number_of_cpus", "default_value"=>"1", "is_null_allowed"=>true, "depends_on"=>array())));
  1073. MetaModel::Init_AddAttribute(new AttributeString("hdd_size", array("allowed_values"=>null, "sql"=>"hdd_size", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1074. MetaModel::Init_AddAttribute(new AttributeString("hdd_free_size", array("allowed_values"=>null, "sql"=>"hdd_free_size", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1075. MetaModel::Init_AddAttribute(new AttributeString("os_family", array("allowed_values"=>null, "sql"=>"os_family", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1076. MetaModel::Init_AddAttribute(new AttributeString("os_version", array("allowed_values"=>null, "sql"=>"os_version", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1077. MetaModel::Init_AddAttribute(new AttributeString("shipment_number", array("allowed_values"=>null, "sql"=>"shipment_number", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1078. MetaModel::Init_AddAttribute(new AttributeString("default_gateway", array("allowed_values"=>null, "sql"=>"default_gateway", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1079. MetaModel::Init_InheritFilters();
  1080. MetaModel::Init_AddFilterFromAttribute("status");
  1081. MetaModel::Init_AddFilterFromAttribute("memory_size");
  1082. MetaModel::Init_AddFilterFromAttribute("cpu");
  1083. MetaModel::Init_AddFilterFromAttribute("number_of_cpus");
  1084. MetaModel::Init_AddFilterFromAttribute("hdd_size");
  1085. MetaModel::Init_AddFilterFromAttribute("hdd_free_size");
  1086. MetaModel::Init_AddFilterFromAttribute("os_family");
  1087. MetaModel::Init_AddFilterFromAttribute("os_version");
  1088. /*
  1089. // Life cycle
  1090. MetaModel::Init_DefineState("InStore", array("attribute_inherit"=>null,
  1091. "attribute_list"=>array()));
  1092. MetaModel::Init_DefineState("Shipped", array("attribute_inherit"=>null,
  1093. "attribute_list"=>array("location_id"=>OPT_ATT_MANDATORY,"serial_number"=>OPT_ATT_MANDATORY,"shipment_number"=>OPT_ATT_MANDATORY)));
  1094. MetaModel::Init_DefineState("Plugged", array("attribute_inherit"=>null,
  1095. "attribute_list"=>array("location_id"=>OPT_ATT_MANDATORY,"mgmt_ip"=>OPT_ATT_MANDATORY,"name"=>OPT_ATT_MANDATORY)));
  1096. MetaModel::Init_DefineState("ProductionCandidate", array("attribute_inherit"=>null,
  1097. "attribute_list"=>array()));
  1098. MetaModel::Init_DefineState("InProduction", array("attribute_inherit"=>null,
  1099. "attribute_list"=>array()));
  1100. MetaModel::Init_DefineState("BeingDeconfigured", array("attribute_inherit"=>null,
  1101. "attribute_list"=>array()));
  1102. MetaModel::Init_DefineState("Obsolete", array("attribute_inherit"=>null,
  1103. "attribute_list"=>array()));
  1104. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_store", array())); // "Store this server / This server is moved to storage"
  1105. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_ship", array())); // "Ship this server / This server is shipped to futur location"
  1106. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_plug", array())); // "Plug this server / The server is pluuged on the network"
  1107. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_configuration_finished", array())); // "Configuration finished / The device is ready to move to production evaluation"
  1108. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_val_failed", array())); // "Review configuration / The configuration for this server is not completed"
  1109. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_mtp", array())); // "Move to Production / The server is moved to production"
  1110. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_decommission", array())); // "Decommission / The server is being decommissioned"
  1111. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_obsolete", array())); // "Obsolete / The server is no more used"
  1112. MetaModel::Init_DefineStimulus(new StimulusUserAction("ev_recycle", array())); // "Recycle this server / The server is move back to deconfiguration"
  1113. MetaModel::Init_DefineTransition("InStore", "ev_ship", array("target_state"=>"Shipped", "actions"=>array(), "user_restriction"=>null));
  1114. MetaModel::Init_DefineTransition("InStore", "ev_plug", array("target_state"=>"Plugged", "actions"=>array(), "user_restriction"=>null));
  1115. MetaModel::Init_DefineTransition("Shipped", "ev_store", array("target_state"=>"InStore", "actions"=>array(), "user_restriction"=>null));
  1116. MetaModel::Init_DefineTransition("Shipped", "ev_plug", array("target_state"=>"Plugged", "actions"=>array(), "user_restriction"=>null));
  1117. MetaModel::Init_DefineTransition("Plugged", "ev_ship", array("target_state"=>"Shipped", "actions"=>array(), "user_restriction"=>null));
  1118. MetaModel::Init_DefineTransition("Plugged", "ev_store", array("target_state"=>"InStore", "actions"=>array(), "user_restriction"=>null));
  1119. MetaModel::Init_DefineTransition("Plugged", "ev_configuration_finished", array("target_state"=>"ProductionCandidate", "actions"=>array(), "user_restriction"=>null));
  1120. MetaModel::Init_DefineTransition("ProductionCandidate", "ev_val_failed", array("target_state"=>"Plugged", "actions"=>array(), "user_restriction"=>null));
  1121. MetaModel::Init_DefineTransition("ProductionCandidate", "ev_mtp", array("target_state"=>"InProduction", "actions"=>array(), "user_restriction"=>null));
  1122. MetaModel::Init_DefineTransition("InProduction", "ev_obsolete", array("target_state"=>"Obsolete", "actions"=>array(), "user_restriction"=>null));
  1123. MetaModel::Init_DefineTransition("InProduction", "ev_decommission", array("target_state"=>"BeingDeconfigured", "actions"=>array(), "user_restriction"=>null));
  1124. MetaModel::Init_DefineTransition("BeingDeconfigured", "ev_ship", array("target_state"=>"Shipped", "actions"=>array(), "user_restriction"=>null));
  1125. MetaModel::Init_DefineTransition("BeingDeconfigured", "ev_plug", array("target_state"=>"Plugged", "actions"=>array(), "user_restriction"=>null));
  1126. MetaModel::Init_DefineTransition("BeingDeconfigured", "ev_store", array("target_state"=>"InStore", "actions"=>array(), "user_restriction"=>null));
  1127. MetaModel::Init_DefineTransition("BeingDeconfigured", "ev_obsolete", array("target_state"=>"Obsolete", "actions"=>array(), "user_restriction"=>null));
  1128. MetaModel::Init_DefineTransition("Obsolete", "ev_recycle", array("target_state"=>"BeingDeconfigured", "actions"=>array(), "user_restriction"=>null));
  1129. */
  1130. // Display lists
  1131. MetaModel::Init_SetZListItems('details', array('name', 'status', 'mgmt_ip','default_gateway', '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
  1132. 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
  1133. // Search criteria
  1134. MetaModel::Init_SetZListItems('standard_search', array('name', 'status','severity', 'brand', 'model', 'os_family', 'location_id')); // Criteria of the std search form
  1135. 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
  1136. }
  1137. function DisplayDetails(WebPage $oPage)
  1138. {
  1139. parent::DisplayDetails($oPage);
  1140. /*
  1141. parent::DisplayDetails($oPage);
  1142. $oSearchFilter = new CMDBSearchFilter('lnkContactRealObject');
  1143. $oSearchFilter->AddCondition('object_id', $this->GetKey(), '=');
  1144. $oSet = new CMDBObjectSet($oSearchFilter);
  1145. $count = $oSet->Count();
  1146. if ($count > 0)
  1147. {
  1148. $oPage->SetCurrentTab("Contacts");
  1149. $oPage->p("$count contact(s) for this server:");
  1150. $this->DisplaySet($oPage, $oSet);
  1151. }
  1152. $oSearchFilter = new CMDBSearchFilter('bizInterface');
  1153. $oSearchFilter->AddCondition('device_id', $this->GetKey(), '=');
  1154. $oSet = new CMDBObjectSet($oSearchFilter);
  1155. $count = $oSet->Count();
  1156. if ($count > 0)
  1157. {
  1158. $oPage->SetCurrentTab("Interfaces");
  1159. $oPage->p("$count interface(s) for this server:");
  1160. $this->DisplaySet($oPage, $oSet);
  1161. }
  1162. $oSearchFilter = new CMDBSearchFilter('Application');
  1163. $oSearchFilter->AddCondition('infra_id', $this->GetKey(), '=');
  1164. $oSet = new CMDBObjectSet($oSearchFilter);
  1165. $count = $oSet->Count();
  1166. if ($count > 0)
  1167. {
  1168. $oPage->SetCurrentTab("Installed applications");
  1169. $oPage->p("$count application(s) installed on this server:");
  1170. $this->DisplaySet($oPage, $oSet);
  1171. }
  1172. $oSearchFilter = new CMDBSearchFilter('bizPatch');
  1173. $oSearchFilter->AddCondition('infra_id', $this->GetKey(), '=');
  1174. $oSet = new CMDBObjectSet($oSearchFilter);
  1175. $count = $oSet->Count();
  1176. if ($count > 0)
  1177. {
  1178. $oPage->SetCurrentTab("Installed patches");
  1179. $oPage->p("$count patch(s) installed on this server:");
  1180. $this->DisplaySet($oPage, $oSet);
  1181. }
  1182. */
  1183. }
  1184. public function Generate(cmdbDataGenerator $oGenerator)
  1185. {
  1186. $this->Set('org_id', $oGenerator->GetOrganizationId());
  1187. $this->Set('location_id', $oGenerator->GenerateKey("bizLocation", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1188. $this->Set('name', $oGenerator->GenerateString("enum(pc,pc,pc,pc,pc,win,redhat,linux,srv,workstation)|number(000-999)|.|domain()"));
  1189. $this->Set('brand', $oGenerator->GenerateString("enum(Hewlett-Packard,Dell,Compaq,Siemens,Packard Bell,IBM,Gateway,Medion,Sony)"));
  1190. $this->Set('model', $oGenerator->GenerateString("enum(Vectra,Deskpro,Dimension,Optiplex,Latitude,Precision,Vaio)"));
  1191. $this->Set('serial_number', $oGenerator->GenerateString("enum(FR,US,TW,CH)|number(000000-999999)"));
  1192. $this->Set('memory_size', $oGenerator->GenerateString("enum(512,1024,2048,4096,2048,4096,8192,8192,8192,16384,32768)"));
  1193. $this->Set('cpu', $oGenerator->GenerateString("enum(Pentium III,Pentium 4,Pentium M,Core Duo,Core 2 Duo,Celeron,Opteron,Thurion,Athlon)"));
  1194. $this->Set('number_of_cpu', $oGenerator->GenerateString("enum(1,1,2,2,2,2,2,4,4,8)"));
  1195. $this->Set('hdd_size', $oGenerator->GenerateString("enum(500,1024,500,1024,500,1024,2048)"));
  1196. $this->Set('hdd_free_size', $this->Get('hdd_size')*$oGenerator->GenerateString("number(20-80)"));
  1197. $this->Set('os_family', $oGenerator->GenerateString("enum(Windows,Windows,Windows,Linux,Windows,Linux,Windows,Linux,Linux,HP-UX,Solaris,AIX)"));
  1198. $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)"));
  1199. }
  1200. }
  1201. ////////////////////////////////////////////////////////////////////////////////////
  1202. /**
  1203. * A network device
  1204. */
  1205. ////////////////////////////////////////////////////////////////////////////////////
  1206. class bizNetworkDevice extends bizDevice
  1207. {
  1208. public static function Init()
  1209. {
  1210. $aParams = array
  1211. (
  1212. "category" => "bizmodel,searchable",
  1213. "name" => "Network Device",
  1214. "description" => "A network device",
  1215. "key_type" => "",
  1216. "key_label" => "id",
  1217. "name_attcode" => "name",
  1218. "state_attcode" => "",
  1219. "reconc_keys" => array("org_id", "name"), // inherited attributes
  1220. "db_table" => "network_devices",
  1221. "db_key_field" => "id",
  1222. "db_finalclass_field" => "",
  1223. "display_template" => "../business/templates/network.device.html",
  1224. );
  1225. MetaModel::Init_Params($aParams);
  1226. MetaModel::Init_InheritAttributes();
  1227. MetaModel::Init_AddAttribute(new AttributeEnum("type", array("allowed_values"=>new ValueSetEnum("switch,router,firewall,load balancer,hub,WAN accelerator"), "sql"=>"type", "default_value"=>"switch", "is_null_allowed"=>false, "depends_on"=>array())));
  1228. MetaModel::Init_AddAttribute(new AttributeString("default_gateway", array("allowed_values"=>null, "sql"=>"default_gateway", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1229. MetaModel::Init_AddAttribute(new AttributeString("ios_version", array("allowed_values"=>null, "sql"=>"ios_version", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1230. MetaModel::Init_AddAttribute(new AttributeString("memory", array("allowed_values"=>null, "sql"=>"memory", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1231. MetaModel::Init_AddAttribute(new AttributeString("snmp_read", array("allowed_values"=>null, "sql"=>"snmp_read", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1232. MetaModel::Init_AddAttribute(new AttributeString("snmp_write", array("allowed_values"=>null, "sql"=>"snmp_write", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1233. MetaModel::Init_InheritFilters();
  1234. MetaModel::Init_AddFilterFromAttribute("type");
  1235. MetaModel::Init_AddFilterFromAttribute("ios_version");
  1236. // Display lists
  1237. MetaModel::Init_SetZListItems('details', array('name', 'status','severity','org_id', 'location_id', 'brand','model','type','mgmt_ip','default_gateway','serial_number','ios_version','memory','snmp_read','snmp_write')); // Attributes to be displayed for the complete details
  1238. MetaModel::Init_SetZListItems('list', array('name', 'status','org_id','brand','model','type','mgmt_ip')); // Attributes to be displayed for a list
  1239. // Search criteria
  1240. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'location_id', 'brand','model','type','mgmt_ip')); // Criteria of the std search form
  1241. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'org_id', 'location_id', 'brand','model','type','mgmt_ip','serial_number','ios_version','snmp_read','snmp_write')); // Criteria of the advanced search form
  1242. }
  1243. public function Generate(cmdbDataGenerator $oGenerator)
  1244. {
  1245. $this->Set('org_id', $oGenerator->GetOrganizationId());
  1246. $this->Set('location_id', $oGenerator->GenerateKey("bizLocation", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1247. $this->Set('name', $oGenerator->GenerateString("enum(sw,swi,switch,rout,rtr,gw)|number(000-999)|.|domain()"));
  1248. $this->Set('brand', $oGenerator->GenerateString("enum(Hewlett-Packard,Cisco,3Com,Avaya,Alcatel,Cabletron,Extrem Networks,Juniper,Netgear,Synopitcs,Xylan)"));
  1249. $this->Set('model', $oGenerator->GenerateString("enum(Procurve ,Catalyst ,Multiswitch ,C)|enum(25,26,36,40,65)|enum(00,09,10,50)"));
  1250. $this->Set('serial_number', $oGenerator->GenerateString("enum(FAA,AGA,PAD,COB,DFE)|number(0000-9999)|enum(M,X,L)"));
  1251. $this->Set('ip_address', $oGenerator->GenerateString("number(10-248)|.|number(1-254)|.|number(1-254)|.|number(1-254)"));
  1252. $this->Set('ios_version', $oGenerator->GenerateString("enum(9,10,12)|.|enum(0,1,2)|enum(,,,,XP,.5.1)"));
  1253. $this->Set('snmp_read', $oGenerator->GenerateString("enum(Ew,+0,**,Ps)|number(00-99)|enum(+,=,],;, )|enum(Aze,Vbn,Bbn,+9+,-9-,#)"));
  1254. $this->Set('snmp_write', $oGenerator->GenerateString("enum(M3,l3,$,*,Zz,Ks,jh)|number(00-99)|enum(A*e,V%n,Bbn,+,-,#)|number(0-9)"));
  1255. }
  1256. }
  1257. ////////////////////////////////////////////////////////////////////////////////////
  1258. /**
  1259. * A "Solution"
  1260. */
  1261. ////////////////////////////////////////////////////////////////////////////////////
  1262. class bizInfraGroup extends logInfra
  1263. {
  1264. public static function Init()
  1265. {
  1266. $aParams = array
  1267. (
  1268. "category" => "bizmodel,searchable",
  1269. "name" => "Infra Group",
  1270. "description" => "A group of infrastructure elements",
  1271. "key_type" => "",
  1272. "key_label" => "id",
  1273. "name_attcode" => "name",
  1274. "state_attcode" => "",
  1275. "reconc_keys" => array("org_id", "name"), // inherited attributes
  1276. "db_table" => "infra_group",
  1277. "db_key_field" => "id",
  1278. "db_finalclass_field" => "",
  1279. "display_template" => "../business/templates/group.html",
  1280. );
  1281. MetaModel::Init_Params($aParams);
  1282. MetaModel::Init_InheritAttributes();
  1283. MetaModel::Init_AddAttribute(new AttributeEnum("type", array("allowed_values"=>new ValueSetEnum("Monitoring,Reporting,list"), "sql"=>"type", "default_value"=>"list", "is_null_allowed"=>true, "depends_on"=>array())));
  1284. MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1285. MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_group_id", array("targetclass"=>"bizInfraGroup", "allowed_values"=>null, "sql"=>"parent_group_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  1286. MetaModel::Init_AddAttribute(new AttributeExternalField("parent_group_name", array("allowed_values"=>null, "extkey_attcode"=> 'parent_group_id', "target_attcode"=>"name")));
  1287. MetaModel::Init_InheritFilters();
  1288. MetaModel::Init_AddFilterFromAttribute("type");
  1289. MetaModel::Init_AddFilterFromAttribute("parent_group_id");
  1290. MetaModel::Init_AddFilterFromAttribute("parent_group_name");
  1291. // Display lists
  1292. MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'type', 'description','parent_group_id')); // Attributes to be displayed for a list
  1293. MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'type', 'description')); // Attributes to be displayed for a list
  1294. // Search criteria
  1295. MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'type')); // Criteria of the std search form
  1296. MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'type', 'description', 'org_id')); // Criteria of the advanced search form
  1297. }
  1298. function DisplayDetails(WebPage $oPage)
  1299. {
  1300. parent::DisplayDetails($oPage);
  1301. /*
  1302. $oSearchFilter = new CMDBSearchFilter('lnkInfraGrouping');
  1303. $oSearchFilter->AddCondition('infra_group_id', $this->GetKey(), '=');
  1304. $oSet = new CMDBObjectSet($oSearchFilter);
  1305. $count = $oSet->Count();
  1306. if ($count > 0)
  1307. {
  1308. $oPage->SetCurrentTab("RelatedInfrastructure");
  1309. $oPage->p("Infrastructure Link to this group:");
  1310. $this->DisplaySet($oPage, $oSet);
  1311. }
  1312. $oSearchFilter = new CMDBSearchFilter('lnkContactRealObject');
  1313. $oSearchFilter->AddCondition('object_id', $this->GetKey(), '=');
  1314. $oSet = new CMDBObjectSet($oSearchFilter);
  1315. $count = $oSet->Count();
  1316. if ($count > 0)
  1317. {
  1318. $oPage->SetCurrentTab("TeamLinks");
  1319. $oPage->p("People concerned by this group:");
  1320. $this->DisplaySet($oPage, $oSet);
  1321. }
  1322. */
  1323. }
  1324. public function Generate(cmdbDataGenerator $oGenerator)
  1325. {
  1326. $this->Set('org_id', $oGenerator->GetOrganizationId());
  1327. $this->Set('name', $oGenerator->GenerateString("enum(ov_nnm_,ovpi_,vitalnet_,datacenter_,web_farm_)|number(000-999)"));
  1328. $this->Set('type', $oGenerator->GenerateString("enum(Application,Infrastructure)"));
  1329. }
  1330. }
  1331. ////////////////////////////////////////////////////////////////////////////////////
  1332. //**
  1333. //* An application is an instance of a software install on a PC or Server
  1334. //*
  1335. ////////////////////////////////////////////////////////////////////////////////////
  1336. class bizApplication extends logInfra
  1337. {
  1338. public static function Init()
  1339. {
  1340. $aParams = array
  1341. (
  1342. "category" => "bizmodel,searchable",
  1343. "name" => "Application",
  1344. "description" => "General application",
  1345. "key_type" => "",
  1346. "key_label" => "id",
  1347. "name_attcode" => "name",
  1348. "state_attcode" => "",
  1349. "reconc_keys" => array("device_id", "name"), // inherited attributes
  1350. "db_table" => "applications",
  1351. "db_key_field" => "id",
  1352. "db_finalclass_field" => "",
  1353. "display_template" => "../business/templates/application.html",
  1354. );
  1355. MetaModel::Init_Params($aParams);
  1356. MetaModel::Init_InheritAttributes();
  1357. MetaModel::Init_AddAttribute(new AttributeExternalKey("device_id", array("targetclass"=>"bizDevice", "jointype"=> '', "allowed_values"=>new ValueSetObjects('SELECT bizDevice AS p WHERE p.org_id = :this->org_id'), "sql"=>"device_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("org_id"))));
  1358. MetaModel::Init_AddAttribute(new AttributeExternalField("device_name", array("allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"name")));
  1359. MetaModel::Init_AddAttribute(new AttributeDate("install_date", array("allowed_values"=>null, "sql"=>"install_date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1360. MetaModel::Init_AddAttribute(new AttributeString("version", array("allowed_values"=>null, "sql"=>"version", "default_value"=>"undefined", "is_null_allowed"=>false, "depends_on"=>array())));
  1361. MetaModel::Init_AddAttribute(new AttributeString("function", array("allowed_values"=>null, "sql"=>"function", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1362. MetaModel::Init_InheritFilters();
  1363. MetaModel::Init_AddFilterFromAttribute("function");
  1364. MetaModel::Init_AddFilterFromAttribute("version");
  1365. MetaModel::Init_AddFilterFromAttribute("device_id");
  1366. MetaModel::Init_AddFilterFromAttribute("device_name");
  1367. // Display lists
  1368. MetaModel::Init_SetZListItems('details', array('name','device_id','org_id','status','install_date', 'version','function')); // Attributes to be displayed for the complete details
  1369. MetaModel::Init_SetZListItems('list', array('name','device_id', 'version', 'function')); // Attributes to be displayed for a list
  1370. // Search criteria
  1371. MetaModel::Init_SetZListItems('standard_search', array('name', 'device_id','version','function')); // Criteria of the std search form
  1372. MetaModel::Init_SetZListItems('advanced_search', array('name', 'device_id','version','function')); // Criteria of the advanced search form
  1373. }
  1374. public static function GetRelationQueries($sRelCode)
  1375. {
  1376. switch ($sRelCode)
  1377. {
  1378. case "impacts":
  1379. $aRels = array(
  1380. );
  1381. return array_merge($aRels, parent::GetRelationQueries($sRelCode));
  1382. }
  1383. }
  1384. function DisplayDetails(WebPage $oPage)
  1385. {
  1386. parent::DisplayDetails($oPage);
  1387. /*
  1388. $oSearchFilter = new CMDBSearchFilter('lnkClientServer');
  1389. $oSearchFilter->AddCondition('server_id', $this->GetKey(), '=');
  1390. $oSet = new CMDBObjectSet($oSearchFilter);
  1391. $count = $oSet->Count();
  1392. if ($count > 0)
  1393. {
  1394. $oPage->SetCurrentTab("Connected clients");
  1395. $oPage->p("Client applications impacted when down:");
  1396. $this->DisplaySet($oPage, $oSet);
  1397. }
  1398. */
  1399. }
  1400. }
  1401. ////////////////////////////////////////////////////////////////////////////////////
  1402. /**
  1403. * n-n link between any Infra and a Group
  1404. */
  1405. ////////////////////////////////////////////////////////////////////////////////////
  1406. class lnkInfraGrouping extends cmdbAbstractObject
  1407. {
  1408. public static function Init()
  1409. {
  1410. $aParams = array
  1411. (
  1412. "category" => "bizmodel,searchable",
  1413. "name" => "Infra Grouping",
  1414. "description" => "Infra part of an Infra Group",
  1415. "key_type" => "autoincrement",
  1416. "key_label" => "link_id",
  1417. "name_attcode" => "impact",
  1418. "state_attcode" => "",
  1419. "reconc_keys" => array(""),
  1420. "db_table" => "infra_grouping",
  1421. "db_key_field" => "link_id",
  1422. "db_finalclass_field" => "",
  1423. "display_template" => "../business/templates/default.html",
  1424. );
  1425. MetaModel::Init_Params($aParams);
  1426. MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_id", array("targetclass"=>"logInfra", "jointype"=> '', "allowed_values"=>null, "sql"=>"infra_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  1427. MetaModel::Init_AddAttribute(new AttributeExternalField("infra_name", array("allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"name")));
  1428. MetaModel::Init_AddAttribute(new AttributeExternalField("infra_status", array("allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"status")));
  1429. MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_group_id", array("targetclass"=>"bizInfraGroup", "jointype"=> '', "allowed_values"=>null, "sql"=>"infra_group_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  1430. MetaModel::Init_AddAttribute(new AttributeExternalField("group_name", array("allowed_values"=>null, "extkey_attcode"=> 'infra_group_id', "target_attcode"=>"name")));
  1431. MetaModel::Init_AddAttribute(new AttributeString("impact", array("allowed_values"=>null, "sql"=>"impact", "default_value"=>"none", "is_null_allowed"=>true, "depends_on"=>array())));
  1432. // impact should modelized: enum (eg: if the group si dead when infra is dead)
  1433. MetaModel::Init_AddFilterFromAttribute("infra_id");
  1434. MetaModel::Init_AddFilterFromAttribute("infra_group_id");
  1435. MetaModel::Init_AddFilterFromAttribute("impact");
  1436. // Display lists
  1437. MetaModel::Init_SetZListItems('details', array('infra_id','infra_status', 'impact', 'infra_group_id')); // Attributes to be displayed for a list
  1438. MetaModel::Init_SetZListItems('list', array('infra_id','infra_status', 'impact', 'infra_group_id')); // Attributes to be displayed for a list
  1439. // Search criteria
  1440. MetaModel::Init_SetZListItems('standard_search', array('infra_id', 'infra_group_id', 'impact')); // Criteria of the std search form
  1441. MetaModel::Init_SetZListItems('advanced_search', array('infra_id', 'infra_group_id', 'impact')); // Criteria of the advanced search form
  1442. }
  1443. public function Generate(cmdbDataGenerator $oGenerator)
  1444. {
  1445. $this->Set('infra_id', $oGenerator->GenerateKey("logInfra", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1446. $this->Set('infra_group_id', $oGenerator->GenerateKey("bizInfraGroup", array('org_id' =>$oGenerator->GetOrganizationId() )));
  1447. $this->Set('impact', $oGenerator->GenerateString("enum(none,mandatory,partial)"));
  1448. }
  1449. }
  1450. ////////////////////////////////////////////////////////////////////////////////////
  1451. /**
  1452. * n-n link between two applications, one is the server side and the scond one the client*/
  1453. ////////////////////////////////////////////////////////////////////////////////////
  1454. class lnkClientServer extends logRealObject
  1455. {
  1456. public static function Init()
  1457. {
  1458. $aParams = array
  1459. (
  1460. "category" => "bizmodel,searchable",
  1461. "name" => "ClientServerLinks",
  1462. "description" => "Link between client server application",
  1463. "key_type" => "autoincrement",
  1464. "key_label" => "link_id",
  1465. "name_attcode" => "relation", // ????
  1466. "state_attcode" => "",
  1467. "reconc_keys" => array("relation"), // ????
  1468. "db_table" => "clientserver_links",
  1469. "db_key_field" => "link_id",
  1470. "db_finalclass_field" => "",
  1471. "display_template" => "../business/templates/default.html",
  1472. );
  1473. MetaModel::Init_Params($aParams);
  1474. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values"=>new ValueSetEnum('production,implementation,obsolete'), "sql"=>"status", "default_value"=>"production", "is_null_allowed"=>false, "depends_on"=>array())));
  1475. MetaModel::Init_AddAttribute(new AttributeExternalKey("client_id", array("targetclass"=>"bizApplication", "jointype"=> '', "allowed_values"=>null, "sql"=>"client_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  1476. MetaModel::Init_AddAttribute(new AttributeExternalField("client_name", array("allowed_values"=>null, "extkey_attcode"=> 'client_id', "target_attcode"=>"name")));
  1477. MetaModel::Init_AddAttribute(new AttributeExternalKey("server_id", array("targetclass"=>"bizApplication", "jointype"=> '', "allowed_values"=>null, "sql"=>"server_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  1478. MetaModel::Init_AddAttribute(new AttributeExternalField("server_name", array("allowed_values"=>null, "extkey_attcode"=> 'server_id', "target_attcode"=>"name")));
  1479. MetaModel::Init_AddAttribute(new AttributeString("relation", array("allowed_values"=>null, "sql"=>"relation", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1480. MetaModel::Init_AddFilterFromAttribute("client_id");
  1481. MetaModel::Init_AddFilterFromAttribute("server_id");
  1482. // Display lists
  1483. MetaModel::Init_SetZListItems('details', array('client_id', 'server_id', 'relation')); // Attributes to be displayed for a list
  1484. MetaModel::Init_SetZListItems('list', array('client_id', 'server_id', 'relation')); // Attributes to be displayed for a list
  1485. // Search criteria
  1486. MetaModel::Init_SetZListItems('standard_search', array('client_id', 'server_id')); // Criteria of the std search form
  1487. MetaModel::Init_SetZListItems('advanced_search', array('client_id', 'server_id')); // Criteria of the advanced search form
  1488. }
  1489. }
  1490. ////////////////////////////////////////////////////////////////////////////////////
  1491. //**
  1492. //* A patch is an application or OS fixe for an infrastructure
  1493. //*
  1494. ////////////////////////////////////////////////////////////////////////////////////
  1495. class bizPatch extends logRealObject
  1496. {
  1497. public static function Init()
  1498. {
  1499. $aParams = array
  1500. (
  1501. "category" => "bizmodel,searchable",
  1502. "name" => "Patch",
  1503. "description" => "Patch installed on infrastucture",
  1504. "key_type" => "",
  1505. "key_label" => "id",
  1506. "name_attcode" => "name",
  1507. "state_attcode" => "",
  1508. "reconc_keys" => array("device_id", "name"), // inherited attributes
  1509. "db_table" => "patches",
  1510. "db_key_field" => "id",
  1511. "db_finalclass_field" => "",
  1512. "display_template" => "../business/templates/default.html",
  1513. );
  1514. MetaModel::Init_Params($aParams);
  1515. MetaModel::Init_InheritAttributes();
  1516. MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values"=>new ValueSetEnum('production,obsolete'), "sql"=>"status", "default_value"=>"production", "is_null_allowed"=>false, "depends_on"=>array())));
  1517. MetaModel::Init_AddAttribute(new AttributeExternalKey("device_id", array("targetclass"=>"bizDevice", "jointype"=> '', "allowed_values"=>new ValueSetObjects('SELECT bizDevice AS p WHERE p.org_id = :this->org_id'), "sql"=>"device_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("org_id"))));
  1518. MetaModel::Init_AddAttribute(new AttributeExternalField("device_name", array("allowed_values"=>null, "extkey_attcode"=> 'device_id', "target_attcode"=>"name")));
  1519. MetaModel::Init_AddAttribute(new AttributeDate("install_date", array("allowed_values"=>null, "sql"=>"install_date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  1520. MetaModel::Init_AddAttribute(new AttributeText("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  1521. MetaModel::Init_AddAttribute(new AttributeString("patch_type", array("allowed_values"=>new ValueSetEnum("OS,Application"), "sql"=>"patch_type", "default_value"=>"OS", "is_null_allowed"=>false, "depends_on"=>array())));
  1522. MetaModel::Init_InheritFilters();
  1523. MetaModel::Init_AddFilterFromAttribute("patch_type");
  1524. MetaModel::Init_AddFilterFromAttribute("device_id");
  1525. // Display lists
  1526. MetaModel::Init_SetZListItems('details', array('name','device_id', 'install_date', 'patch_type','description')); // Attributes to be displayed for the complete details
  1527. MetaModel::Init_SetZListItems('list', array('name','device_id', 'patch_type','install_date')); // Attributes to be displayed for a list
  1528. // Search criteria
  1529. MetaModel::Init_SetZListItems('standard_search', array('name', 'device_id','patch_type')); // Criteria of the std search form
  1530. MetaModel::Init_SetZListItems('advanced_search', array('name', 'device_id','patch_type')); // Criteria of the advanced search form
  1531. }
  1532. }
  1533. /*** Insert here all modules requires for ITOP application ***/
  1534. require_once('incidentMgmt.business.php');
  1535. require_once('ServiceMgmt.business.php');
  1536. require_once('ChangeMgmt.business.php');
  1537. require_once('KEDB.business.php');
  1538. require_once('ServiceDesk.business.php');
  1539. ?>