Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
cd26ebaa
Commit
cd26ebaa
authored
6 years ago
by
felmer
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-6958: Fixing data set archiving status update in DataDAO
parent
cc931ca6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/DataDAO.java
+48
-48
48 additions, 48 deletions
...sx/cisd/openbis/generic/server/dataaccess/db/DataDAO.java
with
48 additions
and
48 deletions
openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/DataDAO.java
+
48
−
48
View file @
cd26ebaa
...
...
@@ -529,7 +529,6 @@ final class DataDAO extends AbstractGenericEntityWithPropertiesDAO<DataPE> imple
return
entity
;
}
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
@Override
public
void
updateDataSetStatuses
(
final
List
<
String
>
dataSetCodes
,
final
DataSetArchivingStatus
status
)
...
...
@@ -558,55 +557,14 @@ final class DataDAO extends AbstractGenericEntityWithPropertiesDAO<DataPE> imple
{
final
int
startIndexFinal
=
startIndex
;
final
int
endIndexFinal
=
endIndex
;
updatedRows
+=
(
Integer
)
hibernateTemplate
.
execute
(
new
HibernateCallback
()
{
//
// HibernateCallback
//
@Override
public
final
Object
doInHibernate
(
final
Session
session
)
throws
HibernateException
{
// NOTE: 'VERSIONED' makes modification time modified too
return
session
.
createQuery
(
"UPDATE VERSIONED "
+
EXTERNAL_DATA_TABLE_NAME
+
" SET status = :status WHERE code IN (:codes) "
)
.
setParameter
(
"status"
,
status
)
.
setParameterList
(
"codes"
,
dataSetCodes
.
subList
(
startIndexFinal
,
endIndexFinal
))
.
executeUpdate
();
}
});
List
<
String
>
codes
=
dataSetCodes
.
subList
(
startIndexFinal
,
endIndexFinal
);
updatedRows
+=
updateStatus
(
hibernateTemplate
,
status
,
codes
);
startIndex
=
endIndex
;
endIndex
=
Math
.
min
(
endIndex
+
MAX_BATCH_SIZE
,
len
);
}
}
else
{
updatedRows
=
(
Integer
)
hibernateTemplate
.
execute
(
new
HibernateCallback
()
{
//
// HibernateCallback
//
@Override
public
final
Object
doInHibernate
(
final
Session
session
)
throws
HibernateException
{
// NOTE: 'VERSIONED' makes modification time modified too
return
session
.
createQuery
(
"UPDATE VERSIONED "
+
EXTERNAL_DATA_TABLE_NAME
+
" SET status = :status WHERE code IN (:codes) "
)
.
setParameter
(
"status"
,
status
)
.
setParameterList
(
"codes"
,
dataSetCodes
).
executeUpdate
();
}
});
updatedRows
=
updateStatus
(
hibernateTemplate
,
status
,
dataSetCodes
);
}
scheduleDynamicPropertiesEvaluationForDataSets
(
dataSetCodes
);
hibernateTemplate
.
flush
();
...
...
@@ -619,6 +577,45 @@ final class DataDAO extends AbstractGenericEntityWithPropertiesDAO<DataPE> imple
}
}
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
private
Integer
updateStatus
(
final
HibernateTemplate
hibernateTemplate
,
final
DataSetArchivingStatus
status
,
List
<
String
>
codes
)
{
return
(
Integer
)
hibernateTemplate
.
execute
(
new
HibernateCallback
()
{
@Override
public
final
Object
doInHibernate
(
final
Session
session
)
throws
HibernateException
{
int
result
=
session
.
createQuery
(
"UPDATE "
+
EXTERNAL_DATA_TABLE_NAME
+
" SET status = :status WHERE code IN (:codes) "
)
.
setParameter
(
"status"
,
status
)
.
setParameterList
(
"codes"
,
codes
)
.
executeUpdate
();
updateVersion
(
session
,
codes
);
return
result
;
/*
// NOTE: 'VERSIONED' makes modification time modified too
return session
.createQuery(
"UPDATE VERSIONED "
+ EXTERNAL_DATA_TABLE_NAME
+ " SET status = :status WHERE code IN (:codes) ")
.setParameter("status", status)
.setParameterList("codes", codes)
.executeUpdate();
*/
}
});
}
private
static
int
updateVersion
(
final
Session
session
,
List
<
String
>
codes
)
{
return
session
.
createQuery
(
"UPDATE "
+
TABLE_NAME
+
" SET version = version + 1 WHERE code IN (:codes) "
)
.
setParameterList
(
"codes"
,
codes
)
.
executeUpdate
();
}
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
@Override
public
void
updateSizes
(
final
Map
<
String
,
Long
>
sizeMap
)
...
...
@@ -828,7 +825,7 @@ final class DataDAO extends AbstractGenericEntityWithPropertiesDAO<DataPE> imple
{
query
=
session
.
createQuery
(
"UPDATE
VERSIONED
"
"UPDATE "
+
EXTERNAL_DATA_TABLE_NAME
+
" SET status = :status, presentInArchive = :presentInArchive, "
+
" archivingRequested = 'f'"
...
...
@@ -837,17 +834,20 @@ final class DataDAO extends AbstractGenericEntityWithPropertiesDAO<DataPE> imple
{
query
=
session
.
createQuery
(
"UPDATE
VERSIONED
"
"UPDATE "
+
EXTERNAL_DATA_TABLE_NAME
+
" SET status = :status, presentInArchive = :presentInArchive"
+
" WHERE code IN (:codes) "
);
}
return
query
int
result
=
query
.
setParameter
(
"status"
,
status
)
.
setParameter
(
"presentInArchive"
,
presentInArchive
)
.
setParameterList
(
"codes"
,
codes
)
.
executeUpdate
();
System
.
err
.
println
(
result
+
" UPDATED "
+
codes
);
updateVersion
(
session
,
codes
);
return
result
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment