Skip to content

Commit

Permalink
Merge 9c07e49 into a24ae5b
Browse files Browse the repository at this point in the history
  • Loading branch information
chripalombella committed May 7, 2018
2 parents a24ae5b + 9c07e49 commit 27bf64f
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ buildNumber.properties
/.settings
/.project
/.classpath
/bin/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If you use Maven to manage the dependencies in your Java project (and you should
<!-- Liferay Journal Article Converter library -->
<groupId>com.github.davidepastore</groupId>
<artifactId>liferay-journal-article-converter</artifactId>
<version>0.1.0</version>
<version>7.0.0</version>
</dependency>
```

Expand Down
22 changes: 21 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<url>https://github.com/DavidePastore/liferay-journal-article-converter</url>

<properties>
<liferay.version>6.2.1</liferay.version>
<liferay.version>7.0.0-nightly</liferay.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -178,6 +178,26 @@
<version>1.8.3</version>
</dependency>

<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.journal.api</artifactId>
<version>2.12.4</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>com.liferay.portal.kernel</artifactId>
<version>2.61.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.dynamic.data.mapping.api</artifactId>
<version>3.7.3</version>
<scope>provided</scope>
</dependency>

<!-- Test -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.github.davidepastore.liferay.util.SimpleLocaleUtil;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portlet.journal.model.JournalArticle;
import com.liferay.journal.model.JournalArticle;

/**
* The Convertible Journal Article class that contains the methods to convert a {@link JournalArticle}
Expand Down Expand Up @@ -120,7 +120,7 @@ protected void setValueFromElements(Elements elements, Object object, String tit
* @throws InstantiationException
* @throws IllegalAccessException
*/
protected Object getObjectValue(Element element, Object object, String title) throws InstantiationException, IllegalAccessException{
protected Object getObjectValue(Element element, Object object, String title) throws InstantiationException, IllegalAccessException, NumberFormatException, IndexOutOfBoundsException {
Object value = null;
String type = element.attr("type");
String stringValue = element.text();
Expand Down Expand Up @@ -184,6 +184,8 @@ protected Object getObjectValue(Element element, Object object, String title) th
}
} else if(type.equals("text_box")){
value = stringValue;
} else if(type.equals("text_area")){
value = stringValue;
}

return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/
public class JournalArticleConverterTest extends TestCase {

@SuppressWarnings("unused")
private static Log log = LogFactoryUtil.getLog(JournalArticleConverterTest.class);

/**
Expand Down Expand Up @@ -98,6 +99,9 @@ public void testFromJournalArticleSimple() throws Exception {

//Text Box value
assertEquals("Text box", testJournalArticle.getTextBox());

//Text Area value
assertEquals("Text area", testJournalArticle.getTextArea());
}

/**
Expand Down Expand Up @@ -179,6 +183,9 @@ public void testFromJournalArticleForDefaultLanguage() throws Exception {

//Text Box value
assertEquals("Text box", testJournalArticle.getTextBox());

//Text Area value
assertEquals("Text area", testJournalArticle.getTextArea());
}

/**
Expand Down
164 changes: 134 additions & 30 deletions src/test/java/com/github/davidepastore/liferay/MockedJournalArticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,30 @@
import org.jsoup.select.Elements;

import com.github.davidepastore.liferay.util.SimpleLocaleUtil;
import com.liferay.portal.LocaleException;
import com.liferay.portal.kernel.exception.LocaleException;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.lar.StagedModelType;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.trash.TrashHandler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.journal.model.JournalArticle;
import com.liferay.portlet.journal.model.JournalArticleResource;
import com.liferay.portlet.journal.model.JournalFolder;
import com.liferay.portlet.trash.model.TrashEntry;
import com.liferay.dynamic.data.mapping.model.DDMStructure;
import com.liferay.dynamic.data.mapping.model.DDMTemplate;
import com.liferay.expando.kernel.model.ExpandoBridge;
import com.liferay.journal.model.JournalArticle;
import com.liferay.journal.model.JournalArticleResource;
import com.liferay.journal.model.JournalFolder;
import com.liferay.exportimport.kernel.lar.StagedModelType;
import com.liferay.portal.kernel.model.Layout;
import com.liferay.portal.kernel.model.CacheModel;

public class MockedJournalArticle implements JournalArticle{

private static final long serialVersionUID = 8768627349017828838L;

@SuppressWarnings("unused")
private static Log log = LogFactoryUtil.getLog(MockedJournalArticle.class);

private String content;
Expand Down Expand Up @@ -555,11 +560,6 @@ public void setStatusDate(Date statusDate) {

}

public TrashEntry getTrashEntry() throws PortalException, SystemException {
// TODO Auto-generated method stub
return null;
}

public long getTrashEntryClassPK() {
// TODO Auto-generated method stub
return 0;
Expand Down Expand Up @@ -689,27 +689,11 @@ public String getDefaultLanguageId() {
return getDefaultLocale();
}

public void prepareLocalizedFieldsForImport() throws LocaleException {
// TODO Auto-generated method stub

}

public void prepareLocalizedFieldsForImport(Locale defaultImportLocale)
throws LocaleException {
// TODO Auto-generated method stub

}

public int compareTo(JournalArticle journalArticle) {
// TODO Auto-generated method stub
return 0;
}

public CacheModel<JournalArticle> toCacheModel() {
// TODO Auto-generated method stub
return null;
}

public JournalArticle toEscapedModel() {
// TODO Auto-generated method stub
return null;
Expand Down Expand Up @@ -858,4 +842,124 @@ public void setSmallImageType(String smallImageType) {

}

}
public boolean isInTrashExplicitly() {
// TODO Auto-generated method stub
return false;
}

public boolean isInTrashImplicitly() {
// TODO Auto-generated method stub
return false;
}

public boolean isEntityCacheEnabled() {
// TODO Auto-generated method stub
return false;
}

public boolean isFinderCacheEnabled() {
// TODO Auto-generated method stub
return false;
}

public long getArticleImageId(String arg0, String arg1, String arg2) {
// TODO Auto-generated method stub
return 0;
}

public DDMStructure getDDMStructure() throws PortalException {
// TODO Auto-generated method stub
return null;
}

public DDMTemplate getDDMTemplate() throws PortalException {
// TODO Auto-generated method stub
return null;
}

public com.liferay.portal.kernel.xml.Document getDocument() {
// TODO Auto-generated method stub
return null;
}

public Layout getLayout() {
// TODO Auto-generated method stub
return null;
}

public void setDefaultLanguageId(String arg0) {
// TODO Auto-generated method stub

}

public void setDocument(com.liferay.portal.kernel.xml.Document arg0) {
// TODO Auto-generated method stub

}

public String getDDMStructureKey() {
// TODO Auto-generated method stub
return null;
}

public String getDDMTemplateKey() {
// TODO Auto-generated method stub
return null;
}

public Date getLastPublishDate() {
// TODO Auto-generated method stub
return null;
}

public com.liferay.trash.kernel.model.TrashEntry getTrashEntry() throws PortalException {
// TODO Auto-generated method stub
return null;
}

public void setDDMStructureKey(String arg0) {
// TODO Auto-generated method stub

}

public void setDDMTemplateKey(String arg0) {
// TODO Auto-generated method stub

}

public void setExpandoBridgeAttributes(com.liferay.portal.kernel.model.BaseModel<?> arg0) {
// TODO Auto-generated method stub

}

public void setExpandoBridgeAttributes(com.liferay.portal.kernel.service.ServiceContext arg0) {
// TODO Auto-generated method stub

}

public void setLastPublishDate(Date arg0) {
// TODO Auto-generated method stub

}

public String getArticleImageURL(com.liferay.portal.kernel.theme.ThemeDisplay arg0) {
// TODO Auto-generated method stub
return null;
}

public CacheModel<JournalArticle> toCacheModel() {
// TODO Auto-generated method stub
return null;
}

public void prepareLocalizedFieldsForImport() throws LocaleException {
// TODO Auto-generated method stub

}

public void prepareLocalizedFieldsForImport(Locale arg0)
throws LocaleException {
// TODO Auto-generated method stub

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class SimpleTestJournalArticle extends ConvertibleJournalArticle {

@JournalArticleField(name = "textBox")
private String textBox;

@JournalArticleField(name = "textArea")
private String textArea;

public String getTitle() {
return title;
Expand Down Expand Up @@ -152,4 +155,12 @@ public void setTextBox(String textBox) {
this.textBox = textBox;
}

public String getTextArea() {
return textArea;
}

public void setTextArea(String textArea) {
this.textArea = textArea;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class TestJournalArticle extends ConvertibleJournalArticle {

@JournalArticleField(name = "textBox")
private String textBox;

@JournalArticleField(name = "textArea")
private String textArea;

@JournalArticleField(name = "documentsAndMedia")
private String documentsAndMedia;
Expand Down Expand Up @@ -155,6 +158,14 @@ public void setTextBox(String textBox) {
this.textBox = textBox;
}

public String getTextArea() {
return textArea;
}

public void setTextArea(String textArea) {
this.textArea = textArea;
}

public String getDocumentsAndMedia() {
return documentsAndMedia;
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/structure0.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@
<dynamic-element name="textBox" type="text_box" index-type="keyword" index="0">
<dynamic-content language-id="en_US"><![CDATA[Text box]]></dynamic-content>
</dynamic-element>
<dynamic-element name="textArea" type="text_area" index-type="keyword" index="0">
<dynamic-content language-id="en_US"><![CDATA[Text area]]></dynamic-content>
</dynamic-element>
</root>
3 changes: 3 additions & 0 deletions src/test/resources/structure1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
<dynamic-element name="textBox" type="text_box" index-type="keyword" index="0">
<dynamic-content language-id="en_US"><![CDATA[Text box]]></dynamic-content>
</dynamic-element>
<dynamic-element name="textArea" type="text_area" index-type="keyword" index="0">
<dynamic-content language-id="en_US"><![CDATA[Text area]]></dynamic-content>
</dynamic-element>
<dynamic-element name="nested" type="document_library" index-type="keyword" index="0">
<dynamic-element name="nestedBoolean" index="0" type="boolean" index-type="keyword">
<dynamic-content language-id="en_US"><![CDATA[true]]></dynamic-content>
Expand Down

0 comments on commit 27bf64f

Please sign in to comment.