
org.beigesoft.acc.rpl.AccImp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of beige-acc Show documentation
Show all versions of beige-acc Show documentation
It consists of double entry accounting and trading (web-store) business logic.
It's based on previous beigesoft-accounting and beigesoft-webstore projects.
The newest version!
/*
BSD 2-Clause License
Copyright (c) 2019, Beigesoft™
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.beigesoft.acc.rpl;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;
import java.util.Arrays;
import java.io.PrintWriter;
import org.beigesoft.mdl.IReqDt;
import org.beigesoft.log.ILog;
import org.beigesoft.prc.IPrc;
import org.beigesoft.rdb.IOrm;
import org.beigesoft.rpl.IReplicator;
/**
* Imports accounting data from source with WEB-service.
*
* @author Yury Demidenko
*/
public class AccImp implements IPrc {
/**
* Logger.
**/
private ILog log;
/**
* Replicator.
**/
private IReplicator repl;
/**
* ORM service.
**/
private IOrm orm;
/**
* Process request.
* @param pRvs request scoped vars
* @param pRqDt Request Data
* @throws Exception - an exception
**/
@Override
public final void process(final Map pRvs,
final IReqDt pRqDt) throws Exception {
PrintWriter htmWri = (PrintWriter) pRvs.get("htmWri");
String urlSrc = "https://" + pRqDt.getParam("urlSrc");
String usr = pRqDt.getParam("usr");
pRvs.put("urlSrc", pRqDt.getParam("urlSrc"));
pRvs.put("maxRecs", pRqDt.getParam("maxRecs"));
pRvs.put("prc", AccExp.class.getSimpleName());
Long rpAcMtId = Long.parseLong(pRqDt.getParam("rpAcMtId"));
RplAcc rplAcc = new RplAcc();
rplAcc.setIid(rpAcMtId);
Map vs = new HashMap();
this.orm.refrEnt(pRvs, vs, rplAcc);
if (rplAcc.getIid() == null) {
throw new Exception("There is no replication method with ID " + rpAcMtId);
}
String[] ndfAc = new String[] {"acnt"};
vs.put("RpExDblndFds", ndfAc);
vs.put("AcntdpLv", 0);
rplAcc.setExDbls(this.orm.retLstCnd(pRvs, vs, RpExDbl.class,
"where OWNR=" + rpAcMtId)); vs.clear();
vs.put("RpExCrlndFds", ndfAc);
vs.put("AcntdpLv", 0);
rplAcc.setExCrds(this.orm.retLstCnd(pRvs, vs, RpExCrl.class,
"where OWNR=" + rpAcMtId)); vs.clear();
pRvs.put("srDbId", rplAcc.getRqDbId().toString());
pRvs.put("ARplMth", rplAcc);
if (usr != null) {
pRvs.put("pwd", pRqDt.getParam("pwd"));
pRvs.put("usr", usr);
pRvs.put("auMt", "form");
String urlBase = urlSrc.substring(0, urlSrc.indexOf("adm") - 1);
pRvs.put("auUrl", urlBase + "/adm/j_security_check");
pRvs.put("urlAuCo", urlBase + "/adm/srv");
pRvs.put("auUsr", "j_username");
pRvs.put("auPwd", "j_password");
}
htmWri.println("");
htmWri.println("");
htmWri.println("");
htmWri.println("");
htmWri.println("");
htmWri.println("");
htmWri.println("");
htmWri.println("Replication data ");
htmWri.println("");
htmWri.println("");
htmWri.println("Home");
htmWri.println("");
htmWri.println("Replication data from " + urlSrc + "
");
htmWri.println("");
htmWri.println("");
this.repl.replicate(pRvs);
htmWri.println("");
htmWri.println("");
htmWri.println("");
rplAcc.setLstDt(new Date());
String[] upFds = new String[] {"lstDt", "ver"};
Arrays.sort(upFds);
vs.put("ndFds", upFds);
this.orm.update(pRvs, vs, rplAcc);
}
//Simple getters and setters:
/**
* Getter for log.
* @return ILog
**/
public final ILog getLog() {
return this.log;
}
/**
* Setter for log.
* @param pLog reference
**/
public final void setLog(final ILog pLog) {
this.log = pLog;
}
/**
* Getter for repl.
* @return IReplicator
**/
public final IReplicator getRepl() {
return this.repl;
}
/**
* Setter for repl.
* @param pRepl reference
**/
public final void setRepl(final IReplicator pRepl) {
this.repl = pRepl;
}
/**
* Getter for orm.
* @return IOrm
**/
public final IOrm getOrm() {
return this.orm;
}
/**
* Setter for orm.
* @param pOrm reference
**/
public final void setOrm(final IOrm pOrm) {
this.orm = pOrm;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy