Example #1
0
 /**
  *
  *
  * @param array $data
  * @return base_database_Where|null
  * @throws base_database_Exception
  */
 protected function getWhereForFindExistingData(array $data)
 {
     if (!isset($data['name']) || !isset($data['FK_tsmserver'])) {
         return null;
     }
     $table = DB::table($this->obj->getTable());
     $column = $table->getColumn('name');
     $where = DB::where($column, DB::term($data['name']));
     $where->addAnd($table->getColumn('FK_tsmserver'), DB::intTerm($data['FK_tsmserver']));
     $where->addAnd($table->getColumn('histtop'), DB::term('Y'));
     return $where;
 }
Example #2
0
 public function mapFieldValue($value)
 {
     $obj = Factory::createObject('vendor');
     $table = DB::table($obj->getTable());
     $where = DB::where($table->getColumn('name'), DB::term($value));
     $finder = Finder::create('vendor')->setWhere($where);
     $result = $finder->find(array($table->getColumn('LK')));
     if (count($result) > 1) {
         throw new base_exception_Mapper(TMS('medexchange.exception.mapper.vendorDuplicatedEntry'));
     }
     $lkArray = $result[0];
     return $lkArray['LK'];
 }
Example #3
0
 /**
  * load the right object by its name
  *
  * @param $name
  * @return mixed|null
  * @throws base_database_Exception
  */
 public static function getGroupLKByName($name)
 {
     $table = DB::table('gruppe');
     $column = $table->getColumn('name');
     $where = DB::where($column, DB::term($name));
     $finder = Finder::create('group')->setWhere($where);
     $results = $finder->find(array($table->getColumn('LK')));
     if (empty($results)) {
         return null;
     }
     $result = $results[0];
     return $result['LK'];
 }
Example #4
0
    /**
     * converts a given value to the specified structure
     *
     * @param $value
     * @return mixed
     * @throws base_database_Exception
     * @throws base_exception_Mapper
     */
    public function mapFieldValue($value)
    {
        $obj = Factory::createObject('TSMCollocgroup');
        $table = DB::table($obj->getTable());
        $where = DB::where($table->getColumn('name'), DB::term($value));
        $where->addAnd($table->getColumn('FK_tsmserver'), DB::term(TSMServerManager::get()->getActualTsmServerLK()));
        $finder = Finder::create('TSMCollocgroup')->setWhere($where);
        $result = $finder->find(array($table->getColumn('LK')));

        if (count($result) > 1) {
            throw new base_exception_Mapper(TMS('tsmviewer.exception.mapper.collocgroupDuplicatedEntry'));
        }

        $lkArray = current($result);

        return $lkArray['LK'];
    }
Example #5
0
File: CSV.php Project: kafruhs/fws
    /**
     * @throws base_database_Exception
     */
    public function import()
    {

        DB::beginTransaction();
        foreach ($this->_data as $data) {
            $result = null;
            $where = $this->getWhereForExistingData($data);
            if ($where instanceof base_database_Where) {
                $result = $this->getExistingObjects($where);
            }
            $statement = $this->getStatementForImport($result);
            $statement->setTable($this->table);
            foreach ($data as $colName => $value) {
                $statement->setColumnValue($this->table->getColumn($colName), DB::term($value));
            }
            $statement->insertDatabase();
        }
        DB::endTransaction();
    }
Example #6
0
 protected function getWhereForFindExistingData(array $data)
 {
     if (!isset($data['nodeName']) || !isset($data['startTime']) || !isset($data['subEntity'])) {
         return null;
     }
     $table = DB::table($this->obj->getTable());
     $nameCol = $table->getColumn('nodeName');
     $startTimeCol = $table->getColumn('startTime');
     $where = DB::where($nameCol, DB::term($data['nodeName']));
     $date = new base_date_model_DateTime(new DateTime($data['startTime']));
     $where->addAnd($startTimeCol, DB::term($date->toDB()));
     if (!empty($data['subEntity'])) {
         $subEntityCol = $table->getColumn('subEntity');
         $where->addAnd($subEntityCol, DB::term($data['subEntity']));
     }
     $where->addAnd($table->getColumn('FK_tsmserver'), DB::intTerm($data['FK_tsmserver']));
     $where->addAnd($table->getColumn('histtop'), DB::term('Y'));
     return $where;
 }
