Source for file TabAssetIterator.class.php

Documentation is available at TabAssetIterator.class.php

  1. <?php
  2. /**
  3. * @since 7/20/05
  4. * @package polyphony.repository_importer
  5. *
  6. * @copyright Copyright &copy; 2005, Middlebury College
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  8. *
  9. * @version $Id: TabAssetIterator.class.php,v 1.12 2007/09/19 14:04:48 adamfranco Exp $
  10. */
  11.  
  12. /**
  13. * <##>
  14. *
  15. * @since 7/20/05
  16. * @package polyphony.repository_importer
  17. *
  18. * @copyright Copyright &copy; 2005, Middlebury College
  19. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  20. *
  21. * @version $Id: TabAssetIterator.class.php,v 1.12 2007/09/19 14:04:48 adamfranco Exp $
  22. */
  23. class TabAssetIterator
  24. extends HarmoniIterator
  25. {
  26. /**
  27. * Index for iterator
  28. *
  29. * @var integer $_current
  30. */
  31. var $_current;
  32. /**
  33. * Array for Iterator
  34. *
  35. * @var array $_assetList
  36. */
  37. var $_assetList;
  38. /**
  39. * Constructor
  40. *
  41. * @return object
  42. * @access public
  43. * @since 7/20/05
  44. */
  45. function TabAssetIterator ($srcDir, $parentRepositoryImporter) {
  46. if (Services::serviceRunning("Logging")) {
  47. $loggingManager = Services::getService("Logging");
  48. $log =$loggingManager->getLogForWriting("Harmoni");
  49. $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes",
  50. "A format in which the acting Agent[s] and the target nodes affected are specified.");
  51. $priorityType = new Type("logging", "edu.middlebury", "Error",
  52. "Events involving critical system errors.");
  53. }
  54. if (file_exists($srcDir."metadata.txt") &&
  55. $meta = fopen($srcDir."metadata.txt", "r"))
  56. {
  57. fgets($meta);
  58. fgets($meta);
  59. while ($line = ereg_replace("[\n\r]*$","",fgets($meta))) {
  60. $metadata = explode("\t", $line);
  61. $this->_assetList[] = $metadata;
  62. }
  63. if (count($this->_assetList) == 0) {
  64. $parentRepositoryImporter->addError("There are no assets to import in: ".$srcDir."metadata.txt.");
  65. if (isset($log)) {
  66. $item = new AgentNodeEntryItem("TabImporter Error",
  67. "There are no assets to import in: $srcDir/metadata.txt.");
  68. $log->appendLogWithTypes($item, $formatType, $priorityType);
  69. }
  70. }
  71. fclose($meta);
  72. $this->_current = 0;
  73. }
  74. else {
  75. $parentRepositoryImporter->addError("Tab-Delimited parse failed: ".$srcDir."metadata.txt does not exist or is unreadable.");
  76. if (isset($log)) {
  77. $item = new AgentNodeEntryItem("TabImporter Error",
  78. "Tab-Delimited parse failed: $srcDir/metadata.txt does not exist or is unreadable.");
  79. $log->appendLogWithTypes($item, $formatType, $priorityType);
  80. }
  81. }
  82. }
  83. /**
  84. * checks for existence of next element
  85. *
  86. * @return boolean
  87. * @access public
  88. * @since 7/20/05
  89. */
  90. function hasNext () {
  91. if ($this->_current < count($this->_assetList))
  92. return true;
  93. else
  94. return false;
  95. }
  96. /**
  97. * returns the next element
  98. *
  99. * @return object DOMIT_Node
  100. * @access public
  101. * @since 7/20/05
  102. */
  103. function next() {
  104. $temp =$this->_assetList[$this->_current];
  105. $this->_current++;
  106. return $temp;
  107. }
  108. }
  109.  
  110. ?>

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