17 import(
'lib.pkp.classes.tombstone.DataObjectTombstone');
36 function getById($tombstoneId, $assocType =
null, $assocId =
null) {
37 $params = array((
int) $tombstoneId);
38 if ($assocId !==
null && $assocType !==
null) {
39 $params[] = (int) $assocType;
40 $params[] = (int) $assocId;
46 if ($result->RecordCount() != 0) {
47 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
61 'SELECT * FROM data_object_tombstones WHERE data_object_id = ?', (
int) $dataObjectId
64 $dataObjectTombstone = $this->
_fromRow($result->GetRowAssoc(
false));
67 return $dataObjectTombstone;
77 $dataObjectTombstone->setId($row[
'tombstone_id']);
78 $dataObjectTombstone->setDataObjectId($row[
'data_object_id']);
79 $dataObjectTombstone->setDateDeleted($this->
datetimeFromDB($row[
'date_deleted']));
80 $dataObjectTombstone->setSetSpec($row[
'set_spec']);
81 $dataObjectTombstone->setSetName($row[
'set_name']);
82 $dataObjectTombstone->setOAIIdentifier($row[
'oai_identifier']);
85 $dataObjectTombstone->setOAISetObjectsIds($OAISetObjectsIds);
87 return $dataObjectTombstone;
97 function deleteById($tombstoneId, $assocType =
null, $assocId =
null) {
98 $tombstone = $this->
getById($tombstoneId, $assocType, $assocId);
99 if (!$tombstone)
return false;
101 assert(is_a($tombstone,
'DataObjectTombstone'));
104 'DELETE FROM data_object_tombstones WHERE tombstone_id = ?',
109 $settingsDeleted = $dataObjectTombstoneSettingsDao->deleteSettings($tombstoneId);
111 if ($settingsDeleted && $setObjectsDeleted) {
125 return $this->
deleteById($dataObjectTombstone->getId());
135 sprintf(
'INSERT INTO data_object_tombstones
136 (data_object_id, date_deleted, set_spec, set_name, oai_identifier)
142 (
int) $dataObjectTombstone->getDataObjectId(),
143 $dataObjectTombstone->getSetSpec(),
144 $dataObjectTombstone->getSetName(),
145 $dataObjectTombstone->getOAIIdentifier()
152 return $dataObjectTombstone->getId();
161 $returner = $this->
update(
162 sprintf(
'UPDATE data_object_tombstones SET
168 WHERE tombstone_id = ?',
172 (
int) $publicationFormatTombstone->getDataObjectId(),
173 $publicationFormatTombstone->getSetSpec(),
174 $publicationFormatTombstone->getSetName(),
175 $publicationFormatTombstone->getOAIIdentifier(),
176 (
int) $publicationFormatTombstone->getId()
190 return $this->
_getInsertId(
'data_object_tombstones',
'tombstone_id');
202 'SELECT DISTINCT dot.set_spec, dot.set_name FROM data_object_tombstones dot
203 LEFT JOIN data_object_tombstone_oai_set_objects oso ON (dot.tombstone_id = oso.tombstone_id)
204 WHERE oso.assoc_type = ? AND oso.assoc_id = ?',
205 array((
int) $assocType, (
int) $assocId)
209 while (!$result->EOF) {
210 $returner[$result->fields[0]] = $result->fields[1];
226 'SELECT * FROM data_object_tombstone_oai_set_objects WHERE tombstone_id = ?',
230 $oaiSetObjectsIds = array();
231 while ($row = $result->FetchRow()) {
232 $oaiSetObjectsIds[$row[
'assoc_type']] = $row[
'assoc_id'];
236 return $oaiSetObjectsIds;
245 'DELETE FROM data_object_tombstone_oai_set_objects WHERE tombstone_id = ?',
257 foreach ($dataObjectTombstone->getOAISetObjectsIds() as $assocType => $assocId) {
258 $this->
update(
'INSERT INTO data_object_tombstone_oai_set_objects
259 (tombstone_id, assoc_type, assoc_id)
263 (
int) $dataObjectTombstone->getId(),
277 foreach ($dataObjectTombstone->getOAISetObjectsIds() as $assocType => $assocId) {
278 $this->
update(
'UPDATE data_object_tombstone_oai_set_objects SET
281 WHERE tombstone_id = ?',
285 (
int) $dataObjectTombstone->getId()
302 return 'FROM data_object_tombstones dot
303 LEFT JOIN data_object_tombstone_oai_set_objects oso ON (dot.tombstone_id = oso.tombstone_id)
304 WHERE dot.tombstone_id = ?' .
305 (isset($assocId) && isset($assocType) ?
'AND oso.assoc_type = ? AND oso.assoc_id = ?' :
'');