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

Commit

Permalink
Merge branch 'integration/master' into rhbz981067
Browse files Browse the repository at this point in the history
Conflicts:
	zanata-war/src/main/resources/db/changelogs/db.changelog-3.1.xml
  • Loading branch information
Alex Eng committed Jul 14, 2013
2 parents 10d1f86 + bc8c0ad commit c90317f
Show file tree
Hide file tree
Showing 66 changed files with 2,295 additions and 290 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>zanata-parent</artifactId>
<version>10</version>
<version>13-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>

Expand Down
4 changes: 4 additions & 0 deletions zanata-model/pom.xml
Expand Up @@ -249,6 +249,10 @@
<artifactId>validation-api</artifactId>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
</dependencies>

</project>
24 changes: 20 additions & 4 deletions zanata-model/src/main/java/org/zanata/model/HTextFlowTarget.java
Expand Up @@ -23,7 +23,6 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -57,13 +56,10 @@
import org.hibernate.search.annotations.AnalyzerDiscriminator;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.FieldBridge;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Parameter;
import org.hibernate.validator.constraints.NotEmpty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zanata.common.ContentState;
import org.zanata.common.HasContents;
import org.zanata.common.LocaleId;
Expand All @@ -74,6 +70,7 @@
import org.zanata.hibernate.search.TextContainerAnalyzerDiscriminator;

import com.google.common.base.Objects;
import com.google.common.collect.Lists;

/**
* Represents a flow of translated text that should be processed as a
Expand Down Expand Up @@ -114,6 +111,8 @@ public class HTextFlowTarget extends ModelEntityBase implements HasContents, Has

private Map<Integer, HTextFlowTargetHistory> history;

private List<HTextFlowTargetReviewComment> reviewComments;

// Only for internal use (persistence transient)
@Setter(AccessLevel.PRIVATE)
private Integer oldVersionNum;
Expand Down Expand Up @@ -388,6 +387,23 @@ public Map<Integer, HTextFlowTargetHistory> getHistory()
return history;
}

@OneToMany(cascade = { CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST }, mappedBy = "textFlowTarget")
public List<HTextFlowTargetReviewComment> getReviewComments()
{
if (reviewComments == null)
{
reviewComments = Lists.newArrayList();
}
return reviewComments;
}

public HTextFlowTargetReviewComment addReviewComment(String comment, HPerson commenter)
{
HTextFlowTargetReviewComment reviewComment = new HTextFlowTargetReviewComment(this, comment, commenter);
getReviewComments().add(reviewComment);
return reviewComment;
}

@PreUpdate
private void preUpdate()
{
Expand Down
@@ -0,0 +1,107 @@
/*
* Copyright 2010, Red Hat, Inc. and individual contributors as indicated by the
* @author tags. See the copyright.txt file in the distribution for a full
* listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/

package org.zanata.model;

import java.util.List;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.zanata.common.ContentState;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* @author Patrick Huang <a
* href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
*/
@Entity
@Immutable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@BatchSize(size = 20)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Access(AccessType.FIELD)
public class HTextFlowTargetReviewComment extends ModelEntityBase
{
private static final long serialVersionUID = 1413384329431214946L;

@Getter
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "commenter_id", nullable = false)
private HPerson commenter;

@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "target_id")
@IndexedEmbedded
@Getter
private HTextFlowTarget textFlowTarget;

@NotNull
@Type(type = "text")
@Getter
private String comment;

@Setter(AccessLevel.PROTECTED)
@Getter
@NotNull
private Integer targetVersion;

private transient String commenterName;

public HTextFlowTargetReviewComment(HTextFlowTarget target, String comment, HPerson commenter)
{
this.textFlowTarget = target;
this.comment = comment;
this.commenter = commenter;
commenterName = commenter.getName();
targetVersion = target.getVersionNum();
}

@Transient
public String getCommenterName()
{
if (commenterName == null)
{
commenterName = getCommenter().getName();
}
return commenterName;
}

}
4 changes: 4 additions & 0 deletions zanata-war/pom.xml
Expand Up @@ -1320,6 +1320,10 @@
<groupId>com.google.guava</groupId>
<artifactId>guava-gwt</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
Expand Down
Expand Up @@ -28,6 +28,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Level;
Expand All @@ -47,7 +48,6 @@
import org.zanata.config.JndiBackedConfig;
import org.zanata.log4j.ZanataHTMLLayout;
import org.zanata.log4j.ZanataSMTPAppender;
import org.zanata.model.HApplicationConfiguration;
import org.zanata.security.AuthenticationType;

@Name("applicationConfiguration")
Expand All @@ -63,22 +63,6 @@ public class ApplicationConfiguration implements Serializable
private static final String EMAIL_APPENDER_NAME = "zanata.log.appender.email";
public static final String EVENT_CONFIGURATION_CHANGED = "zanata.configuration.changed";



private static final String[] allConfigKeys = new String[]
{
HApplicationConfiguration.KEY_ADMIN_EMAIL,
HApplicationConfiguration.KEY_DOMAIN,
HApplicationConfiguration.KEY_EMAIL_FROM_ADDRESS,
HApplicationConfiguration.KEY_EMAIL_LOG_EVENTS,
HApplicationConfiguration.KEY_EMAIL_LOG_LEVEL,
HApplicationConfiguration.KEY_HELP_CONTENT,
HApplicationConfiguration.KEY_HOME_CONTENT,
HApplicationConfiguration.KEY_HOST,
HApplicationConfiguration.KEY_LOG_DESTINATION_EMAIL,
HApplicationConfiguration.KEY_REGISTER
};

private DatabaseBackedConfig databaseBackedConfig;
private JndiBackedConfig jndiBackedConfig;

Expand All @@ -97,7 +81,6 @@ public class ApplicationConfiguration implements Serializable
public void load()
{
log.info("Reloading configuration");
Map<String, String> configValues = new HashMap<String, String>();
databaseBackedConfig = (DatabaseBackedConfig)Component.getInstance(DatabaseBackedConfig.class);
jndiBackedConfig = (JndiBackedConfig)Component.getInstance(JndiBackedConfig.class);

Expand Down
11 changes: 11 additions & 0 deletions zanata-war/src/main/java/org/zanata/action/CopyTransManager.java
Expand Up @@ -69,19 +69,30 @@ public class CopyTransManager implements Serializable
Collections.synchronizedMap( new HashMap<CopyTransProcessKey, CopyTransProcessHandle>() );

// Collection of recently cancelled copy trans processes (discards the oldest ones)
// TODO deprecated, switch to CacheBuilder
private Map<CopyTransProcessKey, CopyTransProcessHandle> recentlyCancelled =
new MapMaker()
.softValues()
.expiration(1, TimeUnit.HOURS) // keep them for an hour
.makeMap();
// CacheBuilder.newBuilder()
// .softValues()
// .expireAfterWrite(1, TimeUnit.HOURS) // keep them for an hour
// .build().asMap();

// Collection of recently completed copy trans processes (discards the olders ones)
// TODO deprecated, switch to CacheBuilder
private Map<CopyTransProcessKey, CopyTransProcessHandle> recentlyFinished =
new MapMaker()
.softValues()
.expiration(1, TimeUnit.HOURS) // keep them for an hour
.makeMap();

// CacheBuilder.newBuilder()
// .softValues()
// .expireAfterWrite(1, TimeUnit.HOURS) // keep them for an hour
// .build().asMap();

@In
private ProcessManagerService processManagerServiceImpl;

Expand Down
Expand Up @@ -60,7 +60,6 @@
import org.zanata.rest.dto.stats.TranslationStatistics;
import org.zanata.rest.dto.stats.TranslationStatistics.StatUnit;
import org.zanata.rest.service.StatisticsResource;
import org.zanata.seam.scope.FlashScopeBean;
import org.zanata.security.ZanataIdentity;
import org.zanata.service.CopyTransService;
import org.zanata.service.LocaleService;
Expand Down Expand Up @@ -106,9 +105,6 @@ public class ViewAllStatusAction implements Serializable
@In
CopyTransManager copyTransManager;

@In
FlashScopeBean flashScope;

private String iterationSlug;

private String projectSlug;
Expand Down
Expand Up @@ -20,6 +20,7 @@
*/
package org.zanata.config;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -40,9 +41,11 @@
@Name("databaseBackedConfig")
@Scope(ScopeType.APPLICATION)
@AutoCreate
public class DatabaseBackedConfig
public class DatabaseBackedConfig implements Serializable
{

private static final long serialVersionUID = 1L;

@In
private ApplicationConfigurationDAO applicationConfigurationDAO;

Expand Down
Expand Up @@ -20,10 +20,12 @@
*/
package org.zanata.config;

import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NameClassPair;
Expand All @@ -45,9 +47,10 @@
@Name("jndiBackedConfig")
@Scope(ScopeType.APPLICATION)
@AutoCreate
public class JndiBackedConfig
public class JndiBackedConfig implements Serializable
{

private static final long serialVersionUID = 1L;

private static final String KEY_AUTH_POLICY = "java:global/zanata/security/auth-policy-names/";
private static final String KEY_ADMIN_USERS = "java:global/zanata/security/admin-users";
private static final String KEY_DEFAULT_FROM_ADDRESS = "java:global/zanata/email/default-from-address";
Expand Down
5 changes: 3 additions & 2 deletions zanata-war/src/main/java/org/zanata/dao/AbstractDAOImpl.java
Expand Up @@ -13,9 +13,10 @@
/**
* Based on code from http://community.jboss.org/wiki/GenericDataAccessObjects
*/
public abstract class AbstractDAOImpl<T, ID extends Serializable> implements GenericDAO<T, ID>
public abstract class AbstractDAOImpl<T, ID extends Serializable> implements GenericDAO<T, ID>, Serializable
{

private static final long serialVersionUID = 1L;

private Class<T> persistentClass;
private Session session;

Expand Down
@@ -1,9 +1,7 @@
package org.zanata.dao;


import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
Expand Down

0 comments on commit c90317f

Please sign in to comment.