Example #7
0
 protected function getData()
 {
     $requestHelper = $this->controller->getRequestHelper();
     $pzn = $requestHelper->getParam('pzn');
     $obj = Factory::createObject('medicament');
     $table = DB::table($obj->getTable());
     $where = DB::where($table->getColumn('pzn'), DB::term($pzn));
     $finder = Finder::create('medicament')->setWhere($where);
     $result = $finder->find();
     if (empty($result)) {
         return array();
     }
     /** @var BaseObject $obj */
     $obj = $result[0];
     foreach ($obj->getAllFields() as $fi) {
         if ($fi->getDisplayClass() == 'system') {
             continue;
         }
         $values[$fi->getFieldName()] = $obj->getField($fi->getFieldName());
     }
     return $values;
 }
Example #8
0
 /**
  * insert a new revision of the given Object
  *
  * @param base_database_Table
  * @throws base_database_Exception
  */
 private function _insertNewData(base_database_Table $table)
 {
     $statement = new base_database_statement_Insert();
     $statement->setTable($table);
     foreach ($this->_fields as $fieldName => $value) {
         if (empty($value) || $fieldName == 'PK') {
             continue;
         }
         if (in_array($fieldName, $this->mnFields)) {
             continue;
         }
         $fi = $this->getFieldinfo($fieldName);
         $dtObj = $fi->getDatatypeObject();
         $value = $dtObj->toDB($value);
         $statement->setColumnValue($table->getColumn($fieldName), DB::term($value));
     }
     $statement->insertDatabase();
     foreach ($this->mnFields as $fieldName) {
         $fi = $this->getFieldinfo($fieldName);
         $this->_saveMNField($fi);
     }
 }
Example #9
0
    /**
     * validates the given values for the properties
     *
     * @throws base_exception_BaseConnectionObject
     */
    private function _validateNeededInformation()
    {
        $properties = ['classLeft', 'classRight', 'lkLeft', 'lkRight'];
        foreach ($properties as $property) {
            if (!isset($this->$property)) {
                throw new base_exception_BaseConnectionObject(TMS(base_exception_BaseConnectionObject::PROPERTY_NOT_SET, array('property' => $property)));
            }
        }

        if (is_null(Factory::loadObject($this->classLeft, $this->lkLeft))) {
            throw new base_exception_BaseConnectionObject(TMS(base_exception_BaseConnectionObject::OBJECT_NOT_EXISTS, array('class' => $this->classLeft, 'lk' => $this->lkLeft)));
        }

        if (is_null(Factory::loadObject($this->classRight, $this->lkRight))) {
            throw new base_exception_BaseConnectionObject(TMS(base_exception_BaseConnectionObject::OBJECT_NOT_EXISTS, array('class' => $this->classRight, 'lk' => $this->lkRight)));
        }

        $select = new base_database_statement_Select();
        $table = DB::table($this->table);
        $select->setTable($table);
        $where = DB::where($table->getColumn('classLeft'), DB::term($this->classLeft));
        $where->addAnd($table->getColumn('classRight'), DB::term($this->classRight));
        $where->addAnd($table->getColumn('lkRight'), DB::term($this->lkRight));
        $where->addAnd($table->getColumn('lkLeft'), DB::term($this->lkLeft));
        $select->setWhere($where);
        $result = $select->fetchDatabase();
        if (!empty($result)) {
            return self::SAVE_OBJECT_ALREADY_EXISTS;
        }
        return self::SAVE_VALIDATION_SUCCESSFULL;
    }
Example #10
0
    public function count($historic = false)
    {
        $columns = array($this->table->getColumn('LK'));

        if ($historic == false) {
            if (empty($this->where)) {
                $this->where = DB::where($this->table->getColumn('histtop'), DB::term('Y'));
            } else {
                $this->where->addAnd($this->table->getColumn('histtop'), DB::term('Y'));
            }
        }

        if (empty($this->order)) {
            $this->order = new base_database_Order($this->table->getColumn('LK'), base_database_Order::ASC);
        }

        $select = $this->_createSelectStatement($columns);
        $result = $select->fetchDatabase();

        return count($result);
    }
