Ajustes para homologação

parent ce6d0e34
...@@ -62,21 +62,8 @@ ...@@ -62,21 +62,8 @@
String SGMPConfig = portletInstanceConfig.SGMPConfig(); String SGMPConfig = portletInstanceConfig.SGMPConfig();
String AAOMCConfig = portletInstanceConfig.AAOMCConfig();
String ARCCConfig = portletInstanceConfig.ARCCConfig();
String GAOMCConfig = portletInstanceConfig.GAOMCConfig();
String ARCCRIConfig = portletInstanceConfig.ARCCRIConfig();
String ACConfig = portletInstanceConfig.ACConfig();
String ADHMConfig = portletInstanceConfig.ADHMConfig();
String AAPConfig = portletInstanceConfig.AAPConfig(); String AAPConfig = portletInstanceConfig.AAPConfig();
String AIConfig = portletInstanceConfig.AIConfig();
%> %>
<liferay-portlet:actionURL portletConfiguration="<%= true %>" <liferay-portlet:actionURL portletConfiguration="<%= true %>"
...@@ -127,7 +114,7 @@ ...@@ -127,7 +114,7 @@
value="<%=SGJAConfig%>" /> value="<%=SGJAConfig%>" />
<aui:input name="SGJPIConfig" <aui:input name="SGJPIConfig"
label="SUBPROCURADORIA GERAL DE JUSTIA DE PLANEJAMENTO INSTITUCIONAL: " label="SUBPROCURADORIA GERAL DE JUSTIA DE PLANEJAMENTO E POLTICAS INSTITUCIONAIS: "
style="width:500px; display:block;" type="text" style="width:500px; display:block;" type="text"
value="<%=SGJPIConfig%>" /> value="<%=SGJPIConfig%>" />
...@@ -137,7 +124,7 @@ ...@@ -137,7 +124,7 @@
value="<%=SGJACIConfig%>" /> value="<%=SGJACIConfig%>" />
<aui:input name="SGJACDHConfig" <aui:input name="SGJACDHConfig"
label="SUBPROCURADORIA GERAL DE JUSTIA DE ASSUNTOS CRIMINAIS E DE DIREITOS HUMANOS: " label="SUBPROCURADORIA GERAL DE JUSTIA DE ASSUNTOS CRIMINAIS: "
style="width:500px; display:block;" type="text" style="width:500px; display:block;" type="text"
value="<%=SGJACDHConfig%>" /> value="<%=SGJACDHConfig%>" />
...@@ -187,44 +174,11 @@ ...@@ -187,44 +174,11 @@
style="width:500px; display:block;" type="text" style="width:500px; display:block;" type="text"
value="<%=SGMPConfig%>" /> value="<%=SGMPConfig%>" />
<aui:input name="AAOMCConfig"
label="ASSESSORIA DE ATRIBUIO ORIGINRIA EM MATRIA CVEL: "
style="width:500px; display:block;" type="text"
value="<%=AAOMCConfig%>" />
<aui:input name="ARCCConfig"
label="ASSESSORIA DE RECURSOS CONSTITUCIONAIS CVEIS: "
style="width:500px; display:block;" type="text"
value="<%=ARCCConfig%>" />
<aui:input name="GAOMCConfig"
label="GRUPO DE ATRIBUIO ORIGINRIA EM MATRIA CRIMINAL: "
style="width:500px; display:block;" type="text"
value="<%=GAOMCConfig%>" />
<aui:input name="ARCCRIConfig"
label="ASSESSORIA DE RECURSOS CONSTITUCIONAIS CRIMINAIS: "
style="width:500px; display:block;" type="text"
value="<%=ARCCRIConfig%>" />
<aui:input name="ACConfig" label="ASSESSORIA CRIMINAL: "
style="width:500px; display:block;" type="text"
value="<%=ACConfig%>" />
<aui:input name="ADHMConfig"
label="ASSESSORIA DE DIRETOS HUMANOS E DE MINORIAS: "
style="width:500px; display:block;" type="text"
value="<%=ADHMConfig%>" />
<aui:input name="AAPConfig" <aui:input name="AAPConfig"
label="ASSESSORIA DE ASSUNTOS PARLAMENTARES: " label="ASSESSORIA DE ASSUNTOS PARLAMENTARES: "
style="width:500px; display:block;" type="text" style="width:500px; display:block;" type="text"
value="<%=AAPConfig%>" /> value="<%=AAPConfig%>" />
<aui:input name="AIConfig" label="ASSESSORIA INTERNACIONAL: "
style="width:500px; display:block;" type="text"
value="<%=AIConfig%>" />
</aui:fieldset> </aui:fieldset>
</liferay-frontend:fieldset> </liferay-frontend:fieldset>
......
...@@ -68,26 +68,5 @@ public interface DoerjCadernoPortletConfiguration { ...@@ -68,26 +68,5 @@ public interface DoerjCadernoPortletConfiguration {
public String SGMPConfig(); public String SGMPConfig();
@Meta.AD(required = false) @Meta.AD(required = false)
public String AAOMCConfig();
@Meta.AD(required = false)
public String ARCCConfig();
@Meta.AD(required = false)
public String GAOMCConfig();
@Meta.AD(required = false)
public String ARCCRIConfig();
@Meta.AD(required = false)
public String ACConfig();
@Meta.AD(required = false)
public String ADHMConfig();
@Meta.AD(required = false)
public String AAPConfig(); public String AAPConfig();
@Meta.AD(required = false)
public String AIConfig();
} }
...@@ -80,14 +80,7 @@ public class DoerjCadernoPortletConfigurationAction extends DefaultConfiguration ...@@ -80,14 +80,7 @@ public class DoerjCadernoPortletConfigurationAction extends DefaultConfiguration
setPreference(actionRequest, "CEAFConfig", ParamUtil.getString(actionRequest, "CEAFConfig")); setPreference(actionRequest, "CEAFConfig", ParamUtil.getString(actionRequest, "CEAFConfig"));
setPreference(actionRequest, "OUVIConfig", ParamUtil.getString(actionRequest, "OUVIConfig")); setPreference(actionRequest, "OUVIConfig", ParamUtil.getString(actionRequest, "OUVIConfig"));
setPreference(actionRequest, "SGMPConfig", ParamUtil.getString(actionRequest, "SGMPConfig")); setPreference(actionRequest, "SGMPConfig", ParamUtil.getString(actionRequest, "SGMPConfig"));
setPreference(actionRequest, "AAOMCConfig", ParamUtil.getString(actionRequest, "AAOMCConfig"));
setPreference(actionRequest, "ARCCConfig", ParamUtil.getString(actionRequest, "ARCCConfig"));
setPreference(actionRequest, "GAOMCConfig", ParamUtil.getString(actionRequest, "GAOMCConfig"));
setPreference(actionRequest, "ARCCRIConfig", ParamUtil.getString(actionRequest, "ARCCRIConfig"));
setPreference(actionRequest, "ACConfig", ParamUtil.getString(actionRequest, "ACConfig"));
setPreference(actionRequest, "ADHMConfig", ParamUtil.getString(actionRequest, "ADHMConfig"));
setPreference(actionRequest, "AAPConfig", ParamUtil.getString(actionRequest, "AAPConfig")); setPreference(actionRequest, "AAPConfig", ParamUtil.getString(actionRequest, "AAPConfig"));
setPreference(actionRequest, "AIConfig", ParamUtil.getString(actionRequest, "AIConfig"));
SessionMessages.add(actionRequest, "servico.sucesso.gravar.config"); SessionMessages.add(actionRequest, "servico.sucesso.gravar.config");
......
...@@ -18,7 +18,6 @@ import javax.xml.bind.JAXBElement; ...@@ -18,7 +18,6 @@ import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.docx4j.XmlUtils;
import org.docx4j.convert.in.xhtml.XHTMLImporterImpl; import org.docx4j.convert.in.xhtml.XHTMLImporterImpl;
import org.docx4j.openpackaging.exceptions.Docx4JException; import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.exceptions.InvalidFormatException; import org.docx4j.openpackaging.exceptions.InvalidFormatException;
...@@ -26,18 +25,19 @@ import org.docx4j.openpackaging.packages.WordprocessingMLPackage; ...@@ -26,18 +25,19 @@ import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.WordprocessingML.DocumentPart; import org.docx4j.openpackaging.parts.WordprocessingML.DocumentPart;
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart; import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
import org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart; import org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart;
import org.docx4j.wml.BooleanDefaultTrue;
import org.docx4j.wml.ContentAccessor; import org.docx4j.wml.ContentAccessor;
import org.docx4j.wml.Lvl;
import org.docx4j.wml.NumFmt;
import org.docx4j.wml.P; import org.docx4j.wml.P;
import org.docx4j.wml.PPr; import org.docx4j.wml.PPr;
import org.docx4j.wml.PPrBase; import org.docx4j.wml.PPrBase;
import org.docx4j.wml.PPrBase.NumPr; import org.docx4j.wml.PPrBase.NumPr;
import org.docx4j.wml.PPrBase.NumPr.Ilvl; import org.docx4j.wml.PPrBase.NumPr.Ilvl;
import org.docx4j.wml.PPrBase.NumPr.NumId; import org.docx4j.wml.PPrBase.NumPr.NumId;
import org.docx4j.wml.R;
import org.docx4j.wml.RPr;
import org.docx4j.wml.Text;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.docx4j.wml.R;
import mprj.doerj.caderno.application.model.Lista; import mprj.doerj.caderno.application.model.Lista;
...@@ -65,8 +65,6 @@ public class CadernoUtil { ...@@ -65,8 +65,6 @@ public class CadernoUtil {
if(tipo.equals("conteudo")||tipo.equals("conteudoPrimeiraPagina")){ if(tipo.equals("conteudo")||tipo.equals("conteudoPrimeiraPagina")){
textoHtml = tratarTagsHtml(textoHtml,"p","manterTags"); textoHtml = tratarTagsHtml(textoHtml,"p","manterTags");
textoHtml = tratarTagsHtml(textoHtml,"o:p","manterTags"); textoHtml = tratarTagsHtml(textoHtml,"o:p","manterTags");
textoHtml = tratarTagsHtml(textoHtml,"b","manterTags"); textoHtml = tratarTagsHtml(textoHtml,"b","manterTags");
...@@ -87,12 +85,23 @@ public class CadernoUtil { ...@@ -87,12 +85,23 @@ public class CadernoUtil {
textoHtml = textoHtml.replaceAll("&ndash;", "-"); textoHtml = textoHtml.replaceAll("&ndash;", "-");
textoHtml = textoHtml.replaceAll("&nbsp;", " "); textoHtml = textoHtml.replaceAll("&nbsp;", " ");
textoHtml = textoHtml.replaceAll("&quot;", "'"); textoHtml = textoHtml.replaceAll("&quot;", "'");
textoHtml = textoHtml.replaceAll("<h1>", "<p>");
textoHtml = textoHtml.replaceAll("</h1>", "</p>");
textoHtml = textoHtml.replaceAll("<h2>", "<p>"); textoHtml = textoHtml.replaceAll("<h2>", "<p>");
textoHtml = textoHtml.replaceAll("</h2>", "</p>"); textoHtml = textoHtml.replaceAll("</h2>", "</p>");
textoHtml = textoHtml.replaceAll("<h3>", "<p>");
textoHtml = textoHtml.replaceAll("</h3>", "</p>");
textoHtml = textoHtml.replaceAll("<h4>", "<p>");
textoHtml = textoHtml.replaceAll("</h4>", "</p>");
textoHtml = textoHtml.replaceAll("<h5>", "<p>"); textoHtml = textoHtml.replaceAll("<h5>", "<p>");
textoHtml = textoHtml.replaceAll("</h5>", "</p>"); textoHtml = textoHtml.replaceAll("</h5>", "</p>");
textoHtml = textoHtml.replaceAll("<h1>", "<p>"); textoHtml = textoHtml.replaceAll("<h6>", "<p>");
textoHtml = textoHtml.replaceAll("</h1>", "</p>"); textoHtml = textoHtml.replaceAll("</h6>", "</p>");
textoHtml = textoHtml.replaceAll("<div>", "");
textoHtml = textoHtml.replaceAll("</div>", "");
textoHtml = textoHtml.replaceAll("\n", "");
textoHtml = textoHtml.replaceAll("\r", "");
textoHtml = textoHtml.replaceAll("o:p", "p"); textoHtml = textoHtml.replaceAll("o:p", "p");
textoHtml = textoHtml.replace("&nspace;"," "); textoHtml = textoHtml.replace("&nspace;"," ");
...@@ -111,22 +120,19 @@ public class CadernoUtil { ...@@ -111,22 +120,19 @@ public class CadernoUtil {
textoHtml = textoHtml.replace("&ndash13;","'"); textoHtml = textoHtml.replace("&ndash13;","'");
textoHtml = textoHtml.replace("&ndash14;","'"); textoHtml = textoHtml.replace("&ndash14;","'");
//"<p>&nbsp;</p>"
String primeirosChar=""; String primeirosChar="";
primeirosChar = textoHtml.substring(1, 3); primeirosChar = textoHtml.substring(0, 3);
/*if (!primeirosChar.equals("<p>")&& !tipo.equals("conteudoPrimeiraPagina")){ if (!primeirosChar.equals("<p>")&& !tipo.equals("conteudoPrimeiraPagina")){
//textoHtml = "<p align='JUSTIFY'>" + textoHtml + "</p>"; //textoHtml = "<p align='JUSTIFY'>" + textoHtml + "</p>";
textoHtml = "<p>" + textoHtml + "</p>"; textoHtml = "<p>" + textoHtml + "</p>";
}*/ }
if(tipo.equals("conteudo")){ if(tipo.equals("conteudo")){
//textoHtml = "<body><head><style type='" + "text/css'" + ">p{font-family:Spranq eco sans;font-size:12px;} </style></head>" + textoHtml + "<p></p></body>"; textoHtml = "<body><head><style type='" + "text/css'" + ">p{font-family:Spranq eco sans;font-size:12px;text-align:justify;margin-left:-8px;margin-top:0px;margin-bottom:0px;} ul {list-style-type: circle;} </style></head>" + textoHtml + "</body>";
textoHtml = "<body><head><style type='" + "text/css'" + ">p{font-family:Spranq eco sans;font-size:12px;margin-left:-4px;text-align:justify;margin-top:0px;margin-bottom:0px;} ul {list-style-type: circle;} </style></head>" + textoHtml + "</body>";
//textoHtml = "<body><head></head>" + textoHtml + "</body>";
} }
} }
...@@ -255,7 +261,7 @@ public class CadernoUtil { ...@@ -255,7 +261,7 @@ public class CadernoUtil {
if (tag.equals("o:p")){ if (tag.equals("o:p")){
tagAberta="<o:p "; tagAberta="<o:p>";
tagFechada="<o:p>"; tagFechada="<o:p>";
tamanhoTag=5; tamanhoTag=5;
...@@ -360,18 +366,13 @@ public class CadernoUtil { ...@@ -360,18 +366,13 @@ public class CadernoUtil {
public WordprocessingMLPackage ConverterHTML(String stringFromFile,String orgao,String titulo, String idMateria,String delimitador,ActionRequest actionRequest) throws Docx4JException{ public WordprocessingMLPackage ConverterHTML(String stringFromFile,String orgao,String titulo, String idMateria,String delimitador,ActionRequest actionRequest) throws Docx4JException{
PortletContext context = actionRequest.getPortletSession().getPortletContext(); PortletContext context = actionRequest.getPortletSession().getPortletContext();
//String baseURL = "file:///" + context.getRealPath("/template");
String baseURL = "file:///" + getClass().getResourceAsStream("/META-INF/resources/template"); String baseURL = "file:///" + getClass().getResourceAsStream("/META-INF/resources/template");
//XRLog.setLoggingEnabled(false);
String unescaped = stringFromFile; String unescaped = stringFromFile;
InputStream templateEstilos = getClass().getResourceAsStream("/META-INF/resources/template/TemplateEstilos.docx"); InputStream templateEstilos = getClass().getResourceAsStream("/META-INF/resources/template/TemplateEstilos.docx");
WordprocessingMLPackage templatePackageEstilos = WordprocessingMLPackage.load(templateEstilos); WordprocessingMLPackage templatePackageEstilos = WordprocessingMLPackage.load(templateEstilos);
// Create an empty docx package // Create an empty docx package
// System.out.println(XmlUtils.marshaltoString(templatePackageEstilos.getMainDocumentPart().getJaxbElement(), true, true));
//WordprocessingMLPackage wordMLPackage=null;
WordprocessingMLPackage wordMLPackage = templatePackageEstilos; WordprocessingMLPackage wordMLPackage = templatePackageEstilos;
try { try {
//wordMLPackage = WordprocessingMLPackage.createPackage();
MainDocumentPart DocumentPart = wordMLPackage.getMainDocumentPart(); MainDocumentPart DocumentPart = wordMLPackage.getMainDocumentPart();
String marcadorMateriaInicio = "##MATERIA##INICIO##ID: " + idMateria; String marcadorMateriaInicio = "##MATERIA##INICIO##ID: " + idMateria;
...@@ -382,7 +383,6 @@ public class CadernoUtil { ...@@ -382,7 +383,6 @@ public class CadernoUtil {
} }
if(!orgao.equals(ORGAO)){ if(!orgao.equals(ORGAO)){
//TituloDoeMPRJ
DocumentPart.addStyledParagraphOfText("TituloDoeMPRJ",orgao); DocumentPart.addStyledParagraphOfText("TituloDoeMPRJ",orgao);
ORGAO=orgao; ORGAO=orgao;
...@@ -396,22 +396,11 @@ public class CadernoUtil { ...@@ -396,22 +396,11 @@ public class CadernoUtil {
TITULO=titulo; TITULO=titulo;
} }
/*NumberingDefinitionsPart ndp = new NumberingDefinitionsPart();
wordMLPackage.getMainDocumentPart().addTargetPart(ndp);
ndp.unmarshalDefaultNumbering();
ndp.restart(1, 0, 1);
ndp.restart(numId, ilvl, val)*/
// Convert the XHTML, and add it into the empty docx we made // Convert the XHTML, and add it into the empty docx we made
XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackage); XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackage);
XHTMLImporter.setHyperlinkStyle("Hyperlink"); XHTMLImporter.setHyperlinkStyle("Hyperlink");
//XHTMLImporter.setRunFormatting(FormattingOption.CLASS_PLUS_OTHER );
// XHTMLImporter.setParagraphFormatting(FormattingOption.CLASS_PLUS_OTHER);
//XHTMLImporter.setParagraphFormatting(FormattingOption.CLASS_TO_STYLE_ONLY);
//XHTMLImporter.setTableFormatting(FormattingOption.IGNORE_CLASS);
wordMLPackage.getMainDocumentPart().getContent().addAll(XHTMLImporter.convert(unescaped, baseURL) ); wordMLPackage.getMainDocumentPart().getContent().addAll(XHTMLImporter.convert(unescaped, baseURL) );
if(delimitador.equals("on")) { if(delimitador.equals("on")) {
...@@ -422,6 +411,8 @@ public class CadernoUtil { ...@@ -422,6 +411,8 @@ public class CadernoUtil {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
wordMLPackage = removerParagrafosVazios(wordMLPackage);
return wordMLPackage; return wordMLPackage;
} }
...@@ -587,23 +578,13 @@ public static WordprocessingMLPackage formatarListas(WordprocessingMLPackage wor ...@@ -587,23 +578,13 @@ public static WordprocessingMLPackage formatarListas(WordprocessingMLPackage wor
P parent = (P) objetoParent; P parent = (P) objetoParent;
PPr ppr = parent.getPPr(); PPr ppr = parent.getPPr();
/*org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory();
Lvl lvl = wmlObjectFactory.createLvl();
NumFmt numfmt = wmlObjectFactory.createNumFmt();
lvl.setNumFmt(numfmt);
numfmt.setVal(org.docx4j.wml.NumberFormat.BULLET);
lvl.setPPr(ppr);*/
NumPr numPr = ppr.getNumPr(); NumPr numPr = ppr.getNumPr();
if(numPr!=null) { if(numPr!=null) {
eLista=true; eLista=true;
//if(itemAnterior==false) {
indiceLista++; indiceLista++;
//}
formatar=false; formatar=false;
Long ilvlValor=0L; Long ilvlValor=0L;
...@@ -617,7 +598,6 @@ public static WordprocessingMLPackage formatarListas(WordprocessingMLPackage wor ...@@ -617,7 +598,6 @@ public static WordprocessingMLPackage formatarListas(WordprocessingMLPackage wor
if(formatar==true) { if(formatar==true) {
Ilvl ilvl = numPr.getIlvl(); Ilvl ilvl = numPr.getIlvl();
//ilvl.setVal(BigInteger.ZERO);
ilvl.setVal(BigInteger.valueOf(ilvlValor)); ilvl.setVal(BigInteger.valueOf(ilvlValor));
numPr.setIlvl(ilvl); numPr.setIlvl(ilvl);
...@@ -627,9 +607,6 @@ public static WordprocessingMLPackage formatarListas(WordprocessingMLPackage wor ...@@ -627,9 +607,6 @@ public static WordprocessingMLPackage formatarListas(WordprocessingMLPackage wor
NumId numId = numPr.getNumId(); NumId numId = numPr.getNumId();
numId.setVal(BigInteger.ZERO); numId.setVal(BigInteger.ZERO);
numPr.setNumId(numId); numPr.setNumId(numId);
}else { }else {
org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory(); org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory();
...@@ -823,9 +800,7 @@ public static String tratarLista(String conteudoHtml){ ...@@ -823,9 +800,7 @@ public static String tratarLista(String conteudoHtml){
conteudoHtml = conteudoHtml.substring(0,i ) + marcador + conteudoHtml.substring(i + tamanhoTag,conteudoHtml.length()); conteudoHtml = conteudoHtml.substring(0,i ) + marcador + conteudoHtml.substring(i + tamanhoTag,conteudoHtml.length());
len = conteudoHtml.length(); len = conteudoHtml.length();
} }
//posicaoItemOl=QTD_LISTAS;
//conteudoHtml = conteudoHtml.replace(tagP, tagP+marcador);
len = conteudoHtml.length(); len = conteudoHtml.length();
} }
...@@ -882,4 +857,73 @@ public String trataNome(JSONArray listaConteudos,String titulo) { ...@@ -882,4 +857,73 @@ public String trataNome(JSONArray listaConteudos,String titulo) {
} }
public WordprocessingMLPackage removerParagrafosVazios(WordprocessingMLPackage wordPackage) {
DocumentPart parte = wordPackage.getMainDocumentPart();
List<Object> paragraphs = getAllElementFromObject(parte, P.class);
for (Object par : paragraphs) {
P p = (P) par;
List<Object> listaP = p.getContent();
if (listaP.size() == 0) {
wordPackage.getMainDocumentPart().getContent().remove(p);
}
}
return wordPackage;
}
public WordprocessingMLPackage tratarExpedienteVago(WordprocessingMLPackage wordPackage) {
DocumentPart parte = wordPackage.getMainDocumentPart();
List<Object> paragraphs = getAllElementFromObject(parte, P.class);
for (Object par : paragraphs) {
P p = (P) par;
List<Object> listaP = p.getContent();
if (listaP.size() > 0) {
for (Object obj : listaP) {
R r = (R)obj;
List<Object> listaR = r.getContent();
if (listaR.size() > 0) {
for (Object objR : listaR) {
JAXBElement jaxb = (JAXBElement)objR;
Object textoValue = jaxb.getValue();
Text texto = (Text)textoValue;
String textoStr=texto.getValue().toString();
if (textoStr.equals("(Vago)") || textoStr.equals("Vago")) {
Object objR2 = texto.getParent();
R r2 = (R)objR2;
RPr rpr=null;
if(r2.getRPr()==null) {
rpr = new RPr();
}else {
rpr = r2.getRPr();
}
BooleanDefaultTrue italico = new BooleanDefaultTrue();
italico.setVal(true);
rpr.setI(italico);
r2.setRPr(rpr);
}
}
}
}
}
}
return wordPackage;
}
} }
...@@ -40,24 +40,20 @@ import mprj.doerj.caderno.application.model.Lista; ...@@ -40,24 +40,20 @@ import mprj.doerj.caderno.application.model.Lista;
public class GeraCaderno { public class GeraCaderno {
public void processaCaderno(ActionRequest actionRequest, ActionResponse actionResponse, JSONArray listaConteudos,
public void processaCaderno(ActionRequest actionRequest,ActionResponse actionResponse,JSONArray listaConteudos,String dataDivulgacao,String delimitador) throws Docx4JException, JAXBException, IOException, ParseException, PortalException{ String dataDivulgacao, String delimitador)
throws Docx4JException, JAXBException, IOException, ParseException, PortalException {
PortletContext context = actionRequest.getPortletSession().getPortletContext(); PortletContext context = actionRequest.getPortletSession().getPortletContext();
//String pathTemplate = context.getRealPath(""); InputStream templateCaderno = getClass()
.getResourceAsStream("/META-INF/resources/template/TemplateCaderno.docx");
//InputStream templateCaderno = GeraCaderno.class.getClass().getResourceAsStream("/META-INF/resources/template/TemplateCaderno.docx");
InputStream templateCaderno = getClass().getResourceAsStream("/META-INF/resources/template/TemplateCaderno.docx");
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
//String templateCaderno = PortalUtil.getPortalURL(themeDisplay) + "/o/mprj.doerj.caderno/template/TemplateCaderno.docx";
String conteudo=""; String conteudo = "";
String orgao=""; String orgao = "";
String titulo=""; String titulo = "";
String idMateria=""; String idMateria = "";
Boolean expedienteVago = false;
PortletPreferences prefs = actionRequest.getPreferences(); PortletPreferences prefs = actionRequest.getPreferences();
CadernoUtil util = new CadernoUtil(); CadernoUtil util = new CadernoUtil();
MainDocumentPart currentDocumentPart = null; MainDocumentPart currentDocumentPart = null;
...@@ -66,32 +62,26 @@ public class GeraCaderno { ...@@ -66,32 +62,26 @@ public class GeraCaderno {
JAXBContext.newInstance("org.docx4j.openpackaging.contenttype"); JAXBContext.newInstance("org.docx4j.openpackaging.contenttype");
System.out.println("Finalizado teste do JAXBContext."); System.out.println("Finalizado teste do JAXBContext.");
//WordprocessingMLPackage templatePackage = WordprocessingMLPackage.load(new File(templateCaderno.toString()));
//WordprocessingMLPackage templatePackage = WordprocessingMLPackage.load(new File(templateCaderno));
WordprocessingMLPackage templatePackage = WordprocessingMLPackage.load(templateCaderno); WordprocessingMLPackage templatePackage = WordprocessingMLPackage.load(templateCaderno);
//System.out.println(XmlUtils.marshaltoString(templatePackage.getMainDocumentPart().getJaxbElement(), true, true)); // System.out.println(XmlUtils.marshaltoString(templatePackage.getMainDocumentPart().getJaxbElement(),
// true, true));
WordprocessingMLPackage acumuladoPackage = WordprocessingMLPackage.createPackage(); WordprocessingMLPackage acumuladoPackage = WordprocessingMLPackage.createPackage();
//Preenche os dados do cabealho //Preenche os dados do cabealho
MainDocumentPart headerDocumentPart = templatePackage.getMainDocumentPart(); MainDocumentPart headerDocumentPart = templatePackage.getMainDocumentPart();
MainDocumentPart mainPart = templatePackage.getMainDocumentPart(); MainDocumentPart mainPart = templatePackage.getMainDocumentPart();
HeaderPart headerPart = templatePackage.getHeaderFooterPolicy().getDefaultHeader(); HeaderPart headerPart = templatePackage.getHeaderFooterPolicy().getDefaultHeader();
HeaderPart firstPageHeaderPart = templatePackage.getHeaderFooterPolicy().getFirstHeader(); HeaderPart firstPageHeaderPart = templatePackage.getHeaderFooterPolicy().getFirstHeader();
// VariablePrepare.prepare(templatePackage);
JSONObject cabecalho = new JSONObject(listaConteudos.getJSONObject(0).toString()); JSONObject cabecalho = new JSONObject(listaConteudos.getJSONObject(0).toString());
String edicao = "--"; String edicao = "--";
String disponibilizacao = util.gerarDataCabecalho(dataDivulgacao); String disponibilizacao = util.gerarDataCabecalho(dataDivulgacao);
String publicacao = "--"; String publicacao = "--";
//Cria o hash map com as variveis para substuio dos dados dos cabealhos e expediente //Cria o hash map com as variveis para substuio dos dados dos cabealhos e expediente
HashMap<String, String> variables = new HashMap<String, String>(); HashMap<String, String> variables = new HashMap<String, String>();
variables.put("edi", edicao); variables.put("edi", edicao);
...@@ -101,173 +91,199 @@ public class GeraCaderno { ...@@ -101,173 +91,199 @@ public class GeraCaderno {
String PGJ = prefs.getValue("PGJConfig", ""); String PGJ = prefs.getValue("PGJConfig", "");
variables.put("PGJ", PGJ); variables.put("PGJ", PGJ);
if (PGJ.equals("(Vago)") || PGJ.equals("Vago")) {
expedienteVago = true;
}
String CGMP = prefs.getValue("CGMPConfig", ""); String CGMP = prefs.getValue("CGMPConfig", "");
variables.put("CGMP", CGMP); variables.put("CGMP", CGMP);
if (CGMP.equals("(Vago)") || CGMP.equals("Vago")) {
expedienteVago = true;
}
String SGJA = prefs.getValue("SGJAConfig", ""); String SGJA = prefs.getValue("SGJAConfig", "");
variables.put("SGJA", SGJA); variables.put("SGJA", SGJA);
if (SGJA.equals("(Vago)") || SGJA.equals("Vago")) {
expedienteVago = true;
}
String SGJPI = prefs.getValue("SGJPIConfig", ""); String SGJPI = prefs.getValue("SGJPIConfig", "");
variables.put("SGJPI", SGJPI); variables.put("SGJPI", SGJPI);
if (SGJPI.equals("(Vago)") || SGJPI.equals("Vago")) {
expedienteVago = true;
}
String SGJACI = prefs.getValue("SGJACIConfig", ""); String SGJACI = prefs.getValue("SGJACIConfig", "");
variables.put("SGJACI", SGJACI); variables.put("SGJACI", SGJACI);
if (SGJACI.equals("(Vago)") || SGJACI.equals("Vago")) {
expedienteVago = true;
}
String SGJACDH = prefs.getValue("SGJACDHConfig", ""); String SGJACDH = prefs.getValue("SGJACDHConfig", "");
variables.put("SGJACDH", SGJACDH); variables.put("SGJACDH", SGJACDH);
if (SGJACDH.equals("(Vago)") || SGJACDH.equals("Vago")) {
expedienteVago = true;
}
String SGJRIDP = prefs.getValue("SGJRIDPConfig", ""); String SGJRIDP = prefs.getValue("SGJRIDPConfig", "");
variables.put("SGJRIDP", SGJRIDP); variables.put("SGJRIDP", SGJRIDP);
if (SGJRIDP.equals("(Vago)") || SGJRIDP.equals("Vago")) {
expedienteVago = true;
}
String CG = prefs.getValue("CGConfig", ""); String CG = prefs.getValue("CGConfig", "");
variables.put("CG", CG); variables.put("CG", CG);
if (CG.equals("(Vago)") || CG.equals("Vago")) {
expedienteVago = true;
}
String CJ = prefs.getValue("CJConfig", ""); String CJ = prefs.getValue("CJConfig", "");
variables.put("CJ", CJ); variables.put("CJ", CJ);
if (CJ.equals("(Vago)") || CJ.equals("Vago")) {
expedienteVago = true;
}
String AE = prefs.getValue("AEConfig", ""); String AE = prefs.getValue("AEConfig", "");
variables.put("AE", AE); variables.put("AE", AE);
if (AE.equals("(Vago)") || AE.equals("Vago")) {
expedienteVago = true;
}
String CMPROCJ = prefs.getValue("CMPROCJConfig", ""); String CMPROCJ = prefs.getValue("CMPROCJConfig", "");
variables.put("CMPROCJ", CMPROCJ); variables.put("CMPROCJ", CMPROCJ);
if (CMPROCJ.equals("(Vago)") || CMPROCJ.equals("Vago")) {
expedienteVago = true;
}
String CMPROMJ = prefs.getValue("CMPROMJConfig", ""); String CMPROMJ = prefs.getValue("CMPROMJConfig", "");
variables.put("CMPROMJ", CMPROMJ); variables.put("CMPROMJ", CMPROMJ);
if (CMPROMJ.equals("(Vago)") || CMPROMJ.equals("Vago")) {
expedienteVago = true;
}
String CSI = prefs.getValue("CSIConfig", ""); String CSI = prefs.getValue("CSIConfig", "");
variables.put("CSI", CSI); variables.put("CSI", CSI);
if (CSI.equals("(Vago)") || CSI.equals("Vago")) {
expedienteVago = true;
}
String CEAF = prefs.getValue("CEAFConfig", ""); String CEAF = prefs.getValue("CEAFConfig", "");
variables.put("CEAF", CEAF); variables.put("CEAF", CEAF);
if (CEAF.equals("(Vago)") || CEAF.equals("Vago")) {
expedienteVago = true;
}
String OUVI = prefs.getValue("OUVIConfig", ""); String OUVI = prefs.getValue("OUVIConfig", "");
variables.put("OUVI", OUVI); variables.put("OUVI", OUVI);
if (OUVI.equals("(Vago)") || OUVI.equals("Vago")) {
expedienteVago = true;
}
String SGMP = prefs.getValue("SGMPConfig", ""); String SGMP = prefs.getValue("SGMPConfig", "");
variables.put("SGMP", SGMP); variables.put("SGMP", SGMP);
String AAOMC = prefs.getValue("AAOMCConfig", ""); if (SGMP.equals("(Vago)") || SGMP.equals("Vago")) {
variables.put("AAOMC", AAOMC); expedienteVago = true;
}
String ARCC = prefs.getValue("ARCCConfig", "");
variables.put("ARCC", ARCC);
String GAOMC = prefs.getValue("GAOMCConfig", "");
variables.put("GAOMC", GAOMC);
String ARCCRI = prefs.getValue("ARCCRIConfig", "");
variables.put("ARCCRI", ARCCRI);
String AC = prefs.getValue("ACConfig", "");
variables.put("AC", AC);
String ADHM = prefs.getValue("ADHMConfig", "");
variables.put("ADHM", ADHM);
String ARIDP = prefs.getValue("ARIDPConfig", ""); String ARIDP = prefs.getValue("ARIDPConfig", "");
variables.put("ARIDP", ARIDP); variables.put("ARIDP", ARIDP);
String AI = prefs.getValue("AIConfig", ""); if (ARIDP.equals("(Vago)") || ARIDP.equals("Vago")) {
variables.put("AI", AI); expedienteVago = true;
}
String AAP = prefs.getValue("AAPConfig", ""); String AAP = prefs.getValue("AAPConfig", "");
variables.put("AAP", AAP); variables.put("AAP", AAP);
if (AAP.equals("(Vago)") || AAP.equals("Vago")) {
expedienteVago = true;
}
firstPageHeaderPart.variableReplace(variables); firstPageHeaderPart.variableReplace(variables);
headerPart.variableReplace(variables); headerPart.variableReplace(variables);
mainPart.variableReplace(variables); mainPart.variableReplace(variables);
// Estilos estilo = new Estilos();
//estilo.alterStyleSheet(acumuladoPackage);
WordprocessingMLPackage firstPagePackage = WordprocessingMLPackage.createPackage(); WordprocessingMLPackage firstPagePackage = WordprocessingMLPackage.createPackage();
boolean firstPage=true; boolean firstPage = true;
List<Lista> listaOls = new ArrayList<Lista>(); List<Lista> listaOls = new ArrayList<Lista>();
//faz a leitura da listagem de todos os contedos recebidos pelo servio Rest
for(int i=0;i<listaConteudos.length();i++){ // faz a leitura da listagem de todos os contedos recebidos pelo servio Rest
for (int i = 0; i < listaConteudos.length(); i++) {
WordprocessingMLPackage wordCurrentPackage = WordprocessingMLPackage.createPackage(); WordprocessingMLPackage wordCurrentPackage = WordprocessingMLPackage.createPackage();
JSONObject obj = new JSONObject(listaConteudos.get(i).toString()); JSONObject obj = new JSONObject(listaConteudos.get(i).toString());
orgao = obj.get("ORGAO").toString(); orgao = obj.get("ORGAO").toString();
orgao = util.tratarString(orgao,"titulo"); orgao = util.tratarString(orgao, "titulo");
titulo = util.trataNome(listaConteudos, obj.get("NOME").toString()); titulo = util.trataNome(listaConteudos, obj.get("NOME").toString());
titulo = util.tratarString(titulo,"titulo"); titulo = util.tratarString(titulo, "titulo");
conteudo = obj.get("CONTEUDO").toString(); conteudo = obj.get("CONTEUDO").toString();
idMateria=obj.get("IDMATERIA").toString(); idMateria = obj.get("IDMATERIA").toString();
conteudo=util.tratarString(conteudo,"conteudo"); conteudo = util.tratarString(conteudo, "conteudo");
conteudo=util.tratarLista(conteudo); conteudo = util.tratarLista(conteudo);
//listaOls.addAll(util.retornarOls(conteudo));
wordCurrentPackage = util.ConverterHTML(conteudo,orgao,titulo,idMateria,delimitador,actionRequest); wordCurrentPackage = util.ConverterHTML(conteudo, orgao, titulo, idMateria, delimitador, actionRequest);
currentDocumentPart = wordCurrentPackage.getMainDocumentPart(); currentDocumentPart = wordCurrentPackage.getMainDocumentPart();
acumuladoPackage.getMainDocumentPart().getContent().addAll(currentDocumentPart.getContent()); acumuladoPackage.getMainDocumentPart().getContent().addAll(currentDocumentPart.getContent());
wordCurrentPackage = null; wordCurrentPackage = null;
currentDocumentPart =null; currentDocumentPart = null;
} }
MainDocumentPart acumuladoDocumentPart = acumuladoPackage.getMainDocumentPart(); MainDocumentPart acumuladoDocumentPart = acumuladoPackage.getMainDocumentPart();
// estilo.alterStyleSheet(templatePackage); if (expedienteVago == true) {
templatePackage = util.tratarExpedienteVago(templatePackage);
}
/*XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(templatePackage);
XHTMLImporter.setParagraphFormatting(FormattingOption.CLASS_PLUS_OTHER);*/
templatePackage.getMainDocumentPart().getContent().addAll(acumuladoDocumentPart.getContent()); templatePackage.getMainDocumentPart().getContent().addAll(acumuladoDocumentPart.getContent());
util.ORGAO=""; util.ORGAO = "";
util.TITULO=""; util.TITULO = "";
//File exportFile = new File("C:/Users/diogo.souza/Documents/Caderno DO/testeDoc4JNovo.docx");
String dataNomeArquivo = dataDivulgacao.replace("/", "-"); String dataNomeArquivo = dataDivulgacao.replace("/", "-");
String nomeArquivo=""; String nomeArquivo = "";
if (delimitador.equals("on")) { if (delimitador.equals("on")) {
nomeArquivo="caderno_doerj_" + dataNomeArquivo + "_materia_delimitada.docx"; nomeArquivo = "caderno_doerj_" + dataNomeArquivo + "_materia_delimitada.docx";
}else { } else {
nomeArquivo="caderno_doerj_" + dataNomeArquivo + ".docx"; nomeArquivo = "caderno_doerj_" + dataNomeArquivo + ".docx";
} }
// InputStream nomeArquivoInputStream = getClass().getResourceAsStream("/META-INF/resources/template/"+nomeArquivo); // cria o arquivo temporrio que ser utilizado na resposta da requisio
// File exportFile = new File(nomeArquivoInputStream.toString());
//cria o arquivo temporrio que ser utilizado na resposta da requisio
File exportFile = File.createTempFile("caderno_doerj_tmp_", ".docx"); File exportFile = File.createTempFile("caderno_doerj_tmp_", ".docx");
try { try {
CadernoUtil caderno = new CadernoUtil(); CadernoUtil caderno = new CadernoUtil();
//templatePackage = caderno.formatarListas(templatePackage,listaOls); // System.out.println(XmlUtils.marshaltoString(templatePackage.getMainDocumentPart().getJaxbElement(),
//acumuladoPackage = caderno.formatarListas(acumuladoPackage,listaOls); // true, true));
//NumberingDefinitionsPart ndp = new NumberingDefinitionsPart();
//templatePackage.getMainDocumentPart().addTargetPart(ndp);
//ndp.getInd(String.valueOf(10),String.valueOf(0));
//ndp.unmarshalDefaultNumbering();
//ndp.restart(1, 0, 1);
System.out.println(XmlUtils.marshaltoString(templatePackage.getMainDocumentPart().getJaxbElement(), true, true));
templatePackage.save(exportFile); templatePackage.save(exportFile);
//acumuladoPackage.save(exportFile);
PortletResponse pResponse = PortalUtil.getLiferayPortletResponse(actionResponse); PortletResponse pResponse = PortalUtil.getLiferayPortletResponse(actionResponse);
HttpServletResponse res = PortalUtil.getHttpServletResponse(pResponse); HttpServletResponse res = PortalUtil.getHttpServletResponse(pResponse);
res.setHeader("Content-Disposition", "attachment; filename=" + nomeArquivo);// res.setHeader("Content-Disposition", "attachment; filename=" + nomeArquivo);//
res.setContentType(ContentTypes.APPLICATION_MSWORD); res.setContentType(ContentTypes.APPLICATION_MSWORD);
/*String redirectURL = ParamUtil.getString(actionRequest, "/view-admin.jsp");
actionResponse.sendRedirect(redirectURL);*/
try (FileInputStream in = new FileInputStream(exportFile);) { try (FileInputStream in = new FileInputStream(exportFile);) {
OutputStream out = res.getOutputStream(); OutputStream out = res.getOutputStream();
...@@ -283,24 +299,19 @@ public class GeraCaderno { ...@@ -283,24 +299,19 @@ public class GeraCaderno {
res.flushBuffer(); res.flushBuffer();
} }
} } catch (Exception e) {
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
exportFile.delete(); exportFile.delete();
CadernoUtil caderno = new CadernoUtil(); CadernoUtil caderno = new CadernoUtil();
caderno.QTD_LISTAS=0L; caderno.QTD_LISTAS = 0L;
} } finally {
finally {
exportFile.delete(); exportFile.delete();
CadernoUtil caderno = new CadernoUtil(); CadernoUtil caderno = new CadernoUtil();
caderno.QTD_LISTAS=0L; caderno.QTD_LISTAS = 0L;
} }
} }
} }
...@@ -62,21 +62,8 @@ ...@@ -62,21 +62,8 @@
String SGMPConfig = portletInstanceConfig.SGMPConfig(); String SGMPConfig = portletInstanceConfig.SGMPConfig();
String AAOMCConfig = portletInstanceConfig.AAOMCConfig();
String ARCCConfig = portletInstanceConfig.ARCCConfig();
String GAOMCConfig = portletInstanceConfig.GAOMCConfig();
String ARCCRIConfig = portletInstanceConfig.ARCCRIConfig();
String ACConfig = portletInstanceConfig.ACConfig();
String ADHMConfig = portletInstanceConfig.ADHMConfig();
String AAPConfig = portletInstanceConfig.AAPConfig(); String AAPConfig = portletInstanceConfig.AAPConfig();
String AIConfig = portletInstanceConfig.AIConfig();
%> %>
<liferay-portlet:actionURL portletConfiguration="<%= true %>" <liferay-portlet:actionURL portletConfiguration="<%= true %>"
...@@ -127,7 +114,7 @@ ...@@ -127,7 +114,7 @@
value="<%=SGJAConfig%>" /> value="<%=SGJAConfig%>" />
<aui:input name="SGJPIConfig" <aui:input name="SGJPIConfig"
label="SUBPROCURADORIA GERAL DE JUSTIA DE PLANEJAMENTO INSTITUCIONAL: " label="SUBPROCURADORIA GERAL DE JUSTIA DE PLANEJAMENTO E POLTICAS INSTITUCIONAIS: "
style="width:500px; display:block;" type="text" style="width:500px; display:block;" type="text"
value="<%=SGJPIConfig%>" /> value="<%=SGJPIConfig%>" />
...@@ -137,7 +124,7 @@ ...@@ -137,7 +124,7 @@
value="<%=SGJACIConfig%>" /> value="<%=SGJACIConfig%>" />
<aui:input name="SGJACDHConfig" <aui:input name="SGJACDHConfig"
label="SUBPROCURADORIA GERAL DE JUSTIA DE ASSUNTOS CRIMINAIS E DE DIREITOS HUMANOS: " label="SUBPROCURADORIA GERAL DE JUSTIA DE ASSUNTOS CRIMINAIS: "
style="width:500px; display:block;" type="text" style="width:500px; display:block;" type="text"
value="<%=SGJACDHConfig%>" /> value="<%=SGJACDHConfig%>" />
...@@ -187,44 +174,11 @@ ...@@ -187,44 +174,11 @@
style="width:500px; display:block;" type="text" style="width:500px; display:block;" type="text"
value="<%=SGMPConfig%>" /> value="<%=SGMPConfig%>" />
<aui:input name="AAOMCConfig"
label="ASSESSORIA DE ATRIBUIO ORIGINRIA EM MATRIA CVEL: "
style="width:500px; display:block;" type="text"
value="<%=AAOMCConfig%>" />
<aui:input name="ARCCConfig"
label="ASSESSORIA DE RECURSOS CONSTITUCIONAIS CVEIS: "
style="width:500px; display:block;" type="text"
value="<%=ARCCConfig%>" />
<aui:input name="GAOMCConfig"
label="GRUPO DE ATRIBUIO ORIGINRIA EM MATRIA CRIMINAL: "
style="width:500px; display:block;" type="text"
value="<%=GAOMCConfig%>" />
<aui:input name="ARCCRIConfig"
label="ASSESSORIA DE RECURSOS CONSTITUCIONAIS CRIMINAIS: "
style="width:500px; display:block;" type="text"
value="<%=ARCCRIConfig%>" />
<aui:input name="ACConfig" label="ASSESSORIA CRIMINAL: "
style="width:500px; display:block;" type="text"
value="<%=ACConfig%>" />
<aui:input name="ADHMConfig"
label="ASSESSORIA DE DIRETOS HUMANOS E DE MINORIAS: "
style="width:500px; display:block;" type="text"
value="<%=ADHMConfig%>" />
<aui:input name="AAPConfig" <aui:input name="AAPConfig"
label="ASSESSORIA DE ASSUNTOS PARLAMENTARES: " label="ASSESSORIA DE ASSUNTOS PARLAMENTARES: "
style="width:500px; display:block;" type="text" style="width:500px; display:block;" type="text"
value="<%=AAPConfig%>" /> value="<%=AAPConfig%>" />
<aui:input name="AIConfig" label="ASSESSORIA INTERNACIONAL: "
style="width:500px; display:block;" type="text"
value="<%=AIConfig%>" />
</aui:fieldset> </aui:fieldset>
</liferay-frontend:fieldset> </liferay-frontend:fieldset>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment