From 1bf36c51d491a0718227479d430d1fc4a6ae8198 Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Fri, 26 Jun 2009 06:07:14 +0000 Subject: [PATCH] minor: externalized common String, fixed DB modification annotations SVN: 11574 --- .../VocabularyRegistrationFieldSet.java | 23 ++++++++++++------- .../openbis/generic/shared/ICommonServer.java | 4 ++-- .../generic/shared/basic/BasicConstant.java | 3 +++ .../generic/shared/dto/VocabularyTermPE.java | 4 +++- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/vocabulary/VocabularyRegistrationFieldSet.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/vocabulary/VocabularyRegistrationFieldSet.java index b7911d5de92..31de58549f2 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/vocabulary/VocabularyRegistrationFieldSet.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/vocabulary/VocabularyRegistrationFieldSet.java @@ -42,6 +42,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget. import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.FieldUtil; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMessageProvider; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.StringUtils; +import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTerm; @@ -238,15 +239,21 @@ public final class VocabularyRegistrationFieldSet extends FieldSet public static VarcharField createURLTemplateField(IMessageProvider messageProvider) { - final VarcharField result = - new VarcharField( - messageProvider.getMessage(Dict.VOCABULARY_TERMS_URL_TEMPLATE), false); + final String fieldLabel = + messageProvider.getMessage(Dict.VOCABULARY_TERMS_URL_TEMPLATE); + final String templatePart = BasicConstant.VOCABULARY_URL_TEMPLATE_TERM_PART; + final String emptyText = + "for example http://www.ebi.ac.uk/QuickGO/GTerm?id=" + templatePart; + final String regex = ".*" + templatePart + ".*"; + final String regexTextMsg = + "URL template must contain '" + templatePart + "', " + + "which will be substituted with appropriate term automatically."; + + final VarcharField result = new VarcharField(fieldLabel, false); result.setAutoValidate(false); - result.setEmptyText("for example http://www.ebi.ac.uk/QuickGO/GTerm?id=$term$"); - result.setRegex(".*\\$term\\$.*"); - result.getMessages().setRegexText( - "URL template must contain '$term$', " - + "which will be substituted with appropriate term automatically."); + result.setEmptyText(emptyText); + result.setRegex(regex); + result.getMessages().setRegexText(regexTextMsg); // manually clear invalid messages on focus (automatic validation is turned off) result.addListener(Events.Focus, new Listener<FieldEvent>() diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/ICommonServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/ICommonServer.java index 2dad6a7c376..9f1d24014ae 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/ICommonServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/ICommonServer.java @@ -340,7 +340,7 @@ public interface ICommonServer extends IServer */ @Transactional @RolesAllowed(RoleSet.INSTANCE_ADMIN) - @DatabaseCreateOrDeleteModification(value = ObjectKind.VOCABULARY) + @DatabaseUpdateModification(value = ObjectKind.VOCABULARY) public void updateVocabulary(String sessionToken, IVocabularyUpdates updates); /** @@ -468,7 +468,7 @@ public interface ICommonServer extends IServer */ @Transactional @RolesAllowed(RoleSet.INSTANCE_ADMIN) - @DatabaseCreateOrDeleteModification(value = ObjectKind.DATASET_TYPE) + @DatabaseUpdateModification(value = ObjectKind.DATASET_TYPE) public void updateDataSetType(String sessionToken, EntityType entityType); /** diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/BasicConstant.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/BasicConstant.java index 538e3fbf1c5..281810c4575 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/BasicConstant.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/BasicConstant.java @@ -38,6 +38,9 @@ public class BasicConstant /** Prefix of user namespace vocabulary code. */ public static final String USER_NAMESPACE_PREFIX = "USER."; + /** Template part of Vocabulary URL that that is replaced with vocabulary term code. */ + public static final String VOCABULARY_URL_TEMPLATE_TERM_PART = "\\$term\\$"; + private BasicConstant() { } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/VocabularyTermPE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/VocabularyTermPE.java index 0561df6631a..4de7cacd76d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/VocabularyTermPE.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/VocabularyTermPE.java @@ -39,6 +39,7 @@ import org.hibernate.validator.Pattern; import ch.systemsx.cisd.common.utilities.ModifiedShortPrefixToStringStyle; import ch.systemsx.cisd.openbis.generic.shared.IServer; +import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant; import ch.systemsx.cisd.openbis.generic.shared.util.EqualsHashUtils; /** @@ -185,7 +186,8 @@ public class VocabularyTermPE extends HibernateAbstractRegistrationHolder implem public String getUrl() { String template = getVocabulary().getURLTemplate(); - return template != null ? (template.replaceAll("\\$term\\$", getCode())) : null; + return template != null ? (template.replaceAll( + BasicConstant.VOCABULARY_URL_TEMPLATE_TERM_PART, getCode())) : null; } } -- GitLab