Example #11
0
 /**
  * creates the admin user
  *
  * @param OutputDevice $od
  * @throws base_database_Exception
  */
 public function createAdminUser(OutputDevice $od)
 {
     $user = new User();
     if (!is_null($user->load(1))) {
         return;
     }
     $seq = new Sequence('User');
     $adminData['LK'] = $seq->getNextSequence();
     $adminData['firstEditor'] = 1;
     $dateTime = new base_date_model_DateTime();
     $adminData['firstEditTime'] = $dateTime->toDB();
     $adminData['editor'] = 1;
     $adminData['editTime'] = $dateTime->toDB();
     $adminData['userid'] = 'admin';
     $adminData['password'] = '******';
     $adminData['firstName'] = 'Admin';
     $adminData['lastName'] = 'Admin';
     $adminData['email'] = '*****@*****.**';
     $statement = new base_database_statement_Insert();
     $table = DB::table('user');
     $statement->setTable($table);
     foreach ($adminData as $fieldName => $value) {
         $statement->setColumnValue($table->getColumn($fieldName), DB::term($value));
     }
     $dbObj = base_database_connection_Mysql::get();
     $dbObj->beginTransaction();
     $seq->save();
     $statement->insertDatabase();
     $dbObj->endTransaction();
     base_install_Message::printOut('----- Admin User created -----', $od);
 }
Example #12
0
base_ui_Site::displayHead($od);
base_ui_Site::displayTop($od);
base_ui_Site::displayNavigation($od);
base_ui_Site::startMainContent($od);

print $od->toString();
$od->flush();

$od->addContent(Html::startTag('h3'));
$od->addContent('Summary');
$od->addContent(Html::endTag('h3'));

$table = DB::table(Factory::createObject('TSMSummary')->getTable());
$dateTime = new base_date_model_DateTime(new DateTime('2015-01-01 00:00:00'));
$where = DB::where($table->getColumn('startTime'), DB::term($dateTime->toDB()), base_database_Where::GREATER);
$order = DB::order($table->getColumn('startTime'));
$finder = Finder::create('TSMSummary')->setWhere($where)->setOrder($order);
$objs = $finder->find();

$times = [];
$nodeNames = [];
$sortedObjects = [];
foreach ($objs as $obj) {
    /** @var base_date_model_DateTime $startTime */
    $startTime = $obj['startTime'];
    $nodeName = $obj['nodeName'];
    if (strpos($nodeName, 'FULLVM')) {
        $nodeName = $obj['subEntity'] . ' (FULLVM)';
    }
    if (!in_array($nodeName, $nodeNames)) {
Example #13
0
    private static function _loadDataPermissionClass($className)
    {
        $table = DB::table('datapermission');
        $where = DB::where($table->getColumn('objClass'), DB::term($className));
        $selectStatement = new base_database_statement_Select();
        $selectStatement->setTable($table);
        $selectStatement->setWhere($where);
        $selectStatement->setColumns(array($table->getColumn('dpClass')));
        $result = $selectStatement->fetchDatabase();
        /** @todo tabelle anlegen!!!!! */
        if (count($result) != 1) {
            return ucfirst('nobody');
        }
        return ucfirst($result[0]['dpClass']);

    }
Example #14
0
File: User.php Project: kafruhs/fws
    private static function _updateLoginTries(base_database_Table $table, User $user)
    {
        $loginTries = $user['loginTries'];
        $where = DB::where($table->getColumn('userid'), DB::term($user['userid']));
        if ($loginTries < self::LOGIN_MAX_TRIES) {
            $loginTries++;
            self::_updateUserLoginData($table, $where, array('loginTries' => DB::term($loginTries)));
            return self::LOGIN_FAILURE;
        }
        if ($loginTries >= self::LOGIN_MAX_TRIES) {
            self::_updateUserLoginData($table, $where, array('disabled' => DB::term(self::USER_DISABLED)));
            return self::LOGIN_USER_DISABLED;
        }
        return self::LOGIN_FAILURE;

    }
Example #15
0
 private function _updateExistingSequence()
 {
     $table = DB::table('sequence');
     $statement = new base_database_statement_Update();
     $statement->setTable($table);
     $statement->setColumnValue($table->getColumn('num'), DB::term($this->nextSeq));
     $where = DB::where($table->getColumn('class'), DB::term($this->class));
     $statement->setWhere($where);
     $statement->insertDatabase();
 }
Example #16
0
 /**
  */
 protected function getWhereForFindExistingData(array $data)
 {
     if (!isset($data['PK'])) {
         return null;
     }
     $table = DB::table($this->obj->getTable());
     $column = $table->getColumn('PK');
     $where = DB::where($column, DB::term((int) $data['PK']));
     $where->addAnd($table->getColumn('histtop'), DB::term('Y'));
     return $where;
 }