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

Commit

Permalink
Include state in TU details
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed May 24, 2013
1 parent dd637db commit 6847414
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 10 deletions.
Expand Up @@ -102,6 +102,7 @@ protected void selectDoc(int selected)
doc = item.getDocId();
lastModifiedBy = item.getLastModifiedBy();
lastModifiedDate = item.getLastModifiedDate();
display.setState(item.getState());
}

display.setSourceComment(sourceComment);
Expand Down
Expand Up @@ -3,6 +3,8 @@
import java.util.Date;
import java.util.List;

import org.zanata.common.ContentState;

import net.customware.gwt.presenter.client.widget.WidgetDisplay;

/**
Expand Down Expand Up @@ -45,4 +47,6 @@ interface Listener

void onDocumentListBoxChanged();
}

void setState(ContentState state);
}
Expand Up @@ -3,6 +3,7 @@
import java.util.Date;
import java.util.List;

import org.zanata.common.ContentState;
import org.zanata.webtrans.client.resources.UiMessages;
import org.zanata.webtrans.client.ui.TextContentsDisplay;
import org.zanata.webtrans.client.util.DateUtil;
Expand Down Expand Up @@ -47,6 +48,9 @@ interface TMIUiBinder extends UiBinder<DialogBox, TransMemoryDetailsView>
@UiField
Label lastModified;

@UiField
Label targetState;

@UiField
Button dismissButton;

Expand Down Expand Up @@ -177,4 +181,10 @@ public void clearDocs()
{
documentListBox.clear();
}

@Override
public void setState(ContentState state)
{
targetState.setText(state.toString());
}
}
Expand Up @@ -26,7 +26,6 @@
}

.headerCol {
vertical-align: top;
text-align: right;
width: 120px;
padding-top: 8px;
Expand Down Expand Up @@ -88,6 +87,14 @@
<g:Label ui:field='targetComment' styleName="{style.comment}"/>
</g:customCell>
</g:row>
<g:row>
<g:customCell styleName="{style.headerCol}">
<g:Label styleName="headerLabel" text="Content State:"/>
</g:customCell>
<g:customCell>
<g:Label ui:field='targetState'/>
</g:customCell>
</g:row>
</g:Grid>
</g:ScrollPanel>
</g:layer>
Expand Down
Expand Up @@ -85,7 +85,7 @@ protected TransMemoryDetails getTransMemoryDetail(HLocale hLocale, HTextFlow tf)
{
username = tft.getLastModifiedBy().getAccount().getUsername();
}
return new TransMemoryDetails(HSimpleComment.toString(sourceComment), HSimpleComment.toString(targetComment), projectName, iterationName, docId, tf.getResId(), msgContext, username, tft.getLastChanged());
return new TransMemoryDetails(HSimpleComment.toString(sourceComment), HSimpleComment.toString(targetComment), projectName, iterationName, docId, tf.getResId(), msgContext, tft.getState(), username, tft.getLastChanged());
}

@Override
Expand Down
Expand Up @@ -2,6 +2,8 @@

import java.util.Date;

import org.zanata.common.ContentState;

import com.google.common.base.Objects;
import com.google.gwt.user.client.rpc.IsSerializable;

Expand All @@ -15,6 +17,7 @@ public class TransMemoryDetails implements IsSerializable
private String docId;
private String resId;
private String msgContext;
private ContentState state;
private String lastModifiedBy;
private Date lastModifiedDate;

Expand All @@ -23,7 +26,7 @@ private TransMemoryDetails()
{
}

public TransMemoryDetails(String sourceComment, String targetComment, String projectName, String iterationName, String docId, String resId, String msgContext, String lastModifiedBy, Date lastModifiedDate)
public TransMemoryDetails(String sourceComment, String targetComment, String projectName, String iterationName, String docId, String resId, String msgContext, ContentState state, String lastModifiedBy, Date lastModifiedDate)
{
this.sourceComment = sourceComment;
this.targetComment = targetComment;
Expand All @@ -32,6 +35,7 @@ public TransMemoryDetails(String sourceComment, String targetComment, String pro
this.docId = docId;
this.resId = resId;
this.msgContext = msgContext;
this.state = state;
this.lastModifiedBy = lastModifiedBy;
this.lastModifiedDate = lastModifiedDate;
}
Expand Down Expand Up @@ -72,6 +76,11 @@ public String getMsgContext()
return msgContext;
}

public ContentState getState()
{
return state;
}

public String getLastModifiedBy()
{
return lastModifiedBy;
Expand All @@ -94,6 +103,7 @@ public String toString()
add("docId", docId).
add("resId", resId).
add("msgContext", msgContext).
add("state", state).
add("lastModifiedBy", lastModifiedBy).
add("lastModifiedDate", lastModifiedDate).
toString();
Expand Down
Expand Up @@ -12,6 +12,7 @@
import org.mockito.MockitoAnnotations;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.zanata.common.ContentState;
import org.zanata.webtrans.client.resources.UiMessages;
import org.zanata.webtrans.client.rpc.AbstractAsyncCallback;
import org.zanata.webtrans.client.rpc.CachingDispatchAsync;
Expand Down Expand Up @@ -71,7 +72,7 @@ public void testShow() throws Exception

Date lastModifiedDate = new Date();
// testing on callback success
TransMemoryDetails details = new TransMemoryDetails("source comment", "target comment", "project", "iteration", "docId", "resId", "msgContext", "admin", lastModifiedDate);
TransMemoryDetails details = new TransMemoryDetails("source comment", "target comment", "project", "iteration", "docId", "resId", "msgContext", ContentState.Approved, "admin", lastModifiedDate);
callback.onSuccess(new TransMemoryDetailsList(Lists.newArrayList(details)));

InOrder inOrder = Mockito.inOrder(display);
Expand Down Expand Up @@ -103,8 +104,8 @@ public void testOnDocumentListBoxChanged() throws Exception
{
Date lastModifiedDate = new Date();
// Given: two details
TransMemoryDetails details1 = new TransMemoryDetails("source comment1", "target comment1", "project", "1", "docId1", "resId", "msgContext", "admin", lastModifiedDate);
TransMemoryDetails details2 = new TransMemoryDetails("source comment2", "target comment2", "project", "2", "docId2", "resId", "msgContext", null, lastModifiedDate);
TransMemoryDetails details1 = new TransMemoryDetails("source comment1", "target comment1", "project", "1", "docId1", "resId", "msgContext", ContentState.Approved, "admin", lastModifiedDate);
TransMemoryDetails details2 = new TransMemoryDetails("source comment2", "target comment2", "project", "2", "docId2", "resId", "msgContext", ContentState.Approved, null, lastModifiedDate);
presenter.setStatForTesting(new TransMemoryDetailsList(Lists.newArrayList(details1, details2)));

// When: selecting second one
Expand Down
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Date;

import org.zanata.common.ContentState;
import org.zanata.webtrans.shared.model.TransMemoryDetails;
import org.zanata.webtrans.shared.rpc.GetTransMemoryDetailsAction;
import org.zanata.webtrans.shared.rpc.TransMemoryDetailsList;
Expand All @@ -28,7 +29,7 @@ public void execute()
ArrayList<TransMemoryDetails> items = new ArrayList<TransMemoryDetails>();
for (int i = 0; i < 4; i++)
{
items.add(new TransMemoryDetails("source " + i + " comment", "target " + i + " comment", "workspace " + i, "iteration "+ i, "doc id:" + + i, "resId", "msgContext", "Bob", new Date()));
items.add(new TransMemoryDetails("source " + i + " comment", "target " + i + " comment", "workspace " + i, "iteration "+ i, "doc id:" + + i, "resId", "msgContext", ContentState.Approved, "Bob", new Date()));
}

callback.onSuccess(new TransMemoryDetailsList(items));
Expand Down
Expand Up @@ -141,7 +141,7 @@ private static TransMemoryResultItem tmResult(Long sourceId, int percent)

private static TransMemoryDetails tmDetail()
{
return new TransMemoryDetails("", "", "project a", "master", "pot/msg.pot", "resId", null, null, null);
return new TransMemoryDetails("", "", "project a", "master", "pot/msg.pot", "resId", null, null, null, null);
}


Expand Down Expand Up @@ -287,7 +287,7 @@ public void willNotTranslateIfDifferentMetaDataOptionSetToSkip() throws ActionEx
.thenReturn(newArrayList(mostSimilarTM, tmResult(12L, 90), tmResult(13L, 80)));
when(textFlowDAO.findById(tmResultSource.getId(), false)).thenReturn(tmResultSource);
// Given: tm detail of text flow id 11 which has different doc id
TransMemoryDetails tmDetails = new TransMemoryDetails("", "", "project a", "master", "different/doc/id", "resId", "", "", new Date());
TransMemoryDetails tmDetails = new TransMemoryDetails("", "", "project a", "master", "different/doc/id", "resId", "", ContentState.Approved, "", new Date());
when(getTransMemoryDetailsHandler.getTransMemoryDetail(hLocale, tmResultSource)).thenReturn(tmDetails);

// When: execute the action
Expand Down
Expand Up @@ -84,7 +84,7 @@ private static TransMemoryResultItem tmResultWithSimilarity(double percent)

private static TransMemoryDetails tmDetail(String projectName, String docId, String resId, String msgContext)
{
return new TransMemoryDetails(null, null, projectName, null, docId, resId, msgContext, null, null);
return new TransMemoryDetails(null, null, projectName, null, docId, resId, msgContext, null, null, null);
}

private static TransMemoryMerge mergeTMAction(MergeOption differentProjectOption, MergeOption differentDocumentOption, MergeOption differentResIdOption)
Expand Down

0 comments on commit 6847414

Please sign in to comment.