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 rhbz828629
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Oct 2, 2012
2 parents ae6e32f + 24f21cb commit e4142c4
Show file tree
Hide file tree
Showing 60 changed files with 2,872 additions and 1,093 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -20,7 +20,7 @@

<properties>
<cobertura.total-line-rate>50</cobertura.total-line-rate>
<cobertura.total-branch-rate>50</cobertura.total-branch-rate>
<cobertura.total-branch-rate>30</cobertura.total-branch-rate>
<cobertura.halt.failure>false</cobertura.halt.failure>
<delombok.dir>${project.build.directory}/delombok/org/zanata</delombok.dir>
<enunciate.version>1.24</enunciate.version>
Expand Down
119 changes: 119 additions & 0 deletions zanata-model/src/main/java/org/zanata/model/HDocumentUpload.java
@@ -0,0 +1,119 @@
/*
* Copyright 2012, 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.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import lombok.Getter;
import lombok.Setter;

import org.hibernate.annotations.IndexColumn;
import org.hibernate.validator.NotEmpty;
import org.zanata.common.DocumentType;


@Entity
@Getter
@Setter
public class HDocumentUpload extends ModelEntityBase implements Serializable
{

private static final long serialVersionUID = 1L;


private HProjectIteration projectIteration;
private String docId;
private DocumentType type;
private HLocale locale;
private String contentHash;
private List<HDocumentUploadPart> parts;

public HDocumentUpload()
{
// hibernate requires this to be an ArrayList
parts = new ArrayList<HDocumentUploadPart>();
}

public void setId(Long id)
{
super.setId(id);
}

@ManyToOne
@JoinColumn(name = "projectIterationid", nullable = false)
public HProjectIteration getProjectIteration()
{
return projectIteration;
}

@NotEmpty
public String getDocId()
{
return docId;
}

@Enumerated(EnumType.STRING)
public DocumentType getType()
{
return type;
}

// null for source document upload
@ManyToOne
@JoinColumn(name = "localeId", nullable = true)
public HLocale getLocale()
{
return locale;
}

@NotEmpty
public String getContentHash()
{
return contentHash;
}

@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "documentUploadId", nullable = false)
@IndexColumn(name = "partIndex", base = 0, nullable = false)
public List<HDocumentUploadPart> getParts()
{
return parts;
}

@Override
public String toString()
{
return getClass().getSimpleName() + "@" + Integer.toHexString(hashCode())
+ "[id=" + id + ",versionNum=" + versionNum
+ ",contentHash=" + contentHash + "]";
}

}
@@ -0,0 +1,80 @@
/*
* Copyright 2012, 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.io.Serializable;
import java.sql.Blob;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;

import lombok.NoArgsConstructor;
import lombok.Setter;

import org.hibernate.validator.NotNull;

@Entity
@NoArgsConstructor // is this necessary?
public class HDocumentUploadPart implements Serializable
{

private static final long serialVersionUID = 1L;

@Setter
private long id;
@Setter
private HDocumentUpload upload;
@Setter
private Blob content;

@Id
@GeneratedValue
public Long getId()
{
return id;
}

@ManyToOne
@JoinColumn(name = "documentUploadId", nullable = false, updatable = false, insertable = false)
public HDocumentUpload getUpload()
{
return upload;
}

@NotNull
@Lob
public Blob getContent()
{
return content;
}

@Override
public String toString()
{
return getClass().getSimpleName() + "@" + Integer.toHexString(hashCode())
+ "[upload id=" + upload.getId() + "]";
}

}
13 changes: 13 additions & 0 deletions zanata-war/pom.xml
Expand Up @@ -226,6 +226,7 @@
<configuration>
<instrumentation>
<excludes>
<!--WebTran exclusion-->
<!--TODO move all gwt wrapper class under specific package. i.e boundary-->
<!--<exclude>**/boundary/**/*</exclude>-->
<exclude>**/test/**/*</exclude>
Expand All @@ -245,6 +246,18 @@
<exclude>**/shared/auth/**</exclude>
<exclude>**/shared/model/**</exclude>
<exclude>**/shared/rpc/**</exclude>

<!--Server exclusion-->
<exclude>**/job/**</exclude>
<exclude>**/liquibase/**</exclude>
<exclude>**/log4j/**</exclude>
<exclude>**/seam/**</exclude>
<exclude>**/rest/files/*</exclude>
<exclude>**/rest/*Mapper</exclude>
<exclude>**/openid/*</exclude>
<exclude>**/servlet/*</exclude>

<!--General exclusion-->
<exclude>**/*Exception*</exclude>
</excludes>
</instrumentation>
Expand Down
Expand Up @@ -71,6 +71,7 @@ public List<HAccount> getSearchResults()

public List<HAccount> search(Object input)
{
this.person = null;
String userInput = (String) input;
return accountDAO.searchQuery(userInput);
}
Expand Down
12 changes: 5 additions & 7 deletions zanata-war/src/main/java/org/zanata/action/LocaleListAction.java
Expand Up @@ -121,16 +121,14 @@ public Map<String, String> loadItems()
customizedItems = localeServiceImpl.getCustomizedLocalesItems(slug);
if (customizedItems.isEmpty())
{
customizedItems = globalItems;
customizedItems = localeServiceImpl.getDefaultCustomizedLocalesItems();
}
else

for (String op : globalItems.keySet())
{
for (String op : globalItems.keySet())
if (!customizedItems.containsKey(op))
{
if (!customizedItems.containsKey(op))
{
availableItems.put(op, op);
}
availableItems.put(op, op);
}
}
return availableItems;
Expand Down
Expand Up @@ -58,9 +58,8 @@ public class ProjectIterationLocaleAction implements Serializable
@In
ProjectIterationDAO projectIterationDAO;

private String projectSlug;

private String iterationSlug;
@In
private ProjectIterationHome projectIterationHome;

@In
LocaleService localeServiceImpl;
Expand Down Expand Up @@ -119,46 +118,25 @@ public Map<String, String> getIterationCustomizedItems()
public Map<String, String> loadItems()
{
log.debug("load iterationCustomizedItems");
HProjectIteration iteration = projectIterationHome.getInstance();
availableItems = new TreeMap<String, String>();
iterationCustomizedItems = localeServiceImpl.getIterationCustomizedLocalesItems(projectSlug, iterationSlug);
globalItems = localeServiceImpl.getIterationGlobalLocaleItems(projectSlug);
iterationCustomizedItems = localeServiceImpl.getIterationCustomizedLocalesItems(iteration.getProject().getSlug(), iteration.getSlug());
globalItems = localeServiceImpl.getIterationGlobalLocaleItems(iteration.getProject().getSlug());
if (iterationCustomizedItems.isEmpty())
{
iterationCustomizedItems = globalItems;
iterationCustomizedItems = localeServiceImpl.getDefaultCustomizedLocalesItems();
}
else

for (String op : globalItems.keySet())
{
for (String op : globalItems.keySet())
if (!iterationCustomizedItems.containsKey(op))
{
if (!iterationCustomizedItems.containsKey(op))
{
availableItems.put(op, op);
}
availableItems.put(op, op);
}
}
return availableItems;
}

public String getProjectSlug()
{
return projectSlug;
}

public void setProjectSlug(String projectSlug)
{
this.projectSlug = projectSlug;
}

public String getIterationSlug()
{
return iterationSlug;
}

public void setIterationSlug(String iterationSlug)
{
this.iterationSlug = iterationSlug;
}

public void setSetting(boolean var)
{
setting = var;
Expand All @@ -169,14 +147,13 @@ public boolean getSetting()
{
if (iterationOverrideLocales == null)
{
if (projectSlug == null || iterationSlug == null)
if (projectIterationHome.getInstance() == null)
{
setting = false;
}
else
{
HProjectIteration project = projectIterationDAO.getBySlug(projectSlug, iterationSlug);
setting = project.getOverrideLocales();
setting = projectIterationHome.getInstance().getOverrideLocales();
}
iterationOverrideLocales = new Boolean(setting);
}
Expand Down

0 comments on commit e4142c4

Please sign in to comment.