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 rhbz903926
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Jan 31, 2013
2 parents e182d96 + d609058 commit f5eae0a
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 41 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -31,7 +31,7 @@
<seam.version>2.2.2.Final</seam.version>

<zanata.api.version>2.1.1-SNAPSHOT</zanata.api.version>
<zanata.client.version>1.6.0</zanata.client.version>
<zanata.client.version>2.0.2-SNAPSHOT</zanata.client.version>
<zanata.common.version>2.1.1</zanata.common.version>

<richfaces.version>3.3.3.Final</richfaces.version>
Expand Down
16 changes: 6 additions & 10 deletions zanata-war/src/main/java/org/zanata/dao/DocumentDAO.java
Expand Up @@ -151,22 +151,18 @@ public Long getTotalWordCountForDocument(HDocument document)

public HTextFlowTarget getLastTranslated(long docId, LocaleId localeId)
{
StringBuilder queryStr = new StringBuilder(
"select tft, max(tft.lastChanged)" +
"from HTextFlowTarget tft " +
"where tft.textFlow.document.id = :docId " +
"and tft.locale.localeId = :localeId"

);
String query = "from HTextFlowTarget tft " +
"where tft.textFlow.document.id = :docId and tft.locale.localeId = :localeId and " +
"tft.lastChanged = (select max(t.lastChanged) from HTextFlowTarget t " +
"where t.id = :docId and t.locale.localeId = :localeId )";

Query q = getSession().createQuery( queryStr.toString() );
Query q = getSession().createQuery( query );
q.setParameter("docId", docId);
q.setParameter("localeId", localeId);
q.setCacheable(true);
q.setComment("DocumentDAO.getLastTranslated");

Object[] obj = (Object[]) q.uniqueResult();
return (HTextFlowTarget) obj[0];
return (HTextFlowTarget) q.uniqueResult();
}


Expand Down
Expand Up @@ -419,7 +419,7 @@ private HDocumentUpload saveFirstUploadPart(String projectSlug, String iteration
private void saveUploadPart(DocumentFileUploadForm uploadForm, HDocumentUpload upload) throws IOException
{
Blob partContent;
partContent = Hibernate.createBlob(uploadForm.getFileStream());
partContent = Hibernate.createBlob(uploadForm.getFileStream(), uploadForm.getSize().intValue());
HDocumentUploadPart newPart = new HDocumentUploadPart();
newPart.setContent(partContent);
upload.getParts().add(newPart);
Expand Down
Expand Up @@ -246,8 +246,16 @@ public static void transfer(Project from, HProject to)
to.setDefaultProjectType(from.getDefaultType());
// TODO Currently all Projects are created as Current
// to.setStatus(from.getStatus());
to.setSourceViewURL(from.getSourceViewURL());
to.setSourceCheckoutURL(from.getSourceCheckoutURL());

// keep source URLs unless they are specifically overwritten
if (from.getSourceViewURL() != null)
{
to.setSourceViewURL(from.getSourceViewURL());
}
if (from.getSourceCheckoutURL() != null)
{
to.setSourceCheckoutURL(from.getSourceCheckoutURL());
}
}

public static void transfer(HProject from, Project to)
Expand Down
8 changes: 3 additions & 5 deletions zanata-war/src/main/resources/messages.properties
Expand Up @@ -561,13 +561,11 @@ jsf.SignUp=Sign Up
jsf.SiteMap=Site map
jsf.SizeMembers=#{languageTeamAction.locale.members.size} members
jsf.Slug=Slug
jsf.SourceCheckoutUrl=Source Checkout
jsf.SourceCheckoutUrl=Source Download/Checkout
jsf.SourceDocuments=Source Documents
jsf.SourceDocs=Source Docs
jsf.SourceUrlHumanReadable=Source URL (human-readable)
jsf.SourceUrlHumanReadableExample=e.g. https://github.com/zanata/zanata
jsf.SourceUrlMachineReadable=Source URL (machine-readable)
jsf.SourceUrlMachineReadableExample=e.g. git@github.com:zanata/zanata.git
jsf.SourceUrlHumanReadableExample=Link to human-readable source, e.g. https://github.com/zanata/zanata
jsf.SourceUrlMachineReadableExample=URL for checkout of source by version control software, e.g. git@github.com:zanata/zanata.git
jsf.Start=Start
jsf.Statistics=Statistics
jsf.Status=Status
Expand Down
Expand Up @@ -47,7 +47,7 @@
</s:decorate>

<s:decorate id="humanViewableSourceUrlField" template="edit.xhtml">
<ui:define name="label">#{messages['jsf.SourceUrlHumanReadable']}</ui:define>
<ui:define name="label">#{messages['jsf.viewSourceFiles']}</ui:define>
<h:inputText id="humanViewableSourceUrl" required="false"
value="#{projectHome.instance.sourceViewURL}" style="width:400px;"/>
<s:span styleClass="icon-info-circle-2 input_help" id="humanSourceUrlHelp">
Expand All @@ -58,7 +58,7 @@
</s:decorate>

<s:decorate id="machineReadableSourceUrlField" template="edit.xhtml">
<ui:define name="label">#{messages['jsf.SourceUrlMachineReadable']}</ui:define>
<ui:define name="label">#{messages['jsf.SourceCheckoutUrl']}</ui:define>
<h:inputText id="machineReadableSourceUrl" required="false"
value="#{projectHome.instance.sourceCheckoutURL}" style="width:400px;"/>
<s:span styleClass="icon-info-circle-2 input_help" id="machineSourceUrlHelp">
Expand Down
Expand Up @@ -96,7 +96,7 @@ public void startCopyTrans()
{
CopyTransResource copyTransResource = getClientRequestFactory().createProxy(CopyTransResource.class);

copyTransResource.startCopyTrans("sample-project", "1.0", "/my/path/document.txt");
copyTransResource.startCopyTrans("sample-project", "1.0", "my/path/document.txt");
verify(mockIdentity).getCredentials();
}

Expand All @@ -105,10 +105,10 @@ public void startCopyTransAndCheckStatus()
{
CopyTransResource copyTransResource = getClientRequestFactory().createProxy(CopyTransResource.class);

copyTransResource.startCopyTrans("sample-project", "1.0", "/my/path/document.txt");
copyTransResource.startCopyTrans("sample-project", "1.0", "my/path/document.txt");
verify(mockIdentity).getCredentials();

CopyTransStatus status = copyTransResource.getCopyTransStatus("sample-project", "1.0", "/my/path/document.txt");
CopyTransStatus status = copyTransResource.getCopyTransStatus("sample-project", "1.0", "my/path/document.txt");
assertThat(status, notNullValue());
verify(mockIdentity, atLeast(1)).checkPermission(eq("copy-trans"), anyVararg());
}
Expand Down Expand Up @@ -137,7 +137,7 @@ public void unauthorizedStartCopyTrans()

try
{
copyTransResource.startCopyTrans("sample-project", "1.0", "/my/path/document.txt");
copyTransResource.startCopyTrans("sample-project", "1.0", "my/path/document.txt");
assertThat("startCopyTrans should have returned 401 in the form of an exception.", false);
}
catch (ClientResponseFailure failure)
Expand Down
Expand Up @@ -11,6 +11,7 @@

import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.core.Headers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.DataProvider;
Expand Down Expand Up @@ -69,7 +70,7 @@ private <T extends Serializable> void testRestUtilUnmarshall(T entity, Class<T>
log.info("expect:" + testStr);

messageBody = new ByteArrayInputStream(testStr.getBytes("UTF-8"));
T unmarshall = (T) RestUtils.unmarshall(type, messageBody, MediaType.APPLICATION_XML_TYPE, null);
T unmarshall = (T) RestUtils.unmarshall(type, messageBody, MediaType.APPLICATION_XML_TYPE, new Headers<String>());
Log.info("got:" + unmarshall.toString());
assertThat(entity.toString(), is(testStr));
}
Expand Down
Expand Up @@ -62,7 +62,7 @@ public void getPo() throws Exception
protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
request.setQueryString(""); // Need to add this when using query params or else the test fails
request.addQueryParameter("docId", "/my/path/document.txt");
request.addQueryParameter("docId", "my/path/document.txt");
}

@Override
Expand Down
Expand Up @@ -141,7 +141,7 @@ protected void onResponse(EnhancedMockHttpServletResponse response)
public void getDocumentStatisticsXml() throws Exception
{
new ResourceRequestEnvironment.ResourceRequest(unauthorizedEnvironment, ResourceRequestEnvironment.Method.GET,
"/restv1/stats/proj/sample-project/iter/1.0/doc//my/path/document.txt")
"/restv1/stats/proj/sample-project/iter/1.0/doc/my/path/document.txt")
{
@Override
protected void prepareRequest(EnhancedMockHttpServletRequest request)
Expand All @@ -156,7 +156,7 @@ protected void onResponse(EnhancedMockHttpServletResponse response)
assertJaxbUnmarshal(response, ContainerTranslationStatistics.class);

ContainerTranslationStatistics stats = jaxbUnmarshal(response, ContainerTranslationStatistics.class);
assertThat(stats.getId(), is("/my/path/document.txt"));
assertThat(stats.getId(), is("my/path/document.txt"));
assertThat(stats.getRefs().size(), greaterThan(0));
assertThat(stats.getDetailedStats(), nullValue()); // No detailed stats
assertThat(stats.getStats().size(), greaterThan(0));
Expand All @@ -178,7 +178,7 @@ protected void onResponse(EnhancedMockHttpServletResponse response)
public void getDocumentStatisticsXmlWithDetails() throws Exception
{
new ResourceRequestEnvironment.ResourceRequest(unauthorizedEnvironment, ResourceRequestEnvironment.Method.GET,
"/restv1/stats/proj/sample-project/iter/1.0/doc//my/path/document.txt")
"/restv1/stats/proj/sample-project/iter/1.0/doc/my/path/document.txt")
{
@Override
protected void prepareRequest(EnhancedMockHttpServletRequest request)
Expand All @@ -194,7 +194,7 @@ protected void onResponse(EnhancedMockHttpServletResponse response)
assertJaxbUnmarshal(response, ContainerTranslationStatistics.class);

ContainerTranslationStatistics stats = jaxbUnmarshal(response, ContainerTranslationStatistics.class);
assertThat(stats.getId(), is("/my/path/document.txt"));
assertThat(stats.getId(), is("my/path/document.txt"));
assertThat(stats.getRefs().size(), greaterThan(0));
//assertThat(stats.getDetailedStats().size(), greaterThan(0)); // No detailed stats (maybe later)
assertThat(stats.getStats().size(), greaterThan(0));
Expand Down Expand Up @@ -303,7 +303,7 @@ protected void onResponse(EnhancedMockHttpServletResponse response)
public void getDocumentStatisticsJson() throws Exception
{
new ResourceRequestEnvironment.ResourceRequest(unauthorizedEnvironment, ResourceRequestEnvironment.Method.GET,
"/restv1/stats/proj/sample-project/iter/1.0/doc//my/path/document.txt")
"/restv1/stats/proj/sample-project/iter/1.0/doc/my/path/document.txt")
{
@Override
protected void prepareRequest(EnhancedMockHttpServletRequest request)
Expand All @@ -318,7 +318,7 @@ protected void onResponse(EnhancedMockHttpServletResponse response)
assertJsonUnmarshal(response, ContainerTranslationStatistics.class);

ContainerTranslationStatistics stats = jsonUnmarshal(response, ContainerTranslationStatistics.class);
assertThat(stats.getId(), is("/my/path/document.txt"));
assertThat(stats.getId(), is("my/path/document.txt"));
assertThat(stats.getRefs().size(), greaterThan(0));
assertThat(stats.getDetailedStats(), nullValue()); // No detailed stats
assertThat(stats.getStats().size(), greaterThan(0));
Expand All @@ -340,7 +340,7 @@ protected void onResponse(EnhancedMockHttpServletResponse response)
public void getDocumentStatisticsJsonWithDetails() throws Exception
{
new ResourceRequestEnvironment.ResourceRequest(unauthorizedEnvironment, ResourceRequestEnvironment.Method.GET,
"/restv1/stats/proj/sample-project/iter/1.0/doc//my/path/document.txt")
"/restv1/stats/proj/sample-project/iter/1.0/doc/my/path/document.txt")
{
@Override
protected void prepareRequest(EnhancedMockHttpServletRequest request)
Expand All @@ -356,7 +356,7 @@ protected void onResponse(EnhancedMockHttpServletResponse response)
assertJsonUnmarshal(response, ContainerTranslationStatistics.class);

ContainerTranslationStatistics stats = jsonUnmarshal(response, ContainerTranslationStatistics.class);
assertThat(stats.getId(), is("/my/path/document.txt"));
assertThat(stats.getId(), is("my/path/document.txt"));
assertThat(stats.getRefs().size(), greaterThan(0));
//assertThat(stats.getDetailedStats().size(), greaterThan(0)); // No detailed stats (maybe later)
assertThat(stats.getStats().size(), greaterThan(0));
Expand Down
Expand Up @@ -159,10 +159,10 @@ public void getSimpleDocumentStatisticsForAllLocales()
{
StatisticsServiceImpl statisticsService = seam.autowire(StatisticsServiceImpl.class);
ContainerTranslationStatistics stats =
statisticsService.getStatistics("sample-project", "1.0", "/my/path/document.txt", false, new String[]{});
statisticsService.getStatistics("sample-project", "1.0", "my/path/document.txt", false, new String[]{});

// Make sure the id matches
assertThat(stats.getId(), is("/my/path/document.txt"));
assertThat(stats.getId(), is("my/path/document.txt"));
// Make sure there are links
assertThat(stats.getRefs().size(), greaterThan(0));

Expand All @@ -187,10 +187,10 @@ public void getDetailedDocumentStatisticsForSpecificLocales()

StatisticsServiceImpl statisticsService = seam.autowire(StatisticsServiceImpl.class);
ContainerTranslationStatistics stats =
statisticsService.getStatistics("sample-project", "1.0", "/my/path/document.txt", true, locales);
statisticsService.getStatistics("sample-project", "1.0", "my/path/document.txt", true, locales);

// Make sure the id matches
assertThat(stats.getId(), is("/my/path/document.txt"));
assertThat(stats.getId(), is("my/path/document.txt"));
// Make sure there are links
assertThat(stats.getRefs().size(), greaterThan(0));

Expand Down
6 changes: 6 additions & 0 deletions zanata-war/src/test/resources/log4j.xml
Expand Up @@ -21,6 +21,12 @@
<level value="info" />
</logger>
-->
<!-- below will log hibernate generated SQL-->
<!--
<logger name="org.hibernate.SQL">
<level value="TRACE" />
</logger>
-->
<logger name="gwt-log">
<level value="OFF" />
</logger>
Expand Down
Expand Up @@ -6,10 +6,10 @@
creationDate="2009-09-01 20:30:16"
lastChanged="2009-09-01 20:30:16"
contentType="text/plain"
docId="/my/path/document.txt"
docId="my/path/document.txt"
locale="4"
name="document.txt"
path="/my/path"
path="my/path"
project_iteration_id="1"
revision="1"
obsolete="0"
Expand Down

0 comments on commit f5eae0a

Please sign in to comment.