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

Commit

Permalink
minor clean up and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed May 4, 2012
1 parent cc082ee commit c4521f5
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 134 deletions.
Expand Up @@ -20,8 +20,6 @@
*/
package org.zanata.model;

import static org.zanata.util.ZanataUtil.equal;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -62,15 +60,15 @@
import org.hibernate.validator.Length;
import org.hibernate.validator.NotEmpty;
import org.hibernate.validator.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zanata.common.LocaleId;
import org.zanata.hibernate.search.IdFilterFactory;
import org.zanata.model.po.HPotEntryData;
import org.zanata.util.HashUtil;
import org.zanata.util.OkapiUtil;
import org.zanata.util.StringUtil;

import com.google.common.base.Objects;

import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
Expand Down Expand Up @@ -228,7 +226,7 @@ public HDocument getDocument()

public void setDocument(HDocument document)
{
if (!equal(this.document, document))
if (!Objects.equal(this.document, document))
{
this.document = document;
updateWordCount();
Expand Down Expand Up @@ -272,8 +270,8 @@ public void setContents(List<String> contents)
// Copy lazily loaded relations to the history object as this cannot be done
// in the entity callbacks
copyLazyLoadedRelationsToHistory();
if (!equal(this.contents, contents))

if (!Objects.equal(this.contents, contents))
{
this.contents = new ArrayList<String>(contents);
updateWordCount();
Expand Down
Expand Up @@ -20,8 +20,6 @@
*/
package org.zanata.model;

import static org.zanata.util.ZanataUtil.equal;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -41,6 +39,7 @@
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.Type;
import org.hibernate.validator.NotEmpty;
import com.google.common.base.Objects;

@Entity
@org.hibernate.annotations.Entity(mutable = false)
Expand Down Expand Up @@ -162,7 +161,7 @@ public void setObsolete(boolean obsolete)
*/
public boolean hasChanged(HTextFlow current)
{
return !equal(current.getRevision(), this.getRevision());
return !Objects.equal(current.getRevision(), this.getRevision());
}

}
Expand Up @@ -20,8 +20,6 @@
*/
package org.zanata.model;

import static org.zanata.util.ZanataUtil.equal;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
Expand All @@ -44,6 +42,7 @@
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.Type;
import org.zanata.common.ContentState;
import com.google.common.base.Objects;

@Entity
@org.hibernate.annotations.Entity(mutable = false)
Expand Down Expand Up @@ -219,13 +218,13 @@ public void setTextFlowRevision(Integer textFlowRevision)
*/
public boolean hasChanged(HTextFlowTarget current)
{
return !equal(current.getContents(), this.contents)
|| !equal(current.getLastChanged(), this.lastChanged)
|| !equal(current.getLastModifiedBy(), this.lastModifiedBy)
|| !equal(current.getState(), this.state)
|| !equal(current.getTextFlowRevision(), this.textFlowRevision)
|| !equal(current.getLastChanged(), this.lastChanged)
|| !equal(current.getTextFlow().getId(), this.textFlowTarget.getId())
|| !equal(current.getVersionNum(), this.versionNum);
return !Objects.equal(current.getContents(), this.contents)
|| !Objects.equal(current.getLastChanged(), this.lastChanged)
|| !Objects.equal(current.getLastModifiedBy(), this.lastModifiedBy)
|| !Objects.equal(current.getState(), this.state)
|| !Objects.equal(current.getTextFlowRevision(), this.textFlowRevision)
|| !Objects.equal(current.getLastChanged(), this.lastChanged)
|| !Objects.equal(current.getTextFlow().getId(), this.textFlowTarget.getId())
|| !Objects.equal(current.getVersionNum(), this.versionNum);
}
}
45 changes: 0 additions & 45 deletions server/zanata-model/src/main/java/org/zanata/util/ListUtil.java

This file was deleted.

59 changes: 0 additions & 59 deletions server/zanata-model/src/main/java/org/zanata/util/ZanataUtil.java

This file was deleted.

Expand Up @@ -56,7 +56,7 @@
import org.zanata.model.validator.SlugValidator;
import org.zanata.rest.MediaTypes;
import org.zanata.rest.dto.ProjectIteration;
import org.zanata.util.ZanataUtil;
import com.google.common.base.Objects;

@Name("projectIterationService")
@Path(ProjectIterationService.SERVICE_PATH)
Expand Down Expand Up @@ -202,12 +202,12 @@ public Response put(ProjectIteration projectIteration)
return Response.status(Status.NOT_FOUND).entity("Project '" + projectSlug + "' not found.").build();
}
// Project is Obsolete
else if( ZanataUtil.in(hProject.getStatus(), OBSOLETE) )
else if(Objects.equal(hProject.getStatus(), OBSOLETE))
{
return Response.status(Status.NOT_FOUND).entity("Project '" + projectSlug + "' not found.").build();
}
// Project is ReadOnly
else if( ZanataUtil.in(hProject.getStatus(), READONLY) )
else if(Objects.equal(hProject.getStatus(), READONLY))
{
return Response.status(Status.FORBIDDEN).entity("Project '" + projectSlug + "' is read-only.").build();
}
Expand All @@ -232,12 +232,12 @@ else if( ZanataUtil.in(hProject.getStatus(), READONLY) )
changed = true;
}
// Iteration is Obsolete
else if( ZanataUtil.in(hProjectIteration.getStatus(), OBSOLETE) )
else if(Objects.equal(hProjectIteration.getStatus(), OBSOLETE))
{
return Response.status(Status.FORBIDDEN).entity("Project Iiteration '" + projectSlug + ":" + iterationSlug + "' is obsolete.").build();
}
// Iteration is ReadOnly
else if( ZanataUtil.in(hProjectIteration.getStatus(), READONLY) )
else if(Objects.equal(hProjectIteration.getStatus(), READONLY))
{
return Response.status(Status.FORBIDDEN).entity("Project Iteration '" + projectSlug + ":" + iterationSlug + "' is read-only.").build();
}
Expand Down
Expand Up @@ -43,7 +43,7 @@
import org.zanata.rest.dto.Link;
import org.zanata.rest.dto.Project;
import org.zanata.rest.dto.ProjectIteration;
import org.zanata.util.ZanataUtil;
import com.google.common.base.Objects;

@Name("projectService")
@Path(ProjectService.SERVICE_PATH)
Expand Down Expand Up @@ -189,12 +189,12 @@ public Response put(Project project)
response = Response.created(uri.getAbsolutePath());
}
// Project is Obsolete
else if( ZanataUtil.in(hProject.getStatus(), OBSOLETE) )
else if(Objects.equal(hProject.getStatus(), OBSOLETE))
{
return Response.status(Status.FORBIDDEN).entity("Project '" + projectSlug + "' is obsolete.").build();
}
// Project is ReadOnly
else if( ZanataUtil.in(hProject.getStatus(), READONLY) )
else if(Objects.equal(hProject.getStatus(), READONLY))
{
return Response.status(Status.FORBIDDEN).entity("Project '" + projectSlug + "' is read-only.").build();
}
Expand Down
Expand Up @@ -52,7 +52,7 @@
import org.zanata.rest.dto.Link;
import org.zanata.rest.dto.Project;
import org.zanata.rest.dto.ProjectType;
import org.zanata.util.ZanataUtil;
import com.google.common.base.Objects;

@Name("projectsService")
@Path("/projects")
Expand Down Expand Up @@ -95,7 +95,7 @@ public Response get()
for (HProject hProject : projects)
{
// Ignore Obsolete projects
if( !ZanataUtil.in(hProject.getStatus(), OBSOLETE) )
if( !Objects.equal(hProject.getStatus(), OBSOLETE))
{
Project project = new Project(hProject.getSlug(), hProject.getName(), ProjectType.IterationProject);
project.setStatus( hProject.getStatus() );
Expand Down

0 comments on commit c4521f5

Please sign in to comment.