Progress 8 for the dashboards
This commit is contained in:
@@ -30,4 +30,56 @@ class DashletInstance extends BaseDashletInstance {
|
||||
}
|
||||
}
|
||||
|
||||
public function save($data) {
|
||||
$connection = Propel::getConnection(DashletInstancePeer::DATABASE_NAME);
|
||||
try {
|
||||
if (!isset($data['DAS_INS_UID'])) {
|
||||
$data['DAS_INS_UID'] = G::generateUniqueID();
|
||||
$dashletInstance = new DashletInstance();
|
||||
}
|
||||
else {
|
||||
$dashletInstance = DashletInstancePeer::retrieveByPK($data['DAS_INS_UID']);
|
||||
}
|
||||
$dashletInstance->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
if ($dashletInstance->validate()) {
|
||||
$connection->begin();
|
||||
$result = $dashletInstance->save();
|
||||
$connection->commit();
|
||||
return $data['DAS_INS_UID'];
|
||||
}
|
||||
else {
|
||||
$message = '';
|
||||
$validationFailures = $dashletInstance->getValidationFailures();
|
||||
foreach($validationFailures as $validationFailure) {
|
||||
$message .= $validationFailure->getMessage() . '. ';
|
||||
}
|
||||
throw(new Exception('Error trying to update: ' . $message));
|
||||
}
|
||||
}
|
||||
catch (Exception $error) {
|
||||
$connection->rollback();
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($dasInsUid) {
|
||||
$connection = Propel::getConnection(DashletInstancePeer::DATABASE_NAME);
|
||||
try {
|
||||
$dashletInstance = DashletInstancePeer::retrieveByPK($dasInsUid);
|
||||
if (!is_null($dashletInstance)) {
|
||||
$connection->begin();
|
||||
$result = $dashletInstance->delete();
|
||||
$connection->commit();
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
throw new Exception('Error trying to delete: The row "' . $dasInsUid. '" not exists.');
|
||||
}
|
||||
}
|
||||
catch (Exception $error) {
|
||||
$connection->rollback();
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
|
||||
} // DashletInstance
|
||||
|
||||
Reference in New Issue
Block a user