19 package org.turro.parser;
21 import java.io.IOException;
22 import java.util.ArrayList;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25 import org.turro.string.ObjectString;
26 import org.turro.annotation.ExternalParser;
27 import org.turro.auth.Authentication;
28 import org.turro.elephant.context.ElephantContext;
29 import org.turro.elephant.context.IConstructor;
30 import org.turro.elephant.util.DecimalFormats;
31 import org.turro.financials.cart.ShoppingCart;
32 import org.turro.financials.cart.www.Checkout;
33 import org.turro.financials.content.ContractContentIterator;
34 import org.turro.financials.content.ProductContentIterator;
35 import org.turro.financials.db.FinancialsPU;
36 import org.turro.financials.entity.Product;
37 import org.turro.financials.product.www.ProductIterator;
38 import org.turro.html.HTMLGenerator;
39 import org.turro.jpa.Dao;
40 import org.turro.util.PhraseBuilder;
65 ci.
setPage((Integer) ObjectString.parseNativeString(
getToken(2), Integer.class,
true));
72 boolean grouped =
"contract-type".equals(
tokens[0]);
79 ci.
setPage((Integer) ObjectString.parseNativeString(
getToken(2), Integer.class,
true));
80 ci.
setType((Integer) ObjectString.parseNativeString(
getToken(4), Integer.class,
true));
103 pci.
setPage((Integer) ObjectString.parseNativeString(
getToken(2), Integer.class,
true));
153 macros.
addMacro(
"contract-type-list")
171 macros.
addMacro(
"product-name-list")
182 String summaryTemplate, String fullTemplate, String context,
boolean promoted) {
203 }
catch (IOException ex) {
210 String[] aids = ids.split(
"\\s*,\\s*");
213 for(String
id : aids) {
214 String[] aid =
id.split(
"\\s*\\*\\s*");
215 Product product = dao.find(
Product.class, Long.parseLong(aid[0]));
216 if(product !=
null) {
221 PhraseBuilder pb =
new PhraseBuilder();
222 for(FinancialsParser.ProductQuantity pq : products) {
223 pb.addWord(
"<a href='" + ElephantContext.getRootWebPath() + context +
"?item=" + pq.product.getId() +
"'>" +
224 (pq.quantity > 1 ? ((
int) pq.quantity) +
" " :
"") + pq.product.getDescription() +
226 pb.addPendingSeparator(
", ");
228 return pb.toString();
230 HTMLGenerator html =
new HTMLGenerator();
232 for(FinancialsParser.ProductQuantity pq : products) {
234 html.startAnchor(ElephantContext.getRootWebPath() + context +
"?item=" + pq.product.getId(),
null);
235 html.write((pq.quantity > 1 ? ((
int) pq.quantity) +
" " :
"") + pq.product.getDescription());
236 html.endTag().endTag();
239 return html.toString();
243 private String createPrice(IConstructor
constructor, String format, String ids) {
244 String[] aids = ids.split(
"\\s*,\\s*");
246 Dao dao =
new FinancialsPU();
247 for(String
id : aids) {
248 String[] aid =
id.split(
"\\s*\\*\\s*");
249 Product product = dao.find(Product.class, Long.parseLong(aid[0]));
250 if(product !=
null) {
251 price += product.
getPrice() * (aid.length == 2 ? Double.parseDouble(aid[1]) : 1.0);
254 return DecimalFormats.format(price, format);
257 private class ProductQuantity {
261 public ProductQuantity(Product product,
double quantity) {
262 this.product = product;
263 this.quantity = quantity;
static IContact getIContact()
static String getRootWebPath()
static String logMsg(String msg)
void setCheckParticipation(boolean checkParticipation)
void setFullSearch(boolean fullSearch)
void setAllowGroups(boolean allowGroups)
void setOnlyPromoted(boolean onlyPromoted)
void setPublishable(boolean publishable)
void setAllowVotes(boolean allowVotes)
void setOnlyPromoted(boolean onlyPromoted)
void setShowDescriptions(boolean showDescriptions)
void setAllowComments(boolean allowComments)
void setAllowGroups(boolean allowGroups)
void setShowAttachments(boolean showAttachments)
void setAllowInterest(boolean allowInterest)
void setPublishable(boolean publishable)
void setAllowAttachments(boolean allowAttachments)
void setAllowInterest(boolean allowInterest)
void setFullTemplate(String fullTemplate)
void setAllowDescriptions(boolean allowDescriptions)
void setAllowComments(boolean allowComments)
void setNavigatorBottom(boolean navigatorBottom)
void setSummaryTemplate(String summaryTemplate)
void setNavigatorTop(boolean navigatorTop)
void setAllowFiles(boolean allowFiles)
String getToken(String name)
void explainMacros(ParserMacroSet macros)
String getPublished(boolean grouped, IConstructor constructor, int count, String summaryTemplate, String fullTemplate, String context, boolean promoted)
ParserMacro addMacro(String macroName)
void copyParametersFrom(String macroName, ParserMacroSet macros)
ParserMacro addParameter(String name, boolean optional)
void setOut(PrintWriter out)