File size: 4,642 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
//require_once 'classes/model/om/BaseAppSolrQueue.php';
//require_once 'classes/entities/AppSolrQueue.php';

/**
 * Skeleton subclass for representing a row from the 'APP_SOLR_QUEUE' table.
 *
 *
 *
 * You should add additional methods to this class to meet the
 * application requirements. This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package classes.model
 */
class AppSolrQueue extends BaseAppSolrQueue
{

    public function exists ($sAppUid)
    {
        try {
            $oRow = AppSolrQueuePeer::retrieveByPK( $sAppUid );
            if (! is_null( $oRow )) {
                return true;
            } else {
                return false;
            }
        } catch (Exception $oError) {
            return false;
        }
    }

    public function createUpdate($sAppUid, $sAppChangeTrace, $iUpdated)
    {
        $con = Propel::getConnection( AppSolrQueuePeer::DATABASE_NAME );
        try {
            if ($this->exists( $sAppUid )) {
                $con->begin();
                //update record
                //$oRow = AppSolrQueuePeer::retrieveByPK( $sAppUid );
                //$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
                //$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
                $this->setNew( false );
                //set field
                $this->setAppUid($sAppUid);
                $this->setAppChangeDate("now");
                $this->setAppChangeTrace($sAppChangeTrace);
                $this->setAppUpdated($iUpdated);
                if ($this->validate()) {
                    $result = $this->save();
                } else {
                    $con->rollback();
                    throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
                }
                $con->commit();
                return $result;
            } else {
                //create record
                //set values
                $this->setAppUid($sAppUid);
                $this->setAppChangeDate("now");
                $this->setAppChangeTrace($sAppChangeTrace);
                $this->setAppUpdated($iUpdated);
                if ($this->validate()) {
                    $result = $this->save();
                } else {
                    $e = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
                    //$e->aValidationFailures=$this->getValidationFailures();
                    throw ($e);
                }
                $con->commit();
                return $result;
            }
        } catch (Exception $e) {
            $con->rollback();
            throw ($e);
        }
    }

    /**
     * Returns the list of updated applications
     * array of Entity_AppSolrQueue
     */
    public function getListUpdatedApplications($updated = true, $deleted = true)
    {
        $updatedApplications = array ();
        try {
            $c = new Criteria();
            
            $c->addSelectColumn(AppSolrQueuePeer::APP_UID);
            $c->addSelectColumn(AppSolrQueuePeer::APP_CHANGE_DATE);
            $c->addSelectColumn(AppSolrQueuePeer::APP_CHANGE_TRACE);
            $c->addSelectColumn(AppSolrQueuePeer::APP_UPDATED);
            
            //"WHERE 
            if($updated == true && $deleted == true){
                $c->add(AppSolrQueuePeer::APP_UPDATED, 0, Criteria::NOT_EQUAL);    
            }
            if($updated == true && $deleted == false){
                $c->add(AppSolrQueuePeer::APP_UPDATED, 1, Criteria::EQUAL);    
            }
            if($updated == false && $deleted == true){
                $c->add(AppSolrQueuePeer::APP_UPDATED, 2, Criteria::EQUAL);    
            }
            
            $rs = AppSolrQueuePeer::doSelectRS($c);
            $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            //echo $c->toString();
            $rs->next();
            $row = $rs->getRow();

            while (is_array( $row )) {
                $appSolrQueue = EntityAppSolrQueue::createEmpty();
                $appSolrQueue->appUid = $row["APP_UID"];
                $appSolrQueue->appChangeDate = $row["APP_CHANGE_DATE"];
                $appSolrQueue->appChangeTrace = $row["APP_CHANGE_TRACE"];
                $appSolrQueue->appUpdated = $row["APP_UPDATED"];
                $updatedApplications[] = $appSolrQueue;
                $rs->next();
                $row = $rs->getRow();
            }
            
            return $updatedApplications;
        } catch (Exception $e) {
            $con->rollback();
            throw ($e);
        }
    }
} // AppSolrQueue