Mercurial > hg > openmind
changeset 117:2db6271a0663
MigrateWitnessNotes now also migrates notes of CODEX and TEXT.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 27 Aug 2019 18:06:46 +0200 |
parents | 8acfd380fffe |
children | d275e1b99bce |
files | src/main/java/org/mpi/openmind/scripts/MigrateWitnessNotes.java |
diffstat | 1 files changed, 15 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/scripts/MigrateWitnessNotes.java Tue Aug 27 12:37:36 2019 +0200 +++ b/src/main/java/org/mpi/openmind/scripts/MigrateWitnessNotes.java Tue Aug 27 18:06:46 2019 +0200 @@ -23,15 +23,16 @@ private static final String migrateUser = "migrate-notes user"; protected static final Set<String> attsToMigrate = new HashSet<>(Arrays.asList( "notes_on_collation_and_corrections", "notes_on_ownership", "notes_on_title_author", - "other_features", "page_layout", "diagrams_and_illustrations")); + "other_features", "page_layout", "diagrams_and_illustrations", "text_arrangement", + "distinguishing_features")); private static Logger logger = Logger.getLogger(MigrateWitnessNotes.class); - protected static void migrate(WrapperService wrapper) { + protected static void migrate(String objectClass, WrapperService wrapper) { List<Entity> saveList = new ArrayList<Entity>(); int cnt = 0; - List<Entity> witnessList = wrapper.getEntitiesByDef("WITNESS"); + List<Entity> witnessList = wrapper.getEntitiesByDef(objectClass); for (Entity witness : witnessList) { if (witness.isLightweight()) { witness = wrapper.getEntityContent(witness); @@ -65,19 +66,19 @@ saveList.add(witness); } if (++cnt % 100 == 0) { - logger.debug(cnt+" witnesses"); + logger.debug(cnt+" "+objectClass); } } // save changed entities for (Entity entity: saveList) { try { - logger.debug("Saving changed witness: "+entity); + logger.debug("Saving changed "+objectClass+": "+entity); wrapper.saveEntity(entity, migrateUser, null); } catch (Exception e) { - logger.error("Error saving changed witnesses!", e); + logger.error("Error saving changed "+objectClass+"!", e); } } - logger.info("Changed "+saveList.size()+" witnesses."); + logger.info("Changed "+saveList.size()+" "+objectClass+"s."); } /** @@ -88,7 +89,13 @@ services.getWrapper(); logger.info("Migrating WITNESS attributes"); - migrate(services.getWrapper()); + migrate("WITNESS", services.getWrapper()); + + logger.info("Migrating CODEX attributes"); + migrate("CODEX", services.getWrapper()); + + logger.info("Migrating TEXT attributes"); + migrate("TEXT", services.getWrapper()); System.exit(0); }