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

Commit

Permalink
rhbz953734 - refactor content state
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed May 27, 2013
1 parent 965df42 commit b829f3b
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 12 deletions.
Expand Up @@ -329,7 +329,7 @@ private static List<String> getContents(Message message)
// NB: we don't check that the number of msgstr_plurals matches nplurals on the client, only on the server
static ContentState getContentState(Message message)
{
ContentState requestedState = message.isFuzzy() ? ContentState.NeedReview : ContentState.Approved;
ContentState requestedState = message.isFuzzy() ? ContentState.NeedReview : ContentState.Translated;
List<String> contents = getContents(message);
return ContentStateUtil.determineState(requestedState, contents);
}
Expand Down
Expand Up @@ -123,7 +123,7 @@ public void testContentStateApprovedSingle()
Message m = new Message();
m.setMsgstr("s");
ContentState actual1 = PoReader2.getContentState(m);
assertThat(actual1, is(ContentState.Approved));
assertThat(actual1, is(ContentState.Translated));
}

public void testContentStateApprovedPlural1()
Expand All @@ -132,7 +132,7 @@ public void testContentStateApprovedPlural1()
m.setMsgidPlural("plural");
m.addMsgstrPlural("s0", 0);
ContentState actual1 = PoReader2.getContentState(m);
assertThat(actual1, is(ContentState.Approved));
assertThat(actual1, is(ContentState.Translated));
}

public void testContentStateApprovedPlural2()
Expand All @@ -142,7 +142,7 @@ public void testContentStateApprovedPlural2()
m.addMsgstrPlural("s0", 0);
m.addMsgstrPlural("s1", 1);
ContentState actual1 = PoReader2.getContentState(m);
assertThat(actual1, is(ContentState.Approved));
assertThat(actual1, is(ContentState.Translated));
}

public void testContentStateNewSingle1()
Expand Down
Expand Up @@ -48,7 +48,7 @@ public PropReader(String charset, LocaleId sourceLocale, ContentState contentSta

public PropReader()
{
this(ISO_8859_1, LocaleId.EN_US, ContentState.Approved);
this(ISO_8859_1, LocaleId.EN_US, ContentState.Translated);
}

// pre: template already extracted
Expand Down
Expand Up @@ -15,7 +15,6 @@
import org.fedorahosted.openprops.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zanata.common.ContentState;
import org.zanata.rest.dto.extensions.comment.SimpleComment;
import org.zanata.rest.dto.resource.Resource;
import org.zanata.rest.dto.resource.TextFlow;
Expand Down Expand Up @@ -144,7 +143,7 @@ private static void storeProps(Properties props, File file, boolean utf8) throws

private static void textFlowTargetToProperty(String resId, TextFlowTarget target, Properties targetProp, boolean createSkeletons)
{
if (target == null || target.getState() != ContentState.Approved || target.getContents() == null || target.getContents().size() == 0)
if (target == null || !target.getState().isTranslated() || target.getContents() == null || target.getContents().size() == 0)
{
// don't save fuzzy or empty values
if (createSkeletons)
Expand Down
Expand Up @@ -40,7 +40,7 @@ public class PropReaderTest
@BeforeMethod
public void resetReader()
{
propReader = new PropReader(ISO_8859_1, new LocaleId(locale), ContentState.Approved);
propReader = new PropReader(ISO_8859_1, new LocaleId(locale), ContentState.Translated);
}

@Test
Expand Down
Expand Up @@ -161,7 +161,7 @@ else if (xmlr.isStartElement() && getLocalName(xmlr).equals(ELE_TRANS_UNIT))
boolean targetEmpty = contents.isEmpty() || StringUtils.isEmpty(contents.get(0));
if (!targetEmpty)
{
tfTarget.setState(ContentState.Approved);
tfTarget.setState(ContentState.Translated);
transDoc.getTextFlowTargets().add(tfTarget);
}
}
Expand Down
Expand Up @@ -13,7 +13,6 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

import org.zanata.common.ContentState;
import org.zanata.rest.dto.extensions.comment.SimpleComment;
import org.zanata.rest.dto.extensions.gettext.TextFlowExtension;
import org.zanata.rest.dto.resource.Resource;
Expand Down Expand Up @@ -83,7 +82,7 @@ private static void writeTransUnits(IndentingXMLStreamWriter writer, Resource do
writer.writeStartElement(ELE_TRANS_UNIT);
writer.writeAttribute(ATTRI_ID, textFlow.getId());
writeTransUnitSource(writer, textFlow);
if (target != null && target.getState() == ContentState.Approved)
if (target != null && target.getState().isTranslated())
{
writeTransUnitTarget(writer, target);
}
Expand Down
Expand Up @@ -29,7 +29,6 @@
import static org.zanata.common.ContentState.*;
import org.testng.annotations.Test;
import org.zanata.common.ContentState;
import org.zanata.common.util.ContentStateUtil;

@Test(groups = { "unit-tests" })
public class ContentStateUtilTest
Expand Down

0 comments on commit b829f3b

Please sign in to comment.