Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Change slug validation message into class related:
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Jun 4, 2012
1 parent e2395c2 commit 0cae6df
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
Expand Up @@ -112,7 +112,7 @@ public boolean validateSlug(String slug, String componentId)
{
if (!isSlugAvailable(slug))
{
FacesMessages.instance().addToControl(componentId, "This slug is not available");
FacesMessages.instance().addToControl(componentId, "This Project ID is not available");
return false;
}
return true;
Expand Down
Expand Up @@ -25,7 +25,6 @@

import javax.faces.event.ValueChangeEvent;
import javax.persistence.EntityNotFoundException;
import javax.persistence.NoResultException;

import org.hibernate.criterion.NaturalIdentifier;
import org.hibernate.criterion.Restrictions;
Expand Down Expand Up @@ -124,7 +123,7 @@ public boolean validateSlug(String slug, String componentId)
{
if (!isSlugAvailable(slug))
{
FacesMessages.instance().addToControl(componentId, "This slug is not available");
FacesMessages.instance().addToControl(componentId, "This Version ID is not available");
return false;
}
return true;
Expand Down
18 changes: 6 additions & 12 deletions zanata-war/src/main/java/org/zanata/action/VersionGroupHome.java
Expand Up @@ -25,7 +25,6 @@

import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import javax.persistence.NoResultException;

import org.hibernate.Session;
import org.hibernate.criterion.NaturalIdentifier;
Expand All @@ -38,6 +37,7 @@
import org.zanata.model.HAccount;
import org.zanata.model.HIterationGroup;
import org.zanata.model.HProjectIteration;
import org.zanata.service.SlugEntityService;

/**
* @author Alex Eng <a href="mailto:aeng@redhat.com">aeng@redhat.com</a>
Expand All @@ -53,6 +53,9 @@ public class VersionGroupHome extends SlugHome<HIterationGroup>
@In(required = false, value = JpaIdentityStore.AUTHENTICATED_USER)
HAccount authenticatedAccount;

@In
SlugEntityService slugEntityServiceImpl;

@Override
protected HIterationGroup loadInstance()
{
Expand Down Expand Up @@ -110,24 +113,15 @@ public boolean validateSlug(String slug, String componentId)
{
if (!isSlugAvailable(slug))
{
FacesMessages.instance().addToControl(componentId, "This slug is not available");
FacesMessages.instance().addToControl(componentId, "This Group ID is not available");
return false;
}
return true;
}

public boolean isSlugAvailable(String slug)
{
try
{
getEntityManager().createQuery("from HIterationGroup g where g.slug = :slug").setParameter("slug", slug).getSingleResult();
return false;
}
catch (NoResultException e)
{
// pass
}
return true;
return slugEntityServiceImpl.isSlugAvailable(slug, HIterationGroup.class);
}

@Override
Expand Down

0 comments on commit 0cae6df

Please sign in to comment.