itop.business.class.inc.php 84 KB

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