itop.business.class.inc.php 90 KB

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