Author: tchemit Date: 2012-06-10 22:09:43 +0200 (Sun, 10 Jun 2012) New Revision: 3428 Url: http://chorem.org/repositories/revision/pollen/3428 Log: refs #583: Make sure pollId is never used twice Modified: trunk/pollen-persistence/src/main/xmi/pollen.properties trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java Modified: trunk/pollen-persistence/src/main/xmi/pollen.properties =================================================================== --- trunk/pollen-persistence/src/main/xmi/pollen.properties 2012-06-06 12:25:14 UTC (rev 3427) +++ trunk/pollen-persistence/src/main/xmi/pollen.properties 2012-06-10 20:09:43 UTC (rev 3428) @@ -39,7 +39,7 @@ org.chorem.pollen.business.persistence.Poll.attribute.pollId.tagValue.naturalId=true # clef naturelle non modifiable sur PollAccount#accountId -org.chorem.pollen.business.persistence.PollAccount.class.tagValue.naturalIdMutable=true +#org.chorem.pollen.business.persistence.PollAccount.class.tagValue.naturalIdMutable=true #org.chorem.pollen.business.persistence.PollAccount.attribute.accountId.stereotype=unique -org.chorem.pollen.business.persistence.PollAccount.attribute.accountId.tagValue.naturalId=true +#org.chorem.pollen.business.persistence.PollAccount.attribute.accountId.tagValue.naturalId=true Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-06 12:25:14 UTC (rev 3427) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-10 20:09:43 UTC (rev 3428) @@ -93,14 +93,12 @@ generateMissingImageThumbs(tx); // add unique on Poll.pollId and PollAccount.accountId (http://www.chorem.org/issues/583) - addUniqueOnPollAndPollAccountIds(queries); + addUniqueOnPollIds(queries); } - private void addUniqueOnPollAndPollAccountIds(List<String> queries) { + private void addUniqueOnPollIds(List<String> queries) { queries.add("CREATE UNIQUE INDEX idx_Pöll_pollId ON poll(pollId);"); - queries.add("UPDATE pollaccount SET accountid = NULL WHERE accountid = '';"); - queries.add("CREATE UNIQUE INDEX idx_PollAccount_accountId ON pollAccount(accountId);"); } private void generateMissingImageThumbs(TopiaContextImplementor tx) throws TopiaException { @@ -146,39 +144,25 @@ String pollId = choiceId.getLeft(); String choiceName = choiceId.getRight(); - File pollChoiceImage = service.getPollChoiceImageFile( - pollId, choiceName, false); + File imageFile = service.getPollChoiceImageFile( + pollId, choiceName); - if (!pollChoiceImage.exists()) { + if (!imageFile.exists()) { // image does not exists, can not generate thumb if (log.isWarnEnabled()) { - log.warn("Could not find image choice " + pollChoiceImage); + log.warn("Could not find image choice " + imageFile); } continue; } - File pollChoiceImageThumb = service.getPollChoiceImageFile( - pollId, choiceName, true); + try { - boolean thumbExists = pollChoiceImageThumb.exists(); - - if (!thumbExists) { - - // creates thumb image - - if (log.isInfoEnabled()) { - log.info("Create missing thumb file " + - pollChoiceImageThumb); - } - try { - service.generateThumb(pollId, choiceName, null); - } catch (IOException e) { - throw new TopiaException("Could not create thumb for " + - pollChoiceImageThumb, e); - } + service.generateThumbIfNeeded(imageFile); + } catch (IOException e) { + throw new TopiaException("Could not create thumb for " + + imageFile, e); } - } }