@@ -40,8 +40,38 @@ function getBy($os, $condition, $expiration_date = false, $status = MIDAS_REMOTE
40
40
return $ return ;
41
41
}
42
42
43
+ /** get Related Items */
44
+ function getRelatedItems ($ job )
45
+ {
46
+ if (!$ job instanceof Remoteprocessing_JobDao)
47
+ {
48
+ throw new Zend_Exception ("Should be an item. " );
49
+ }
50
+
51
+ $ sql = $ this ->database ->select ()
52
+ ->from ('remoteprocessing_job2item ' )
53
+ ->setIntegrityCheck (false )
54
+ ->where ('job_id = ? ' , $ job ->getKey ())
55
+ ->order ('item_id DESC ' );
56
+
57
+ $ loader = new MIDAS_ModelLoader ();
58
+ $ itemModel = $ loader ->loadModel ('Item ' );
59
+ $ rowset = $ this ->database ->fetchAll ($ sql );
60
+ $ return = array ();
61
+ foreach ($ rowset as $ row )
62
+ {
63
+ $ tmpDao = $ itemModel ->load ($ row ['item_id ' ]);
64
+ if ($ tmpDao != false )
65
+ {
66
+ $ return [] = $ tmpDao ;
67
+ unset($ tmpDao );
68
+ }
69
+ }
70
+ return $ return ;
71
+ }
72
+
43
73
/** add item relation*/
44
- function addItemRelation ($ job , $ item )
74
+ function addItemRelation ($ job , $ item, $ type = MIDAS_REMOTEPROCESSING_RELATION_TYPE_EXECUTABLE )
45
75
{
46
76
if (!$ job instanceof Remoteprocessing_JobDao)
47
77
{
@@ -51,7 +81,15 @@ function addItemRelation($job, $item)
51
81
{
52
82
throw new Zend_Exception ("Should be an item. " );
53
83
}
84
+ if (!is_numeric ($ type ))
85
+ {
86
+ throw new Zend_Exception ("Should be a number. " );
87
+ }
54
88
$ this ->database ->link ('items ' , $ job , $ item );
89
+
90
+ // sql because the query is simple and it
91
+ $ data = array ('type ' => $ type );
92
+ $ this ->database ->update ('remoteprocessing_job2item ' , $ data , 'job_id = ' .$ job ->getKey ().' AND item_id = ' .$ item ->getKey ());
55
93
}
56
94
57
95
/** get related job */
0 commit comments