Source for file PrimitiveIOManager.class.php

Documentation is available at PrimitiveIOManager.class.php

  1. <?php
  2. /**
  3. * @package polyphony.datamanager_gui
  4. *
  5. * @copyright Copyright &copy; 2005, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: PrimitiveIOManager.class.php,v 1.13 2007/09/19 14:04:44 adamfranco Exp $
  9. */
  10.  
  11. /**
  12. * Handles the creation of {@link PrimitiveIO} objects for different data types, as registered with the DataTypeManager of Harmoni.
  13. *
  14. * @package polyphony.datamanager_gui
  15. *
  16. * @copyright Copyright &copy; 2005, Middlebury College
  17. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  18. *
  19. * @version $Id: PrimitiveIOManager.class.php,v 1.13 2007/09/19 14:04:44 adamfranco Exp $
  20. * @author Gabe Schine
  21. */
  22. class PrimitiveIOManager {
  23. /**
  24. * Creates a new {@link PrimitiveIO} object for the given dataType.
  25. * @param string $dataType a datatype string as registered with the DataManager of Harmoni
  26. * @return ref object A new {@link PrimitiveIO} object.
  27. * @access public
  28. * @static
  29. */
  30. function createComponent($dataType) {
  31. $class = "PrimitiveIO_".$dataType;
  32. if (!class_exists($class)) return ($null=null);
  33.  
  34. $obj = new $class();
  35.  
  36. return $obj;
  37. }
  38.  
  39. /**
  40. * Creates a new {@link PrimitiveIO} object for the given dataType.
  41. * @param string $dataType a datatype string as registered with the DataManager of Harmoni
  42. * @return ref object A new {@link PrimitiveIO} object.
  43. * @access public
  44. * @static
  45. */
  46. function createAuthoritativeComponent($dataType) {
  47. $class = "PrimitiveIO_Authoritative_".$dataType;
  48. if (!class_exists($class)) return ($null=null);
  49.  
  50. $obj = new $class();
  51.  
  52. return $obj;
  53. }
  54. /**
  55. * Create a new PrimitiveIO object that allows for selection from an authority
  56. * list
  57. *
  58. * @param <##>
  59. * @return <##>
  60. * @access public
  61. * @since 5/1/06
  62. */
  63. function createComponentForPartStructure ($partStruct) {
  64. ArgumentValidator::validate($partStruct, ExtendsValidatorRule::getRule("PartStructure"));
  65. $partStructType =$partStruct->getType();
  66. // get the datamanager data type
  67. $dataType = $partStructType->getKeyword();
  68. // printpre($dataType);
  69. $authoritativeValues =$partStruct->getAuthoritativeValues();
  70. if ($authoritativeValues->hasNext()) {
  71. $authZManager = Services::getService("AuthZ");
  72. $idManager = Services::getService("Id");
  73. if ($authZManager->isUserAuthorized(
  74. $idManager->getId("edu.middlebury.authorization.modify_authority_list"),
  75. $partStruct->getRepositoryId()))
  76. {
  77. $component = new PrimitiveIO_AuthoritativeContainer();
  78. $component->setSelectComponent(
  79. PrimitiveIOManager::createAuthoritativeComponent($dataType));
  80. $component->setNewComponent(
  81. PrimitiveIOManager::createComponent($dataType));
  82. } else {
  83. $component = PrimitiveIOManager::createAuthoritativeComponent($dataType);
  84. }
  85. while($authoritativeValues->hasNext()) {
  86. $component->addOptionFromSObject($authoritativeValues->next());
  87. }
  88. } else {
  89. // get the simple component for this data type
  90. $component = PrimitiveIOManager::createComponent($dataType);
  91. }
  92. return $component;
  93. }
  94. }

Documentation generated on Wed, 19 Sep 2007 10:25:36 -0400 by phpDocumentor 1.3.0RC3