Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
63848b3c
Commit
63848b3c
authored
Oct 02, 2013
by
Matija Obreza
Browse files
Update FaoInstitute countries based on WIEWS code
parent
feade8a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/persistence/domain/GenesysLowlevelRepository.java
View file @
63848b3c
...
...
@@ -14,13 +14,20 @@
* limitations under the License.
**/
package
org.genesys2.server.persistence.domain
;
import
org.genesys2.server.model.impl.Country
;
import
org.genesys2.server.model.impl.FaoInstitute
;
public
interface
GenesysLowlevelRepository
{
void
updateCountryRefs
();
void
updateFaoInstituteRefs
();
/**
* Relink {@link FaoInstitute} with {@link Country} based on institute code
*/
void
updateFaoInstituteCountries
();
}
src/main/java/org/genesys2/server/persistence/domain/GenesysLowlevelRepositoryImpl.java
View file @
63848b3c
...
...
@@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -38,6 +39,7 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository
}
@Override
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@Transactional
(
readOnly
=
false
)
public
void
updateFaoInstituteRefs
()
{
LOG
.
info
(
"Updating institute references"
);
...
...
@@ -52,10 +54,21 @@ public class GenesysLowlevelRepositoryImpl implements GenesysLowlevelRepository
}
@Override
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@Transactional
(
readOnly
=
false
)
public
void
updateCountryRefs
()
{
LOG
.
info
(
"Updating country references"
);
int
count
=
jdbcTemplate
.
update
(
"UPDATE `accession` A inner join `country` C on C.code3=A.Origin set A.originId=C.id WHERE A.Origin IS NOT NULL;"
);
LOG
.
info
(
"Country references updated: "
+
count
);
}
@Override
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@Transactional
(
readOnly
=
false
)
public
void
updateFaoInstituteCountries
()
{
LOG
.
info
(
"Updating country references"
);
int
count
=
jdbcTemplate
.
update
(
"UPDATE `faoinstitute` I inner join `country` C on C.code3=left(I.code, 3) set I.countryId=C.id;"
);
LOG
.
info
(
"Country references updated: "
+
count
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment