itop.business.class.inc.php 84 KB

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