blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 7
332
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
50
| license_type
stringclasses 2
values | repo_name
stringlengths 7
115
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 557
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
684M
⌀ | star_events_count
int64 0
77.7k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 17
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 82
values | src_encoding
stringclasses 28
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
5.41M
| extension
stringclasses 11
values | content
stringlengths 7
5.41M
| authors
listlengths 1
1
| author
stringlengths 0
161
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fa6be3f5fa4e302010d54dfb4da172c4208e8b0a | 8f85b7f766b672370001d11af466cc8e4648c295 | /assignment2/ABAGAIL/src/dist/DiscretePermutationDistribution.java | edf0abaa792d44c048355762216bbccf3eb6779c | [
"MIT"
]
| permissive | jasneetbhatti/CS-7641-assignments | e179e1a21ccbb2a6a3fc971c5a02a08a64d4b3fd | a0091d88fa9b4d03d44dffc2bba0f08f36f6105c | refs/heads/master | 2020-04-19T09:08:55.380757 | 2019-03-24T20:40:52 | 2019-03-24T20:40:52 | 168,101,180 | 1 | 2 | MIT | 2019-03-09T22:49:31 | 2019-01-29T06:22:28 | Java | UTF-8 | Java | false | false | 1,422 | java | package dist;
import shared.DataSet;
import shared.Instance;
import util.ABAGAILArrays;
/**
* A distribution of all of the permutations
* of a set size.
* @author Andrew Guillory [email protected]
* @version 1.0
*/
public class DiscretePermutationDistribution extends AbstractDistribution {
/**
* The size of the data
*/
private int n;
/**
* The probability
*/
private double p;
/**
* Make a new discrete permutation distribution
* @param n the size of the data
*/
public DiscretePermutationDistribution(int n) {
this.n = n;
p = n;
for (int i = n - 1; i >= 1; i--) {
p *= i;
}
p = 1 / p;
}
/**
* @see dist.Distribution#probabilityOf(shared.Instance)
*/
public double p(Instance i) {
return p;
}
/**
* @see dist.Distribution#generateRandom(shared.Instance)
*/
public Instance sample(Instance ignored) {
double[] d = ABAGAILArrays.dindices(n);
ABAGAILArrays.permute(d);
return new Instance(d);
}
/**
* @see dist.Distribution#generateMostLikely(shared.Instance)
*/
public Instance mode(Instance ignored) {
return sample(ignored);
}
/**
* @see dist.Distribution#estimate(shared.DataSet)
*/
public void estimate(DataSet observations) {
return;
}
}
| [
"[email protected]"
]
| |
8e90d1e8a1d2f8d45296fd969f3672de9b02aaf1 | 8ba92cbe84cb5ad908beabe2236101d6a543610d | /src/cn/jsprun/dao/impl/TypevarsDaoImpl.java | d7c759b95e33ddfd47b2bb119ab94e4728668fe0 | []
| no_license | gy0531/jsprun | 6f9f9aa4b9d514d74b7b38160e66f9f5fbb6c82c | b350aab4296d3b18fda61528ba861ce03d61b7c3 | refs/heads/master | 2021-01-10T11:01:02.031292 | 2016-01-26T09:55:50 | 2016-01-26T09:55:50 | 50,401,072 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,730 | java | package cn.jsprun.dao.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import cn.jsprun.dao.TypevarsDao;
import cn.jsprun.domain.Typevars;
import cn.jsprun.domain.TypevarsId;
import cn.jsprun.utils.HibernateUtil;
public class TypevarsDaoImpl implements TypevarsDao {
public boolean addTypevar(Typevars typevar) {
boolean flag = false;
if (typevar != null) {
Session session = null;
Transaction tran = null;
try {
session = HibernateUtil.getSessionFactory().getCurrentSession();
tran = session.beginTransaction();
session.save(typevar);
flag = true;
tran.commit();
} catch (HibernateException e) {
flag = false;
if(tran!=null){
tran.rollback();
}
e.printStackTrace();
}
}
return flag;
}
public Typevars findById(TypevarsId id) {
Session session = null;
Transaction tran = null;
Typevars typevar = null;
try {
session = HibernateUtil.getSessionFactory().getCurrentSession();
tran = session.beginTransaction();
typevar = (Typevars) session.get(Typevars.class, id);
tran.commit();
} catch (HibernateException e) {
if(tran!=null){
tran.rollback();
}
e.printStackTrace();
}
return typevar;
}
public List<Typevars> findByTId(Short typeid) {
List<Typevars> typevars = new ArrayList<Typevars>();
List<Typevars> allTypevars = this.findAll();
if(allTypevars!=null)
{
Iterator<Typevars> iterators = allTypevars.iterator();
while (iterators.hasNext()) {
Typevars moderator = iterators.next();
if (moderator.getId().getTypeid().equals(typeid)) {
typevars.add(moderator);
}
}
}
return typevars;
}
public Typevars findByTO(Short typeid, Short optionid) {
List<Typevars> typevars = this.findAll();
if(typevars!=null)
{
for(int i=0;i<typevars.size();i++)
{
Typevars typevar=typevars.get(i);
if(typevar.getId().getTypeid().equals(typeid)&&typevar.getId().getOptionid().equals(optionid))
{
return typevar;
}
}
}
return null;
}
public boolean removeTypevar(Typevars typevar) {
boolean flag = false;
if (typevar != null) {
Session session = null;
Transaction tran = null;
try {
session = HibernateUtil.getSessionFactory().getCurrentSession();
tran = session.beginTransaction();
session.delete(typevar);
flag = true;
tran.commit();
} catch (HibernateException e) {
flag = false;
if(tran!=null){
tran.rollback();
}
e.printStackTrace();
}
}
return flag;
}
public boolean updateTypevar(Typevars typevar) {
boolean flag = false;
if (typevar != null) {
Session session = null;
Transaction tran = null;
try {
session = HibernateUtil.getSessionFactory().getCurrentSession();
tran = session.beginTransaction();
session.saveOrUpdate(typevar);
flag = true;
tran.commit();
} catch (HibernateException e) {
flag = false;
if(tran!=null){
tran.rollback();
}
e.printStackTrace();
}
}
return flag;
}
@SuppressWarnings("unchecked")
public List<Typevars> findAll() {
Session session = null;
Transaction tran = null;
Query query = null;
List<Typevars> typevars = null;
try {
typevars = new ArrayList<Typevars>();
session = HibernateUtil.getSessionFactory().getCurrentSession();
tran = session.beginTransaction();
query = session.createQuery("from Typevars order by displayorder");
typevars = query.list();
tran.commit();
} catch (HibernateException e) {
if(tran!=null){
tran.rollback();
}
e.printStackTrace();
}
return typevars;
}
}
| [
"[email protected]"
]
| |
e2077a9cbf1e308f16f1f8e1f8e7135909b921cb | 7d408e37aa6abf2dd388081404c0a2f03f542114 | /Ramecek.java | 82baeb289196f55d4c4cacb7eaae2e9c602f0aed | []
| no_license | Snexie/Programovani | 34b0453ad712c1d8842aedeebd3aefb5d2fe1913 | 5f338b1b210ad9783525d9b7d2a658b0e3f4b43e | refs/heads/master | 2021-01-10T15:45:23.762858 | 2015-11-19T18:33:22 | 2015-11-19T18:33:22 | 46,494,890 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 739 | java | public class Ramecek {
public static void main(String[] args) {
int sirka = 20;
int vyska = 3;
int tloustka = 2;
for (int radek = 0; radek < vyska + 2*tloustka; radek++) {
for (int sloupec = 0; sloupec < sirka + 2*tloustka; sloupec++) {
if (
(radek >= tloustka)
&& (radek < tloustka + vyska)
&& (sloupec >= tloustka)
&& (sloupec < tloustka + sirka)
) {
System.out.printf(" ");
} else {
System.out.printf("X");
}
}
System.out.println();
}
}
} | [
"[email protected]"
]
| |
49f4acba586cd8828b4d903217c129e2717f230e | 6e082ad55b5211494096918392cfc5972850b3e0 | /sigf_v1/src/main/java/com/areatecnica/sigf_v1/controllers/InformeAbonoBusController.java | e82651dc98ecaeed3e5487fa9248e0daba1fd7c0 | []
| no_license | ianfranco/sigf_v1 | 6de9cb6cb4fad00634b54dc56e361205a2909665 | 9bfaee5b1c5530483dbee941564e7de7e6685529 | refs/heads/master | 2021-10-10T20:33:57.456106 | 2019-01-16T17:08:55 | 2019-01-16T17:08:55 | 66,803,093 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,611 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.areatecnica.sigf_v1.controllers;
import com.areatecnica.sigf_v1.controllers.util.JsfUtil;
import com.areatecnica.sigf_v1.dao.AbonoBusDaoImpl;
import com.areatecnica.sigf_v1.dao.BusDao;
import com.areatecnica.sigf_v1.dao.BusDaoImpl;
import com.areatecnica.sigf_v1.dao.CargosBusQuery;
import com.areatecnica.sigf_v1.dao.UnidadNegocioDao;
import com.areatecnica.sigf_v1.dao.UnidadNegocioDaoImpl;
import com.areatecnica.sigf_v1.entities.AbonoBus;
import com.areatecnica.sigf_v1.entities.Bus;
import com.areatecnica.sigf_v1.entities.UnidadNegocio;
import javax.inject.Named;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.LinkedHashMap;
import java.util.List;
import javax.faces.view.ViewScoped;
/**
*
* @author ianfr
*/
@Named(value = "informeAbonosBusController")
@ViewScoped
public class InformeAbonoBusController implements Serializable {
private UnidadNegocioDao unidadNegocioDao;
private AbonoBusDaoImpl abonoBusDaoImpl;
private BusDao busDao;
private List<AbonoBus> items;
private List<UnidadNegocio> unidadNegocioItems;
private List<Bus> busItems;
private Bus bus;
private ArrayList<LinkedHashMap> listOfMaps;
private List<String> resultsHeader;// = service.getResultsValues(...);
private List<String> resultsTotals;
private LinkedHashMap totales;
private Object header;
private CargosBusQuery cargosBusQuery;
private AbonoBus selected;
private int mes;
private int anio;
private Date fecha;
private UnidadNegocio unidadNegocio;
/**
* Creates a new instance of InstitucionPrevisionController
*/
public InformeAbonoBusController() {
this.unidadNegocioDao = new UnidadNegocioDaoImpl();
this.unidadNegocioItems = this.unidadNegocioDao.findAll();
Calendar calendar = GregorianCalendar.getInstance();
this.mes = calendar.get(Calendar.MONTH) + 1;
this.anio = calendar.get(Calendar.YEAR);
}
public ArrayList<LinkedHashMap> getListOfMaps() {
return listOfMaps;
}
public void setListOfMaps(ArrayList<LinkedHashMap> listOfMaps) {
this.listOfMaps = listOfMaps;
}
public List<String> getResultsHeader() {
return resultsHeader;
}
public void setResultsHeader(List<String> resultsHeader) {
this.resultsHeader = resultsHeader;
}
public List<String> getResultsTotals() {
return resultsTotals;
}
public void setResultsTotals(List<String> resultsTotals) {
this.resultsTotals = resultsTotals;
}
public int getMes() {
return mes;
}
public void setMes(int mes) {
this.mes = mes;
}
public int getAnio() {
return anio;
}
public void setAnio(int anio) {
this.anio = anio;
}
public String getStringMonth() {
switch (this.mes) {
case 1:
return "Enero";
case 2:
return "Febrero";
case 3:
return "Marzo";
case 4:
return "Abril";
case 5:
return "Mayo";
case 6:
return "Junio";
case 7:
return "Julio";
case 8:
return "Agosto";
case 9:
return "Septiembre";
case 10:
return "Octubre";
case 11:
return "Noviembre";
case 12:
return "Diciembre";
}
return "";
}
public void init() {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
String from = "01/" + mes + "/" + anio;
try {
this.fecha = format.parse(from);
} catch (ParseException p) {
}
this.abonoBusDaoImpl = new AbonoBusDaoImpl();
if (this.bus != null) {
this.items = this.abonoBusDaoImpl.findByBus(bus);
}
}
public void resetParents() {
//JsfUtil.addSuccessMessage("Guía:" + this.selected.getFolio());
}
public void delete() {
}
public String getComponentMessages(String clientComponent, String defaultMessage) {
return JsfUtil.getComponentMessages(clientComponent, defaultMessage);
}
public LinkedHashMap getTotales() {
return totales;
}
public void setTotales(LinkedHashMap totales) {
this.totales = totales;
}
public List<UnidadNegocio> getUnidadNegocioItems() {
return unidadNegocioItems;
}
public void setUnidadNegocioItems(List<UnidadNegocio> unidadNegocioItems) {
this.unidadNegocioItems = unidadNegocioItems;
}
public UnidadNegocio getUnidadNegocio() {
return unidadNegocio;
}
public void setUnidadNegocio(UnidadNegocio unidadNegocio) {
this.unidadNegocio = unidadNegocio;
}
public void handleUnidadChange() {
if (this.unidadNegocio != null) {
this.busDao = new BusDaoImpl();
this.busItems = this.busDao.findByUnidad(this.unidadNegocio.getIdUnidadNegocio());
}
}
public List<AbonoBus> getItems() {
return items;
}
public void setItems(List<AbonoBus> items) {
this.items = items;
}
public List<Bus> getBusItems() {
return busItems;
}
public void setBusItems(List<Bus> busItems) {
this.busItems = busItems;
}
public Object getHeader() {
return header;
}
public void setHeader(Object header) {
this.header = header;
}
public AbonoBus getSelected() {
return selected;
}
public void setSelected(AbonoBus selected) {
this.selected = selected;
}
public Date getFecha() {
return fecha;
}
public void setFecha(Date fecha) {
this.fecha = fecha;
}
public Bus getBus() {
return bus;
}
public void setBus(Bus bus) {
this.bus = bus;
}
}
| [
"[email protected]"
]
| |
b7813d165aba8127217a6bf37797ef748e268ef6 | 440c767120d2ef53742d71eb5d3d5dba5e1e15c1 | /workspace/workspace/adv/src/main/java/com/listen/controller/ListenSdkOperateController.java | 5d1e1ef396c475ed1cbb30d98afcd6fdcf96fc27 | []
| no_license | SHHXWLWKJYXGS/Data | fac8d65e46629571f2e5b34a95664fe80c3a396f | 1ac70420383a9f87a789cfbef1f325483e28457a | refs/heads/master | 2023-08-03T15:08:08.772051 | 2020-07-06T02:54:06 | 2020-07-06T02:54:06 | 278,303,356 | 0 | 0 | null | 2023-07-15T05:12:31 | 2020-07-09T08:09:17 | JavaScript | UTF-8 | Java | false | false | 6,661 | java | /* */ package com.listen.controller;
/* */
/* */ import com.listen.model.ResponseModel;
/* */ import com.listen.model.ResultBean;
/* */ import com.listen.model.TmlDeviceMapImage;
/* */ import com.listen.model.query.DeviceQuery;
/* */ import com.listen.model.task.PlayTaskBasicVo;
/* */ import com.listen.service.AuthService;
/* */ import com.listen.service.CardService;
/* */ import com.listen.util.ConfigUtil;
/* */ import java.util.List;
/* */ import javax.annotation.Resource;
/* */ import javax.servlet.http.HttpServletRequest;
/* */ import org.springframework.stereotype.Controller;
/* */ import org.springframework.ui.Model;
/* */ import org.springframework.web.bind.annotation.RequestMapping;
/* */ import org.springframework.web.bind.annotation.RequestMethod;
/* */ import org.springframework.web.bind.annotation.ResponseBody;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @RequestMapping({"/sdkNew/"})
/* */ @Controller
/* */ public class ListenSdkOperateController
/* */ extends BaseController
/* */ {
/* */ @Resource
/* */ private CardService cardService;
/* */ @Resource
/* */ private AuthService authService;
/* */
/* */ @RequestMapping({"/deviceMain"})
/* */ public String deviceMain(HttpServletRequest request, Model model) {
/* 38 */ List<DeviceQuery> list = this.cardService.getDevList();
/* 39 */ model.addAttribute("devList", (list != null && list.size() > 0) ? list : null);
/* 40 */ List<TmlDeviceMapImage> mapList = this.cardService.getMapDevList();
/* 41 */ model.addAttribute("mapDevList", (mapList != null && mapList.size() > 0) ? mapList : null);
/* 42 */ return "device/device";
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @RequestMapping({"/getDeviceList"})
/* */ @ResponseBody
/* */ public ResultBean getDevList(Integer pageNo, Integer pageSize, String devCodeOrMac) {
/* 55 */ ResultBean rb = this.cardService.getDevList(pageNo, pageSize, devCodeOrMac);
/* 56 */ return rb;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @RequestMapping({"/getMapDevList"})
/* */ @ResponseBody
/* */ public ResultBean getMapDevList(Integer pageNo, Integer pageSize, String devCode) {
/* 69 */ ResultBean rb = this.cardService.getMapDevList(pageNo, pageSize, devCode);
/* 70 */ return rb;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @RequestMapping({"/deviceHeartBeatList"})
/* */ public String deviceHeartBeatList(HttpServletRequest request, Model model) {
/* 80 */ List<DeviceQuery> list = this.cardService.getDeviceHeartBeatList();
/* 81 */ model.addAttribute("onlineDevList", (list != null && list.size() > 0) ? list : null);
/* 82 */ return "device/deviceHeartBeatList";
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @RequestMapping({"/getDeviceHeartBeatList"})
/* */ @ResponseBody
/* */ public ResultBean getdeviceHeartBeatList(Integer pageNo, Integer pageSize, String devCodeOrMac) {
/* 95 */ ResultBean rb = this.cardService.getDeviceHeartBeatList(pageNo, pageSize, devCodeOrMac);
/* 96 */ return rb;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @RequestMapping({"/deviceTaskUpdateList"})
/* */ public String deviceTaskUpdateList(HttpServletRequest request, Model model) {
/* 107 */ List<PlayTaskBasicVo> list = this.cardService.getDeviceTaskUpdateList();
/* 108 */ model.addAttribute("taskUpdateList", (list != null && list.size() > 0) ? list : null);
/* 109 */ return "device/deviceTaskUpdateList";
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @RequestMapping({"/getDeviceTaskUpdateList"})
/* */ @ResponseBody
/* */ public ResultBean deviceTaskUpdateList(Integer pageNo, Integer pageSize, String devCode) {
/* 123 */ ResultBean rb = this.cardService.getDeviceTaskUpdateList(pageNo, pageSize, devCode);
/* 124 */ return rb;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @RequestMapping(value = {"/lsPublishProgram.fgl"}, method = {RequestMethod.POST})
/* */ @ResponseBody
/* */ public ResponseModel saveAndSendProgram(HttpServletRequest request, String devCode, String strProgramList) {
/* 137 */ String defaultStoragePosition = ConfigUtil.getProperties("default.storagePosition");
/* 138 */ ResponseModel rm = null;
/* 139 */ if (defaultStoragePosition.equals("1")) {
/* 140 */ rm = this.authService.saveAndSendProgram(devCode, strProgramList);
/* 141 */ } else if (defaultStoragePosition.equals("2")) {
/* 142 */ rm = this.authService.saveAndSendProgramNew(devCode, strProgramList);
/* */ }
/* 144 */ return rm;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @RequestMapping(value = {"/lsPublishTask.fgl"}, method = {RequestMethod.POST})
/* */ @ResponseBody
/* 157 */ public ResponseModel saveAndSendTask(HttpServletRequest request, String devCode, Integer type, String content) { return this.authService.saveAndSendTask(devCode, type, content); }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @RequestMapping(value = {"/updateData.fgl"}, method = {RequestMethod.POST})
/* */ @ResponseBody
/* 171 */ public ResponseModel updateData(HttpServletRequest request, String devCode, String devType, String devDataType, String dataInfo) { return this.authService.updateData(devCode, devType, devDataType, dataInfo); }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @ResponseBody
/* */ @RequestMapping(value = {"/addMapDevice.fgl"}, method = {RequestMethod.POST})
/* 183 */ public ResponseModel addMapDevice(HttpServletRequest request, String devCode, String imageName) { return this.authService.addMapDevice(devCode, imageName); }
/* */ }
/* Location: C:\Users\Administrator\Desktop\com.zip!\com\listen\controller\ListenSdkOperateController.class
* Java compiler version: 7 (51.0)
* JD-Core Version: 1.1.2
*/ | [
"[email protected]"
]
| |
bc7c30d097cdc76d658daa4a2bd78c3c1327632d | 501057802018ce1fc40ca14da85910ee53c4933b | /recomendShopping/src/main/java/com/example/recomendShopping/RecomendShoppingApplication.java | bb54c5569243b87f5ba4c263fdd8c36f131fcaed | []
| no_license | mingg123/naver_api_demo_project | d0c14289b36b4bee9781abe8e04760182bfc4c3c | 3a03bdcc6737f5d3e7ec2c1f3a3ba4ceb62428a0 | refs/heads/main | 2023-06-28T21:35:34.858014 | 2021-08-03T05:57:09 | 2021-08-03T05:57:09 | 389,955,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 341 | java | package com.example.recomendShopping;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class RecomendShoppingApplication {
public static void main(String[] args) {
SpringApplication.run(RecomendShoppingApplication.class, args);
}
}
| [
"[email protected]"
]
| |
f8fdebb8b7830ee5c5b4dd550914786faddba154 | e9affefd4e89b3c7e2064fee8833d7838c0e0abc | /aws-java-sdk-chime/src/main/java/com/amazonaws/services/chime/model/transform/ListAttendeeTagsRequestMarshaller.java | faff2b99fe5d071ac146619dbca8571959085616 | [
"Apache-2.0"
]
| permissive | aws/aws-sdk-java | 2c6199b12b47345b5d3c50e425dabba56e279190 | bab987ab604575f41a76864f755f49386e3264b4 | refs/heads/master | 2023-08-29T10:49:07.379135 | 2023-08-28T21:05:55 | 2023-08-28T21:05:55 | 574,877 | 3,695 | 3,092 | Apache-2.0 | 2023-09-13T23:35:28 | 2010-03-22T23:34:58 | null | UTF-8 | Java | false | false | 2,338 | java | /*
* Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.chime.model.transform;
import javax.annotation.Generated;
import com.amazonaws.SdkClientException;
import com.amazonaws.services.chime.model.*;
import com.amazonaws.protocol.*;
import com.amazonaws.annotation.SdkInternalApi;
/**
* ListAttendeeTagsRequestMarshaller
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
@SdkInternalApi
public class ListAttendeeTagsRequestMarshaller {
private static final MarshallingInfo<String> MEETINGID_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PATH)
.marshallLocationName("meetingId").build();
private static final MarshallingInfo<String> ATTENDEEID_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PATH)
.marshallLocationName("attendeeId").build();
private static final ListAttendeeTagsRequestMarshaller instance = new ListAttendeeTagsRequestMarshaller();
public static ListAttendeeTagsRequestMarshaller getInstance() {
return instance;
}
/**
* Marshall the given parameter object.
*/
public void marshall(ListAttendeeTagsRequest listAttendeeTagsRequest, ProtocolMarshaller protocolMarshaller) {
if (listAttendeeTagsRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(listAttendeeTagsRequest.getMeetingId(), MEETINGID_BINDING);
protocolMarshaller.marshall(listAttendeeTagsRequest.getAttendeeId(), ATTENDEEID_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
}
}
| [
""
]
| |
1e6826dcdfa28528bbcf25f6a873ffcd7d7abc1a | 292c856ccc306655dba79afef242d114eb64bc1c | /app/src/main/java/com/cheng/budgetplanner/bean/BaseBean.java | ce73e8eeb7415b224c6bf85c3824df97e3c7410a | []
| no_license | chenghan15/BudgetPlanner | 35dd3ada8e5e84f580039816872ace1d827bc052 | d304aae16111927c31a7111c829edf1be14ca9ae | refs/heads/master | 2020-09-06T10:31:50.179752 | 2019-11-08T06:16:36 | 2019-11-08T06:16:36 | 220,399,849 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 456 | java | package com.cheng.budgetplanner.bean;
import java.io.Serializable;
public class BaseBean implements Serializable {
private int status;
private String message;
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
} | [
"[email protected]"
]
| |
9336e4dccbe54fbdf36c564969f2f46f2fb4a921 | 2687b74bb779f3481a0fbf7342d0fdb45e45fa53 | /Android-Studio-4/Belajar-Android/IntentActivity/app/src/main/java/com/yapi/intentactivity/Barang.java | 7f0ff08b23825dfc3cb4852f47d8a534fadf81fc | []
| no_license | Yushan-Riry/Android-Studio | fa6784e0a3a865c5b5f1ea47c7681f6631e66097 | e5ba29e56bce1cf488c0b5d1ccb4211015c48ad1 | refs/heads/master | 2023-07-17T20:38:51.715512 | 2021-09-03T16:45:38 | 2021-09-03T16:45:38 | 386,357,482 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 634 | java | package com.yapi.intentactivity;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class Barang extends AppCompatActivity {
TextView tvbarang;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_barang);
load();
ambilData();
}
public void load() {
tvbarang = findViewById(R.id.tvBarang);
}
public void ambilData() {
String ambil = getIntent().getStringExtra("ISI");
tvbarang.setText(ambil);
}
} | [
"[email protected]"
]
| |
80157e4d5683bda755835c74e806649a0a181916 | 7d549413a0f627c6434586a592d8919eebd25d5f | /app/src/main/java/com/likeit/currenciesapp/ui/chat/db/DBManager.java | c813c9f4b0734d7545a3de0893543f4843407a77 | []
| no_license | 13512780735/dataibei99 | f5820d4d16a7d72fd71a98a588d0eb83b3e6b3f6 | 5bd6f4c2162b6aafe48dc322a72ab500dc84d8c0 | refs/heads/master | 2020-03-15T04:16:37.708008 | 2018-11-10T08:17:09 | 2018-11-10T08:17:09 | 131,961,462 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,954 | java | package com.likeit.currenciesapp.ui.chat.db;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import com.likeit.currenciesapp.ui.chat.SealConst;
import java.io.File;
import io.rong.common.RLog;
import io.rong.imkit.userInfoCache.RongDatabaseContext;
import static android.content.Context.MODE_PRIVATE;
/**
* [数据库管理类,数据采用GreenDao来实现,所有实现通过模板自动生成;通过获取daoSession来获取所有的dao,从而实现操作对象]
*
* @author devin.hu
* @version 1.0
* @date 2013-9-17
*
**/
public class DBManager {
private final static String TAG = "DBManager";
private final static String DB_NAME = "SealUserInfo";
private static DBManager instance;
private DaoMaster daoMaster;
private DaoSession daoSession;
private static Context mContext;
private static boolean isInitialized;
/**
* [获取DBManager实例,单例模式实现]
*
* @return DBManager
*/
public static DBManager getInstance() {
return instance;
}
/**
* [初始化DBManager实例,单例模式实现]
*
* @param context
* @return DBManager
*/
public static DBManager init(Context context) {
if (isInitialized) {
RLog.d(TAG, "DBManager has init");
return instance;
}
RLog.d(TAG, "DBManager init");
mContext = context;
instance = new DBManager(context);
isInitialized = true;
return instance;
}
public boolean isInitialized() {
return isInitialized;
}
/**
* 构造方法
* @param context
*/
private DBManager(Context context) {
DaoMaster.OpenHelper helper = new
DaoMaster.DevOpenHelper(new RongDatabaseContext(context, getDbPath()), DB_NAME, null);
daoMaster = new DaoMaster(helper.getWritableDatabase());
daoSession = daoMaster.newSession();
//数据库存贮路径修改,直接删除旧的数据库
mContext.deleteDatabase(mContext.getPackageName());
}
public DaoMaster getDaoMaster() {
return daoMaster;
}
public void setDaoMaster(DaoMaster daoMaster) {
this.daoMaster = daoMaster;
}
public DaoSession getDaoSession() {
return daoSession;
}
public void setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
}
private static String getAppKey() {
String appKey = null;
try {
ApplicationInfo applicationInfo = mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(), PackageManager.GET_META_DATA);
if (applicationInfo != null) {
appKey = applicationInfo.metaData.getString("RONG_CLOUD_APP_KEY");
}
if (TextUtils.isEmpty(appKey)) {
throw new IllegalArgumentException("can't find RONG_CLOUD_APP_KEY in AndroidManifest.xml.");
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
throw new ExceptionInInitializerError("can't find packageName!");
}
return appKey;
}
private static String getDbPath () {
String currentUserId = mContext.getSharedPreferences("config", MODE_PRIVATE).getString(SealConst.SEALTALK_LOGIN_ID, null);
String dbPath = mContext.getFilesDir().getAbsolutePath();
dbPath = dbPath + File.separator + getAppKey() + File.separator + currentUserId;
RLog.d(TAG, "DBManager dbPath = " + dbPath);
return dbPath;
}
public void uninit() {
RLog.d(TAG, "DBManager uninit");
if (daoSession != null && daoSession.getDatabase() != null) {
daoSession.getDatabase().close();
}
daoSession = null;
daoMaster = null;
isInitialized = false;
}
}
| [
"[email protected]"
]
| |
9b79bab6b4aa0c3d86f06db023dcb5a6ba1dcb04 | cbfb41ba97fc8f5e5d66b0a5784e6d9968da4236 | /src/com/kwic/html/parser/JHTMLParser.java | 22c55775e8fab7f92b34bf7fd89733dc2fc94281 | []
| no_license | suhojang/HTMLtoPdf-Image | eaf46fb20749576d9194644d1b3bb22226aa08c8 | 950b71f53236b76e7fce04247a74688b3c674653 | refs/heads/main | 2023-04-07T14:36:53.052221 | 2021-04-07T08:21:48 | 2021-04-07T08:21:48 | 355,097,434 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 29,062 | java | package com.kwic.html.parser;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.htmlparser.jericho.Element;
import net.htmlparser.jericho.FormControl;
import net.htmlparser.jericho.HTMLElementName;
import net.htmlparser.jericho.Source;
/**
* <pre>
* Title : JHTMLParser
* Description : HTML Parser
* Date :
* Copyright : Copyright (c) 2012
* Company : KWIC.
*
* 수정일 수정자 수정내용
* -------------------------------------------
*
* </pre>
*
* @author 장정훈
* @version
* @since
*/
public class JHTMLParser {
private Source src;
public JHTMLParser(String htmlString){
src = new Source(htmlString);
}
public JHTMLParser(String filePath,boolean isURL) throws FileNotFoundException, IOException{
src = new Source(new FileInputStream(new File(filePath)));
}
public List<Element> getElementsByTagName(String tagName){
return src.getAllElements(tagName);
}
public Element getElementById(String id){
return src.getElementById(id);
}
public List<FormControl> getFormControl(String name) throws Exception{
List<FormControl> rsts = new ArrayList<FormControl>();
List<FormControl> forms = src.getFormControls();
for(int i=0;i<forms.size();i++){
if(forms.get(i)==null || forms.get(i).getAttributesMap()==null || forms.get(i).getAttributesMap().get("name")==null)
continue;
if(forms.get(i).getAttributesMap().get("name").equals(name)){
rsts.add(forms.get(i));
}
}
if(rsts.size()<1)
throw new Exception("[name='"+name+"']에 해당하는 ELEMENT가 없습니다.");
return rsts;
}
public List<FormControl> getFormControlStartsWith(String name) throws Exception{
List<FormControl> rsts = new ArrayList<FormControl>();
List<FormControl> forms = src.getFormControls();
for(int i=0;i<forms.size();i++){
if(forms.get(i)==null || forms.get(i).getAttributesMap()==null || forms.get(i).getAttributesMap().get("name")==null)
continue;
if(forms.get(i).getAttributesMap().get("name").startsWith(name)){
rsts.add(forms.get(i));
}
}
if(rsts.size()<1)
throw new Exception("[name='"+name+"...']에 해당하는 ELEMENT가 없습니다.");
return rsts;
}
public List<FormControl> getFormControlEndsWith(String name) throws Exception{
List<FormControl> rsts = new ArrayList<FormControl>();
List<FormControl> forms = src.getFormControls();
for(int i=0;i<forms.size();i++){
if(forms.get(i)==null || forms.get(i).getAttributesMap()==null || forms.get(i).getAttributesMap().get("name")==null)
continue;
if(forms.get(i).getAttributesMap().get("name").endsWith(name)){
rsts.add(forms.get(i));
}
}
if(rsts.size()<1)
throw new Exception("[name='..."+name+"']에 해당하는 ELEMENT가 없습니다.");
return rsts;
}
public String getFormValue(String elementName) throws Exception{
return getFormValue(elementName,0);
}
public String getFormValue(String elementName,int idx) throws Exception{
List<FormControl> list = getFormControl(elementName);
if(list.size()<=idx)
throw new Exception("[name='"+elementName+"']의 index는 최대 ["+(list.size()-1)+"]까지 입니다.");
FormControl control = list.get(idx);
return control.getAttributesMap().get("value");
}
public String getFormValue(FormControl control) throws Exception{
return control.getAttributesMap().get("value");
}
public String getFormType(String elementName) throws Exception{
return getFormType(elementName,0);
}
public String getFormType(String elementName,int idx) throws Exception{
List<FormControl> list = getFormControl(elementName);
if(list.size()<=idx)
throw new Exception("[name='"+elementName+"']의 index는 최대 ["+(list.size()-1)+"]까지 입니다.");
FormControl control = list.get(idx);
return control.getAttributesMap().get("type");
}
public String getFormAttribute(String elementName,String attrName) throws Exception{
return getFormAttribute(elementName,0,attrName);
}
public String getFormAttribute(String elementName,int idx,String attrName) throws Exception{
List<FormControl> list = getFormControl(elementName);
if(list.size()<=idx)
throw new Exception("[name='"+elementName+"']의 index는 최대 ["+(list.size()-1)+"]까지 입니다.");
FormControl control = list.get(idx);
return control.getAttributesMap().get(attrName);
}
public String getTdValue(int tbIdx,int trIdx,int tdIdx) throws Exception{
List<Element> list = src.getAllElements(HTMLElementName.TABLE);
if(list.size()<=tbIdx)
throw new Exception("TABLE의 index는 최대 ["+(list.size()-1)+"]까지 입니다.");
Element table = list.get(tbIdx);
list = table.getAllElements(HTMLElementName.TR);
if(list.size()<=trIdx)
throw new Exception("TABLE["+tbIdx+"]-TR의 index는 최대 ["+(list.size()-1)+"]까지 입니다.");
Element tr = list.get(trIdx);
list = tr.getAllElements(HTMLElementName.TD);
if(list.size()<=tdIdx)
throw new Exception("TABLE["+tbIdx+"]-TR["+trIdx+"]-TD의 index는 최대 ["+(list.size()-1)+"]까지 입니다.");
Element td = list.get(tdIdx);
return td.getContent().toString();
}
public String getTdValue(Element tr,int tdIdx) throws Exception{
List<Element> list = tr.getAllElements(HTMLElementName.TD);
if(list.size()<=tdIdx)
throw new Exception("TD의 index는 최대 ["+(list.size()-1)+"]까지 입니다.");
Element td = list.get(tdIdx);
return td.getContent().toString();
}
public List<Element> getTRList(int tbIdx) throws Exception{
List<Element> list = src.getAllElements(HTMLElementName.TABLE);
if(list.size()<=tbIdx)
throw new Exception("TABLE의 index는 최대 ["+(list.size()-1)+"]까지 입니다.");
Element table = list.get(tbIdx);
list = table.getAllElements(HTMLElementName.TR);
return list;
}
public String getTdValue(String tbId,int trIdx,int tdIdx) throws Exception{
Element table = getElementById(tbId);
List<Element> list = table.getAllElements(HTMLElementName.TR);
if(list.size()<=trIdx)
throw new Exception("TABLE[id='"+tbId+"']-TR의 index는 최대 ["+(list.size()-1)+"]까지 입니다.");
Element tr = list.get(trIdx);
list = tr.getAllElements(HTMLElementName.TD);
if(list.size()<=tdIdx)
throw new Exception("TABLE[id='"+tbId+"']-TR["+trIdx+"]-TD의 index는 최대 ["+(list.size()-1)+"]까지 입니다.");
Element td = list.get(tdIdx);
return td.getContent().toString();
}
public String getTdValue(String trId,int tdIdx) throws Exception{
Element tr = getElementById(trId);
List<Element> list = tr.getAllElements(HTMLElementName.TD);
if(list.size()<=tdIdx)
throw new Exception("TR[id='"+trId+"']-TD의 index는 최대 ["+(list.size()-1)+"]까지 입니다.");
Element td = tr.getAllElements(HTMLElementName.TD).get(tdIdx);
return td.getContent().toString();
}
public String getTdValue(String tdId){
Element td = getElementById(tdId);
return td.getContent().toString();
}
public static void main(String[] args) throws Exception{
StringBuffer sb = new StringBuffer();
sb.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
sb.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"ko\" lang=\"ko\">");
sb.append("<head>");
sb.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");
sb.append("<title>매출전자세금계산서합계표</title>");
sb.append("");
sb.append("");
sb.append("<style type=\"text/css\">");
sb.append("body {padding-left:1px;}");
sb.append("body, h1, h2, h3, th, td, div, p {font-size: 13px; font-family: \"Malgun Gothic\", sans-serif;color: #000; font-weight:normal;}");
sb.append("img {border:none;}");
sb.append("table {border-collapse: collapse; width: 100%; }");
sb.append("th, td, li, p {}");
sb.append("em {font-style:normal;}");
sb.append("dl, ul, ol, menu, li {list-style: none;} ");
sb.append("* {margin: 0; padding: 0;}");
sb.append("");
sb.append("");
sb.append(".table_area {/*border:2px solid #000;*/ width:695px;}");
sb.append(".table_area tr td {padding:15px;}");
sb.append(".t_tit {font-size:16px; font-weight:bold; margin-bottom:3px}");
sb.append(".marbt30 {margin-bottom:30px;}");
sb.append(".board_table01.pad3 tbody th.pdtb_none, .board_table01.pad3 tbody td.pdtb_none {padding:0 3px 0 3px !important;}");
sb.append("");
sb.append(".tearm {font-size:12px; font-weight:normal;}");
sb.append(".title_03 .print_date {font-size:11px; font-weight:normal; text-align:left; padding-top:0}");
sb.append(".title_03 .page_num {font-size:11px; font-weight:normal; text-align:right; padding-top:0}");
sb.append(".w100 {width:100% !important}");
sb.append(" ");
sb.append("/***************board_table01***************/");
sb.append(".board_area_01 {width:695px; border-left:2px solid #000; border-right:2px solid #000; border-bottom:2px solid #000;}");
sb.append(".board_area_01.bd_01 {border-left:0 !important; border-right:0 !important;}");
sb.append(".board_table01 {width: 695px;}");
sb.append(".board_table01.bd_01 {border-top:2px solid #000; border-left:2px solid #000; border-right:2px solid #000;}");
sb.append(".board_table01.bd_02 {border-left:2px solid #000; border-right:2px solid #000;}");
sb.append(".board_table01.bd_03 {border-top:2px solid #000;}");
sb.append(".board_table01.bd_04 {border-bottom:2px solid #000;}");
sb.append(".board_table01.bd_05 {border:2px solid #000;}");
sb.append(".marbt4 {margin-bottom:4px;}");
sb.append(".board_table01.w220 {width:220px !important}");
sb.append(".board_table01.w240 {width:240px !important}");
sb.append(".board_table01 thead th {text-align:center; height: 21px;padding: 7px 0 7px 3px; color: #000000; font-size:13px ; font-weight:normal;border: #000 1px solid;}");
sb.append(".board_table01 tbody th {text-align:left; padding: 7px 0 7px 5px; color: #000000; font-size: 13px; font-weight:normal;border: 1px solid #000;}");
sb.append("");
sb.append(".board_table01 tbody th.line_B_none, .board_table01 tbody td.line_B_none {border-bottom:0 !important}");
sb.append(".board_table01 tbody th.line_T_none, .board_table01 tbody td.line_T_none {border-top:0 !important}");
sb.append(".board_table01 tbody th.line_L_none, .board_table01 tbody td.line_L_none {border-left:0 !important}");
sb.append(".board_table01 tbody th.line_R_none, .board_table01 tbody td.line_R_none {border-right:0 !important}");
sb.append(".board_table01 tbody td {font-size:13px; text-align: left; padding: 7px 0 7px 5px; background: #fff; border: 1px solid #000;}");
sb.append(".board_table01 tbody td.center, .board_table01 tbody th.center {text-align:center;}");
sb.append(".board_table01 tbody td.sum {text-align: right; padding-right:3px;}");
sb.append(".board_table01 tbody th.bggray, .board_table01 tbody td.bggray {background:#eeeeee !important}");
sb.append(".board_table01 thead th.bggray, .board_table01 tbody td.bggray {background:#eeeeee !important}");
sb.append(".board_table01 tbody tr.padtb5 th, .board_table01 tbody tr.padtb5 td {padding:5px 0 5px 5px !important} ");
sb.append(".board_table01 tbody td.right {text-align:right;}");
sb.append("");
sb.append(".board_table01 tbody tr td.none table tr td {border:0;}");
sb.append(".board_table01.b_none tbody tr td {border:0;}");
sb.append(".board_table01.pad2 tbody td.padnone {padding:0;}");
sb.append(".board_table01.pad2 tbody td.bdnone {border:0 !important;}");
sb.append(".board_table01 tbody th b.padL {padding-left:16px !important; display:inline-block}");
sb.append(".board_table01.pad2 tbody th, .board_table01.pad2 tbody td {padding: 0 3px 0 3px !important;}");
sb.append("");
sb.append(".board_table01.pad3 tbody th, .board_table01.pad3 tbody td {line-height:12px; padding: 7px 3px 7px 3px !important;}");
sb.append(".board_table01.pad3 tbody tr.tit11 th, .board_table01.pad3 tbody tr.tit11 td {font-size:12px;}");
sb.append("");
sb.append(".top_tit {font-size:24px; font-weight:bold; margin-bottom:3px}");
sb.append(".top_tit_02 {font-size:20px; font-weight:bold; margin-bottom:3px}");
sb.append(".top_tit_02.marbt20 {margin-bottom:20px !important}");
sb.append(".top_tit_03 {font-size:26px; font-weight:bold; margin-bottom:15px}");
sb.append(".top_tit_s {font-size:16px; font-weight:bold}");
sb.append(".marL30 {margin-left:30px; display:inline-block}");
sb.append(".bt_sign {vertical-align:bottom; text-align:right; padding:0 35px 15px 0; font-size:16px}");
sb.append(".bt_sign_02 {vertical-align:bottom; text-align:right; padding:0 35px 50px 0; font-size:16px}");
sb.append(".date {margin-right:90px; margin-bottom:20px;}");
sb.append(".h80 {height:80px;}");
sb.append(".btdot {border-bottom:1px dotted #666 !important;}");
sb.append("");
sb.append("/**** board_table07 ****/");
sb.append(".board_table07 {width:695px; border-left:2px solid #000; border-right:2px solid #000; border-bottom:2px solid #000;}");
sb.append(".board_table07.bdbt {border-bottom:1px solid #000 !important;}");
sb.append(".board_table07 thead th {text-align:center; height: 21px;padding: 7px 3px 7px 3px; color: #000000; font-size: 100%; font-weight:normal;border: #000 1px solid;}");
sb.append(".board_table07 body th {text-align:center; height: 21px;padding: 7px 3px 7px 3px; color: #000000; font-size: 100%; font-weight:normal;border: #000 1px solid;}");
sb.append(".board_table07 tbody td {font-size:100%; text-align: center; padding: 7px 3px 7px 3px; background: #fff;border: #000 1px solid;}");
sb.append(".board_table07 tbody td.center {text-align:center;}");
sb.append(".board_table07 tbody td.sum {text-align: right; padding-right:3px;}");
sb.append(".board_table07 tfoot th {text-align:center; height: 21px;padding: 2px 0 2px 3px; color: #000000; font-size: 100%; font-weight:normal;border: #000 1px solid;}");
sb.append("");
sb.append(".board_table07 tbody th.left, .board_table07 tfoot th.left {text-align:left; padding-left:3px;}");
sb.append(".board_table07 tbody td.num {text-align:right; padding-right:3px;}");
sb.append(".board_table07 tfoot th.sum {text-align:right; padding-right:3px; font-weight:bold;}");
sb.append("");
sb.append(".board_table07 tbody th.line_B_none, .board_table07 tbody td.line_B_none {border-bottom:0 !important}");
sb.append(".board_table07 tbody th.line_T_none, .board_table07 tbody td.line_T_none {border-top:0 !important}");
sb.append(".board_table07 tbody th.line_L_none, .board_table07 tbody td.line_L_none, .board_table07 thead th.line_L_none {border-left:0 !important}");
sb.append(".board_table07 tbody th.line_R_none, .board_table07 tbody td.line_R_none, .board_table07 thead th.line_R_none {border-right:0 !important}");
sb.append("");
sb.append("");
sb.append("/**** board_table08 ****/");
sb.append(".board_table08 {width:695px; border:1px solid #000;}");
sb.append(".board_table08 thead th {text-align:center; padding: 3px 3px 3px 3px; color: #000000; font-size: 12px; font-weight:normal;border: #000 1px solid;}");
sb.append(".board_table08 tbody th {text-align:center; padding: 1px 3px 1px 3px; color: #000000; font-size: 11px; font-weight:normal;border: #000 1px solid;}");
sb.append(".board_table08 tbody td {font-size:11px; text-align: center; padding: 1px 3px 1px 3px; background: #fff;border: #000 1px solid;}");
sb.append(".board_table08 tbody td.center {text-align:center;}");
sb.append(".board_table08 tbody td.sum {text-align: right; padding-right:3px;}");
sb.append(".board_table08 tfoot th {text-align:center; height: 21px;padding: 2px 0 2px 3px; color: #000000; font-size: 100%; font-weight:normal;border: #000 1px solid;}");
sb.append("");
sb.append(".board_table08 tbody th.left, .board_table08 tfoot th.left {text-align:left; padding-left:3px;}");
sb.append(".board_table08 tbody td.num {text-align:right; padding-right:3px;}");
sb.append("");
sb.append(".board_table08 tbody td.right {text-align: right;}");
sb.append("");
sb.append(".board_table08 tbody th.line_B_none, .board_table08 tbody td.line_B_none {border-bottom:0 !important}");
sb.append(".board_table08 tbody th.line_T_none, .board_table08 tbody td.line_T_none {border-top:0 !important}");
sb.append(".board_table08 thead th.line_L_none, .board_table08 tbody th.line_L_none, .board_table08 tbody td.line_L_none, .board_table07 table thead th.line_L_none {border-left:0 !important}");
sb.append(".board_table08 thead th.line_R_none, .board_table08 tbody th.line_R_none, .board_table08 tbody td.line_R_none, .board_table07 table thead th.line_R_none {border-right:0 !important}");
sb.append("");
sb.append(".board_table08 thead th, .board_table08 tbody th, .board_table08 tbody td {font-size:11px !important}");
sb.append(".ft11 {font-size:10px !important;}");
sb.append("");
sb.append("");
sb.append(".pre {white-space:pre;}");
sb.append(".fontS12 {font-size:12px !important}");
sb.append(".fontS11 {font-size:11px !important}");
sb.append(".va_top {vertical-align:top;}");
sb.append("");
sb.append(".table_bt_txt .bt_txt_01 {text-align:center; padding-top:10px;}");
sb.append(".table_bt_txt .bt_txt_02 {padding-top:10px; padding-left:5px}");
sb.append(".table_bt_txt .bt_txt_03 {text-align:right; padding-top:10px; padding-right:120px}");
sb.append(".table_bt_txt .bt_txt_04 {text-align:center; padding-top:30px;}");
sb.append(".table_bt_txt .bt_txt_05 {text-align:center; padding-top:10px; padding-bottom:30px;}");
sb.append(".table_bt_txt .bt_txt_06 {padding:20px 5px;}");
sb.append(".top_num_table {width:695px; margin-bottom:3px}");
sb.append(".top_num_table .top_num {font-size:11px;}");
sb.append(".fsize14 {font-size:14px !important}");
sb.append("");
sb.append(".won {width:695px; border-left:2px solid #000; border-right:2px solid #000}");
sb.append(".won td {text-align:right; padding:2px 2px 2px 0;}");
sb.append(".chkbox01 {display:inline-block; margin-right:20px;}");
sb.append(".chkbox02 {display:inline-block;}");
sb.append(".chkbox01 input, .chkbox02 input {vertical-align:middle; display:inline-block; margin-right:8px;}");
sb.append(".h30 {height:28px;}");
sb.append(".title {text-align:center; font-size:26px; font-weight:bold; margin-top:10px; padding-bottom:10px; width:695px;}");
sb.append(".title_02 {text-align:center; font-size:26px; margin-top:10px; padding-bottom:20px; width:695px;}");
sb.append(".txtR_02 {display:block; text-align:right; margin-right:10px}");
sb.append(".txtright {text-align:right !important;}");
sb.append(".d_block {display:block}");
sb.append(".ex_txt {padding:0 10px}");
sb.append(".ex_txt .ex01 {padding-left:10px; display:block}");
sb.append(".ex_txt .ex02 {padding-left:20px; display:block}");
sb.append(".use_txt {text-align:center !important; font-size:18px !important}");
sb.append(".bd_bt {border-bottom:0}");
sb.append(".use_tit {text-align:center !important; font-size:22px !important;}");
sb.append("");
sb.append(".title_03 {width:695px;}");
sb.append(".title_03 tbody tr td {text-align: center; font-size: 18px; font-weight: bold; padding-top: 10px; padding-bottom: 15p;}");
sb.append(".fontS11 {font-size:11px !important;}");
sb.append(".txt05 {margin-bottom:10px; padding:0 10px}");
sb.append(".txt06 {padding:0 10px}");
sb.append(".bt_pv {margin-top:15px}");
sb.append("");
sb.append(".taxpayer {text-align:right !important; font-size:11px !important}");
sb.append(".txt_none {text-align:center; font-size:14px; font-weight:bold; border-bottom:1px solid #000; padding-bottom:4px;}");
sb.append(".add {margin-top:10px}");
sb.append(".add dt, .add dd {font-weight:bold; margin-bottom:5px;}");
sb.append(".martp20 {margin-top:20px;}");
sb.append("");
/*sb.append("body {");
sb.append(" page-break-after:always;");
sb.append("}");*/
sb.append("");
sb.append(".pageNo::after{");
sb.append(" counter-increment : page;");
sb.append(" content : counter(page);");
sb.append("}");
sb.append("");
sb.append("</style>");
sb.append("");
sb.append("</head>");
sb.append("");
sb.append("<body>");
sb.append(" <table>");
sb.append(" <!-- 테이블의 header 부분 -->");
sb.append(" <thead>");
sb.append(" <tr>");
sb.append(" <td>");
sb.append(" <table class=\"title_03\">");
sb.append(" <tbody>");
sb.append(" <tr>");
sb.append(" <td colspan=\"2\">매출 전자세금계산서 합계표<br /><span class=\"tearm\">(2019-01-23~2019-01-29)</span></td>");
sb.append(" </tr>");
sb.append(" <tr>");
sb.append(" <td class=\"print_date\" style=\"padding-left:15px;\">출력일자 : 2019년 1월 29일</td>");
sb.append(" <td class=\"page_num\" style=\"padding-right:15px;\">페이지: <span class=\"pageNo\"></span></td>");
sb.append(" </tr>");
sb.append(" </tbody> ");
sb.append(" </table>");
sb.append(" </td>");
sb.append(" </tr>");
sb.append(" </thead>");
sb.append("");
sb.append("");
sb.append(" <!-- 페이지 content 부분 -->");
sb.append(" <tbody>");
sb.append(" <tr>");
sb.append(" <td>");
sb.append(" <table class=\"table_area\">");
sb.append(" <tr>");
sb.append(" <td>");
sb.append(" <p class=\"t_tit\">인적사항</p>");
sb.append(" <table summary=\"\" class=\"board_table01 bd_05 pad3 marbt30 w100\">");
sb.append(" <colgroup>");
sb.append(" <col width=\"12%\" />");
sb.append(" <col width=\"15%\" />");
sb.append(" <col width=\"10%\" />");
sb.append(" <col width=\"12%\" />");
sb.append(" <col width=\"13%\" />");
sb.append(" <col width=\"38%\" />");
sb.append(" ");
sb.append(" </colgroup>");
sb.append(" <tbody>");
sb.append(" <tr class=\"tit11\">");
sb.append(" <th class=\"center bggray\">사업자번호</th>");
sb.append(" <td class=\"center\">214-81-59394</td>");
sb.append(" <th class=\"center bggray pdtb_none\">종사업장<br />번호</th>");
sb.append(" <td> </td>");
sb.append(" <th class=\"center bggray\">상호(법인명)</th>");
sb.append(" <td>기웅정보통신(주)</td>");
sb.append(" </tr>");
sb.append(" <tr class=\"tit11\">");
sb.append(" <th class=\"center bggray\">성명(대표자)</th>");
sb.append(" <td colspan=\"3\">최병인</td>");
sb.append(" <th class=\"center bggray\">사업장소재지</th>");
sb.append(" <td class=\"pdtb_none\">서울특별시 금천구 가산디지털2로 98(가산동,롯데IT캐슬 제6층613호~615호)</td>");
sb.append(" </tr>");
sb.append(" <tr class=\"tit11\">");
sb.append(" <th class=\"center bggray\">거래기간</th>");
sb.append(" <td colspan=\"5\">2019-01-23 ~ 2019-01-29</td>");
sb.append(" </tr>");
sb.append(" </tbody>");
sb.append(" </table>");
sb.append(" ");
sb.append(" <p class=\"t_tit\">매출 전자세금계산서 총합계</p>");
sb.append(" <table summary=\"\" class=\"board_table01 bd_05 pad3 marbt30 w100\">");
sb.append(" <colgroup>");
sb.append(" <col width=\"16.6%\" />");
sb.append(" <col width=\"16.6%\" />");
sb.append(" <col width=\"16.6%\" />");
sb.append(" <col width=\"16.6%\" />");
sb.append(" <col width=\"16.6%\" />");
sb.append(" <col width=\"16.6%\" />");
sb.append(" </colgroup>");
sb.append(" <tbody>");
sb.append(" <tr class=\"tit11\">");
sb.append(" <th class=\"center bggray\">구분</th>");
sb.append(" <th class=\"center bggray\">매출처수</th>");
sb.append(" <th class=\"center bggray\">매수</th>");
sb.append(" <th class=\"center bggray\">공급가액</th>");
sb.append(" <th class=\"center bggray\">세액</th>");
sb.append(" <th class=\"center bggray\">합계금액</th>");
sb.append(" </tr>");
sb.append(" <tr class=\"tit11\">");
sb.append(" <th class=\"center bggray\">합계</th>");
sb.append(" <td class=\"right\">78</td>");
sb.append(" <td class=\"right\">84</td>");
sb.append(" <td class=\"right\">37,167,101</td>");
sb.append(" <td class=\"right\">3,716,809</td>");
sb.append(" <td class=\"right\">40,884,910</td>");
sb.append(" </tr>");
sb.append(" <tr class=\"tit11\">");
sb.append(" <th class=\"center bggray pdtb_none\">사업자등록번호<br />발급분</th>");
sb.append(" <td class=\"right\">78</td>");
sb.append(" <td class=\"right\">84</td>");
sb.append(" <td class=\"right\">37,167,101</td>");
sb.append(" <td class=\"right\">3,716,809</td>");
sb.append(" <td class=\"right\">40,884,910</td>");
sb.append(" </tr>");
sb.append(" <tr class=\"tit11\">");
sb.append(" <th class=\"center bggray pdtb_none\">주민등록번호<br />발급분</th>");
sb.append(" <td class=\"right\">0</td>");
sb.append(" <td class=\"right\">0</td>");
sb.append(" <td class=\"right\">0</td>");
sb.append(" <td class=\"right\">0</td>");
sb.append(" <td class=\"right\">0</td>");
sb.append(" </tr>");
sb.append(" </tbody>");
sb.append(" </table>");
sb.append(" ");
sb.append(" <table summary=\"\" class=\"board_table01 bd_05 pad3\" style=\"width:100%\">");
sb.append(" <colgroup>");
sb.append(" <col width=\"5%\" />");
sb.append(" <col width=\"17%\" />");
sb.append(" <col width=\"16%\" />");
sb.append(" <col width=\"10%\" />");
sb.append(" <col width=\"17%\" />");
sb.append(" <col width=\"17%\" />");
sb.append(" <col width=\"17%\" />");
sb.append(" </colgroup>");
sb.append(" <thead>");
sb.append(" <tr class=\"tit11\">");
sb.append(" <th class=\"center bggray\">번호</th>");
sb.append(" <th class=\"center bggray pdtb_none\">공급받는자<br />등록번호</th>");
sb.append(" <th class=\"center bggray\">상호(법인명)</th>");
sb.append(" <th class=\"center bggray\">매수</th>");
sb.append(" <th class=\"center bggray\">공급가액</th>");
sb.append(" <th class=\"center bggray\">세액</th>");
sb.append(" <th class=\"center bggray\">합계금액</th>");
sb.append(" </tr>");
sb.append(" </thead>");
sb.append(" <tbody>");
for (int i = 0; i < 30; i++) {
sb.append(" <tr class=\"tit11\" name=\"tr_arr\">");
sb.append(" <td class=\"center\">"+(i+1)+"</td>");
sb.append(" <td class=\"center\">208-81-06344</td>");
sb.append(" <td>(주)웅진</td>");
sb.append(" <td class=\"right\">1</td>");
sb.append(" <td class=\"right\">70,000</td>");
sb.append(" <td class=\"right\">7,000</td>");
sb.append(" <td class=\"right\">77,000</td>");
sb.append(" </tr>");
}
sb.append(" </tbody>");
sb.append(" </table>");
sb.append(" ");
sb.append(" </td>");
sb.append(" </tr>");
sb.append(" </table><!--//table_area-->");
sb.append(" </td>");
sb.append(" </tr>");
sb.append(" </tbody>");
sb.append("");
sb.append(" <!-- 테이블의 footer 부분 -->");
sb.append(" ");
sb.append(" <tfoot>");
sb.append(" <tr>");
sb.append(" <td>");
sb.append(" <p style=\"text-align:right; width:695px;\">페이지 계속</p>");
sb.append(" <!--<p style=\"text-align:right; width:695px;padding-top:15px;\">페이지 계속</p>-->");
sb.append(" </td>");
sb.append(" </tr>");
sb.append(" </tfoot>");
sb.append(" ");
sb.append(" </table>");
sb.append("</body>");
sb.append("</html>");
;
JHTMLParser parser = new JHTMLParser(sb.toString());
List<Element> trs = parser.getTRList(5);
for (int i = 0; i < trs.size(); i++) {
Element tr = trs.get(i);
List<Element> tds = tr.getChildElements();
for (int j = 0; j < tds.size(); j++) {
System.out.println(tds.get(j).getContent());
}
}
}
}
| [
"[email protected]"
]
| |
8a9a343366738795978e8bdc3567f3615cf891e4 | e95e61a2e497aa7316287ac3f481bb7723f83ccd | /app/src/main/java/com/example/user/pfinder/MainActivity.java | 3655335acd79a6750584c9b217bd7c59462286da | []
| no_license | DmytroCh/PFinder | aaf01fd154f373dff5a485f204d95e5f60c3ad1c | d9994b672393e25fc1793d7edc79db3eb8227eaa | refs/heads/master | 2020-03-14T18:23:23.832341 | 2018-05-01T17:09:56 | 2018-05-01T17:09:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,286 | java | package com.example.user.pfinder;
import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.example.user.pfinder.Accelerometer.FallDetection;
import com.example.user.pfinder.Location.MyLocation;
import com.google.android.gms.common.api.GoogleApiClient;
public class MainActivity extends AppCompatActivity{
private TextView latitudeTextView,longitudeTextView, square;
private final static int REQUEST_CHECK_SETTINGS_GPS=0x1;
private MyLocation myLocation;
FallDetection fallDetection;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
declareVariables();
}
private void declareVariables(){
latitudeTextView=(TextView)findViewById(R.id.latitudeTextView);
longitudeTextView=(TextView)findViewById(R.id.longitudeTextView);
square=(TextView)findViewById(R.id.square);
myLocation = new MyLocation(this, latitudeTextView, longitudeTextView);
myLocation.setUpGClient();
fallDetection = new FallDetection(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_CHECK_SETTINGS_GPS:
switch (resultCode) {
case Activity.RESULT_OK:
myLocation.getMyLocation();
break;
case Activity.RESULT_CANCELED:
finish();
break;
}
break;
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
int permissionLocation = ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.ACCESS_FINE_LOCATION);
if (permissionLocation == PackageManager.PERMISSION_GRANTED) {
myLocation.getMyLocation();
}
}
}
| [
"[email protected]"
]
| |
c8e5566564197ba5270ec76dd2b8887c875dbcef | 2d036db658f276cf33c4e9bf6fd06d87321d6e35 | /P4/AddressBook/src/addressbook/view/UserInterface.java | 009254f55012db882b868903b38b939df820064e | [
"MIT"
]
| permissive | didi28108/Object-Oriented-Software-Engineering-1 | 0c082be30ab5132a1ad98005a0b04146583af915 | 042802b6b3eb555af2e208861c10cc1f10f7ae4b | refs/heads/master | 2021-04-17T16:57:09.352618 | 2017-10-12T13:33:44 | 2017-10-12T13:33:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,054 | java | package addressbook.view;
import java.io.*;
import java.util.*;
import addressbook.model.*;
public class UserInterface{
private List<Option> optionList;
public UserInterface(){
optionList = new ArrayList<Option>();
}
public static void printToConsole(String message){
System.out.println(message);
}
public void addOption(int label, Option op){
optionList.add(label, op);
}
public void showMenu(AddressBook addressBook)
{
Scanner input = new Scanner(System.in);
boolean done = false;
while(!done)
{
try
{
System.out.print("Enter a Number (enter '-1' to exit): ");
int option = input.nextLine();
System.out.print("Enter Search Term: ");
String term = input.nextLine();
if(option == -1)
System.exit(0);
optionList.get(option).doOption(term, addressBook);
}
catch(NumberFormatException nfe)
{
// The user entered something non-numerical.
System.out.println("Enter a number");
}
}
}
}
| [
"[email protected]"
]
| |
2f847432465879ef3327aed2efb8bb8e9c24aa08 | fbf7a3980d284f0afa8c3ccb72d0ed40c015579d | /topic1consumer/src/main/java/com/consumertopic/kafka/springbootkafkaconsumer/config/KafkaConfiguration.java | f829216f430903bba4c998be1ac5c60f84debb0e | []
| no_license | devyassinepro/Intergiciel-Kafka | 2d2ec768a04fee24ce4f45d201917752180826db | bf1e9286a4b86a913643cb0e8c61a429eea1634e | refs/heads/main | 2023-02-13T21:16:24.859029 | 2021-01-09T10:32:46 | 2021-01-09T10:32:46 | 328,128,526 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,613 | java | package com.consumertopic.kafka.springbootkafkaconsumer.config;
import com.consumertopic.kafka.springbootkafkaconsumer.model.Countries;
import com.consumertopic.kafka.springbootkafkaconsumer.model.Globale;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
import org.springframework.kafka.support.serializer.JsonDeserializer;
import java.util.HashMap;
import java.util.Map;
@EnableKafka
@Configuration
public class KafkaConfiguration {
@Bean
public ConsumerFactory<String, String> consumerFactory() {
Map<String, Object> config = new HashMap<>();
config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "127.0.0.1:9092");
config.put(ConsumerConfig.GROUP_ID_CONFIG, "group_id");
config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
return new DefaultKafkaConsumerFactory<>(config);
}
@Bean
public ConcurrentKafkaListenerContainerFactory<String, String> kafkaListenerContainerFactory() {
ConcurrentKafkaListenerContainerFactory<String, String> factory = new ConcurrentKafkaListenerContainerFactory();
factory.setConsumerFactory(consumerFactory());
return factory;
}
@Bean
public ConsumerFactory<String, Countries> countryConsumerFactory() {
Map<String, Object> config = new HashMap<>();
config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "127.0.0.1:9092");
config.put(ConsumerConfig.GROUP_ID_CONFIG, "group_json");
config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
return new DefaultKafkaConsumerFactory<>(config, new StringDeserializer(),
new JsonDeserializer<>(Countries.class));
}
@Bean
public ConcurrentKafkaListenerContainerFactory<String, Countries> userKafkaListenerFactory() {
ConcurrentKafkaListenerContainerFactory<String, Countries> factory = new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(countryConsumerFactory());
return factory;
}
@Bean
public ConsumerFactory<String, Globale> globalConsumerFactory() {
Map<String, Object> config = new HashMap<>();
config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "127.0.0.1:9092");
config.put(ConsumerConfig.GROUP_ID_CONFIG, "group_json1");
config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
return new DefaultKafkaConsumerFactory<>(config, new StringDeserializer(),
new JsonDeserializer<>(Globale.class));
}
@Bean
public ConcurrentKafkaListenerContainerFactory<String, Globale> globalKafkaListenerFactory() {
ConcurrentKafkaListenerContainerFactory<String, Globale> factory = new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(globalConsumerFactory());
return factory;
}
}
| [
"[email protected]"
]
| |
60d231f396643b6149e89187edfb7caa6eed78b1 | ed15cde7cf5b0c578b63b7fb036d39ba78ee63ab | /src/com/depdropdowntag/tags/SessionTag.java | a3d4510b6a95846c4379e0d5fd974ec460241816 | []
| no_license | yogesh4982/DependentDropDownsTag | f1ca8aeaae078e04c5cdfe44d3e91d2a695bb8d0 | c36145dccf4f6a0fe1796ba8f5f0b23b6a8dd796 | refs/heads/master | 2016-09-06T15:12:12.962969 | 2011-01-29T10:18:32 | 2011-01-29T10:18:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 785 | java | package com.depdropdowntag.tags;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;
public class SessionTag extends SimpleTagSupport {
private String name;
private String var;
@Override
public void doTag() throws JspException, IOException {
// TODO Auto-generated method stub
super.doTag();
getJspContext().setAttribute(var, ((PageContext)getJspContext()).getRequest().getAttribute(getName()));
getJspBody().invoke(null);
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setVar(String var) {
this.var = var.toString();
}
public String getVar() {
return var;
}
}
| [
"[email protected]"
]
| |
6c84ff0e34c4720c19e6eb8586ba658aaf61827c | 5c159eca5f0f6f434b7c2ebb65a9e821a7fbff11 | /JaxwsClient/src/bullhorn/ApiFindResult.java | d6748d39620e321ceabfc4452586fabecd44aa21 | []
| no_license | venualokam/alokam | bfc1c1a327de6ff58dbff00b97abf69650042ee2 | d91db6d7e7fa62a435fb59d68ed90ebe81f2bf99 | refs/heads/master | 2016-09-06T18:34:38.622338 | 2015-01-12T11:51:28 | 2015-01-12T11:51:28 | 5,438,896 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,402 | java |
package bullhorn;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for apiFindResult complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="apiFindResult">
* <complexContent>
* <extension base="{http://result.apiservice.bullhorn.com/}apiResult">
* <sequence>
* <element name="dto" type="{http://entity.bullhorn.com/}abstractDto" minOccurs="0"/>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "apiFindResult", namespace = "http://result.apiservice.bullhorn.com/", propOrder = {
"dto"
})
public class ApiFindResult
extends ApiResult
{
protected AbstractDto dto;
/**
* Gets the value of the dto property.
*
* @return
* possible object is
* {@link AbstractDto }
*
*/
public AbstractDto getDto() {
return dto;
}
/**
* Sets the value of the dto property.
*
* @param value
* allowed object is
* {@link AbstractDto }
*
*/
public void setDto(AbstractDto value) {
this.dto = value;
}
}
| [
"[email protected]"
]
| |
f0c04404214af2dfeb43648d249ca4c43e74043b | 5d40a6bf9b255bc90230a07b82f3a16d08bca26e | /core/src/com/mygdx/game/MyGdxGame.java | 3072fc2612e2f256bd181302a2df98ff7ecf2a70 | []
| no_license | andesal/libGDX_example | b874c38a93d77f496da43b59112a4a92f98a7190 | f05b6fb24b336bb6dcb4faa8a1bf45985087dd0a | refs/heads/master | 2021-09-05T01:48:12.821687 | 2018-01-23T15:18:33 | 2018-01-23T15:18:33 | 118,627,744 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 969 | java | package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.mygdx.game.states.GameStateManager;
import com.mygdx.game.states.MenuState;
public class MyGdxGame extends ApplicationAdapter {
public final static int WIDTH = 480;
public final static int HEIGHT = 800;
public final static String TITLE = "Flappy Bird";
private GameStateManager gsm;
private SpriteBatch batch;
Texture img;
@Override
public void create () {
batch = new SpriteBatch();
gsm = new GameStateManager();
Gdx.gl.glClearColor(1, 0, 0, 1);
gsm.push(new MenuState(gsm));
}
@Override
public void render () {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
gsm.update(Gdx.graphics.getDeltaTime());
gsm.render(batch);
}
@Override
public void dispose () {
batch.dispose();
img.dispose();
}
}
| [
"[email protected]"
]
| |
d3b45f5e2d1678d3ce78e2686e970b13ce5dafd2 | 8fab2b5e4663350ec3231cb5840c730def9ecc81 | /simulator/src/allow/simulator/world/layer/SafetyLayer.java | 5d5b4e322f38921af48e72951cdbcf5c69df3491 | []
| no_license | poxrucker/adaptation | 2dfae0eaed4ffd86ae3e72b9505cd15fb4d45237 | 619fcae913eb1986bfd658cf9f1d4d0bfe755b7d | refs/heads/master | 2021-01-21T13:30:06.704920 | 2016-05-25T07:18:04 | 2016-05-25T07:18:04 | 55,673,292 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 286 | java | package allow.simulator.world.layer;
import allow.simulator.world.StreetMap;
public class SafetyLayer extends Layer {
public SafetyLayer(Type type, StreetMap base) {
super(type, base);
}
@Override
public void addArea(Area area) {
// TODO Auto-generated method stub
}
}
| [
"[email protected]"
]
| |
1a051d5f5d4f9dc174d8344160ce46dd9a0abe4f | 29152e1c9e8c2b32240ae66aec0c063574a3667d | /visualizationAlgorithm/src/main/java/com/_9/fractal/tree/FractalData.java | bb9eb5fb67ebcc2e720b0fc938eed88ec1e15586 | []
| no_license | liljaewayne/DataStructuresAndAlgorithms | 8cf8cdf3600b751a8b3103b846997d8a4ea17dba | 593a40f91e93de99e893f84ed55bba41fefa2eea | refs/heads/master | 2021-07-07T12:58:46.773659 | 2018-02-26T13:32:21 | 2018-02-26T13:32:21 | 96,667,792 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 240 | java | package com._9.fractal.tree;
public class FractalData {
public int depth;
public double splitAngle;
public FractalData(int depth, double splitAngle) {
this.depth = depth;
this.splitAngle = splitAngle;
}
}
| [
"[email protected]"
]
| |
b84683a0cbe01f5bc47958c977cd6e84d20d7366 | 6e9aa5fba0e68d143eb130a4f90146082109aa3c | /src/main/java/sort/Sort.java | 38b93dea4328234e66e25692a59a4c16048ceca1 | []
| no_license | qlong8807/MyJavaTest | 7d1a51e2369c7cd0f033d6b582f21e94198e81a0 | 466fcb1f1ae0007b8c68ddf0e0754f1439bb78d7 | refs/heads/master | 2022-12-17T09:30:18.013441 | 2020-02-27T01:39:35 | 2020-02-27T01:39:35 | 35,074,091 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,182 | java | package sort;
import java.util.Random;
public abstract class Sort {
private int count;
protected int[] sort(int[] array) {
return null;
};
/**
* 互换位置的方法
*
* @param array
* 要换位置的目标数组
* @param i
* 数组位置1
* @param j
* 数组位置2
* @return 换好位置以后的数组
*/
protected int[] swap(int[] array, int i, int j) {
int t = array[i];
array[i] = array[j];
array[j] = t;
count++;
return array;
}
protected void show(int[] array) {
for (int a : array) {
System.out.print(a+",");
}
System.out.println();
System.out.println("数组长度:" + array.length + ",执行交换次数:" + count);
}
public int[] getIntArrayRandom(int len, int max) {
int[] arr = new int[len];
Random r = new Random();
for (int i = 0; i < arr.length; i++) {
arr[i] = r.nextInt(max);
}
return arr;
}
/**
* 取得数组的最大值
*
* @param arr
* @return
*/
protected int max(int[] arr) {
int max = 0;
for (int a : arr) {
if (a > max)
max = a;
}
return max;
}
} | [
"[email protected]"
]
| |
6579faa64a3e80c71d81860df9466a44b7d7c451 | f883007c83cd5cf722119719872e991bd348de44 | /src/main/java/terminal/TerminalTest.java | 531a33b984c6a4c7269b0c3aa05c27a55e45350e | []
| no_license | QSYdev/terminal | d5912f1147f74525affe2cc4a0f7bbeaa56ddd51 | 577e07aa997f04139b906e4df5d6239b208b8c11 | refs/heads/master | 2020-03-18T10:31:50.850978 | 2018-06-20T23:50:28 | 2018-06-20T23:50:28 | 134,617,780 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,294 | java | package terminal;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Scanner;
import terminal.Color;
import terminal.Event.ExternalEvent;
import terminal.Event.ExternalEvent.ConnectedNode;
import terminal.Event.ExternalEvent.DisconnectedNode;
import terminal.Event.ExternalEvent.ExecutionFinished;
import terminal.Event.ExternalEvent.ExecutionInterrupted;
import terminal.Event.ExternalEvent.ExecutionStarted;
import terminal.Event.ExternalEvent.ExternalEventVisitor;
import terminal.Event.ExternalEvent.StepTimeOut;
import terminal.Event.ExternalEvent.Touche;
import terminal.QSYPacket.CommandArgs;
public final class TerminalTest {
private static Terminal terminal;
private static Routine routine;
static {
// ArrayList<Step> steps = new ArrayList<>(2);
// {
// LinkedList<NodeConfiguration> nodeConfigurationList = new LinkedList<>();
// nodeConfigurationList.add(new NodeConfiguration(0, 500, Color.RED));
// nodeConfigurationList.add(new NodeConfiguration(1, 500, Color.GREEN));
// steps.add(new Step(nodeConfigurationList, 0, "0|1", false));
// }
// {
// LinkedList<NodeConfiguration> nodeConfigurationList = new LinkedList<>();
// nodeConfigurationList.add(new NodeConfiguration(0, 500, Color.YELLOW));
// nodeConfigurationList.add(new NodeConfiguration(1, 500, Color.BLUE));
// steps.add(new Step(nodeConfigurationList, 0, "0&1", false));
// }
// routine = new Routine(2, 2, 0, steps, "Prueba");
// try {
// routine = RoutineManager.loadRoutine("src/resources/routine1.json");
// RoutineManager.validateRoutine(routine);
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }
}
public static void main(String[] args) throws Exception {
StressTask streesTask = null;
final EventTask task = new EventTask();
final Thread thread = new Thread(task, "Task");
thread.start();
terminal = new Terminal("10.0.0.2");
terminal.addListener(task);
Scanner scanner = new Scanner(System.in);
char command = 0;
do {
try {
command = scanner.next().charAt(0);
switch (command) {
case 's':
terminal.start();
break;
case 'n':
terminal.searchNodes();
break;
case 'e':
if (streesTask == null)
streesTask = new StressTask();
break;
case 'f':
terminal.finalizeNodesSearching();
break;
case 'c':
System.out.println(terminal.getConnectedNodes());
break;
case 'r':
terminal.startCustomRoutine(routine);
break;
case 'y':
terminal.stopRoutine();
break;
case 'p':
ArrayList<Color> playersAndColors = new ArrayList<>();
playersAndColors.add(Color.RED);
playersAndColors.add(Color.GREEN);
playersAndColors.add(Color.BLUE);
terminal.startPlayerExecution(3, playersAndColors, false, 500, 1000, true, 10, 0);
break;
case 'b':
terminal.sendCommand(new CommandArgs(19, Color.RED, 500, 1));
break;
}
} catch (Exception e) {
e.printStackTrace();
}
} while (command != 'q');
if (streesTask != null)
streesTask.close();
scanner.close();
terminal.close();
thread.interrupt();
thread.join();
}
private static final class EventTask extends EventListener<ExternalEvent> implements Runnable, ExternalEventVisitor {
private volatile boolean running;
public EventTask() {
this.running = true;
}
@Override
public void run() {
while (running) {
try {
ExternalEvent event = getEvent();
event.accept(this);
} catch (final InterruptedException e) {
running = false;
}
}
}
@Override
public void visit(ConnectedNode event) {
System.out.println("Se ha conectado el nodo " + event.getPhysicalId());
}
@Override
public void visit(DisconnectedNode event) {
System.err.println("Se ha desconectado el nodo " + event.getPhysicalId());
}
@Override
public void visit(Touche event) {
System.out.println("Se ha tocado el nodo " + event.getToucheArgs().getPhysicalId());
}
@Override
public void visit(ExecutionStarted event) {
System.out.println("Rutina Iniciada");
}
@Override
public void visit(ExecutionFinished event) {
System.out.println("Rutina terminada");
}
@Override
public void visit(StepTimeOut event) {
System.out.println("Step Time Out");
}
@Override
public void visit(ExecutionInterrupted event) {
System.out.println(event.getReason());
}
}
private static final class StressTask implements Runnable, AutoCloseable {
private boolean running;
private final Thread thread;
public StressTask() {
this.running = true;
this.thread = new Thread(this, "Stress Task");
thread.start();
}
@Override
public void run() {
while (running) {
try {
Thread.sleep(1000);
for (int i = 1; i <= terminal.getConnectedNodes(); i++) {
terminal.sendCommand(new CommandArgs(17 + i, Color.CYAN, 500, 3));
}
} catch (InterruptedException e) {
running = false;
}
}
}
@Override
public void close() {
thread.interrupt();
try {
thread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
| [
"[email protected]"
]
| |
cee6da2cc9ccc16a964410bb74a199e9876b5196 | ec1890a3de9f38810119dfef55be71ce5aac46bc | /app/src/main/java/com/example/laptop/satisficationtest/MainActivity.java | 1a0412be543c3c987fa7f0402d58eb266c5d7bde | []
| no_license | chelbikhalil/Satisfaction-Client | 697ec76629f824c91f428eb077839cdfc5b2640e | 682fcc497d38a48b50065fa3b818013779e1b62b | refs/heads/master | 2021-09-18T06:25:32.816640 | 2018-07-10T15:36:40 | 2018-07-10T15:36:40 | 122,963,851 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 771 | java | package com.example.laptop.satisficationtest;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
private static int SPLASH_TIME_OUT = 4000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_main );
new Handler( ).postDelayed( new Runnable() {
@Override
public void run() {
Intent homeIntent = new Intent(MainActivity.this, TestActivity.class);
startActivity( homeIntent );
finish();
}
} , SPLASH_TIME_OUT);
}
}
| [
"[email protected]"
]
| |
03afb110509b875199fdbc77ffda77992b64e0ba | 85f5f023d21da39729c7d1baed9baf3ae2e80e8e | /InsertBiodata/src/insertbiodata/InsertBiodata.java | 9bb4d59b95376d2e6e8829211643b6bcfae172bb | []
| no_license | Schiffer1945/modul10_pbo | 23b84c6c64abd3ce54e7994fa83dbd54f355bcb0 | 995dd7e4e2688685b3008363338c644dea634bdd | refs/heads/master | 2021-01-19T12:21:30.730778 | 2017-03-09T14:46:53 | 2017-03-09T14:46:53 | 84,449,057 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 452 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package insertbiodata;
/**
*
* @author Fariz
*/
public class InsertBiodata {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
}
| [
"[email protected]"
]
| |
57f316cf5875257cc9d430948ca629849f1a1cb1 | 5c9d730c445a7dd43338df6c13ac6d984683f49a | /src/examen/Test.java | 5f8a7999b6adeef7f9d0d2ca42893a84da37e1a5 | []
| no_license | Christophe16522/ResourceHumaine | ffcc3ffb9daf88b75283589f2e95f6abd0ea20fb | 5ebc451a4ccc942677bf75901e5a4b6c80cc2d11 | refs/heads/master | 2021-01-11T18:04:57.110464 | 2017-01-19T19:23:54 | 2017-01-19T19:23:54 | 79,486,311 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,528 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package examen;
import java.text.ParseException;
/**
*
* @author Lai.C
*/
public class Test {
public static void main(String[] args) throws ParseException {
//System.out.println(FonctionDate.isValidDate("2017-01-01"));
//System.out.println(FonctionDate.isValidTime(FonctionDate.minToHour(120).toString()));
//System.out.println(FonctionDate.retToHentre(1,60,"08:00"));
//System.out.println(Retard.getRetard("08:02:00","08:20:00"));
// Scanner input = new Scanner(System.in);
// int minute;
// System.out.print("Enter the minutes to convert:");
// minute =input.nextInt();
// int h = minute/60;
// int m = minute%60;
// System.out.println(h+"heure"+" "+m+"minute");
//System.out.println(FonctionDate.minToHour(175));
// SimpleDateFormat df = new SimpleDateFormat("HH:mm");
// Date newTime = df.parse("02:02");
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(newTime);
// calendar.add(Calendar.HOUR, 23);
// calendar.add(Calendar.MINUTE, 30);
// newTime = calendar.getTime();
//
// System.out.println(newTime.getHours()+":"+newTime.getMinutes());
//Date heure1 = ;
// Date h2 = heure + heure1;
};
}
| [
"Lai.C@AlienwareX51R2"
]
| Lai.C@AlienwareX51R2 |
6b145ad8a1be17b6a2a967e9d3756af68d028769 | 02efbb6546ccd71e885e7c3fc5da1688daaeb4e2 | /BMMS/src/dou/webServlet/DelSupplierServlet.java | 0e084c55f5c02a9a28ddb3f6c838f8997d6de13c | []
| no_license | Free-Dou/BMMS | 23eaf1ecec5855ef17af597055e5c242afe772e0 | 3eb36591721447dc30cb11023efa3ff42c6adbd5 | refs/heads/master | 2020-03-28T07:03:34.629029 | 2016-05-22T14:14:50 | 2016-05-22T14:14:50 | 53,335,794 | 1 | 1 | null | 2016-05-22T14:14:50 | 2016-03-07T15:24:51 | JavaScript | UTF-8 | Java | false | false | 1,124 | java | package dou.webServlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import dou.config.Config;
import dou.metaObject.Supplier;
public class DelSupplierServlet extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
this.doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Logger logger = Config.getLogger(this.getClass());
req.setCharacterEncoding("utf-8");
String sKeyName = req.getParameter("del_supplier_name");
if (("" != sKeyName) && (null != sKeyName)){
logger.info("[DelSupplierServlet.java:doPost] Supplier: " + sKeyName);
Supplier.delSupplierFromDB(sKeyName);
} else {
logger.info("[DelSupplierServlet.java:doPost] Supplier name is null or \"\" !!! Name : " + sKeyName);
}
}
}
| [
"[email protected]"
]
| |
93edd309069560f5e749cc16467e67cf9689f470 | 1684f2ca7328cbb42389156232c6a9437594b832 | /web/org/ace/accounting/web/report/TrialBalanceDetailActionBean.java | 08f923fb0bfe285e64e87432026116fed2f67703 | []
| no_license | LifeTeam-TAT/GGITM-General-Account | c11e1acf0d83f97672838dd8c6b29ed5aea9ede3 | 84aa97947bf60d491cca6a7770f97d3655e77431 | refs/heads/master | 2023-03-29T11:05:23.883529 | 2021-04-06T02:22:44 | 2021-04-06T02:22:44 | 355,030,072 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,815 | java | package org.ace.accounting.web.report;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.ace.accounting.common.CurrencyType;
import org.ace.accounting.common.MonthNames;
import org.ace.accounting.common.PropertiesManager;
import org.ace.accounting.common.utils.DateUtils;
import org.ace.accounting.common.validation.MessageId;
import org.ace.accounting.dto.TrialBalanceCriteriaDto;
import org.ace.accounting.dto.TrialBalanceReportDto;
import org.ace.accounting.process.interfaces.IUserProcessService;
import org.ace.accounting.report.TrialBalanceAccountType;
import org.ace.accounting.report.trialBalanceDetail.service.interfaces.ITrialBalanceDetailService;
import org.ace.accounting.system.branch.Branch;
import org.ace.accounting.system.branch.service.interfaces.IBranchService;
import org.ace.accounting.system.currency.Currency;
import org.ace.accounting.system.currency.service.interfaces.ICurrencyService;
import org.ace.accounting.system.systempost.SystemPost;
import org.ace.accounting.system.systempost.service.interfaces.ISystemPostService;
import org.ace.java.web.common.BaseBean;
import org.apache.commons.io.FileUtils;
import org.primefaces.PrimeFaces;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.export.SimpleExporterInput;
import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
import net.sf.jasperreports.export.SimpleXlsReportConfiguration;
@ManagedBean(name = "TrialBalanceDetailActionBean")
@ViewScoped
public class TrialBalanceDetailActionBean extends BaseBean {
private TrialBalanceCriteriaDto trialBalanceCriteriaDto;
private List<TrialBalanceReportDto> reportResultList;
private List<Currency> currencyList;
private List<Branch> branchList;
private EnumSet<MonthNames> monthSet;
private List<Integer> yearList;
private boolean isBranchDiabled = true;
@ManagedProperty(value = "#{PropertiesManager}")
private PropertiesManager propertiesManager;
private Date postingDate;
public void setPropertiesManager(PropertiesManager propertiesManager) {
this.propertiesManager = propertiesManager;
}
@ManagedProperty(value = "#{TrialBalanceDetailService}")
private ITrialBalanceDetailService trialBalanceService;
public void setTrialBalanceService(ITrialBalanceDetailService trialBalanceService) {
this.trialBalanceService = trialBalanceService;
}
@ManagedProperty(value = "#{UserProcessService}")
private IUserProcessService userProcessService;
public void setUserProcessService(IUserProcessService userProcessService) {
this.userProcessService = userProcessService;
}
@ManagedProperty(value = "#{CurrencyService}")
private ICurrencyService currencyService;
public void setCurrencyService(ICurrencyService currencyService) {
this.currencyService = currencyService;
}
@ManagedProperty(value = "#{BranchService}")
private IBranchService branchService;
public void setBranchService(IBranchService branchService) {
this.branchService = branchService;
}
@ManagedProperty(value = "#{SystemPostService}")
private ISystemPostService sysService;
public void setSysService(ISystemPostService sysService) {
this.sysService = sysService;
}
@PostConstruct
public void init() {
monthSet = EnumSet.allOf(MonthNames.class);
yearList = DateUtils.getActiveYears();
createNewTrialBalance();
SystemPost sysPost = sysService.findbyPostingName("TRIALPOST");
postingDate = sysPost.getPostingDate();
reportResultList = new ArrayList<>();
}
public void createNewTrialBalance() {
branchList = branchService.findAllBranch();
currencyList = currencyService.findAllCurrency();
trialBalanceCriteriaDto = new TrialBalanceCriteriaDto();
if (userProcessService.getLoginUser().isAdmin()) {
trialBalanceCriteriaDto.setBranch(null);
isBranchDiabled = false;
} else {
trialBalanceCriteriaDto.setBranch(userProcessService.getLoginUser().getBranch());
isBranchDiabled = true;
}
trialBalanceCriteriaDto.setCurrencyType(CurrencyType.HOMECURRENCY);
trialBalanceCriteriaDto.setAccountType(TrialBalanceAccountType.Gl_ACODE);
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
trialBalanceCriteriaDto.setRequiredMonth(cal.get(Calendar.MONTH));
trialBalanceCriteriaDto.setRequiredYear(cal.get(Calendar.YEAR));
}
public void previewReport() {
reportResultList.clear();
reportResultList = trialBalanceService.findTrialBalanceOldFormat(trialBalanceCriteriaDto);
if (reportResultList.size() == 0) {
addErrorMessage(null, MessageId.NO_RESULT);
} else
try {
reportResultList = reportResultList.stream().filter(dto ->dto.getDebit().compareTo(dto.getCredit()) !=0).collect(Collectors.toList());
if (generateReport(reportResultList)) {
PrimeFaces.current().executeScript("PF('TBPdfDialog').show();");
/*
* RequestContext context =
* RequestContext.getCurrentInstance();
* context.execute("PF('TBPdfDialog').show();");
*/
}
} catch (Exception e) {
handleException(e);
}
}
public boolean generateReport(List<TrialBalanceReportDto> reportResultList2) throws IOException, JRException {
try {
InputStream inputStream = null;
inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("trialBalanceReport.jrxml");
String image = FacesContext.getCurrentInstance().getExternalContext().getRealPath(propertiesManager.getProperties("LOGO"));
Map<String, Object> parameters = new HashMap<String, Object>();
String branch;
String currency;
if (trialBalanceCriteriaDto.getBranch() == null) {
branch = "All Branches";
} else {
branch = trialBalanceCriteriaDto.getBranch().getName();
}
if (trialBalanceCriteriaDto.getCurrency() == null) {
currency = "All Currencies";
} else {
currency = trialBalanceCriteriaDto.getCurrency().getCurrencyCode();
}
if (trialBalanceCriteriaDto.isHomeCurrencyConverted()) {
currency = currency + " By Home Currency Converted";
}
String month = null;
int monthVal = trialBalanceCriteriaDto.getRequiredMonth();
month = String.valueOf(MonthNames.values()[monthVal]);
parameters.put("logoPath", image);
parameters.put("reportDate", DateUtils.formatDateToString(new Date()));
parameters.put("reportTime", DateUtils.formatDateToStringTime(new Date()));
parameters.put("postingDate", DateUtils.formatDateToString(postingDate));
parameters.put("branch", branch);
parameters.put("currency", currency);
parameters.put("year", trialBalanceCriteriaDto.getRequiredYear());
parameters.put("month", month);
parameters.put("detailLabel", trialBalanceCriteriaDto.isGroup() ? "Group " : "Detail ");
JRBeanCollectionDataSource source = new JRBeanCollectionDataSource(reportResultList2);
parameters.put("datasource", source);
JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JREmptyDataSource());
String path = getWebRootPath() + dirPath;
FileUtils.forceMkdir(new File(path));
JasperExportManager.exportReportToPdfFile(jasperPrint, path + fileName.concat(".pdf"));
return true;
} catch (Exception e) {
e.printStackTrace();
addErrorMessage(null, MessageId.REPORT_ERROR);
return false;
}
}
public StreamedContent getDownload() {
reportResultList.clear();
reportResultList = trialBalanceService.findTrialBalanceOldFormat(trialBalanceCriteriaDto);
StreamedContent result = null;
if (reportResultList.size() == 0) {
addErrorMessage(null, MessageId.NO_RESULT);
} else {
result = getDownloadValue(reportResultList);
}
return result;
}
private StreamedContent getDownloadValue(List<TrialBalanceReportDto> reportResultList2) {
try {
List<JasperPrint> prints = new ArrayList<JasperPrint>();
InputStream inputStream = null;
inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("trialBalanceReport.jrxml");
String image = FacesContext.getCurrentInstance().getExternalContext().getRealPath(propertiesManager.getProperties("LOGO"));
Map<String, Object> parameters = new HashMap<String, Object>();
String branch;
String currency;
if (trialBalanceCriteriaDto.getBranch() == null) {
branch = "All Branches";
} else {
branch = trialBalanceCriteriaDto.getBranch().getName();
}
if (trialBalanceCriteriaDto.getCurrency() == null) {
currency = "All Currencies";
} else {
currency = trialBalanceCriteriaDto.getCurrency().getCurrencyCode();
}
if (trialBalanceCriteriaDto.isHomeCurrencyConverted()) {
currency = currency + " By Home Currency Converted";
}
String month = null;
int monthVal = trialBalanceCriteriaDto.getRequiredMonth();
month = String.valueOf(MonthNames.values()[monthVal]);
parameters.put("logoPath", image);
parameters.put("reportDate", DateUtils.formatDateToString(new Date()));
parameters.put("reportTime", DateUtils.formatDateToStringTime(new Date()));
parameters.put("postingDate", DateUtils.formatDateToString(postingDate));
parameters.put("branch", branch);
parameters.put("currency", currency);
parameters.put("year", trialBalanceCriteriaDto.getRequiredYear());
parameters.put("month", month);
parameters.put("detailLabel", trialBalanceCriteriaDto.isGroup() ? "Group " : "Detail ");
JRBeanCollectionDataSource source = new JRBeanCollectionDataSource(reportResultList2);
parameters.put("datasource", source);
JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JREmptyDataSource());
prints.add(jasperPrint);
FileUtils.forceMkdir(new File(dirPath));
File destFile = new File(dirPath + fileName.concat(".xls"));
JRXlsExporter exporter = new JRXlsExporter();
exporter.setExporterInput(SimpleExporterInput.getInstance(prints));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
// configuration.setOnePagePerSheet(true);
configuration.setDetectCellType(true);
configuration.setIgnoreCellBorder(false);
configuration.setAutoFitPageHeight(true);
configuration.setCollapseRowSpan(true);
configuration.setFontSizeFixEnabled(true);
configuration.setColumnWidthRatio(1F);
exporter.setConfiguration(configuration);
exporter.exportReport();
StreamedContent download = new DefaultStreamedContent();
File file = new File(dirPath + fileName.concat(".xls"));
InputStream input = new FileInputStream(file);
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
download = new DefaultStreamedContent(input, externalContext.getMimeType(file.getName()), file.getName());
return download;
} catch (Exception e) {
e.printStackTrace();
addErrorMessage(null, MessageId.REPORT_ERROR);
return null;
}
}
public TrialBalanceCriteriaDto getTrialBalanceDto() {
return trialBalanceCriteriaDto;
}
public List<Currency> getCurrencyList() {
return currencyList;
}
public List<Branch> getBranchList() {
return branchList;
}
public CurrencyType[] getCurrencyTypes() {
return CurrencyType.values();
}
public TrialBalanceAccountType[] getTrialBalanceAcodeTypes() {
return TrialBalanceAccountType.values();
}
public List<Integer> getYearList() {
return yearList;
}
public EnumSet<MonthNames> getMonthSet() {
return monthSet;
}
public boolean isBranchDiabled() {
return isBranchDiabled;
}
// path for jrxml template.
private String dirPath = "/pdf-report/" + "trialBalanceReport" + "/" + System.currentTimeMillis() + "/";
// pdf name.
private final String fileName = "Trial Balance Report";
public String getStream() {
String fileFullName = dirPath + fileName.concat(".pdf");
return fileFullName;
}
public TrialBalanceCriteriaDto getTrialBalanceCriteriaDto() {
return trialBalanceCriteriaDto;
}
public void setTrialBalanceCriteriaDto(TrialBalanceCriteriaDto trialBalanceCriteriaDto) {
this.trialBalanceCriteriaDto = trialBalanceCriteriaDto;
}
public List<TrialBalanceReportDto> getReportResultList() {
return reportResultList;
}
public void setReportResultList(List<TrialBalanceReportDto> reportResultList) {
this.reportResultList = reportResultList;
}
public Date getPostingDate() {
return postingDate;
}
public void setPostingDate(Date postingDate) {
this.postingDate = postingDate;
}
}
| [
"[email protected]"
]
| |
b7723c6be0079664f576cbcee8270bb8259b8031 | f44dd73aa30b4477038ed9904f8e43aaafe35dee | /src/test/java/cn/bd/test/DomainSourceGenerator.java | 896d2161ca1d05e2e0b5861dbf204098828d3821 | []
| no_license | iricpan/gitTest | 5b8de0eeb7ec622d19c65a7c28f6622bf9f7074e | 3d4f3faf3e3f16685ee73cbe7be5f6d4550bd02d | refs/heads/master | 2020-03-14T21:26:13.297731 | 2018-05-02T09:34:33 | 2018-05-02T09:34:33 | 131,796,064 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,881 | java | package cn.bd.test;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Properties;
import java.util.Scanner;
import org.junit.Test;
/**
author:taft
*/
public class DomainSourceGenerator {
private String domain;
private String domainID;
private String home;
private String basePackageName;
private String domainFirstLower;
private String domainAction;
private String domainService;
private String domainServiceImpl;
private String domainDao;
private static final String DAO = "Repository";
private static final String SERVICE = "Service";
private static final String ACTION = "Action";
private static final String SERVICEIMPL = "ServiceImpl";
// 构造方法,加载属性文件,查找路径
public DomainSourceGenerator() {
Properties prop = new Properties();
try {
InputStream inStream = this.getClass().getClassLoader().getResourceAsStream("sourceCodeGeneratorConfig.properties");
prop.load(inStream);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
Scanner scanner = new Scanner(System.in);
System.out.print("Please input your domainName and domainName ID Type.\r\n" +
"Example Area,String\r\n" +
"-->");
String inputValue = scanner.next().trim();
String [] arrays = inputValue.split(",");
domain = arrays[0];
domainID = arrays[1];
home = prop.getProperty("home");
basePackageName = prop.getProperty("basePackageName");
domainFirstLower = this.getFirstLower(domain);
domainAction = domain+"Action";
domainService = domain+"Service";
domainServiceImpl = domain+"ServiceImpl";
domainDao = domain+"Repository";
}
/**
* 生成所有的java文件(action类、service接口、service的实现类、dao接口)
* @throws Exception
*/
@Test
public void generateAll() throws Exception {
this.generateAction();
this.generateDao();
this.generateService();
this.generateServiceImpl();
}
/**
* 生成dao和dao impl文件
* @throws Exception
*/
@Test
public void generateDaoAndDaoImpl() throws Exception {
this.generateDao();
}
/**
* 生成service和service impl文件
* @throws Exception
*/
@Test
public void generateServiceAndServiceImpl() throws Exception {
this.generateService();
this.generateServiceImpl();
}
/**
* 生成action文件
* @throws Exception
*/
@Test
public void generateAction() throws Exception {
try {
PrintWriter writer = this.getWriter(ACTION);
writer.println("@ParentPackage(value=\"json-default\")");
writer.println("@Namespace(\"/\")");
writer.println("@Controller");
writer.println("@Scope(\"prototype\")");
writer.println("public class " + domainAction
+ " extends BaseAction<" + domain + "> {");
writer.println("");
writer.println("\t@Autowired");
writer.println("\tprivate " + domainService + " "
+ domainFirstLower + SERVICE + ";");
writer.println("}");
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 生成service文件
* @throws Exception
*/
@Test
public void generateService() throws Exception {
try {
PrintWriter writer = this.getWriter(SERVICE);
writer.println("public interface " + domainService + " {");
writer.println("");
writer.println("");
writer.println("}");
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 生成service impl文件
* @throws Exception
*/
@Test
public void generateServiceImpl() throws Exception {
try {
PrintWriter writer = this.getWriter(SERVICEIMPL);
writer.println("@Service");
writer.println("@Transactional");
writer.println("public class " + domainServiceImpl + " implements "
+ domainService + " {");
writer.println("");
writer.println("\t@Autowired");
writer.println("\tprivate " + domainDao + " "
+ domainFirstLower + DAO + ";");
writer.println("");
writer.println("}");
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 生成dao文件
* @throws Exception
*/
@Test
public void generateDao() throws Exception {
try {
PrintWriter writer = this.getWriter(DAO);
writer.println("public interface " + domainDao
+ " extends JpaRepository<" + domain + ","+domainID+">,JpaSpecificationExecutor<"+domain+"> {");
writer.println("");
writer.println("");
writer.println("}");
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
private String getFirstLower(String domain) {
char[] chars = domain.toCharArray();
chars[0] = Character.toLowerCase(chars[0]);
return String.valueOf(chars);
}
private PrintWriter getWriter(String generatorObejctName) throws IOException {
String packagePath = null;
String packageName = null;
String filename = null;
if(generatorObejctName.equals(ACTION)) {
packageName = basePackageName+".web.action";
filename = domainAction+".java";
} else if(generatorObejctName.equals(SERVICE)) {
packageName = basePackageName+".service";
filename = domainService+".java";
} else if(generatorObejctName.equals(SERVICEIMPL)) {
packageName = basePackageName+".service.impl";
filename = domainServiceImpl+".java";
} else if(generatorObejctName.equals(DAO)) {
packageName = basePackageName+".dao";
filename = domainDao+".java";
} else {
throw new RuntimeException("Invalid arguments " + generatorObejctName);
}
packagePath = packageName.replaceAll("\\.", "/");
String path = home+"/"+packagePath+"/"+filename;
File file = new File(path);
if (!file.exists()) {
System.out.println(file.getPath());
file.createNewFile();
} else {
throw new IOException("File already exists :" + path);
}
PrintWriter writer = new PrintWriter(file);
writer.println("package "+ packageName +";");
writer.println("");
return writer;
}
}
| [
"[email protected]"
]
| |
a003f5a7967da3aeaad69ba3aac409a8bb37f09b | 953b691e93c3215d679b6ffe378b77d49eb53126 | / java-web-blog --username [email protected]/blog/src/com/blog/po/Article.java | 5d07ff61fc2197c7398fbf72f4752f3147861d7d | []
| no_license | binsky1988/java-web-blog | bcfa153228cff812325b00020b1cd2ae5245220a | 54d536db7d9310cf937ab5e9f2e3985b78d71135 | refs/heads/master | 2020-05-26T08:26:03.883787 | 2015-01-06T12:17:17 | 2015-01-06T12:17:17 | 32,142,986 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,082 | java | package com.blog.po;
import java.util.Date;
public class Article {
private int id;
private String title;
private String content;
private String username;
private Date date;
private int hasread;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public int getHasread() {
return hasread;
}
public void setHasread(int hasread) {
this.hasread = hasread;
}
}
| [
"naples.alex@546fa267-e3c1-0736-ef2d-9897acde9ee8"
]
| naples.alex@546fa267-e3c1-0736-ef2d-9897acde9ee8 |
8b446e4e79f748963041d124d2e44103a3781c46 | 69ca85c148fcf0cbfe3d5151530d321af0dd6312 | /parking_lot/src/main/java/com/gojek/helper/InputDataProcessHelper.java | 9c3de1d7381d64f7e636e6da5ab091a3ce27c499 | []
| no_license | spatwal/parking_lot | 72eae137ca907c48804e1e834773296dfdff7539 | 935ba6db1692ffd81b9d25f4d9cd0f843d880f45 | refs/heads/master | 2020-05-17T13:58:04.854787 | 2019-04-27T09:22:48 | 2019-04-27T09:22:48 | 183,648,975 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,011 | java | package com.gojek.helper;
import java.util.HashMap;
import com.gojek.constants.ParkingLotConstants;
import com.gojek.model.Car;
import com.gojek.service.CarParkOpertaions;
import com.gojek.serviceImpl.CarParkOperationsImpl;
public class InputDataProcessHelper {
public void creataCarParkingSpace(String input, HashMap<Integer, Car> carMap, int size) {
CarParkOpertaions carParkService = new CarParkOperationsImpl();
switch (input) {
case ParkingLotConstants.CREATE_PARKING_LOT:
// size = Integer.parseInt(inputArr[1]);
carMap = carParkService.createParkingLot(size);
MessageCreationHelper.displayMessage(
ParkingLotConstants.SUSCCESSFUL_CRETAION_1 + size + ParkingLotConstants.SUSCCESSFUL_CRETAION_2);
break;
default:
System.out.println(ParkingLotConstants.NO_PARKING_LOT);
}
}
public void processCarParkOperations(String input, HashMap<Integer, Car> carMap, int size) {
CarParkOpertaions carParkService = new CarParkOperationsImpl();
String[] input2Arr = input.split(" ");
String registrationNumber;
String colour;
String message;
switch (input2Arr[0]) {
case ParkingLotConstants.PARK:
carParkService.parkCar(carMap, size, input2Arr[2], input2Arr[1]);
break;
case ParkingLotConstants.LEAVE:
carParkService.leaveLot(carMap, input2Arr[1]);
break;
case ParkingLotConstants.STATUS:
carParkService.checkParkingLotStatus(carMap);
break;
case ParkingLotConstants.REGISTRTION_ENQUIRY_FOR_COLOUR:
carParkService.searchRegistartionNumberByColour(carMap, input2Arr[1]);
break;
case ParkingLotConstants.SLOT_ENQUIRY_FOR_COLOR:
carParkService.searchSlotNumberByColor(carMap, input2Arr[1]);
break;
case ParkingLotConstants.SLOT_ENQUIRY_FOR_REGISTARTION_NUMBER:
carParkService.searchSlotNumberByRegistration(carMap, input2Arr[1]);
break;
default:
System.out.println(ParkingLotConstants.WRONG_INPUT);
}
}
}
| [
"[email protected]"
]
| |
9bad2d2c80e2d610fb7f58f0903b0624e56b2f9b | 55241d91df445c57b7348976612ebe86ae732438 | /src/test/java/fi/aalto/dmg/KafkaWindowJoinTest.java | d6e1a16e8af18873c140c95e70a69410875c2450 | []
| no_license | mineminemine123/flink-stream-join | 217bfd9c024456ae0553960dc3c51f8d1780d2e7 | 4456a7314d537c11eac98073e2a8e4df24c94937 | refs/heads/master | 2021-12-07T13:31:09.917441 | 2015-12-04T22:52:06 | 2015-12-04T22:52:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,956 | java | package fi.aalto.dmg;
import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.api.common.functions.JoinFunction;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.java.functions.KeySelector;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.streaming.api.TimeCharacteristic;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSink;
import org.apache.flink.streaming.api.datastream.MultiWindowsJoinedStreams;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.AscendingTimestampExtractor;
import org.apache.flink.streaming.api.functions.TimestampExtractor;
import org.apache.flink.streaming.api.functions.sink.SinkFunction;
import org.apache.flink.streaming.api.windowing.assigners.SlidingTimeWindows;
import org.apache.flink.streaming.api.windowing.assigners.TumblingTimeWindows;
import org.apache.flink.streaming.api.windowing.time.Time;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer082;
import org.apache.flink.streaming.util.serialization.SimpleStringSchema;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
/**
* Created by jun on 03/12/15.
*/
public class KafkaWindowJoinTest {
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
// Window base on event time
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
// env.setStreamTimeCharacteristic(TimeCharacteristic.ProcessingTime);
final KeySelector<Tuple2<String, Long>, String> keySelector = new KeySelector<Tuple2<String, Long>, String>() {
private static final long serialVersionUID = -1787574339917074648L;
@Override
public String getKey(Tuple2<String, Long> value) throws Exception {
return value.f0;
}
};
Properties properties = new Properties();
properties.put("bootstrap.servers", "localhost:9092");
properties.put("zookeeper.connect", "localhost:2181");
properties.put("group.id", "test");
properties.put("topic", "advertisement");
properties.put("auto.offset.reset", "smallest");
TimestampExtractor<Tuple2<String, Long>> timestampExtractor1 = new AscendingTimestampExtractor<Tuple2<String, Long>>() {
private static final long serialVersionUID = 8965896144592350020L;
@Override
public long extractAscendingTimestamp(Tuple2<String, Long> element, long currentTimestamp) {
return element.f1;
}
};
TimestampExtractor<Tuple2<String, Long>> timestampExtractor2 = new TimestampExtractor<Tuple2<String, Long>>() {
private static final long serialVersionUID = -6672551198307157846L;
private long currentTimestamp = 0;
@Override
public final long extractTimestamp(Tuple2<String, Long> element, long currentTimestamp) {
long newTimestamp = element.f1;
this.currentTimestamp = newTimestamp;
return this.currentTimestamp;
}
@Override
public final long extractWatermark(Tuple2<String, Long> element, long currentTimestamp) {
return currentTimestamp-30000;
}
@Override
public final long getCurrentWatermark() {
return currentTimestamp - 30000;
}
};
DataStream<Tuple2<String, Long>> advertisement = env
.addSource(new FlinkKafkaConsumer082<String>("advertisement", new SimpleStringSchema(), properties))
.map(new MapFunction<String, Tuple2<String, Long>>() {
private static final long serialVersionUID = -6564495005753073342L;
@Override
public Tuple2<String, Long> map(String value) throws Exception {
String[] splits = value.split(" ");
return new Tuple2<String, Long>(splits[0], Long.parseLong(splits[1]));
}
}).keyBy(keySelector).assignTimestamps(timestampExtractor1);
DataStream<Tuple2<String, Long>> click = env
.addSource(new FlinkKafkaConsumer082<String>("click", new SimpleStringSchema(), properties))
.map(new MapFunction<String, Tuple2<String, Long>>() {
private static final long serialVersionUID = -6564495005753073342L;
@Override
public Tuple2<String, Long> map(String value) throws Exception {
String[] splits = value.split(" ");
return new Tuple2<String, Long>(splits[0], Long.parseLong(splits[1]));
}
}).keyBy(keySelector).assignTimestamps(timestampExtractor2);
MultiWindowsJoinedStreams<Tuple2<String, Long>, Tuple2<String, Long>> joinedStreams =
new MultiWindowsJoinedStreams<>(advertisement, click);
DataStream<Tuple3<String, Long, Long>> joinedStream = joinedStreams.where(keySelector)
.window(SlidingTimeWindows.of(Time.of(25, TimeUnit.SECONDS), Time.of(5, TimeUnit.SECONDS)))
.equalTo(keySelector)
.window(TumblingTimeWindows.of(Time.of(5, TimeUnit.SECONDS)))
.apply(new JoinFunction<Tuple2<String, Long>, Tuple2<String, Long>, Tuple3<String, Long, Long>>() {
private static final long serialVersionUID = -3625150954096822268L;
@Override
public Tuple3<String, Long, Long> join(Tuple2<String, Long> first, Tuple2<String, Long> second) throws Exception {
return new Tuple3<>(first.f0, first.f1, second.f1);
}
});
joinedStream = joinedStream.filter(new FilterFunction<Tuple3<String, Long, Long>>() {
private static final long serialVersionUID = -4325256210808325338L;
@Override
public boolean filter(Tuple3<String, Long, Long> value) throws Exception {
return value.f1<value.f2&&value.f1+20000>=value.f2;
}
});
// joinedStream.addSink(new SinkFunction<Tuple3<String, Long, Long>>() {
// private static final long serialVersionUID = 5162922996056277977L;
//
// @Override
// public void invoke(Tuple3<String, Long, Long> value) throws Exception {
// // write to mysql
// Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test?" +
// "user=root&password=123456");
// Statement stmt = null;
//
// stmt = conn.createStatement();
// stmt.execute("INSERT INTO advertise_shown_join"
// + " VALUES('" + value.f0 + "'," + String.valueOf(value.f1) + ","
// + String.valueOf(value.f2) +")");
// conn.close();
// }
// });
DataStream<Tuple2<String, Integer>> newStream = joinedStream.map(new MapFunction<Tuple3<String,Long,Long>, Tuple2<String, Integer>>() {
private static final long serialVersionUID = -8619815378463068708L;
@Override
public Tuple2<String, Integer> map(Tuple3<String, Long, Long> value) throws Exception {
return new Tuple2<String, Integer>("Key", 1);
}
}).keyBy(0).sum(1);
newStream.print();
env.execute("Window Join");
}
}
| [
"[email protected]"
]
| |
b46a555f7e773016d426f455cc8ce3bf00574b26 | 0cb0728a965d1ed6373289ad9b8c6d6c040a3320 | /src/fr/demos/Article.java | d7ef86dfa08f488b1280febffdf160ecd3278a16 | []
| no_license | gregoiredemos/Premiertest | 379c3dbf2568027f8480f6ef26d8937d4e0d79b5 | 5b60c43adb9c86393989c0fa9b457c522bd3f4ad | refs/heads/master | 2021-01-01T03:58:37.931172 | 2016-04-11T14:29:48 | 2016-04-11T14:29:48 | 56,050,720 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 765 | java | package fr.demos;
public class Article {
private String description;
private String reference;
private int stock;
private double prixHT;
public Article(String descrip, String ref , int stk ,double pHT){
this.description = descrip;
this.reference = ref;
this.stock = stk;
this.prixHT = pHT;
}
public String getDescription() {
return description;
}
public String getReference() {
return reference;
}
public int getStock() {
return stock;
}
public double getPrixHT() {
return prixHT;
}
@Override
public String toString() {
return "Article [description=" + description + ", reference=" + reference + ", stock=" + stock + ", prixHT="
+ prixHT + "]";
}
public void setStock(int stock) {
this.stock = stock;
}
}
| [
"[email protected]"
]
| |
deacc36c7f4d94a344b8caf586b8773b598e0e8a | dc1dbb7e5a4b95bf44170d2f51fd08b3814f2ac9 | /data_defect4j/preprossed_method_corpus/Lang/45/org/apache/commons/lang/StringUtils_replaceChars_3852.java | 3d3da11480aaa19f0936f1f3e7d99744c6736f0f | []
| no_license | hvdthong/NetML | dca6cf4d34c5799b400d718e0a6cd2e0b167297d | 9bb103da21327912e5a29cbf9be9ff4d058731a5 | refs/heads/master | 2021-06-30T15:03:52.618255 | 2020-10-07T01:58:48 | 2020-10-07T01:58:48 | 150,383,588 | 1 | 1 | null | 2018-09-26T07:08:45 | 2018-09-26T07:08:44 | null | UTF-8 | Java | false | false | 10,062 | java |
org apach common lang
oper link java lang string
code code safe
empti isempti blank isblank
check string text
trim strip
remov lead trail whitespac
equal
compar string safe
start startswith
check string start prefix safe
end endswith
check string end suffix safe
index indexof index lastindexof
safe index check
index indexofani index lastindexofani index indexofanybut index lastindexofanybut
index set string
containsonli containsnon containsani
string charact
substr left mid
safe substr extract
substr substringbefor substr substringaft substr substringbetween
substr extract rel string
split join
split string arrai substr vice versa
remov delet
remov part string
replac overlai
search string replac string
chomp chop
remov part string
left pad leftpad pad rightpad center repeat
pad string
upper case uppercas lower case lowercas swap case swapcas capit uncapit
string
count match countmatch
count number occurr string
alpha isalpha numer isnumer whitespac iswhitespac ascii printabl isasciiprint
check charact string
default string defaultstr
protect input string
revers revers delimit reversedelimit
revers string
abbrevi
abbrevi string ellipsi
differ
compar string report differ
levenstein distanc levensteindist
number need chang string
code string util stringutil code defin word relat
string handl
code code
empti length string code code
space space charact code code
whitespac charact defin link charact whitespac iswhitespac
trim charact link string trim
code string util stringutil code handl code code input string quietli
code code input code code
code code code code return
detail vari method
side effect code code handl
code null pointer except nullpointerexcept code consid bug
code string util stringutil code deprec method
method give sampl code explain oper
symbol code code input includ code code
java lang string
author href http jakarta apach org turbin apach jakarta turbin
author href mailto jon latchkei jon steven
author daniel rall
author href mailto gcoladonato yahoo greg coladonato
author href mailto apach org korthof
author href mailto rand mcneeli yahoo rand neeli mcneeli
author stephen colebourn
author href mailto fredrik westermarck fredrik westermarck
author holger krauth
author href mailto alex purpletech alexand dai chaffe
author href mailto hp intermeta hen schmiedehausen
author arun mammen thoma
author gari gregori
author phil steitz
author chou
author michael davei
author reuben sivan
author chri hyzer
author scott johnson
version
string util stringutil
replac multipl charact string
method delet charact
code replac char replacechar quot quot quot quot quot quot jelli code
code code string input return code code
empti string input return empti string
empti set search charact return input string
length search charact equal length
replac charact
search charact longer extra search charact
delet
search charact shorter extra replac charact
pre
string util stringutil replac char replacechar
string util stringutil replac char replacechar
string util stringutil replac char replacechar abc abc
string util stringutil replac char replacechar abc abc
string util stringutil replac char replacechar abc
string util stringutil replac char replacechar abc
string util stringutil replac char replacechar abcba ayzya
string util stringutil replac char replacechar abcba ayya
string util stringutil replac char replacechar abcba yzx ayzya
pre
param str string replac charact
param search char searchchar set charact search
param replac char replacechar set charact replac
modifi string code code string input
string replac char replacechar string str string search char searchchar string replac char replacechar
empti isempti str empti isempti search char searchchar
str
replac char replacechar
replac char replacechar empti
modifi
replac char length replacecharslength replac char replacechar length
str length strlength str length
string buffer stringbuff buf string buffer stringbuff str length strlength
str length strlength
str charat
index search char searchchar index indexof
index
modifi
index replac char length replacecharslength
buf append replac char replacechar charat index
buf append
modifi
buf string tostr
str
| [
"[email protected]"
]
| |
9ab58a705c129caa6c73c578450172c89fcf3672 | 63711ef5eb49c237c67a5754494626dc4e0f88e6 | /src/main/java/ru/veryprosto/restVote/repository/jpa/JpaUserRepository.java | 16c9a5fb6033131bba16277507e9fbcee73b3053 | []
| no_license | veryprosto/restVote | f17dbadae292b20b565ae73861e51cdd2cbf174d | daaced0bb9716ef3639d53d48f230ebf224af17b | refs/heads/main | 2023-02-12T12:00:14.346247 | 2021-01-12T19:03:39 | 2021-01-12T19:03:39 | 324,754,339 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,759 | java | package ru.veryprosto.restVote.repository.jpa;
import org.springframework.dao.support.DataAccessUtils;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import ru.veryprosto.restVote.model.User;
import ru.veryprosto.restVote.repository.UserRepository;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
@Repository
@Transactional(readOnly = true)
public class JpaUserRepository implements UserRepository {
@PersistenceContext
private EntityManager em;
@Override
@Transactional
public User save(User user) {
if (user.isNew()) {
em.persist(user);
return user;
} else {
return em.merge(user);
}
}
@Override
public User get(int id) {
return em.find(User.class, id);
}
@Override
@Transactional
public boolean delete(int id) {
return em.createNamedQuery(User.DELETE)
.setParameter("id", id)
.executeUpdate() != 0;
}
@Override
public User getByEmail(String email) {
List<User> users = em.createNamedQuery(User.BY_EMAIL, User.class)
.setParameter(1, email)
.getResultList();
return DataAccessUtils.singleResult(users);
}
@Override
public User getByName(String name) {
List<User> users = em.createNamedQuery(User.BY_NAME, User.class)
.setParameter(1, name)
.getResultList();
return DataAccessUtils.singleResult(users);
}
@Override
public List<User> getAll() {
return em.createNamedQuery(User.ALL_SORTED, User.class).getResultList();
}
} | [
"[email protected]"
]
| |
3b657246e41f7ba602aed4b2c5b9c8112edf8d0f | 4311cc67a3439d461ef6a5f4931dfd526ab32a26 | /app/src/main/java/com/pzhu/top250mvp/wp/api/ApiManager.java | 2b245091f5f3cedb970277c6cdf25d93ad828085 | []
| no_license | wp529/MVPDemo | bbc4e0a7a15769f0a608a2f34148131cf7958331 | a666f2bb603f4846a3444e87f3e436665507b12d | refs/heads/master | 2021-01-20T05:29:29.898151 | 2019-03-17T07:36:33 | 2019-03-17T07:36:33 | 89,787,399 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 826 | java | package com.pzhu.top250mvp.wp.api;
import com.pzhu.top250mvp.wp.ToStringConverterFactory;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.Observable;
public class ApiManager {
private static final String BASE_URL = "http://api.douban.com/";
private static Retrofit retrofit = new Retrofit.Builder().
baseUrl(BASE_URL)
.addConverterFactory(new ToStringConverterFactory())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
private static final MovieService movieService = retrofit.create(MovieService.class);
public static Observable<String> getMovieData(int start, int count) {
return movieService.getMovie(start, count);
}
}
| [
"[email protected]"
]
| |
ede2150695c201065993fdb3ab3986bae97027cf | 647844921adbb37e12817dbebf9f09edfa89adf3 | /src/testCases/Framework_008.java | e9bab6dcce8df0d5af32b3aba5bd57b29bd0aed4 | []
| no_license | Abhi17march/JDSelenium | f17632eb6119e1122eb52481110758952ed02cc6 | 99b40a6e1f1af55f268e85c323d66ab94aa867da | refs/heads/master | 2021-01-20T20:42:54.371384 | 2016-06-27T09:15:56 | 2016-06-27T09:15:56 | 62,041,804 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,960 | java | package testCases;
import org.apache.log4j.xml.DOMConfigurator;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import pageObjects.BaseClass;
import utility.Constant;
import utility.ExcelUtils;
import utility.ExcelWrite008;
import utility.Log;
import utility.Utils;
import appModules.SignIn_Action;
import appModules.Verification_Action008;
public class Framework_008{
public WebDriver driver;
private String sTestCaseName;
private int iTestCaseRow;
// Following TestNg Test case pattern, and divided a Test case in to three different part.
// In Before Method, your code will always be the same for every other test case.
// In other way before method is your prerequisites of your main Test Case
@BeforeMethod
public void beforeMethod() throws Exception {
// Configuring Log4j logs, please see the following posts to learn about Log4j Logging
// http://www.toolsqa.com/test-case-with-log4j/
// http://www.toolsqa.com/log4j-logging/
DOMConfigurator.configure("log4j.xml");
// Getting the Test Case name, as it will going to use in so many places
// The main use is to get the TestCase row from the Test Data Excel sheet
sTestCaseName = this.toString();
// From above method we get long test case name including package and class name etc.
// The below method will refine your test case name, exactly the name use have used
sTestCaseName = Utils.getTestCaseName(this.toString());
// Start printing the logs and printing the Test Case name
Log.startTestCase(sTestCaseName);
// Setting up the Test Data Excel file using Constants variables
// For Constant Variables please see http://www.toolsqa.com/constant-variables/
// For setting up Excel for Data driven testing, please see http://www.toolsqa.com/data-driven-testing-excel-poi/
ExcelUtils.setExcelFile(Constant.Path_TestData + Constant.File_TestData,"Sheet1");
// Fetching the Test Case row number from the Test Data Sheet
// This row number will be feed to so many functions, to get the relevant data from the Test Data sheet
iTestCaseRow = ExcelUtils.getRowContains(sTestCaseName,Constant.Col_TestCaseName);
// Launching the browser, this will take the Browser Type from Test Data Sheet
driver = Utils.OpenBrowser(iTestCaseRow);
driver.manage().window().maximize();
// Initializing the Base Class for Selenium driver
// Now we do need to provide the Selenium driver to any of the Page classes or Module Actions
// Will soon write a post on Base Class
new BaseClass(driver);
}
// This is the starting of the Main Test Case
@Test
public void main() throws Exception {
// Every exception thrown from any class or method, will be catch here and will be taken care off
// For Exception handling please see http://www.toolsqa.com/selenium-webdriver/exception-handling-selenium-webdriver/
try{
SignIn_Action.Execute(iTestCaseRow);
Verification_Action008.Execute();
// Now your test is about to finish but before that you need to take decision to Pass your test or Fail
// For selenium your test is pass, as you do not face any exception and you come to the end or you test did not stop anywhere
// But for you it can be fail, if any of your verification is failed
// This is to check that if any of your verification during the execution is failed
if(BaseClass.bResult==true){
// If the value of boolean variable is True, then your test is complete pass and do this
ExcelUtils.setCellData("Pass", iTestCaseRow, Constant.Col_Result);
ExcelWrite008.setCellData();
System.out.println("ExcelWrite008 Data entered");
}else{
// If the value of boolean variable is False, then your test is fail, and you like to report it accordingly
// This is to throw exception in case of fail test, this exception will be caught by catch block below
throw new Exception("Test Case Failed because of Verification");
}
// Below are the steps you may like to perform in case of failed test or any exception faced before ending your test
}catch (Exception e){
// If in case you got any exception during the test, it will mark your test as Fail in the test result sheet
ExcelUtils.setCellData("Fail", iTestCaseRow, Constant.Col_Result);
// If the exception is in between the test, bcoz of any element not found or anything, this will take a screen shot
// This will print the error log message
Log.error(e.getMessage());
// Again throwing the exception to fail the test completely in the TestNG results
throw (e);
}
}
// Its time to close the finish the test case
@AfterMethod
public void afterMethod() {
// Printing beautiful logs to end the test case
Log.endTestCase(sTestCaseName);
// Closing the opened driver
driver.close();
}
}
| [
"[email protected]"
]
| |
4e25be8af8e1771130cd87fab9856fe89a9c8df3 | 488d18341b9d0f72e69f0e6dabf2d1edb04e12b8 | /BlockDiagramCodeAdapter/src/BlockDiagramCodeAdapter/org/moflon/tie/BlockDiagramCodeAdapterSync.java | ab604b083f58d49762eec94dde5f805d827d6d24 | []
| no_license | eMoflon/emoflon-tests | c5718bcf827c95fbf78f2c8e94667f39b7c1fc2d | 39c23ee9fa45c2162bf4a5f51976f97b2e0c31ae | refs/heads/master | 2020-09-05T13:16:20.200891 | 2018-12-13T12:45:30 | 2018-12-13T12:45:30 | 67,930,072 | 0 | 1 | null | 2016-11-10T07:49:54 | 2016-09-11T13:01:23 | HTML | UTF-8 | Java | false | false | 2,237 | java | package BlockDiagramCodeAdapter.org.moflon.tie;
import java.io.IOException;
import org.apache.log4j.BasicConfigurator;
import org.moflon.tgg.algorithm.synchronization.SynchronizationHelper;
import org.moflon.tgg.runtime.CorrespondenceModel;
import java.util.function.BiConsumer;
import BlockDiagramCodeAdapter.BlockDiagramCodeAdapterPackage;
public class BlockDiagramCodeAdapterSync extends SynchronizationHelper{
public BlockDiagramCodeAdapterSync()
{
super(BlockDiagramCodeAdapterPackage.eINSTANCE, ".");
}
public static void main(String[] args) throws IOException {
// Create helper
BasicConfigurator.configure();
BlockDiagramCodeAdapterSync helper = new BlockDiagramCodeAdapterSync();
// Adjust values as required
String delta = "instances/fwd.trg.delta.xmi";
String corr = "instances/fwd.corr.xmi";
BiConsumer<String, String> synchronizer = helper::syncBackward;
// Propagate changes
synchronizer.accept(corr, delta);
}
public void syncForward(String corr, String delta) {
setChangeSrc(executeDeltaSpec(delta));
loadTriple(corr);
loadSynchronizationProtocol("instances/fwd.protocol.xmi");
integrateForward();
saveResult("fwd");
System.out.println("Completed forward synchronization");
}
public void syncBackward(String corr, String delta) {
setChangeTrg(executeDeltaSpec(delta));
loadTriple(corr);
loadSynchronizationProtocol("instances/fwd.protocol.xmi");
integrateBackward();
saveResult("fwd");
System.out.println("Completed backward synchronization");
}
private void loadTriple(String corr) {
try {
loadCorr(corr);
CorrespondenceModel corrModel = (CorrespondenceModel) getCorr();
setSrc(corrModel.getSource());
setTrg(corrModel.getTarget());
} catch (IllegalArgumentException iae) {
System.err.println("Unable to load input triple for " + corr + ", " + iae.getMessage());
}
}
private void saveResult(String direction) {
saveSrc("instances/" + direction + ".src.xmi");
saveTrg("instances/" + direction + ".trg.xmi");
saveCorr("instances/" + direction + ".corr.xmi");
saveSynchronizationProtocol("instances/" + direction + ".protocol.xmi");
}
} | [
"[email protected]"
]
| |
5616c4a7e9fa68595a74242cecf8f785190e66a6 | 4cf7c386e9649e910963f3c0713435fa638095e3 | /src/t9/core/funcs/workflow/util/sort/T9FeedbackComparator.java | 23fa50bd91c2da67d21ed4b68f9e167954dc5ad4 | []
| no_license | zhanght86/t9 | 498f4a5800ca3f054468f465baa0339c824888f8 | 2478bc3f4b3eff73024dc2ddf1b8ca5115f62c1f | refs/heads/master | 2021-08-26T09:45:00.992932 | 2017-11-23T03:05:11 | 2017-11-23T03:05:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 510 | java | package t9.core.funcs.workflow.util.sort;
import java.util.Comparator;
import t9.core.funcs.workflow.data.T9FlowRunFeedback;
public class T9FeedbackComparator implements Comparator {
public int compare(Object arg0, Object arg1) {
// TODO Auto-generated method stub
T9FlowRunFeedback feedback = (T9FlowRunFeedback) arg0;
T9FlowRunFeedback feedback1 = (T9FlowRunFeedback) arg1;
if( feedback.getEditTime().compareTo(feedback1.getEditTime()) > 0 ){
return 0;
}
return 1;
}
}
| [
"[email protected]"
]
| |
96ea1a1c516f33a913011c5d686f7541b69002d8 | 30581d5505c62f9c74d11d8a3428c12f1bb57f32 | /src/test/java/LongestZigZagPathInBinaryTreeTest.java | 9557d24ed7733bfcfd3aed3ca6c7119bb87e3b37 | []
| no_license | spunkprs/NAVIC | ba623c7a38cb3b63b93d3337ed13acabf1021e83 | 9c2afc02bdffd93fcd14e33d4bd4ffeed4461f1b | refs/heads/master | 2023-07-06T01:38:56.730615 | 2021-08-01T08:28:02 | 2021-08-01T08:28:02 | 284,240,956 | 0 | 0 | null | 2020-10-14T00:06:19 | 2020-08-01T10:47:43 | Java | UTF-8 | Java | false | false | 1,591 | java | import org.junit.Before;
import org.junit.Test;
import binarytree.LongestZigZagPathInBinaryTree;
import binarytree.TreeNode;
import org.junit.Assert;
public class LongestZigZagPathInBinaryTreeTest {
private LongestZigZagPathInBinaryTree unit;
@Before
public void setUp() {
unit = new LongestZigZagPathInBinaryTree();
}
@Test
public void shouldComputeLongestZigZagPathSumCaseOne() {
TreeNode root = new TreeNode(1);
TreeNode childOne = new TreeNode(1);
TreeNode childTwo = new TreeNode(1);
TreeNode childThree = new TreeNode(1);
TreeNode childFour = new TreeNode(1);
TreeNode childFive = new TreeNode(1);
TreeNode childSix = new TreeNode(1);
TreeNode childSeven = new TreeNode(1);
root.setRight(childOne);
childOne.setLeft(childTwo);
childOne.setRight(childThree);
childThree.setLeft(childFour);
childThree.setRight(childFive);
childFour.setRight(childSix);
childSix.setRight(childSeven);
Assert.assertEquals(3, unit.longestZigZag(root));
}
@Test
public void shouldComputeLongestZigZagPathSumCaseTwo() {
TreeNode root = new TreeNode(1);
TreeNode childOne = new TreeNode(1);
TreeNode childTwo = new TreeNode(1);
TreeNode childThree = new TreeNode(1);
TreeNode childFour = new TreeNode(1);
TreeNode childFive = new TreeNode(1);
TreeNode childSix = new TreeNode(1);
root.setLeft(childOne);
childOne.setLeft(childTwo);
childOne.setRight(childThree);
childThree.setLeft(childFour);
childThree.setRight(childFive);
childFour.setLeft(childSix);
Assert.assertEquals(3, unit.longestZigZag(root));
}
}
| [
"[email protected]"
]
| |
55fc912cc1c2a1b917005d63d9fdb1e4ca4d5d43 | 43a17e106805c58f44f6473d8ef670f67553c0ce | /MXClient/src/com/htmitech/emportal/ui/plugin/zt/entity/Doc.java | 5a731344fa36375ec0a6ffabe02e28cbfaf3f4a8 | [
"Apache-2.0"
]
| permissive | Spider-007/Android_example_view12 | db45571005094a4921279b12f5ddcb792780ee03 | 00a22fc31dfd870226964d696a2c9edb5dc1654a | refs/heads/master | 2020-08-18T06:29:12.546416 | 2019-10-17T14:39:00 | 2019-10-17T14:39:00 | 215,756,231 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,474 | java | package com.htmitech.emportal.ui.plugin.zt.entity;
import java.io.Serializable;
public class Doc implements Serializable{
private static final long serialVersionUID = 1L;
private String docTitle;
private String docID;
private String sendFrom;
private String sendDate;
private String docType;
private String todoFlag;
private String kind;
private String iconId;
public String getDocTitle() {
return docTitle;
}
public void setDocTitle(String docTitle) {
this.docTitle = docTitle;
}
public String getDocID() {
return docID;
}
public void setDocID(String docID) {
this.docID = docID;
}
public String getSendFrom() {
return sendFrom;
}
public void setSendFrom(String sendFrom) {
this.sendFrom = sendFrom;
}
public String getSendDate() {
return sendDate;
}
public void setSendDate(String sendDate) {
this.sendDate = sendDate;
}
public String getDocType() {
return docType;
}
public void setDocType(String docType) {
this.docType = docType;
}
public String getTodoFlag() {
return todoFlag;
}
public void setTodoFlag(String todoFlag) {
this.todoFlag = todoFlag;
}
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public void setIconId(String iconUrl) {
this.iconId = iconUrl;
}
public String getIconId() {
return iconId;
}
@Override
public String toString() {
return docID+docTitle;
}
}
| [
"[email protected]"
]
| |
9dd65f99175a88889ed77a197de5be138d0bde8e | 9285b06526af9cc5ef3b795a576d2b2b70d10984 | /src/main/java/com/automation/pages/advisor_checkin/ACI_AssignROPage.java | 3770e36ed62b249c75ccad74aeaacd9c033d3e31 | []
| no_license | ssp-user/DFXBrowserStackIntegration | 4a9f361ee9cd7986ab817134a43348cf3b4ef742 | e20d1ca09a1a16070c0bdd11b4eda0d975ec918c | refs/heads/master | 2023-04-16T15:39:04.486721 | 2021-04-28T15:10:35 | 2021-04-28T15:10:35 | 362,512,527 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 17,422 | java | package com.automation.pages.advisor_checkin;
import com.automation.utils.otherUtils.CommonMethods;
import org.apache.log4j.Logger;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
public class ACI_AssignROPage extends ACI_FramePage {
public void AdvisorCheckInAssignROPage(){
setWait();
}
private static Logger log = Logger.getLogger(ACI_AssignROPage.class);
//next button on assign ro page
public static By bNextButtonOnAssignRo = By.id("g-aproceed");
//assign RO tag
public static By bAssignRoTag = By.xpath("//a[contains(text(),'ASSIGN R.O.')]");
//promise time on the assign RO page
private static By bPromiseTime = By.xpath("//div[@date-picker-title='PROMISE TIME']/input");
//year up arrow on promise time pop up on assign RO page
// private static By bYearPlus = By.xpath("(//input[@class='dateCalendarinput']/..//div[@class='dwb-e dwwb dwwbp'])[3]/span");
// updated by David
private static By bYearPlus = By.xpath("(//div[@class='dwwl dwrc dwwl2'])[1]/div[1]/span");
private static By bYearMus = By.xpath("(//div[@class='dwwl dwrc dwwl2'])[1]/div[2]/span");
private static By bMonthPlus = By.xpath("(//div[@class='dwwl dwrc dwwl1'])[1]/div[1]/span");
private static By bMonthMus = By.xpath("(//div[@class='dwwl dwrc dwwl1'])[1]/div[2]/span");
private static By bDayPlus = By.xpath("(//div[@class='dwwl dwrc dwwl0'])[1]/div[1]/span");
private static By bDayMus = By.xpath("(//div[@class='dwwl dwrc dwwl0'])[1]/div[2]/span");
//green check confirm on the promise time pop up
private static By bConfirmPromiseTime = By.id("saveDate");
//tag input field on Assign RO page
private static By bTag = By.xpath("//input[@name='tagNumber']");
//comment input field on Assign RO page
private static By bComments = By.xpath("//textarea[@title='comments']");
// // Promise Time Picker Button
// @FindBy(css="[date-picker-title='PROMISE TIME'] button")
// private static WebElement promiseTimePicker;
private static By bpromiseTimePickerLocator = By.cssSelector("[date-picker-title='PROMISE TIME'] button");
//
// // TAG enter field
//// @FindBy(css=".span12.ng-invalid.ng-invalid-required") // 2.7
// @FindBy(name="tagNumber") // 2.8
// private static WebElement tagField;
//
// // Tag Mandatory Message List
// @FindBy(css=".span12.ng-invalid.ng-invalid-required+label")
// protected static WebElement tagMandatoryMsg;
//
// // Hour plus for Promise time
// @FindBy(css="div.dwwl.dwrc.dwwl3>div.dwb-e.dwwb.dwwbp>span")
// private static WebElement hourPlus;
private static By bhourPlus = By.cssSelector("div.dwwl.dwrc.dwwl3>div.dwb-e.dwwb.dwwbp>span");
//
// // Hour Minus for Promise time
// @FindBy(css="div.dwwl.dwrc.dwwl3>div.dwb-e.dwwb.dwwbm>span")
// private static WebElement hourMinus;
private static By bhourMinus = By.cssSelector("div.dwwl.dwrc.dwwl3>div.dwb-e.dwwb.dwwbm>span");
//
//
// // Current Hour
// @FindBy(css=" div.modal.hide.fade.ng-scope.in div.dwwl.dwrc.dwwl3 div.dw-li.dw-v.dw-sel")
// private static WebElement currentHour;
private static By bcurrentHour = By.cssSelector("div.modal.hide.fade.ng-scope.in div.dwwl.dwrc.dwwl3 div.dw-li.dw-v.dw-sel");
//
//
// // Hour At 9
// @FindBy(css="div.dwwl.dwrc.dwwl3 div.dw-bf div:nth-child(10)")
// private static WebElement hourAt9;
//
// // Hour At 10
// @FindBy(css="div.dwwl.dwrc.dwwl3 div.dw-bf div:nth-child(11)")
// private static WebElement hourAt10;
private static By bhourAt10 = By.cssSelector("div.dwwl.dwrc.dwwl3 div.dw-bf div:nth-child(11)");
//
//
// // Minute At 00
// @FindBy(css="div.dwwl.dwrc.dwwl4 div.dw-bf:nth-child(1) div.dw-li.dw-v:nth-child(1)")
// private static WebElement minuteAtZero;
//
//
// // Month at January
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li:nth-child(1)")
// private static WebElement monAtJan;
//
// // Month at February
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li:nth-child(2)")
// private static WebElement monAtFeb;
//
// // Month at March
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li:nth-child(3)")
// private static WebElement monAtMarch;
//
// // Month at April
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li:nth-child(4)")
// private static WebElement monAtApril;
//
// // Month at May
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li:nth-child(5)")
// private static WebElement monAtMay;
//
// // Month at June
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li:nth-child(6)")
// private static WebElement monAtJune;
//
// // Month at July
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li:nth-child(7)")
// private static WebElement monAtJul;
//
// // Month at August
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li:nth-child(8)")
// private static WebElement monAtAug;
//
// // Month at September
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li:nth-child(9)")
// private static WebElement monAtSep;
//
// // Month at October
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li:nth-child(10)")
// private static WebElement monAtOct;
//
// // Month at November
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li:nth-child(11)")
// private static WebElement monAtNov;
//
// // Month at December
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li:nth-child(12)")
// private static WebElement monAtDec;
//
// // Current Month, use getText attribute to get the month reading
// @FindBy(css="div.dwwl.dwrc.dwwl1 div.dw-li.dw-sel.dw-v")
// private static WebElement currentMon;
private static By currentMonthLocator = By.cssSelector("div.dwwl.dwrc.dwwl1 div.dw-li.dw-sel.dw-v");
//
// // Month Plus
// @FindBy(css="div.dwwl.dwrc.dwwl1>div.dwb-e.dwwb.dwwbp>span")
// private static WebElement monthPlus;
private static By bmonthPlus = By.cssSelector("div.dwwl.dwrc.dwwl1>div.dwb-e.dwwb.dwwbp>span");
//
//
// // current Date, use getText attribute to get the date reading
// @FindBy(css="div.dwwl.dwrc.dwwl0 div.dw-li.dw-sel.dw-v")
// private static WebElement currentDate;
private static By currentDateLocator = By.cssSelector("div.dwwl.dwrc.dwwl0 div.dw-li.dw-sel.dw-v");
//
//
//
// // Date Plus for Promise time
// @FindBy(css="div.dwwl.dwrc.dwwl0>div.dwb-e.dwwb.dwwbp>span")
// private static WebElement datePlus;
//
// // Current Year
// @FindBy(css=".dwwl.dwrc.dwwl2 .dw-li.dw-sel.dw-v")
// private static WebElement currentYear;
private static By currentYearLocator = By.cssSelector(".dwwl.dwrc.dwwl2 .dw-li.dw-sel.dw-v");
//
//
// // Year Plus
// @FindBy(css="div.dwwl.dwrc.dwwl2>div.dwb-e.dwwb.dwwbp>span")
// private static WebElement yearPlus;
//
// // AM or Pm Plus
// @FindBy(css="div.dwwl.dwrc.dwwl5>div.dwb-e.dwwb.dwwbp>span")
// private static WebElement amPMPlus;
private static By bAPMPlus = By.cssSelector("div.dwwl.dwrc.dwwl5>div.dwb-e.dwwb.dwwbp>span");
//
// @FindBy(css="div.modal.hide.fade.ng-scope.in div.dwwl.dwrc.dwwl5 div.dw-bf div.dw-li.dw-v:nth-child(1)")
// private static WebElement aM;
private static By bAM = By.cssSelector("div.modal.hide.fade.ng-scope.in div.dwwl.dwrc.dwwl5 div.dw-bf div.dw-li.dw-v:nth-child(1)");
//
//
// // Next Button
// @FindBy(id="g-aproceed")
// protected static WebElement nextBtn;
//
// // Promise Time Title Locator
// private static By promiseTimeTitleLocator = By.cssSelector(".modal .modal-pad .modal-header h3.ng-binding");
//
// // Comment Field
// @FindBy(css="textarea[title='comments']")
// private static WebElement commentField;
//
// // Current selected date
// @FindBy(id="mobiscroll1425410286881")
// private static WebElement selectDate;
//
// // Transportation Selection Field
// @FindBy(css="#assign div.scrollcontent > div:nth-child(3) select")
// private static WebElement transportationField;
// private static Select transportation;
private static By btransportation = By.cssSelector("#assign div.scrollcontent > div:nth-child(3) select");
//
// // Inspection Type Field
// @FindBy(css="#assign div.scrollcontent div:nth-child(7) .inspectiontype select")
// private static WebElement inspectionTypeField;
// private static Select inspectionType;
private static By binspectionType = By.cssSelector("#assign div.scrollcontent div:nth-child(7) .inspectiontype select");
//
// // Inspection Type Field
// @FindBy(css="#g-viewDropdown > select")
// private static WebElement sAdvisorSelect;
private static By bAdvisorSelect = By.xpath("//select[@name='service_advisor']");
private static By bTechnicianSelect = By.xpath("//select[@name='technician']");
public void clickNextOnAssignRO(){
clickElementWithException(bNextButtonOnAssignRo);
}
public void updateYearOnAssignRO(String year){
clickElementWithException(bPromiseTime);
int actualYear = Integer.parseInt(year);
for(int i=0;i<actualYear;i++){
clickElementWithException(bYearPlus);
}
clickElementWithException(bConfirmPromiseTime);
}
public void setPromiseDateTimeOnAssignRO(String aday , int ahour , String apm ){
moveToClick(bpromiseTimePickerLocator);
setPromiseDay(aday);
setHour(ahour);
// set AM PM
WebElement eAM = driver.findElement(bAM);
if (apm.equalsIgnoreCase("AM")){
if(!webElementHasClass(eAM,"dw-sel")){
driver.findElement(bAPMPlus).click();
}
}else if (apm.equalsIgnoreCase("PM")){
if(webElementHasClass(eAM,"dw-sel")){
driver.findElement(bAPMPlus).click();
}
}
dWait.until(conditionClick(bConfirmPromiseTime)).click();
}
private void setHour(int ahour){ // Select Hour to 10
// String ch = ahour.substring(0,1);
// String num = ahour.substring(1);
// int iNum = Integer.valueOf(num);
// for (int i =0; i< iNum ; i++){
// if (ch.equals("+")){
// dWait.until(conditionVisible(bhourPlus)).click();
// }else if (ch.equals("-")){
// dWait.until(conditionVisible( bhourMinus)).click();
// }
// }
By locator = bhourAt10;
if (ahour==10){
locator = bhourAt10;
}
int hour = Integer.parseInt(driver.findElement(bcurrentHour).getText().trim());
while(!webElementHasClass(driver.findElement(locator),"dw-sel")){
if(hour > 9 || hour < 3){
dWait.until(conditionVisible(bhourPlus)).click();
} else {
dWait.until(conditionVisible( bhourMinus)).click();
}
}
}
private void setPromiseDay(String aday ){
int iday = Integer.parseInt(aday);
if (iday == 1){
actionClick(bDayPlus);
}
String sDate = driver.findElement(currentYearLocator).getText().trim();
int iYear = Integer.valueOf(sDate);
if (iYear < 2000){ iYear = iYear + 2000;
}
sDate = driver.findElement(currentMonthLocator).getText().trim();
int iMonth = Integer.valueOf(sDate.substring(0,2));
sDate = driver.findElement(currentDateLocator).getText().trim();
int iDay = Integer.valueOf(sDate.substring(0,2));
if (CommonMethods.isToday(iYear,iMonth,iDay)){
actionClick(bDayPlus);
}
boolean weekendFound = true;
do{
if(isEndOfMonthOrYear()){
actionClick(bDayPlus);
}
if(isWeekend()){
actionClick(bDayPlus);
weekendFound = true;
} else {
weekendFound = false;
}
} while (weekendFound);
}
private boolean isEndOfMonthOrYear(){
String sDate = driver.findElement(currentMonthLocator).getText().trim();
int iMonth = Integer.valueOf(sDate.substring(0,2));
sDate = driver.findElement(currentDateLocator).getText().trim();
int date = Integer.valueOf(sDate.substring(0,2));
boolean result = false;
switch(iMonth){
case 1: if(date==31){
actionClick(bmonthPlus);
result = true;
}
break;
case 2: if(date==28 || date==29){
actionClick(bmonthPlus);
result = true;
}
break;
case 3: if(date==31){
actionClick(bmonthPlus);
result = true;
}
break;
case 4: if(date==30){
actionClick(bmonthPlus);
result = true;
}
break;
case 5: if(date==31){
actionClick(bmonthPlus);
result = true;
}
break;
case 6: if(date==30){
actionClick(bmonthPlus);
result = true;
}
break;
case 7: if(date==31){
actionClick(bmonthPlus);
result = true;
}
break;
case 8: if(date==31){
actionClick(bmonthPlus);
result = true;
}
break;
case 9: if(date==30){
actionClick(bmonthPlus);
result = true;
}
break;
case 10: if(date==31){
actionClick(bmonthPlus);
result = true;
}
break;
case 11: if(date==30){
actionClick(bmonthPlus);
result = true;
}
break;
case 12:
if(date==31){
actionClick(bYearPlus);
actionClick(bmonthPlus);
actionClick(bDayPlus);
result = true;
}
break;
}
return result;
}
private boolean isWeekend(){
String sDate = driver.findElement(currentYearLocator).getText().trim();
int iYear = Integer.valueOf(sDate);
if (iYear < 2000){ iYear = iYear + 2000;
}
sDate = driver.findElement(currentMonthLocator).getText().trim();
int iMonth = Integer.valueOf(sDate.substring(0,2));
sDate = driver.findElement(currentDateLocator).getText().trim();
int iDay = Integer.valueOf(sDate.substring(0,2));
return CommonMethods.isWeekend(iYear,iMonth,iDay);
}
public void updatePageInformation(String updateFieldName, String pageName){
switch (pageName){
case "ASSIGN R.O.":
if(updateFieldName.toLowerCase().equals("random")){
updateFieldName = CommonMethods.getRandomText(5);
}
clearAndInputElementWithException(bTag,updateFieldName);
//dWait.until(conditionVisible(bComments)).click(); //will remove in the future
//clearAndSend(bComments, "QA Darren travel here and mark on it"); //will remove in the future, it will get override by next method
break;
}
}
public void setTagValueOnAssignROPage(String updateFieldName){
if(updateFieldName.toLowerCase().equals("random")){
updateFieldName = CommonMethods.getRandomText(5);
}
clearAndInputElementWithException(bTag,updateFieldName);
//dWait.until(conditionVisible(bComments)).click(); //will remove in the future
//clearAndSend(bComments, "QA Darren travel here and mark on it"); //will remove in the future, it will get override by next method
}
public void updateComment(String comment){
clearAndInputElementWithException(bComments, comment);
}
public void selectServiceAdvisorInASSIGNRO(String value ) {
sleep(1000);
try{
selectDropList(driver.findElement(bAdvisorSelect),value);
} catch (NoSuchElementException e){
log.info("Advisor not exists");
}
}
public void selectTechnicianInASSIGNRO(String value ) {
sleep(1000);
try{
selectDropList(driver.findElement(bTechnicianSelect),value);
} catch (NoSuchElementException e){
log.info("Technician not exists");
}
}
public void setTransportationInASSIGNRO(String value ) {
sleep(1000);
try{
selectDropList(driver.findElement(btransportation),value);
} catch (NoSuchElementException e){
log.info("Transportation not exists");
}
}
public void setInspectionTypeInASSIGNRO(String value ) {
try{
selectDropList(driver.findElement(binspectionType),value);
} catch (NoSuchElementException e){
log.info("Transportation not exists");
}
}
public void validateTransportationOption(String transportationOption){
CommonMethods.verifyElementExists(driver.findElement(By.xpath("//select[@name='transportationOption']/option[text()='"+transportationOption+"']")));
}
}
| [
"[email protected]"
]
| |
f7a8785ac2d9dfcfb57bb1a8ff0ff4cd6a8245a1 | 73749486e20ccc951f100b65ea4d2901898be3d0 | /task-service/src/main/java/ba/unsa/etf/nwt/taskservice/response/base/ErrorResponse.java | f4635d556597082f1a2e02eb3aada24e3e95efa5 | []
| no_license | SoftTech-Course/ProjectHub | e07ee9ca518914c599b05baef9f5bfe67c851425 | 6fec2b515691d0212807785d99452d3b6782f540 | refs/heads/master | 2023-05-10T16:24:20.531436 | 2021-06-07T20:05:47 | 2021-06-07T20:05:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 505 | java | package ba.unsa.etf.nwt.taskservice.response.base;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ErrorResponse {
private Map<String, List<String>> errors = new HashMap<>();
public void addError(final String message) {
errors.put("message", Collections.singletonList(message));
}
}
| [
"[email protected]"
]
| |
418b71f6cd0f1dd32aeed5de2eb1775286e7051e | c2a6a429263b48a9a3a402e973f88f5dd660c29d | /src/main/java/es/upm/miw/pd/doo/polymorphism/vehiculos/models/CategoriaC.java | cd13eafa8e0c10a7d83d957492a5b3ea542f7511 | []
| no_license | rpuerta85/pd.ecp1.doo | 46969e69f428cb768369705391e5b007e030b46c | 8edc07fe24554b63544fa9f4111458c4912792a0 | refs/heads/master | 2021-01-21T12:26:15.919128 | 2014-10-22T22:09:02 | 2014-10-22T22:09:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 278 | java | package es.upm.miw.pd.doo.polymorphism.vehiculos.models;
public class CategoriaC extends Categoria {
private static final String NOMBRE = "C";
private static final float PRECIO = 10;
public CategoriaC() {
super(NOMBRE,PRECIO);
}
}
| [
"raul@raul-VAIO"
]
| raul@raul-VAIO |
53e63934b45d5c985ac5b69c6a425738041a05fc | 70ccfbae36438a62c88bae428add40711770e528 | /src/FunctionProps.java | 46edf4da4adbc661d968878b7915384623b9daa1 | []
| no_license | vsinha/compiler | cb38f4db5a94aa18156c770d7f30275b904e49a4 | 84a6c6aaba9231848fa4ed1d218c315382060086 | refs/heads/master | 2021-01-21T12:23:26.171108 | 2014-12-13T02:37:00 | 2014-12-13T02:37:00 | 23,475,950 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,194 | java | import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Set;
public class FunctionProps {
private String funcName;
private String returnType;
LinkedHashMap<String, String> params;
LinkedHashMap<String, String> locals;
public FunctionProps (String funcName) {
this.funcName = funcName;
params = new LinkedHashMap<String, String>();
locals = new LinkedHashMap<String, String>();
}
public void addParam(String name, String type) {
params.put(name, type);
}
public void printParams() {
Set<String> keys = params.keySet();
for (String key : keys) {
System.out.println(key + " : " + params.get(key));
}
}
public void addLocal(String name, String type) {
locals.put(name, type);
}
public int numLocals() {
return locals.size();
}
public int numParams() {
return params.size();
}
public String getName() {
return this.funcName;
}
public void setReturnType(String returnType) {
this.returnType = returnType;
}
public String getReturnType() {
return this.returnType;
}
}
| [
"[email protected]"
]
| |
2d04527b1aca7ec3fd82ea1df95caed2af5055a6 | c06db1f90af511d98197cae015ee24e6e9234f7f | /app/src/main/java/in/mvpstarter/sample/injection/module/ViewModule.java | 16777efa4321c95310514b304e4c5e64155a5d91 | []
| no_license | j7arsen/new_mvp_example | 48ce96aabdf4afdaf1d83c112f294f8f0392d57c | c070d9ebb073ecbc902c91810d8de25c9afb5196 | refs/heads/master | 2021-01-13T10:57:32.080167 | 2017-08-08T13:42:25 | 2017-08-08T13:42:25 | 81,671,306 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 643 | java | package in.mvpstarter.sample.injection.module;
import android.content.Context;
import android.view.View;
import dagger.Module;
import dagger.Provides;
import in.mvpstarter.sample.injection.qualifier.ViewContext;
import in.mvpstarter.sample.injection.scope.PerView;
/**
* Created by j7ars on 12.07.2017.
*/
@Module
public class ViewModule {
private final View mView;
public ViewModule(View view){
this.mView = view;
}
@Provides
@PerView
View provideView(){
return mView;
}
@Provides
@PerView
@ViewContext
Context provideContext(){
return mView.getContext();
}
}
| [
"Arsen Esatov"
]
| Arsen Esatov |
8d7d1f34a54289dcc8e23a66400929c08cd06fa5 | 214b061d839cf1bcadb2a7546684bbfbd9f311fc | /src/algorithmen/GreedyStichprobe.java | 35b8558662404b5de7368520dd89394c034fe444 | []
| no_license | domoritz/informaticup-2011 | 074c355e0300a32e268f9196ee63a6caf7db33cb | 85e97253e796f9913da9bdc66378b63366e64e75 | refs/heads/master | 2021-01-12T02:10:53.374961 | 2017-01-10T01:03:11 | 2017-01-10T01:03:11 | 78,483,738 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,768 | java | package algorithmen;
import informaticup.Algorithmus;
import informaticup.Weltfunktion;
import informaticup.datenstruktur.*;
/**
* Algorithmus: Heurisitik: Greedy-Algorithmus mit Stichproben-Suche.
*/
public class GreedyStichprobe implements informaticup.Algorithmus {
// Zustand ohne bereits gesetzte Automaten
private Zustand _zustand;
// Zeiger auf die Weltfuntkion
private Weltfunktion _weltfunktion;
// Instanz der Greedy-Klasse (-> Doku)
private Greedy _greedy;
// GUI: Fortschrittsbalken
private Algorithmus.ProgressCallbackDelegate _progressDelegate = null;
/**
* Konstruktor der Algorithmus-Klasse: Variablen initialisieren.
* @param weltfunktion Weltfunktion
* @param zustand Zustand ohne Automaten
*/
public GreedyStichprobe(Weltfunktion weltfunktion, Zustand zustand) {
_weltfunktion = weltfunktion;
_zustand = zustand;
_greedy = new Greedy(weltfunktion, zustand);
_greedy.setStichproben(true);
}
/**
* Startet den eigentlichen Algorithmus aus der Greedy-Klasse.
* @param progressDelegate GUI: Fortschrittsbalken
* @throws AlgorithmusException Ausnahme
*/
public void Berechne(Algorithmus.ProgressCallbackDelegate progressDelegate) throws AlgorithmusException {
this._progressDelegate = progressDelegate;
// Algorithmus aus der Greedy-Klasse aufrufen
_greedy.Berechne(progressDelegate);
}
/**
* Gibt das Ergebnis mit den Automaten zurück.
* @return Zustand mit Automaten
*/
public Zustand getErgebnis() {
return _greedy.getErgebnis();
}
public int getFortschritt() {
return 0;
}
public String getStatusText() {
return "";
}
}
| [
"[email protected]"
]
| |
da7eb42a1647ce5b5423f0d22a46026a42c57ade | 57ee988f58e7dbdeffcbe1ce58b566f71452bcd0 | /app/src/main/java/com/wuxiantao/wxt/ui/popupwindow/RedBagWithdrawalPopupWindow.java | 5a8d31846251eb9c456bff69390018399c043bf1 | []
| no_license | AndroidLwk/android_unlimited | 52d0e75533f80a8eacb75d368b28f0cf88b1dedc | 67fb33539f75d47cebcaf6cbc5718991a3e5db87 | refs/heads/master | 2022-10-17T10:36:10.593566 | 2020-06-08T01:36:17 | 2020-06-08T01:36:17 | 270,985,317 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,156 | java | package com.wuxiantao.wxt.ui.popupwindow;
import android.content.Context;
import com.wuxiantao.wxt.R;
import com.wuxiantao.wxt.ui.popupwindow.base.BaseBuild;
import com.wuxiantao.wxt.ui.popupwindow.base.BasePopupWindow;
/**
* Company:成都可信网络科技有限责任公司
* FileName:ActivationFriendPopupWindow
* Author:android
* Mail:[email protected]
* Date:19-6-19 上午10:44
* Description:${DESCRIPTION} 红包取现
*/
public class RedBagWithdrawalPopupWindow extends BasePopupWindow {
public RedBagWithdrawalPopupWindow(Build build) {
super(build);
}
public static class Build extends BaseBuild {
private OnPopupClickListener listener;
private boolean isShare;
public Build(Context context) {
super(context, R.layout.popupwindow_withdrawal_red_bag,true);
setOnButtonListener(R.id.popup_withdrawal_red_bg_share,R.id.popup_withdrawal_red_bg_close);
}
public Build setOnPopupClickListener(OnPopupClickListener l){
this.listener = l;
return this;
}
public Build setPopupWindowAnimStyle(int animationStyle) {
super.setPopupWindowAnimStyle(animationStyle);
return this;
}
public Build setMoneyText(String money){
if (!isEmpty(money)){
setText(money,R.id.popup_withdrawal_red_bg_money);
}
return this;
}
@Override
public void onWindowDismiss() {
if (listener != null) {
listener.onConfirm(isShare);
}
}
@Override
public BasePopupWindow builder() {
return new RedBagWithdrawalPopupWindow(this);
}
@Override
public void onClick(int viewId) {
if (viewId == R.id.popup_withdrawal_red_bg_share) {
isShare = true;
}
else if (viewId == R.id.popup_withdrawal_red_bg_close){
isShare = false;
}
}
public interface OnPopupClickListener{
void onConfirm(boolean isShare);
}
}
}
| [
"jason1985"
]
| jason1985 |
e067199dd84ff8d4a34b6f7046714cf4bd03091a | ac587620c4335c93f78d22afc63bdf4f7a2f410f | /app/src/main/java/com/example/sikandermangat/click/Adapters/StoryViewAdapter.java | 7497bb9a1d02b280b96cd35c1e17aeee5cbf54c7 | []
| no_license | Sikander-Singh/Click | 775156b732254bfc7529b66f3e83e0894e23818c | eb3c469cfd50a526f17fcebde20416d30e3f960e | refs/heads/master | 2020-03-12T08:40:21.845069 | 2018-04-22T03:48:25 | 2018-04-22T03:48:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,124 | java | package com.example.sikandermangat.click.Adapters;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.example.sikandermangat.click.Image;
import com.example.sikandermangat.click.Model.StoryClass;
import com.example.sikandermangat.click.R;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
public class StoryViewAdapter extends BaseAdapter {
private Context context;
private FirebaseStorage firebaseStorage;
private StorageReference ref;
private ProgressBar progressBar;
private ImageView image;
private TextView storyTitle;
private Bitmap bmp;
List<StoryClass> list=new ArrayList<>();
public StoryViewAdapter(Context context,List<StoryClass> list) {
this.context=context;
this.list=list;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
final LayoutInflater layoutInflater = LayoutInflater.from(context);
convertView = layoutInflater.inflate(R.layout.stories_row, null);
}
storyTitle = (TextView)convertView.findViewById(R.id.storyTitle);
image = (ImageView)convertView.findViewById(R.id.story_image);
progressBar=convertView.findViewById(R.id.storyProgress);
RelativeLayout layout=(RelativeLayout)convertView.findViewById(R.id.story_list_layout);
if(list.size()>0) {
ref = firebaseStorage.getInstance().getReference().child(list.get(position).getStoryImaage());
final long ONE_MEGABYTE = 2048 * 2048;
ref.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
@Override
public void onSuccess(byte[] bytes) {
bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
image.setScaleType(ImageView.ScaleType.CENTER_CROP);
image.setImageBitmap(bmp);
//image.setImageBitmap(Bitmap.createScaledBitmap(bmp, image.getWidth(),image.getHeight(), false));
storyTitle.setText("Story");
progressBar.setVisibility(View.GONE);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
progressBar.setVisibility(View.GONE);
Toast.makeText(context, "Unable to unload picture", Toast.LENGTH_SHORT);
}
});
}
layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
Intent intent=new Intent(context,Image.class);
intent.putExtra("picture", byteArray);
context.startActivity(intent);
}
});
return convertView;
}
}
| [
"[email protected]"
]
| |
e0fd0509215cdb16b0e06df406501688da644f98 | 2e1fb2fab4672c1fde8421aea272b5480df461c6 | /src/main/java/com/splitbill/splitbillapp/customer/Customer.java | 186769768ccd189e7356b7a43ffdf42f4e608e2a | []
| no_license | shreyans-sureja/SpliteBill | 159b1d2006a31c296316df77b3c6c81f9ee772a0 | 38d192a962cc02b9d2b944248f1878d3f12b5dbf | refs/heads/master | 2022-09-12T15:01:48.206548 | 2020-05-29T03:04:43 | 2020-05-29T03:04:43 | 263,818,552 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,223 | java | package com.splitbill.splitbillapp.customer;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.splitbill.splitbillapp.team.Team;
import com.splitbill.splitbillapp.teamTransaction.TeamTransaction;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class Customer {
@Id
private String id;
@NotNull
private String name;
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
@NotNull
private String password;
@JsonIgnore
@ManyToMany(mappedBy = "customers")
private List<Team> teams = new ArrayList<>();
@JsonIgnore
@OneToMany(mappedBy = "teamTransactionId.customer")
private List<TeamTransaction> teamTransactions;
}
| [
"[email protected]"
]
| |
4397053e8ae9ae0b42fe6e4ab1f90fa28f540e5b | 7f20b1bddf9f48108a43a9922433b141fac66a6d | /core3/viewmodel-api/branches/vp-tree/src/test/java/org/cytoscape/view/model/AbstractViewTest.java | aae66c2206fa68ffa23292b7a9e38a3401db28ef | []
| no_license | ahdahddl/cytoscape | bf783d44cddda313a5b3563ea746b07f38173022 | a3df8f63dba4ec49942027c91ecac6efa920c195 | refs/heads/master | 2020-06-26T16:48:19.791722 | 2013-08-28T04:08:31 | 2013-08-28T04:08:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,523 | java | package org.cytoscape.view.model;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
public abstract class AbstractViewTest<S> {
protected VisualProperty<Integer> integerVP;
protected VisualProperty<String> stringVP;
protected View<S> view;
@Before
public void setUp() throws Exception {
integerVP = new IntegerVisualProperty(Integer.valueOf(0), "integerVP", "INTVP");
stringVP = new StringVisualProperty("", "stringVP", "STRVP");
}
@Test
public void testVisualPropertyGetterAndSetter() {
view.setVisualProperty(integerVP, 1);
assertEquals(Integer.valueOf(1), view.getVisualProperty(integerVP));
// For Null, return default value.
view.setVisualProperty(integerVP, null);
assertNotNull(view.getVisualProperty(integerVP));
view.setVisualProperty(integerVP,-12345);
assertEquals(Integer.valueOf(-12345), view.getVisualProperty(integerVP));
view.setVisualProperty(stringVP, "Test string.");
assertEquals("Test string.", view.getVisualProperty(stringVP));
view.setVisualProperty(stringVP, "");
assertEquals("", view.getVisualProperty(stringVP));
// For Null, return default value.
view.setVisualProperty(stringVP, null);
assertNotNull(view.getVisualProperty(stringVP));
}
@Test
public void testLock() {
final Integer unlocked = 123;
final Integer locked = 1000;
view.setVisualProperty(integerVP, unlocked);
assertFalse(view.isValueLocked(integerVP));
view.setLockedValue(integerVP, locked);
assertTrue(view.isValueLocked(integerVP));
assertEquals(locked, view.getVisualProperty(integerVP));
view.clearValueLock(integerVP);
assertEquals(unlocked, view.getVisualProperty(integerVP));
}
@Test
public void testAddViewChangeListener() {
// ViewChangeListener mock = createMock(ViewChangeListener.class);
// mock.visualPropertySet(integerVP,5);
// replay(mock);
// view.addViewChangeListener( mock );
// view.setVisualProperty(integerVP,5);
//
// verify(mock);
}
@Test
public void testRemoveViewChangeListener() {
// ViewChangeListener mock = createMock(ViewChangeListener.class);
// mock.visualPropertySet(integerVP,5);
// replay(mock);
// view.addViewChangeListener( mock );
// view.setVisualProperty(intVP,5);
//
// view.removeViewChangeListener( mock );
// view.setVisualProperty(intVP,10);
//
// verify(mock);
}
}
| [
"kono@0ecc0d97-ab19-0410-9704-bfe1a75892f5"
]
| kono@0ecc0d97-ab19-0410-9704-bfe1a75892f5 |
870d1149a3b54fc3c4a0c674db7f7d67b92b6852 | 5cf22a2d9d3cf770f5698429ceb614971ec1c0be | /src/main/java/com/zjg/collect/service/impl/RecordServiceImpl.java | b4345a1f2e36ed196f6d7c20e2f80ad0fa371311 | []
| no_license | GHBigBig/collect | d8c60adbd186c788d5428cb41e323edcff442cd6 | 5a388808b30670d41bcea1bdbe80161435a7bb98 | refs/heads/master | 2021-01-02T01:51:41.787372 | 2020-02-10T06:18:54 | 2020-02-10T06:18:54 | 239,441,801 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 874 | java | package com.zjg.collect.service.impl;
import com.zjg.collect.dao.mapper.RecordMapper;
import com.zjg.collect.dao.model.Record;
import com.zjg.collect.service.RecordService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author zjg
* @create 2020-02-03 20:18
*/
@Service
public class RecordServiceImpl implements RecordService {
private static final Logger LOGGER = LoggerFactory.getLogger(RecordServiceImpl.class);
@Autowired
private RecordMapper recordMapper;
@Override
public int addRecord(Record record) {
LOGGER.debug("###添加 record : {}###", record);
int insert = recordMapper.insert(record);
LOGGER.debug("###添加操作影响 {} 行记录###", insert);
return insert;
}
}
| [
"[email protected]"
]
| |
283bfbab084cbfc8355e2ac303d830b6cd9c15bd | d997583b689adeb65c21b6db864a97b3587954d5 | /src/main/java/com/training/app/model/Customer.java | ace464e88a62f7fba0540f7f7d2f45094480c027 | []
| no_license | apache888/TestDB | 24ebb64d69d529ad52b0d0e21eed0f5b74d800e6 | 5723df1d900a8a4982c58613e9f148455bd67f4b | refs/heads/master | 2021-01-22T20:35:34.278093 | 2017-07-05T08:12:23 | 2017-07-05T08:12:23 | 85,335,402 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,450 | java | package com.training.app.model;
import javax.persistence.*;
import java.util.Set;
/**
* Create on 24.03.2017.
* @author Roman Hayda
*
* Class describes entity Customer
*/
@Entity
@Table(name = "customers", catalog = "it_test_db")
public class Customer extends BaseObject {
@ManyToMany
@JoinTable(name="customers_projects",
joinColumns= @JoinColumn(name="customer_id", referencedColumnName="id"),
inverseJoinColumns= @JoinColumn(name="project_id", referencedColumnName="id")
)
private Set<Project> customerProjects;
public Customer() {
}
public Customer(int id, String name) {
super(id, name);
}
public Set<Project> getCustomerProjects() {
return customerProjects;
}
public void setCustomerProjects(Set<Project> customerProjects) {
this.customerProjects = customerProjects;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder("Customer{" +
"id=" + id +
", name='" + name + '\'' +
", projects:\n");
for (Project project : customerProjects) {
builder.append("Project{id=");
builder.append(project.getId());
builder.append(", name='");
builder.append(project.getName());
builder.append("\'},\n");
}
return builder.substring(0, builder.length() - 2) + "}\n";
}
}
| [
"[email protected]"
]
| |
978b75a36f39b1548cf0918e83fbb64abe144204 | 56cf34c40c5048b7b5f9a257288bba1c34b1d5e2 | /src/org/xpup/hafmis/syscollection/chgbiz/chgorgrate/action/OrgChgAAC.java | 17632d54cb1215ec241a60c929ff3931be5a7a86 | []
| no_license | witnesslq/zhengxin | 0a62d951dc69d8d6b1b8bcdca883ee11531fbb83 | 0ea9ad67aa917bd1911c917334b6b5f9ebfd563a | refs/heads/master | 2020-12-30T11:16:04.359466 | 2012-06-27T13:43:40 | 2012-06-27T13:43:40 | null | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 3,291 | java | package org.xpup.hafmis.syscollection.chgbiz.chgorgrate.action;
import java.math.BigDecimal;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.xpup.common.exception.BusinessException;
import org.xpup.common.util.BSUtils;
import org.xpup.hafmis.common.util.BusiConst;
import org.xpup.hafmis.common.util.BusiTools;
import org.xpup.hafmis.orgstrct.dto.SecurityInfo;
import org.xpup.hafmis.syscollection.chgbiz.chgorgrate.bsinterface.IChgorgrateBS;
import org.xpup.hafmis.syscollection.common.domain.entity.Org;
public class OrgChgAAC extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
response.setContentType("text/html;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
String text;
try {
String orgID = request.getParameter("orgID");
IChgorgrateBS chgorgrateBS = (IChgorgrateBS) BSUtils.getBusinessService(
"chgorgrateBS", this, mapping.getModuleConfig());
SecurityInfo securityInfo = (SecurityInfo) request.getSession()
.getAttribute("SecurityInfo");
Org org = chgorgrateBS.queryOrgByorgIDYg(orgID, securityInfo);
if (org == null) {
throw new BusinessException("无此单位信息!");
}
String orgid = BusiTools.convertTenNumber(orgID);
String orgname = org.getOrgInfo().getName();
String orgaddress = org.getOrgInfo().getAddress() == null ? "" : org
.getOrgInfo().getAddress();
String orgdep = "";
String orgcharacter = BusiTools.getBusiValue(Integer.parseInt(org
.getOrgInfo().getCharacter()), BusiConst.NATUREOFUNITS);
String orgtransactorname = "";
String orgtransactortelephone = "";
if (org.getOrgInfo().getTransactor() != null) {
orgtransactorname = org.getOrgInfo().getTransactor().getName() == null ? ""
: org.getOrgInfo().getTransactor().getName();
orgtransactortelephone = org.getOrgInfo().getTransactor()
.getTelephone() == null ? "" : org.getOrgInfo().getTransactor()
.getTelephone();
}
int orgcount = chgorgrateBS.queryPersonCountByOrgID(orgID);
BigDecimal preRate = org.getOrgRate();
BigDecimal prePay = org.getSumPay()==null?new BigDecimal(0):org.getSumPay();
text = "displays('" + orgid + "','" + orgname + "','" + orgaddress
+ "','" + orgdep + "','" + orgcharacter + "','" + orgtransactorname
+ "','" + orgtransactortelephone + "','" + orgcount + "','" + preRate
+ "','" + prePay + "')";
response.getWriter().write(text);
response.getWriter().close();
} catch (BusinessException be) {
be.printStackTrace();
text = "backErrors('" + be.getLocalizedMessage() + "')";
response.getWriter().write(text);
response.getWriter().close();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
| [
"[email protected]"
]
| |
01b420748b89abac634f4684e52285c0ed9db8c2 | 92f7ba1ebc2f47ecb58581a2ed653590789a2136 | /src/com/infodms/dms/actions/parts/salesManager/carFactorySalesManager/PartDlrOrderCheck.java | 52235b059ec9772521e4c68909291c83e60aa804 | []
| no_license | dnd2/CQZTDMS | 504acc1883bfe45842c4dae03ec2ba90f0f991ee | 5319c062cf1932f8181fdd06cf7e606935514bf1 | refs/heads/master | 2021-01-23T15:30:45.704047 | 2017-09-07T07:47:51 | 2017-09-07T07:47:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 169,803 | java | package com.infodms.dms.actions.parts.salesManager.carFactorySalesManager;
import com.infodms.dms.actions.sales.planmanage.PlanUtil.BaseImport;
import com.infodms.dms.bean.AclUserBean;
import com.infodms.dms.bean.OrgBean;
import com.infodms.dms.common.Arith;
import com.infodms.dms.common.Constant;
import com.infodms.dms.common.ErrorCodeConstant;
import com.infodms.dms.common.materialManager.MaterialGroupManagerDao;
import com.infodms.dms.constants.PTConstants;
import com.infodms.dms.dao.parts.baseManager.partsBaseManager.PartWareHouseDao;
import com.infodms.dms.dao.parts.purchaseManager.partPlanConfirm.PartPlanConfirmDao;
import com.infodms.dms.dao.parts.purchaseManager.purchasePlanSetting.PurchasePlanSettingDao;
import com.infodms.dms.dao.parts.salesManager.PartDlrOrderDao;
import com.infodms.dms.dao.parts.salesManager.PartSoManageDao;
import com.infodms.dms.dao.parts.salesManager.PartTransPlanDao;
import com.infodms.dms.dao.sales.ordermanage.orderreport.MarketPartDlrOrderDao;
import com.infodms.dms.exception.BizException;
import com.infodms.dms.po.*;
import com.infodms.dms.util.CheckUtil;
import com.infodms.dms.util.CommonUtils;
import com.infodms.dms.util.OrderCodeManager;
import com.infodms.dms.util.sequenceUitl.SequenceManager;
import com.infoservice.mvc.context.ActionContext;
import com.infoservice.mvc.context.RequestWrapper;
import com.infoservice.mvc.context.ResponseWrapper;
import com.infoservice.po3.bean.PageResult;
import com.infoservice.po3.core.context.POContext;
import jxl.Workbook;
import jxl.write.Label;
import org.apache.log4j.Logger;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 配件订单审核
* @author
* @version
* @see
* @since
* @deprecated
*/
public class PartDlrOrderCheck extends BaseImport implements PTConstants {
private static final String PART_BO_QUERY = "/jsp/parts/salesManager/carFactorySalesManager/dlrOrderBoQuery.jsp";
private static final String PART_OEM_GX_ORDER_ADD = "/jsp/parts/salesManager/carFactorySalesManager/partOemGxOrderAdd.jsp";
public Logger logger = Logger.getLogger(PartDlrOrderCheck.class);
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
String PART_DIRECT_DLR_ORDER_CHECK_QUERY = "/jsp/parts/salesManager/carFactorySalesManager/partDirectDlrOrderQuery.jsp";
String PART_PLAN_DLR_ORDER_CHECK_QUERY = "/jsp/parts/salesManager/carFactorySalesManager/partPlanDlrOrderQuery.jsp";
String PART_MARKET_DLR_ORDER_CHECK_QUERY = "/jsp/parts/salesManager/carFactorySalesManager/partMarketDlrOrderQuery.jsp";
/**
* @param : @param response
* @param : @param request
* @param : @param head
* @param : @param list
* @param : @return
* @param : @throws Exception
* @return :
* @throws : LastDate : 2013-5-3
* @Title : 文件导出为xls文件
*/
public static Object exportEx(String fileName, ResponseWrapper response,
RequestWrapper request, String[] head, List<String[]> list)
throws Exception {
String name = fileName + ".xls";
jxl.write.WritableWorkbook wwb = null;
OutputStream out = null;
try {
response.setContentType("application/octet-stream");
response.addHeader("Content-disposition", "attachment;filename="
+ URLEncoder.encode(name, "utf-8"));
out = response.getOutputStream();
wwb = Workbook.createWorkbook(out);
jxl.write.WritableSheet ws = wwb.createSheet("sheettest", 0);
if (head != null && head.length > 0) {
for (int i = 0; i < head.length; i++) {
ws.addCell(new Label(i, 0, head[i]));
}
}
int pageSize = list.size() / 30000;
for (int z = 1; z < list.size() + 1; z++) {
String[] str = list.get(z - 1);
for (int i = 0; i < str.length; i++) {
/*ws.addCell(new Label(i, z, str[i]));*/ //modify by yuan
if (CheckUtil.checkFormatNumber1(str[i] == null ? "" : str[i])) {
ws.addCell(new jxl.write.Number(i, z, Double.parseDouble(str[i])));
} else {
ws.addCell(new Label(i, z, str[i]));
}
}
}
wwb.write();
out.flush();
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
if (null != wwb) {
wwb.close();
}
if (null != out) {
out.close();
}
}
return null;
}
public static Object exportEx(ResponseWrapper response,
RequestWrapper request, String[] head, List<String[]> list)
throws Exception {
String name = "配件订单审核列表.xls";
jxl.write.WritableWorkbook wwb = null;
OutputStream out = null;
try {
response.setContentType("application/octet-stream");
response.addHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(name, "utf-8"));
out = response.getOutputStream();
wwb = Workbook.createWorkbook(out);
jxl.write.WritableSheet ws = wwb.createSheet("sheettest", 0);
if (head != null && head.length > 0) {
for (int i = 0; i < head.length; i++) {
ws.addCell(new Label(i, 0, head[i]));
}
}
int pageSize = list.size() / 30000;
for (int z = 1; z < list.size() + 1; z++) {
String[] str = list.get(z - 1);
for (int i = 0; i < str.length; i++) {
ws.addCell(new Label(i, z, str[i]));
}
}
wwb.write();
out.flush();
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
if (null != wwb) {
wwb.close();
}
if (null != out) {
out.close();
}
}
return null;
}
/**
* 配件审核查询-初始化
*/
public void partDlrOrderCheckInit() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
boolean salerFlag = false;
RequestWrapper request = act.getRequest();
try {
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
String userType = null;
TtPartUserposeDefinePO userposeDefinePO = new TtPartUserposeDefinePO();
userposeDefinePO.setUserId(loginUser.getUserId());
if (dao.select(userposeDefinePO).size() > 0) {
userposeDefinePO = (TtPartUserposeDefinePO) dao.select(userposeDefinePO).get(0);
userType = userposeDefinePO.getUserType() + "";
}
List<Map<String, Object>> salerList = dao.getSaler(userType);
String dealerId = "";
PartWareHouseDao partWareHouseDao = PartWareHouseDao.getInstance();
List<OrgBean> beanList = partWareHouseDao.getOrgInfo(loginUser);
if (null != beanList || beanList.size() >= 0) {
dealerId = beanList.get(0).getOrgId() + "";
}
if (dealerId.equals(Constant.OEM_ACTIVITIES)) {
salerFlag = true;
}
Map<String, Object> map = new HashMap<String, Object>();
if (null != act.getSession().get("condition")) {
if (null != request.getParamValue("flag")) {
map = (Map) act.getSession().get("condition");
act.getSession().remove("condition");
} else {
act.getSession().remove("condition");
}
}
Map<String, String> orderType = new LinkedHashMap<String, String>();
orderType.put(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_02 + "", "常规订单");
orderType.put(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_01 + "", "紧急订单");
orderType.put(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_04 + "", "委托订单");
orderType.put(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_08 + "", "促销订单");
orderType.put(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_12 + "", "销售采购订单");
act.setOutData("orderType", orderType);
act.setOutData("condition", map);
act.setOutData("old", CommonUtils.getBefore(new Date()));
act.setOutData("now", CommonUtils.getDate());
act.setOutData("planFlag", "noPlan");
act.setOutData("curUserId", loginUser.getUserId());
act.setOutData("salerList", salerList);
act.setOutData("salerFlag", salerFlag);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
} catch (Exception e) {//异常方法
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "配件销售审核初始化错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-18
* @Title : PartDlrOrderDao
* @Description: 广宣品订单审核初始化
*/
public void partGxDlrOrderCheckInit() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
boolean salerFlag = false;
RequestWrapper request = act.getRequest();
try {
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
List<Map<String, Object>> salerList = dao.getSaler();
String dealerId = "";
PartWareHouseDao partWareHouseDao = PartWareHouseDao.getInstance();
List<OrgBean> beanList = partWareHouseDao.getOrgInfo(loginUser);
if (null != beanList || beanList.size() >= 0) {
dealerId = beanList.get(0).getOrgId() + "";
}
if (dealerId.equals(Constant.OEM_ACTIVITIES)) {
salerFlag = true;
}
Map<String, Object> map = new HashMap<String, Object>();
if (null != act.getSession().get("condition")) {
if (null != request.getParamValue("flag")) {
map = (Map) act.getSession().get("condition");
act.getSession().remove("condition");
} else {
act.getSession().remove("condition");
}
}
act.setOutData("condition", map);
act.setOutData("old", CommonUtils.getBefore(new Date()));
act.setOutData("now", CommonUtils.getDate());
act.setOutData("planFlag", "noPlan");
act.setOutData("curUserId", loginUser.getUserId());
act.setOutData("salerList", salerList);
act.setOutData("salerFlag", salerFlag);
act.setForword(PART_DLR_GXORDER_CHECK_QUERY);
} catch (Exception e) {//异常方法
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "配件销售审核初始化错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-18
* @Title : PartDlrOrderDao
* @Description: 配件销售审核初始化
*/
public void partDirectDlrOrderCheckInit() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String now = sdf.format(date);
act.setOutData("now", now);
act.setForword(PART_DIRECT_DLR_ORDER_CHECK_QUERY);
} catch (Exception e) {//异常方法
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "配件销售审核初始化错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-18
* @Title : PartDlrOrderDao
* @Description: 配件计划销售审核初始化
*/
public void partPlanDlrOrderCheckInit() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
act.setOutData("planFlag", "plan");
act.setForword(PART_PLAN_DLR_ORDER_CHECK_QUERY);
} catch (Exception e) {//异常方法
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "配件销售审核初始化错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-18
* @Title : PartDlrOrderDao
* @Description: 配件计划销售审核初始化
*/
public void partMarketDlrOrderCheckInit() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
act.setOutData("planFlag", "plan");
act.setForword(PART_MARKET_DLR_ORDER_CHECK_QUERY);
} catch (Exception e) {//异常方法
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "配件销售审核初始化错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
/**
* 配件订单审核-查询
* @param :
* @return :
* @throws : LastDate : 2013-4-18
* @Title :
* @Description: 配件销售审核查询
*/
public void partDlrOrderQuery() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
try {
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
//分页方法 begin
Integer curPage = request.getParamValue("curPage") != null ? Integer.parseInt(request.getParamValue("curPage")): 1; // 处理当前页
PageResult<Map<String, Object>> ps = null;
saveQueryCondition();
Map<String, Object> getSumResult = dao.querySumPartDlrOrder(request);
ps = dao.queryCheckPartDlrOrder(request, curPage, Constant.PAGE_SIZE);
act.setOutData("accountSum", getSumResult.get("AMOUNT"));
act.setOutData("xs", getSumResult.get("XS"));
act.setOutData("ps", ps);
} catch (Exception e) {
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "配件销售订单审核查询数据错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-18
* @Title :
* @Description: 广宣订单审核查询
*/
public void partDlrOrderGxQuery() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
try {
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
//分页方法 begin
Integer curPage = request.getParamValue("curPage") != null ? Integer
.parseInt(request.getParamValue("curPage"))
: 1; // 处理当前页
PageResult<Map<String, Object>> ps = null;
ps = dao.queryCheckPartDlrGxOrder(request, curPage, Constant.PAGE_SIZE);
act.setOutData("ps", ps);
} catch (Exception e) {
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "广宣订单审核查询失败,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-19
* @Title :
* @Description: 订单提报明细-查看
*/
public void detailDlrOrder() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
try {
MarketPartDlrOrderDao dao = MarketPartDlrOrderDao.getInstance();
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
String orderCode = CommonUtils.checkNull(request.getParamValue("orderCode"));
String showFlag = null;
if (loginUser.getDealerId() == null) {
showFlag = "1";
}
String buttonFalg = "";//采购订单查看 隐藏 【返回】按钮
if (null != request.getParamValue("buttonFalg")) {
buttonFalg = request.getParamValue("buttonFalg");
}
Map<String, Object> mainMap = dao.queryPartDlrOrderMain(orderId);
List<Map<String, Object>> detailList = dao.queryPartDlrOrderDetail(orderId);
List<Map<String, Object>> historyList = dao.queryOrderHistory(orderId);
Map<String, Object> transMap = this.getTransMap();
String transType = CommonUtils.checkNull(mainMap.get("TRANS_TYPE"));
transType = CommonUtils.checkNull(transMap.get(transType));
mainMap.put("TRANS_TYPE", transType);
request.setAttribute("mainMap", mainMap);
request.setAttribute("historyList", historyList);
request.setAttribute("detailList", detailList);
act.setOutData("buttonFalg", buttonFalg);
act.setOutData("orderId", orderId);
act.setOutData("showFlag", showFlag);
act.setForword(PART_DLR_ORDER_CHECK_DETAIL);
} catch (Exception e) {
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "配件销售提报查询数据错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-12-10
* @Title : 订单提报-订单明细导出
*/
public void exportOrderExcel() {
ActionContext act = ActionContext.getContext();
RequestWrapper request = act.getRequest();
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
// 订单单号
String orderCode = CommonUtils.checkNull(request.getParamValue("orderCode"));
// 订单ID
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
String[] head = new String[15];
head[0] = "序号";
head[1] = "配件编码";
head[2] = "配件名称";
head[3] = "最小包装量";
head[4] = "单位";
head[5] = "订货数量";
head[6] = "有效数量";
head[7] = "关闭数量";
head[8] = "订货单价";
head[9] = "有效订货金额";
head[10] = "备注";
if (logonUser.getDealerId() == null) {
head[11] = "当前库存";
}
List<Map<String, Object>> list = dao.queryPartDlrOrderDetail(orderId);
List list1 = new ArrayList();
if (list != null && list.size() != 0) {
for (int i = 0; i < list.size(); i++) {
Map map = (Map) list.get(i);
if (map != null && map.size() != 0) {
String[] detail = new String[15];
detail[0] = CommonUtils.checkNull(i + 1);
detail[1] = CommonUtils.checkNull(map.get("PART_OLDCODE"));
detail[2] = CommonUtils.checkNull(map.get("PART_CNAME"));
detail[3] = CommonUtils.checkNull(map.get("MIN_PACKAGE"));
detail[4] = CommonUtils.checkNull(map.get("UNIT"));
detail[5] = CommonUtils.checkNull(map.get("BUY_QTY"));
detail[6] = CommonUtils.checkNull(map.get("YX_QTY"));
detail[7] = CommonUtils.checkNull(map.get("CLOSE_QTY"));
detail[8] = CommonUtils.checkNull(map.get("BUY_PRICE"));
detail[9] = CommonUtils.checkNull(map.get("YX_AMOUNT"));
detail[10] = CommonUtils.checkNull(map.get("REMARK"));
if (logonUser.getDealerId() == null) {
detail[11] = CommonUtils.checkNull(map.get("STOCK_QTY"));
}
list1.add(detail);
}
}
}
String fileName = "订单" + orderCode + "明细";
this.exportEx(fileName, ActionContext.getContext().getResponse(),request, head, list1);
} catch (Exception e) {
BizException e1 = new BizException(act, e,
ErrorCodeConstant.SPECIAL_MEG, "导出采购订单明细失败");
logger.error(logonUser, e1);
act.setException(e1);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-19
* @Title :
* @Description: 选择经销商弹出页面
*/
public void selSales() {
ActionContext act = ActionContext.getContext();
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
RequestWrapper request = act.getRequest();
act.getResponse().setContentType("application/json");
String dealerId = CommonUtils.checkNull(request.getParamValue("dealerId"));
String type = CommonUtils.checkNull(request.getParamValue("type"));
String parentorgName = CommonUtils.checkNull(request.getParamValue("PARENTORG_NAME"));
String parentorgCode = CommonUtils.checkNull(request.getParamValue("PARENTORG_CODE"));
int page_size = Constant.PAGE_SIZE;
//分页方法 begin
Integer curPage = request.getParamValue("curPage") != null ? Integer
.parseInt(request.getParamValue("curPage"))
: 1; // 处理当前页
Integer poseBusType = logonUser.getPoseBusType();
PageResult<Map<String, Object>> ps = dao.getSalesRelation(dealerId, type, parentorgName, parentorgCode, "", page_size, curPage);
act.setOutData("ps", ps);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "获取数据错误!,请联系管理员!");
logger.error(logonUser, e1);
act.setException(e1);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-19
* @Title :
* @Description: 选择地址弹出页面
*/
public void selAddress() {
ActionContext act = ActionContext.getContext();
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
RequestWrapper request = act.getRequest();
act.getResponse().setContentType("application/json");
String dealerId = CommonUtils.checkNull(request.getParamValue("dealerId"));
String type = CommonUtils.checkNull(request.getParamValue("type"));
String parentorgName = CommonUtils.checkNull(request.getParamValue("PARENTORG_NAME"));
String parentorgCode = CommonUtils.checkNull(request.getParamValue("PARENTORG_CODE"));
int page_size = Constant.PAGE_SIZE;
//分页方法 begin
Integer curPage = request.getParamValue("curPage") != null ? Integer
.parseInt(request.getParamValue("curPage"))
: 1; // 处理当前页
Integer poseBusType = logonUser.getPoseBusType();
PageResult<Map<String, Object>> ps = dao.getAddress(dealerId, page_size, curPage);
act.setOutData("ps", ps);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "获取数据错误!,请联系管理员");
logger.error(logonUser, e1);
act.setException(e1);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-19
* @Title :
* @Description: 选择地址弹出页面
*/
public void getPartItemStock() {
ActionContext act = ActionContext.getContext();
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
RequestWrapper request = act.getRequest();
act.getResponse().setContentType("application/json");
String whId = CommonUtils.checkNull(request.getParamValue("whId"));
String partId = CommonUtils.checkNull(request.getParamValue("partId"));
if ("".equals(partId)) {
return;
}
partId = partId.replaceFirst(",", "");
String partArr[] = partId.split(",");
String dealerId = "";
//判断是否为车厂 PartWareHouseDao
PartWareHouseDao partWareHouseDao = PartWareHouseDao.getInstance();
List<OrgBean> beanList = partWareHouseDao.getOrgInfo(logonUser);
if (null != beanList || beanList.size() >= 0) {
dealerId = beanList.get(0).getOrgId() + "";
}
request.setAttribute("orgId", dealerId);
List<Map<String, Object>> list = new ArrayList();
for (int i = 0; i < partArr.length; i++) {
Map<String, Object> ps = dao.getPartItemStock(whId, partArr[i]);
if (null == ps) {
ps = new HashMap<String, Object>();
ps.put("PART_ID", partArr[i]);
ps.put("NORMAL_QTY", "0");
}
list.add(ps);
}
act.setOutData("list", list);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "获取数据错误!,请联系管理员");
logger.error(logonUser, e1);
act.setException(e1);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-19
* @Title :
* @Description: 查看配件
*/
public void showPartBase() {
ActionContext act = ActionContext.getContext();
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
act.getResponse().setContentType("application/json");
RequestWrapper req = act.getRequest();
try {
String dealerId = CommonUtils.checkNull(req.getParamValue("SELLER_ID"));
//分页方法 begin
Integer curPage = req.getParamValue("curPage") != null ? Integer.parseInt(req.getParamValue("curPage")): 1; // 处理当前页
PageResult<Map<String, Object>> ps = null;
ps = dao.showPartBase(req, dealerId, curPage, Constant.PAGE_SIZE);
act.setOutData("ps", ps);
} catch (Exception e) {//异常方法
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "查看配件信息出错,请联系管理员!");
logger.error(logonUser, e1);
act.setException(e1);
}
}
/**
* 保存日志 Tt_Part_Operation_History
* @param req
* @param act
* @param status
* @throws Exception
*/
public void saveHistory(String orderType,RequestWrapper req, ActionContext act, int status) throws Exception {
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
//订单编号
Long orderId = Long.valueOf(CommonUtils.checkNull(req.getParamValue("orderId")));
TtPartOperationHistoryPO po = new TtPartOperationHistoryPO();
Long optId = Long.parseLong(SequenceManager.getSequence(""));
po.setBussinessId(CommonUtils.checkNull(req.getParamValue("orderCode")));
po.setOptId(optId);
po.setOptBy(logonUser.getUserId());
po.setOptDate(new Date());
po.setOptType(Constant.PART_OPERATION_TYPE_01);
po.setWhat("配件订单审核");
po.setOptName(logonUser.getName());
po.setStatus(status);
po.setOrderId(orderId);
dao.insert(po);
if(!orderType.equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_04) &&
!orderType.equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_12)){
//还需要插入销售单保存初始历史
po = new TtPartOperationHistoryPO();
Long optId1 = Long.parseLong(SequenceManager.getSequence(""));
po.setBussinessId(CommonUtils.checkNull(req.getAttribute("soCode")));
po.setOptId(optId1);
po.setOptBy(logonUser.getUserId());
po.setOptDate(new Date());
po.setOptType(Constant.PART_OPERATION_TYPE_02);
po.setWhat("配件销售单");
po.setOptName(logonUser.getName());
po.setStatus(Constant.CAR_FACTORY_SALE_ORDER_STATE_01);
po.setOrderId(orderId);
dao.insert(po);
}
} catch (Exception ex) {
throw ex;
}
}
/**
* 审核订单-明细查看
*/
public void checkDlrOrder() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
try {
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
String accountPurpose = CommonUtils.checkNull(request.getParamValue("ACCOUNT_PURPOSE"));
//根据订单id查询订单信息
Map<String, Object> mainMap = dao.queryPartDlrOrderMain(orderId);
if (!(mainMap.get("STATE") + "").equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_02 + "")) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "订单状态已改变!请重新查询!");
throw e1;
}
String dealerId = "";
String flag = "";//用于前端是否展示供应商字段,1展示2不展示
PartWareHouseDao partWareHouseDao = PartWareHouseDao.getInstance();
List<OrgBean> beanList = partWareHouseDao.getOrgInfo(loginUser);
if (null != beanList || beanList.size() >= 0) {
dealerId = beanList.get(0).getOrgId() + "";
}
//折扣率
String discount = dao.getDiscount(mainMap.get("DEALER_ID").toString());
mainMap.put("discount", discount);
mainMap.put("saleName", loginUser.getName());
//获取账户
Map<String, Object> accountMap = dao.getAccountMoney(mainMap.get("DEALER_ID").toString(), mainMap.get("SELLER_ID").toString(), accountPurpose);
String accountSumNow = "";
String accountKyNow = "";
String accountDjNow = "";
boolean accountFlag = false;
if (null != accountMap) {
accountFlag = true;
accountSumNow = accountMap.get("ACCOUNT_SUM").toString();
accountKyNow = accountMap.get("ACCOUNT_KY").toString();
accountDjNow = accountMap.get("ACCOUNT_DJ").toString();
}
mainMap.put("accountFlag", accountFlag);
mainMap.put("accountSumNow", accountSumNow);
mainMap.put("accountKyNow", accountKyNow);
mainMap.put("accountDjNow", accountDjNow);
PurchasePlanSettingDao purchasePlanSettingDao = PurchasePlanSettingDao.getInstance();
List<OrgBean> lo = PartWareHouseDao.getInstance().getOrgInfo(loginUser);
List<Map<String, Object>> wareHouseList = purchasePlanSettingDao.getWareHouse(lo.get(0).getOrgId().toString());
List<Map<String, Object>> wareHouseFacList = null;
//20170904 屏蔽 start
// String sellerId = CommonUtils.checkNull(mainMap.get("SELLER_ID"));
// if (sellerId.equals(Constant.OEM_ACTIVITIES + "")) {
// wareHouseList = dao.getWareHouse(lo.get(0).getOrgId().toString(), CommonUtils.checkNull(mainMap.get("PRODUCE_FAC")));
// wareHouseFacList = dao.getWareHouseFac(lo.get(0).getOrgId().toString(), CommonUtils.checkNull(mainMap.get("PRODUCE_FAC")));//产地,众泰没有
// }
//20170904 屏蔽 end
//查询订单明细并取销售价格
List<Map<String, Object>> detailList = dao.queryPartDlrOrderDetail4SODTL(orderId, wareHouseList.get(0).get("WH_ID").toString());
//委托订单、销售采购订单审核(便于前台展示制造商,暂时不用)
if (CommonUtils.checkNull(mainMap.get("ORDER_TYPE")).equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_04 + "")
|| CommonUtils.checkNull(mainMap.get("ORDER_TYPE")).equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_12 + "")) {
if (dealerId.equals(Constant.OEM_ACTIVITIES)) {
flag = "1";
// for (Map<String, Object> map : detailList) {
// String partId = map.get("PART_ID").toString();
// List<Map<String, Object>> venderList = dao.getStoVender(CommonUtils.checkNull(map.get("DEFT_ID")));
//
// if (venderList != null && venderList.size() > 0 && venderList.get(0) != null) {
// map.put("venderId", CommonUtils.checkNull(venderList.get(0).get("VENDER_ID")));
// map.put("venderName", CommonUtils.checkNull(venderList.get(0).get("VENDER_NAME")));
// }
// }
} else {
flag = "2";
}
}
List<Map<String, Object>> historyList = dao.queryOrderHistory(orderId);
// List list = CommonUtils.getPartUnitList(Constant.FIXCODE_TYPE_04);// 获取配件发运方式
PartTransPlanDao daoTrans=PartTransPlanDao.getInstance();
List list = daoTrans.getTransportType();// 获取配件发运方式
//获取服务商联系人和联系方式
String orderDealerId = CommonUtils.checkNull(mainMap.get("DEALER_ID"));
Map<String, Object> map = dao.getAddrMap(orderDealerId);
Map<String, Object> dealerMap = dao.getDealerName(orderDealerId);
request.setAttribute("phone", CommonUtils.checkNull(dealerMap.get("TEL")));
request.setAttribute("linkMan", CommonUtils.checkNull(dealerMap.get("LINKMAN")));
request.setAttribute("phone2", CommonUtils.checkNull(map.get("TEL2")));
request.setAttribute("linkMan2", CommonUtils.checkNull(map.get("LINKMAN2")));
request.setAttribute("transList", list);
request.setAttribute("wareHouseList", wareHouseList);
request.setAttribute("wareHouseFacList", wareHouseFacList);
request.setAttribute("mainMap", mainMap);
request.setAttribute("historyList", historyList);
request.setAttribute("detailList", detailList);
request.setAttribute("flag", flag);
request.setAttribute("planFlag", CommonUtils.checkNull(request.getParamValue("planFlag")));
request.setAttribute("oemFlag", CommonUtils.checkNull(mainMap.get("OEM_FLAG")));
request.setAttribute("produceFac", CommonUtils.checkNull(mainMap.get("PRODUCE_FAC")));
act.setForword(PART_DLR_ORDER_CHECK_CHECK);
} catch (Exception e) {
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "配件销售提报查询数据错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-19
* @Title :
* @Description: 审核广宣订单
*/
public void checkDlrGxOrder() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
try {
MarketPartDlrOrderDao dao = MarketPartDlrOrderDao.getInstance();
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
String accountPurpose = CommonUtils.checkNull(request.getParamValue("ACCOUNT_PURPOSE"));
Map<String, Object> mainMap = dao.queryPartDlrOrderMain(orderId);
if (!(mainMap.get("STATE") + "").equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_02 + "")) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "订单状态已改变!请重新查询!");
throw e1;
}
String orgId = "";
String flag = "";
String dealerId = "";
PartWareHouseDao partWareHouseDao = PartWareHouseDao.getInstance();
List<OrgBean> beanList = partWareHouseDao.getOrgInfo(loginUser);
if (null != beanList || beanList.size() >= 0) {
orgId = beanList.get(0).getOrgId() + "";
}
dealerId = mainMap.get("DEALER_ID").toString();
mainMap.put("discount", 1);
mainMap.put("saleName", loginUser.getName());
//获取账户
List<Map<String, Object>> dealerBusinessArea = MaterialGroupManagerDao.getDealerBusinessArea(mainMap.get("DEALER_ID").toString());
String yieldId = dealerBusinessArea.get(0).get("AREA_ID").toString();
PageResult<Map<String, Object>> ps = dao.getSalesRelation(dealerId, yieldId, "1", "", "", "", Constant.PAGE_SIZE_MAX, 1);
List<Map<String, Object>> acountMap = ps.getRecords();
Map<String, Object> accMap = acountMap.get(0);
String accountSumNow = "";
String accountKyNow = "";
String accountDjNow = "";
boolean accountFlag = false;
if (null != accMap) {
accountFlag = true;
accountSumNow = accMap.get("ACCOUNT_SUM").toString();
accountKyNow = accMap.get("ACCOUNT_KY").toString();
accountDjNow = accMap.get("ACCOUNT_DJ").toString();
}
mainMap.put("accountFlag", accountFlag);
mainMap.put("accountSumNow", accountSumNow);
mainMap.put("accountKyNow", accountKyNow);
mainMap.put("accountDjNow", accountDjNow);
PurchasePlanSettingDao purchasePlanSettingDao = PurchasePlanSettingDao.getInstance();
List<OrgBean> lo = PartWareHouseDao.getInstance().getOrgInfo(loginUser);
List<Map<String, Object>> wareHouseList = purchasePlanSettingDao.getWareHouse(lo.get(0).getOrgId().toString(), "2");
String sellerId = CommonUtils.checkNull(mainMap.get("SELLER_ID"));
/*if(sellerId.equals(Constant.OEM_ACTIVITIES+"")){
wareHouseList = dao.getWareHouse(lo.get(0).getOrgId().toString(), CommonUtils.checkNull(mainMap.get("PRODUCE_FAC")));
}*/
//查询订单明细并取销售价格
List<Map<String, Object>> detailList = dao.queryPartDlrOrderDetail4SODTL(orderId, wareHouseList.get(0).get("WH_ID").toString());
Long allBuyQty = 0l;
List<Map<String, Object>> detailList1 = new ArrayList<Map<String, Object>>();
for (Map<String, Object> map : detailList) {
String partId = map.get("PART_ID").toString();
Long buyQty = ((BigDecimal) map.get("BUY_QTY")).longValue();
allBuyQty += buyQty;
//获取当前配件已经提报的数量
Map map1 = dao.getReportedQty(orderId, partId);
Long reportedQty = ((BigDecimal) map1.get("REPORTED_QTY")).longValue();
map.put("reportQty", buyQty - reportedQty);
map.put("checkQty", reportedQty);
if (buyQty > reportedQty) {
detailList1.add(map);
}
}
List<Map<String, Object>> historyList = dao.queryOrderHistory(orderId);
List list = CommonUtils.getPartUnitList(Constant.FIXCODE_TYPE_04);// 获取配件发运方式
//获取服务商联系人和联系方式
String orderDealerId = CommonUtils.checkNull(mainMap.get("DEALER_ID"));
Map<String, Object> map = dao.getSalesRelation(dealerId, null, "3", "", "", "", 10, 1).getRecords().get(0);
//获取当前时间
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String now = sdf.format(date);
act.setOutData("now", now);
request.setAttribute("phone2", CommonUtils.checkNull(map.get("TEL2")));
request.setAttribute("linkMan2", CommonUtils.checkNull(map.get("LINKMAN2")));
request.setAttribute("transList", list);
request.setAttribute("wareHouseList", wareHouseList);
request.setAttribute("mainMap", mainMap);
request.setAttribute("historyList", historyList);
request.setAttribute("detailList", detailList1);
request.setAttribute("flag", flag);
request.setAttribute("allBuyQty", allBuyQty);
request.setAttribute("planFlag", CommonUtils.checkNull(request.getParamValue("planFlag")));
act.setForword(PART_DLR_ORDER_CHECK_GX);
} catch (Exception e) {
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_GXORDER_CHECK_QUERY);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "广宣订单审核失败,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_GXORDER_CHECK_QUERY);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-19
* @Title :
* @Description: 审核计划订单
*/
public void checkPlanDlrOrder() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
try {
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
String accountPurpose = CommonUtils.checkNull(request.getParamValue("ACCOUNT_PURPOSE"));
Map<String, Object> mainMap = dao.queryPartDlrOrderMain(orderId);
String dealerId = "";
String flag = "";
PartWareHouseDao partWareHouseDao = PartWareHouseDao.getInstance();
List<OrgBean> beanList = partWareHouseDao.getOrgInfo(loginUser);
if (null != beanList || beanList.size() >= 0) {
dealerId = beanList.get(0).getOrgId() + "";
}
//折扣率
String discount = dao.getDiscount(mainMap.get("DEALER_ID").toString());
mainMap.put("discount", discount);
mainMap.put("saleName", loginUser.getName());
//获取账户
Map<String, Object> accountMap = dao.getAccountMoney(mainMap.get("DEALER_ID").toString(), mainMap.get("SELLER_ID").toString(), accountPurpose);
String accountSumNow = "";
String accountKyNow = "";
String accountDjNow = "";
boolean accountFlag = false;
if (null != accountMap) {
accountFlag = true;
accountSumNow = accountMap.get("ACCOUNT_SUM").toString();
accountKyNow = accountMap.get("ACCOUNT_KY").toString();
accountDjNow = accountMap.get("ACCOUNT_DJ").toString();
}
mainMap.put("accountFlag", accountFlag);
mainMap.put("accountSumNow", accountSumNow);
mainMap.put("accountKyNow", accountKyNow);
mainMap.put("accountDjNow", accountDjNow);
List<Map<String, Object>> list = dao.queryPartDlrOrderDetail(orderId);
List<Map<String, Object>> detailList = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> soMainList = dao.getSoMain(orderId);
//如果没做过 销售单越过
if (null != soMainList) {
if (soMainList.size() > 0) {
String soIds = "";
for (Map<String, Object> map : soMainList) {
String soId = CommonUtils.checkNull(map.get("SO_ID"));
soIds += "," + soId;
}
if (!"".equals(soIds)) {
soIds = soIds.replaceFirst(",", "");
}
//做过销售单
for (Map<String, Object> map : list) {
String partId = CommonUtils.checkNull(map.get("PART_ID"));
Long saleQty = dao.getSoDetailPartNum(soIds, partId);
Long buyQty = Long.valueOf(CommonUtils.checkNull(map.get("BUY_QTY")));
if (buyQty <= saleQty) {
continue;
} else {
Long qty = buyQty - saleQty;
map.put("BUY_QTY", qty);
detailList.add(map);
}
}
} else {
detailList = list;
}
} else {
detailList = list;
}
List<Map<String, Object>> historyList = dao.queryOrderHistory(orderId);
PurchasePlanSettingDao purchasePlanSettingDao = PurchasePlanSettingDao.getInstance();
List<OrgBean> lo = PartWareHouseDao.getInstance().getOrgInfo(loginUser);
List<Map<String, Object>> wareHouseList = purchasePlanSettingDao.getWareHouse(lo.get(0).getOrgId().toString());
List transList = CommonUtils.getPartUnitList(Constant.FIXCODE_TYPE_04);// 获取配件发运方式
//获取服务商联系人和联系方式
String orderDealerId = CommonUtils.checkNull(mainMap.get("DEALER_ID"));
Map<String, Object> map = dao.getDealerName(orderDealerId);
request.setAttribute("phone", CommonUtils.checkNull(map.get("PHONE")));
request.setAttribute("linkMan", CommonUtils.checkNull(map.get("LINK_MAN")));
request.setAttribute("transList", transList);
request.setAttribute("wareHouseList", wareHouseList);
request.setAttribute("mainMap", mainMap);
request.setAttribute("historyList", historyList);
request.setAttribute("detailList", detailList);
request.setAttribute("flag", flag);
request.setAttribute("planFlag", CommonUtils.checkNull(request.getParamValue("planFlag")));
act.setForword(PART_DLR_ORDER_CHECK_CHECK);
} catch (Exception e) {
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_PLAN_DLR_ORDER_CHECK_QUERY);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "配件销售提报查询数据错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_PLAN_DLR_ORDER_CHECK_QUERY);
}
}
/**
* @param : @param orgAmt
* @param : @return
* @return :
* @throws : LastDate : 2013-4-3
* @Title :
* @Description:导出
*/
public void exportPartPlanExcel() {
ActionContext act = ActionContext.getContext();
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
RequestWrapper request = act.getRequest();
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
String[] head = new String[13];
head[0] = "订单号 ";
head[1] = "订货单位编码";
head[2] = "订货单位";
head[3] = "订货人";
head[4] = "订货日期";
head[5] = "销售单位";
head[6] = "订货次数";
head[7] = "订单类型";
head[8] = "总金额";
head[9] = "提交时间";
head[10] = "订单状态";
head[11] = "备注";
PageResult<Map<String, Object>> list = dao.queryCheckPartDlrOrder(request, 1, 9999);
List list1 = new ArrayList();
if (list.getRecords() != null) {
for (int i = 0; i < list.getRecords().size(); i++) {
Map map = (Map) list.getRecords().get(i);
if (map != null && map.size() != 0) {
String[] detail = new String[13];
detail[0] = CommonUtils.checkNull(map.get("ORDER_CODE"));
detail[1] = CommonUtils.checkNull(map.get("DEALER_CODE"));
detail[2] = CommonUtils.checkNull(map.get("DEALER_NAME"));
detail[3] = CommonUtils.checkNull(map.get("BUYER_NAME"));
detail[4] = CommonUtils.checkNull(map.get("CREATE_DATE"));
detail[5] = CommonUtils.checkNull(map.get("SELLER_NAME"));
detail[6] = CommonUtils.checkNull(map.get("ORDER_NUM"));
detail[7] = CommonUtils.checkNull(map.get("ORDER_TYPE"));
detail[8] = CommonUtils.checkNull(map.get("ORDER_AMOUNT"));
detail[9] = CommonUtils.checkNull(map.get("CREATE_DATE"));
detail[10] = CommonUtils.checkNull(map.get("STATE"));
detail[11] = CommonUtils.checkNull(map.get("REMARK"));
list1.add(detail);
}
}
}
this.exportEx(ActionContext.getContext().getResponse(), request, head, list1);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "");
logger.error(logonUser, e1);
act.setException(e1);
}
}
/**
* @param : @param orgAmt
* @param : @return
* @return :
* @throws : LastDate : 2013-4-3
* @Title :
* @Description:导出
*/
public void exportPartGxExcel() {
ActionContext act = ActionContext.getContext();
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
RequestWrapper request = act.getRequest();
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
String[] head = new String[9];
head[0] = "订单号 ";
head[1] = "订货单位编码";
head[2] = "订货单位";
head[3] = "订货人";
head[4] = "订货日期";
head[5] = "销售单位";
head[6] = "总金额";
head[7] = "提交时间";
head[8] = "订单状态";
List<Map<String, Object>> list = dao.queryCheckPartDlrGxOrder(request);
List list1 = new ArrayList();
for (int i = 0; i < list.size(); i++) {
Map map = (Map) list.get(i);
if (map != null && map.size() != 0) {
String[] detail = new String[9];
detail[0] = CommonUtils.checkNull(map.get("ORDER_CODE"));
detail[1] = CommonUtils.checkNull(map.get("DEALER_CODE"));
detail[2] = CommonUtils.checkNull(map.get("DEALER_NAME"));
detail[3] = CommonUtils.checkNull(map.get("BUYER_NAME"));
detail[4] = CommonUtils.checkNull(map.get("CREATE_DATE"));
detail[5] = CommonUtils.checkNull(map.get("SELLER_NAME"));
detail[6] = CommonUtils.checkNull(map.get("ORDER_AMOUNT"));
detail[7] = CommonUtils.checkNull(map.get("CREATE_DATE"));
detail[8] = CommonUtils.checkNull(map.get("STATE"));
list1.add(detail);
}
}
this.exportEx("广宣订单审核列表", ActionContext.getContext().getResponse(), request, head, list1);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "");
logger.error(logonUser, e1);
act.setException(e1);
}
}
/**
* 总部审核-生成销售单
* @throws : LastDate : 2017-7-27
* @Description:生成销售单
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public void createSaleOrder() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
request.setAttribute("boFlag", false);//bo单标志
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));//订单ID
String orderCode = CommonUtils.checkNull(request.getParamValue("orderCode")); //订单CODE
String orderType = CommonUtils.checkNull(request.getParamValue("orderType")); //订单类型
Double discount = Double.valueOf(request.getParamValue("DISCOUNT")); //折扣
String whId = CommonUtils.checkNull(request.getParamValue("wh_id")); //库房
String dealerId = CommonUtils.checkNull(request.getParamValue("dealerId")); //订货单位ID
//校验是否有同时操作,防止重复生成销售单
Map<String, Object> mainMap = dao.queryPartDlrOrderMain(orderId);
String state = CommonUtils.checkNull(mainMap.get("STATE"));//订单状态
if (state.equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_03 + "")) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "该订单已审核,请不要重复审核!");
throw e1;
}
//判断是否订单已经生成销售单,防止重复生成
orderDubCheck(orderId, dao, act);
if ((Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_04 + "").equals(orderType)) {
//委托订单
//生成销售单-->总部采购单,采购单类型为经销商委托 -->总部虚拟入库和虚拟出库、发运单-->经销商入库(经销商端入库操作)
//1.生成销售单,包括销售订单主表、明细表
// this.insertOrderInfo(orderId,orderCode,orderType,discount,whId,dealerId);
//2.生成总部采购单,采购单类型:经销商委托
//3.总部虚拟入库、出库、发运单
//更新订单发运方式
String transType = CommonUtils.checkNull(request.getParamValue("TRANS_TYPE")); //发运方式
TtPartDlrOrderMainPO po1=new TtPartDlrOrderMainPO();
po1.setOrderId(Long.valueOf(orderId));
TtPartDlrOrderMainPO updPo=new TtPartDlrOrderMainPO();
updPo.setTransType(transType);
dao.update(po1,updPo);
//生成总部采购单,总部虚拟入库和虚拟出库、发运单、销售单
ArrayList ins1 = new ArrayList();
ins1.add(0, Long.valueOf(orderId));
ins1.add(1, loginUser.getUserId());
dao.callProcedure("PROC_DIRECT_ORDER_DEAL", ins1, null);
//更新订单状态
this.changeOrderStatus(orderType,loginUser, orderId, act, request);
act.setOutData("success", "委托订单" + CommonUtils.checkNull(request.getAttribute("soCode")) + ",操作成功!");
return;
}else if ((Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_12 + "").equals(orderType)) {
String remark2 = CommonUtils.checkNull(request.getParamValue("REMARK2")); //审核时备注
//销售采购订单
//1、生成总部采购单 2、采购单手工转换成验收单 3、手工入库 (入库判断订单类型,入库完成时生成销售单(销售单只能卖给订货单位))
//5、然后走销售流程:销售单-拣货单-装箱-发运计划-出库-发运
//更新订单发运方式
String transType = CommonUtils.checkNull(request.getParamValue("TRANS_TYPE")); //发运方式
TtPartDlrOrderMainPO po1=new TtPartDlrOrderMainPO();
po1.setOrderId(Long.valueOf(orderId));
TtPartDlrOrderMainPO updPo=new TtPartDlrOrderMainPO();
updPo.setTransType(transType);
dao.update(po1,updPo);
//1、生成总部采购单
List ins = new ArrayList();
ins.add(0, Long.valueOf(orderId));
ins.add(1, loginUser.getUserId());//制单人
ins.add(2, remark2);//备注
dao.callProcedure("PROC_TT_PART_SALE_ORDER", ins, null);
//更新订单状态
this.changeOrderStatus(orderType,loginUser, orderId, act, request);
act.setOutData("success", "销售采购订单" + CommonUtils.checkNull(request.getAttribute("soCode")) + ",操作成功!");
return;
}else{
//紧急订单、常规订单、促销订单 流程相同
//插入主数据,销售订单明细表
this.insertOrderDetail(orderId,orderType,discount,whId,dealerId);
//插入明细数据,销售单主表
this.insertSoMain(orderId,orderCode,discount,whId);
//更新订单状态
this.changeOrderStatus(orderType,loginUser, orderId, act, request);
//存在bo单时则插入bo单主表、明细表
this.createBoOrder(orderId);
//账户增加内部领用订单判断 众泰无领用单
// if (!orderType.equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_09 + "") && !"".equals(CommonUtils.checkNull(mainMap.get("ACCOUNT_SUM"))) && !"".equals(CommonUtils.checkNull(mainMap.get("ACCOUNT_KY"))) && !"".equals(CommonUtils.checkNull(mainMap.get("ACCOUNT_DJ")))) {
// insertAccount();
// }
// //判断是否订单已经生成销售单,防止重复生成
// orderDubCheck(orderId, dao, act);
//资源锁定 start 资源占用(TT_PART_BOOK_DTL,占用明细表)
List ins = new ArrayList();
ins.add(0, Long.valueOf(request.getAttribute("soId").toString()));
ins.add(1, Constant.PART_CODE_RELATION_07);
ins.add(2, 1);
dao.callProcedure("PROC_TT_PART_UPDATE_PART_STATE", ins, null);
//资源锁定 end
act.setOutData("boStr", request.getAttribute("boStr"));//bo单标志,1表示存在bo单
}
act.setOutData("orderId", orderId);
act.setOutData("orderCode", orderCode);
act.setOutData("success", "销售单号:" + CommonUtils.checkNull(request.getAttribute("soCode")) + ",操作成功!");
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "生成销售单错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
/**
* 总部销售单-插入销售订单明细表、主表
* @param orderId订单id
* @param orderCode订单编码
* @param orderType订单类型
* @param discount折扣
* @param whId库房
* @param dealerId订货单位ID
* @throws Exception
*/
private void insertOrderInfo(String orderId,String orderCode,String orderType,Double discount,
String whId,String dealerId) throws Exception {
ActionContext act = ActionContext.getContext();
RequestWrapper request = act.getRequest();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
PartPlanConfirmDao partPlanConfirmDao = PartPlanConfirmDao.getInstance();
try {
//折扣后的金额
Double reCountMoney = 0d;
//销售单id
Long soId = Long.parseLong(SequenceManager.getSequence(""));
request.setAttribute("soId", soId);
//获取当前用户机构ID
String orgId = "";
PartWareHouseDao partWareHouseDao = PartWareHouseDao.getInstance();
List<OrgBean> beanList = partWareHouseDao.getOrgInfo(loginUser);
if (null != beanList || beanList.size() >= 0) {
orgId = beanList.get(0).getOrgId() + "";
}
//机构id
request.setAttribute("orgId", orgId);
//订单明细list
List<TtPartSoDtlPO> list = new ArrayList<TtPartSoDtlPO>();
//查询订单明细
List<Map<String, Object>> detailList = dao.queryPartDlrOrderDetail4SODTL(orderId);
//-------------------------------------插入销售订单明细数据-------------------------------------
//循环处理明细
String[] partIdArr = request.getParamValues("cb");//前端传入值
System.out.println("******审核-配件总条数-前端传入:"+partIdArr.length);
System.out.println("******审核-配件总条数-数据库查询:"+detailList.size());
for (Map<String, Object> map : detailList) {
for (int i = 0; i < partIdArr.length; i++) {
String partId = partIdArr[i];
if (partId.equals(map.get("PART_ID").toString())) {//如果前端传入选中的partid等于明细里面查询的partid
Double price = parseDouble(map.get("BUY_PRICE"));//销售单价
Double saleQty = Double.valueOf(request.getParamValue("saleQty_" + partId));//前台销售数量
Double realPrice = Arith.mul(price, discount);//折扣后单价
Double amount = Arith.mul(realPrice, saleQty);//行金额
reCountMoney = Arith.add(reCountMoney, amount);//折扣后行金额
String partCode = CommonUtils.checkNull(map.get("PART_CODE"));
String partOldCode = CommonUtils.checkNull(map.get("PART_OLDCODE"));
String partCname = CommonUtils.checkNull(map.get("PART_CNAME"));
String unit = CommonUtils.checkNull(map.get("UNIT"));
String isDirect = CommonUtils.checkNull(map.get("IS_DIRECT"));
String isPlan = CommonUtils.checkNull(map.get("IS_PLAN"));
String isLack = CommonUtils.checkNull(map.get("IS_LACK"));
String isReplaced = CommonUtils.checkNull(map.get("IS_REPLACED"));
String stockQty = CommonUtils.checkNull(map.get("STOCK_QTY"));
String minPackage = CommonUtils.checkNull(map.get("MIN_PACKAGE"));
String isHava = CommonUtils.checkNull(map.get("IS_HAVA"));
String remark = CommonUtils.checkNull(map.get("REMARK"));
String isGift = CommonUtils.checkNull(map.get("IS_GIFT"));
String venderId = CommonUtils.checkNull(request.getParamValue("VENDER_ID_" + partId));
//主销售单
TtPartSoDtlPO po = new TtPartSoDtlPO();
po.setSoId(soId);
po.setSlineId(Long.parseLong((i + 1 + soId) + ""));
po.setOrderId(Long.valueOf(orderId));
po.setPartId(Long.valueOf(partId));
po.setPartOldcode(partOldCode);
po.setPartCode(partCode);
po.setPartCname(partCname);
po.setUnit(unit);
if (!"".equals(venderId)) {
po.setVenderId(Long.valueOf(venderId));
TtPartMakerDefinePO venderList = partPlanConfirmDao.getMaker(venderId);//部品制造商
if (null != venderList) {
po.setVenderName(CommonUtils.checkNull(venderList.getMakerName()));
po.setVenderCode(CommonUtils.checkNull(venderList.getMakerCode()));
}
}
if (!"".equals(isDirect)) {
po.setIsDirect(Integer.valueOf(isDirect));//直发件,如机油
}
if (!"".equals(isPlan)) {
po.setIsPlan(Integer.valueOf(isPlan));//大件、占空间(如保险杠)
}
if (!"".equals(isLack)) {
po.setIsLack(Integer.valueOf(isLack));//紧缺件
}
po.setIsReplaced(Constant.IF_TYPE_NO);//是否替换件
po.setIsGift(Constant.IF_TYPE_NO);//是否赠品
po.setStockQty(Long.valueOf(stockQty));//当前库存
po.setMinPackage(Long.valueOf(minPackage));//最小包装量
po.setBuyQty(Long.valueOf(CommonUtils.checkNull(map.get("BUY_QTY"))));//订货数量
po.setSalesQty(Long.valueOf(request.getParamValue("saleQty_" + partId)));//销售数量
po.setBuyPrice(price);//销售单价
po.setBuyAmount(amount);//销售金额
po.setRemark(remark);
po.setCreateBy(loginUser.getUserId());
po.setCreateDate(new Date());
po.setSalesQty(po.getSalesQty());
// if (po.getSalesQty() == 0) {
// continue;
// }
//单价和金额重新校验
if (po.getBuyPrice() == 0d || po.getBuyAmount() == 0d) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "配件【" + po.getPartOldcode() + "】销售数据出现异常,请联系管理员!");
throw e1;
}
list.add(po);
}
}
}
//插入销售订单明细数据
dao.insert(list);
request.setAttribute("reCountMoney", reCountMoney);//折扣后金额
//-------------------------------------插入销售订单主数据-------------------------------------
String payType = CommonUtils.checkNull(request.getParamValue("PAY_TYPE")); //付费方式
// String dealerId = CommonUtils.checkNull(request.getParamValue("dealerId")); //订货单位ID
String dealerCode = CommonUtils.checkNull(request.getParamValue("dealerCode")); //订货单位CODE
String dealerName = CommonUtils.checkNull(request.getParamValue("dealerName")); //订货单位CODE
String sellerId = CommonUtils.checkNull(request.getParamValue("sellerId")); //销售单位ID
String sellerCode = CommonUtils.checkNull(request.getParamValue("sellerCode")); //销售单位CODE
String sellerName = CommonUtils.checkNull(request.getParamValue("sellerName")); //销售单位NAME
String buyerId = CommonUtils.checkNull(request.getParamValue("buyerId")); //订货人ID
String buyerName = CommonUtils.checkNull(request.getParamValue("buyerName")); //订货人
String consignees = CommonUtils.checkNull(request.getParamValue("RCV_ORG")); //接收单位
String consigneesId = CommonUtils.checkNull(request.getParamValue("RCV_ORGID")); //接收单位ID
String addr = CommonUtils.checkNull(request.getParamValue("ADDR")); //接收地址
String addrId = CommonUtils.checkNull(request.getParamValue("ADDR_ID")); //接收地址ID
String receiver = CommonUtils.checkNull(request.getParamValue("RECEIVER")); //接收人
String tel = CommonUtils.checkNull(request.getParamValue("TEL")); //接收人电话
String postCode = CommonUtils.checkNull(request.getParamValue("POST_CODE")); //接收邮编
String station = CommonUtils.checkNull(request.getParamValue("STATION")); //接收站
String transType = CommonUtils.checkNull(request.getParamValue("TRANS_TYPE")); //发运方式
String transpayType = CommonUtils.checkNull(request.getParamValue("transpayType")); //发运付费方式
Double amount = Double.valueOf(request.getAttribute("reCountMoney").toString()); //获取JAVA重新计算的金额
// String discount = CommonUtils.checkNull(request.getParamValue("DISCOUNT")); //折扣
String remark = CommonUtils.checkNull(request.getParamValue("remark")); //订单备注
String remark2 = CommonUtils.checkNull(request.getParamValue("REMARK2")); //备注
Double freight = Double.valueOf(CommonUtils.checkNull(request.getParamValue("freight")).replace(",", ""));//运费
String isLock = CommonUtils.checkNull(request.getParamValue("isLock"));
//订单编码
String soCode = OrderCodeManager.getOrderCode(Constant.PART_CODE_RELATION_07, request.getParamValue("dealerId"));
request.setAttribute("soCode", soCode);
//如果运费产生改变 占用和释放也需要改变
Map<String, Object> mainMap = dao.queryPartDlrOrderMain(orderId);
amount = Arith.add(freight, amount);
//重新放入给资金使用
request.setAttribute("reCountMoney", amount);
//销售主订单
TtPartSoMainPO po = new TtPartSoMainPO();
po.setSoId(soId);
po.setSoCode(soCode);
po.setOrderId(Long.valueOf(orderId));
po.setOrderCode(orderCode);
po.setOrderType(Integer.valueOf(orderType));
po.setIsBatchso(Constant.PART_BASE_FLAG_NO);//默认否铺货
po.setSoFrom(Constant.CAR_FACTORY_SO_FORM_02);//订单生成
po.setPayType(Integer.valueOf(payType));//支付方式,目前只有现金
po.setDealerId(Long.valueOf(dealerId));//订货单位ID
po.setDealerCode(dealerCode);
po.setDealerName(dealerName);
po.setSellerId(Long.valueOf(sellerId));//销售单位ID
po.setSellerCode(sellerCode);
po.setSellerName(sellerName);
po.setSaleDate(new Date());//审核日期
if (buyerId != null && !"".equals(buyerId)) {
po.setBuyerId(Long.valueOf(buyerId));//订货人ID
}
po.setBuyerName(buyerName);
po.setConsigneesId(Long.valueOf(consigneesId));//接收单位ID
po.setConsignees(consignees);//接收单位
po.setAddr(addr);//接收地址
po.setAddrId(Long.valueOf(addrId));//接收地址ID
po.setReceiver(receiver);//接收人
po.setTel(tel);//接收人电话
po.setPostCode(postCode);//邮政编码
po.setStation(station);//到站名称
po.setTransType(transType);//发运方式
po.setTranspayType(Integer.valueOf(transpayType));//运费支付方式
po.setAmount(amount);//销售金额
po.setDiscount(discount);//折扣率
po.setRemark(remark);//订单备注
po.setRemark2(remark2);//备注
po.setWhId(Long.valueOf(whId));//仓库ID
po.setVer(1);//版本
po.setState(Constant.CAR_FACTORY_ORDER_CHECK_STATE_05);//生成销售单状态直接为财务审核通过
po.setFcauditDate(new Date());//财务审核日期
po.setSubmitDate(new Date());
po.setCreateBy(loginUser.getUserId());
po.setCreateDate(new Date());
if (isLock != null && isLock.equals("1")) {
po.setLockFreight(1);//运费锁定
}
if (freight != null) {
po.setFreight(freight);//运费
}
//是否免运费
if (freight != null && freight > 0) {
po.setIsTransfree(Constant.IF_TYPE_NO);
} else {
po.setIsTransfree(Constant.IF_TYPE_YES);
}
po.setAccountId(Long.valueOf(mainMap.get("ACCOUNT_ID").toString()));//账户ID
po.setCheckId(Long.valueOf(orderId));//校验ID(唯一不允许重复)
//插入销售订单主表数据
dao.insert(po);
//-----------------------------------------------------------------------------------------------------------
} catch (Exception ex) {
throw ex;
}
}
/**
* 订单重复生成校验
*
* @param orderId 订单ID
* @param dao
* @param act
* @throws BizException
*/
public void orderDubCheck(String orderId, PartDlrOrderDao dao, ActionContext act) throws BizException {
TtPartSoMainPO soMainPO1 = new TtPartSoMainPO();
soMainPO1.setOrderId(Long.valueOf(orderId));
if (dao.select(soMainPO1).size() > 1) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "该订单已经生成销售不能重复生成!");
throw e1;
}
}
/**
* 显示订单产生的bo信息
*/
public void showPartBoInit() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
act.setForword(PART_BO_QUERY);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "bo信息查询失败,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
/**
* 显示订单产生的bo信息
*/
public void showPartBo() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
//分页方法 begin
Integer curPage = request.getParamValue("curPage") != null ? Integer
.parseInt(request.getParamValue("curPage"))
: 1; // 处理当前页
PageResult<Map<String, Object>> ps = null;
ps = dao.queryPartBo(request, curPage, Constant.PAGE_SIZE);
act.setOutData("ps", ps);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "bo信息查询失败,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
/**
* @param : @param orgAmt
* @param : @return
* @return :
* @throws : LastDate : 2013-4-3
* @Title :
* @Description:生成发运计划
*/
public void createPlanOrder() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
//订单id
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
Long allBuyQty = Long.valueOf(CommonUtils.checkNull(request.getParamValue("allBuyQty")));//所有订货数量
//插入数据
this.insertPlanMain(orderId);
this.insertPlanDtl(orderId);
//判断当前订单是否已经全部审核完成,如果全部完成就更新状态为已审核
Long allReportedQty = dao.getReportedQty(orderId);
if (allReportedQty.equals(allBuyQty)) {
TtPartDlrOrderMainPO spo = new TtPartDlrOrderMainPO();
TtPartDlrOrderMainPO po = new TtPartDlrOrderMainPO();
spo.setOrderId(CommonUtils.parseLong(orderId));
po.setState(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_03);
dao.update(spo, po);
}
act.setOutData("success", "发运计划单生成成功!");
} catch (Exception e) {
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "生成发运计划错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
/**
* @return
* @throws Exception
*/
public boolean doReplace() throws Exception {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
boolean rtnFlag = false;
try {
String whId = CommonUtils.checkNull(request.getParamValue("wh_id"));
String dealerId = CommonUtils.checkNull(request.getParamValue("dealerId")); //订货单位ID
String sellerId = CommonUtils.checkNull(request.getParamValue("sellerId")); //销售单位ID
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
Map<String, Object> accountMap = dao.getAccount(dealerId, sellerId, "");
//非主机厂不做设变,没帐户不做设变
if (!sellerId.equals(Constant.OEM_ACTIVITIES.toString()) || accountMap == null || accountMap.isEmpty() || null == accountMap.get("ACCOUNT_KY")) {
return false;
}
Long soId = Long.valueOf(request.getAttribute("soId").toString());
Map<String, Object> mainMap = dao.queryPartDlrOrderMain(orderId);
if (request.getAttribute("boMap") != null && !((Map) request.getAttribute("boMap")).isEmpty()) {
Map<String, Object> boMap = (Map<String, Object>) request.getAttribute("boMap");
List<TtPartBoDtlPO> detailVoList = (List<TtPartBoDtlPO>) boMap.get("detailVoList");
List<TtPartBoDtlPO> removeList = new ArrayList<TtPartBoDtlPO>();
Double amount = 0D;
Double reCountMoney = Double.valueOf(request.getAttribute("reCountMoney").toString()); //获取JAVA重新计算的金额
Double reTotalAmout = 0D;
for (TtPartBoDtlPO po : detailVoList) {
Long partId = po.getPartId();
List<Map<String, Object>> list = dao.getReplacePart(partId + "");
if (list == null || list.size() <= 0) {
continue;
}
Long boQty = po.getBoQty();
for (Map<String, Object> map : list) {
Long replaceQty = 0L;
String replacePartId = CommonUtils.checkNull(map.get("REPART_ID"));
//库存最大满足
Map<String, Object> stockMap = dao.getPartItemStock(whId, replacePartId + "");
if (null == stockMap || stockMap.isEmpty() || null == stockMap.get("NORMAL_QTY")) {
continue;
}
Long stockQty = Long.valueOf(CommonUtils.checkNull(stockMap.get("NORMAL_QTY")));
if (stockQty >= boQty) {
replaceQty = boQty;
} else {
replaceQty = stockQty;
}
//金额开始
Double buyPrice = dao.getBuyPrice(dealerId, replacePartId + "");
Double orderBuyPrice = dao.getOrderPrice(orderId, partId + "");
Double boAmount = Arith.mul(replaceQty, orderBuyPrice);
Double kyAmount = Arith.sub(Double.valueOf(CommonUtils.checkNull(accountMap.get("ACCOUNT_KY")).replaceAll(",", "")), reTotalAmout);
kyAmount = Arith.add(kyAmount, boAmount);
//金额最大满足公式
replaceQty = Arith.div(kyAmount, buyPrice) > replaceQty ? replaceQty : Long.valueOf(Math.floor(Arith.div(kyAmount, buyPrice)) + "");
Double rpAmount = Arith.mul(buyPrice, replaceQty);
reTotalAmout = Arith.add(reTotalAmout, rpAmount);
//插入设变件纪录
List<Map<String, Object>> partList = dao.getReplacePartInfo(replacePartId + "", dealerId, sellerId);
if (null == list || list.size() <= 0 || list.get(0) == null) {
continue;
}
Map<String, Object> partMap = partList.get(0);
TtPartSoDtlPO soDtlPo = new TtPartSoDtlPO();
Long lineId = Long.parseLong(SequenceManager.getSequence(""));
soDtlPo.setSoId(soId);
soDtlPo.setSlineId(lineId);
soDtlPo.setOrderId(Long.valueOf(orderId));
soDtlPo.setPartId(Long.valueOf(replacePartId));
soDtlPo.setPartOldcode(CommonUtils.checkNull(partMap.get("PART_OLDCODE")));
soDtlPo.setPartCode(CommonUtils.checkNull(partMap.get("PART_CODE")));
soDtlPo.setPartCname(CommonUtils.checkNull(partMap.get("PART_CNAME")));
soDtlPo.setUnit(partMap.get("UNIT") == null ? "件" : CommonUtils.checkNull(partMap.get("UNIT")));
soDtlPo.setIsReplaced(Constant.IF_TYPE_YES);
soDtlPo.setIsGift(Constant.IF_TYPE_NO);
soDtlPo.setStockQty(Long.valueOf(stockQty));
soDtlPo.setMinPackage(Long.valueOf(CommonUtils.checkNull(partMap.get("MIN_PACKAGE"))));
soDtlPo.setBuyQty(replaceQty);
soDtlPo.setSalesQty(replaceQty);
soDtlPo.setBuyPrice(buyPrice);
soDtlPo.setBuyAmount(rpAmount);
soDtlPo.setRemark("设变件");
soDtlPo.setCreateBy(loginUser.getUserId());
soDtlPo.setCreateDate(new Date());
dao.insert(soDtlPo);
rtnFlag = true;
if (replaceQty == boQty) {
removeList.add(po);
} else {
po.setBoQty(boQty - replaceQty);
po.setBoOddqty(boQty - replaceQty);
}
}
}
reCountMoney = Arith.add(reCountMoney, reTotalAmout);
request.setAttribute("reCountMoney", reCountMoney);
((List<TtPartBoDtlPO>) boMap.get("detailVoList")).removeAll(removeList);
}
} catch (Exception e) {
throw e;
}
return rtnFlag;
}
private boolean validateChangeState() throws Exception {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
List<Map<String, Object>> list = dao.queryPartDlrOrderDetail(orderId);
List<Map<String, Object>> soMainList = dao.getSoMain(orderId);
//如果没做过 销售单越过
if (null == soMainList) {
if (soMainList.size() > 0) {
String soIds = "";
for (Map<String, Object> map : soMainList) {
String soId = CommonUtils.checkNull(map.get("SO_ID"));
soIds += "," + soId;
}
if (!"".equals(soIds)) {
soIds = soIds.replaceFirst(",", "");
}
//做过销售单
for (Map<String, Object> map : list) {
String partId = CommonUtils.checkNull(map.get("PART_ID"));
Long saledQty = dao.getSoDetailPartNum(soIds, partId);
Long buyQty = Long.valueOf(CommonUtils.checkNull(map.get("BUY_QTY")));
if (buyQty > saledQty) {
return false;
}
}
}
}
return true;
} catch (Exception ex) {
throw ex;
}
}
private void changeOrderStatus(String orderType,AclUserBean loginUser, String orderId, ActionContext act, RequestWrapper request) throws Exception {
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
TtPartDlrOrderMainPO newPo = new TtPartDlrOrderMainPO();
String whId = CommonUtils.checkNull(request.getParamValue("wh_id"));
newPo.setOrderId(Long.valueOf(orderId));
newPo.setWhId(Long.valueOf(whId));
TtPartDlrOrderMainPO mainPO = new TtPartDlrOrderMainPO();
mainPO.setOrderId(Long.valueOf(orderId));
mainPO = (TtPartDlrOrderMainPO) dao.select(mainPO).get(0);
mainPO.setWhId(Long.valueOf(whId));
TtPartSoMainPO soMainPO = new TtPartSoMainPO();
soMainPO.setOrderId(Long.valueOf(orderId));
//TtPartSoMainPO po = new TtPartSoMainPO();
/*if(mainPO.getState().equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_06)){//如果订单状态为车厂已审核,那就是调拨,此时销售单状态直接更新为财务审核通过
//po.setState(Constant.CAR_FACTORY_ORDER_CHECK_STATE_05);
po.setSubmitDate(new Date());
dao.update(soMainPO, po);
PartSoManage partSoManage = new PartSoManage();
partSoManage.insertHistory(request, act,Constant.CAR_FACTORY_ORDER_CHECK_STATE_05);
}*//*else{*/
newPo.setState(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_03);
newPo.setAuditBy(loginUser.getUserId());
newPo.setAuditDate(new Date());
TtPartDlrOrderMainPO oldPo = new TtPartDlrOrderMainPO();
oldPo.setOrderId(Long.valueOf(orderId));
dao.update(oldPo, newPo);
this.saveHistory(orderType,request, act, Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_03);
/*}*/
} catch (Exception ex) {
throw ex;
}
}
/**
* 插入销售订单主表
* @param orderId 订单id
* @param orderCode 订单编码
* @param discount 折扣率
* @param whId 仓库
* @throws Exception
*/
private void insertSoMain(String orderId,String orderCode,Double discount,String whId) throws Exception {
ActionContext act = ActionContext.getContext();
RequestWrapper request = act.getRequest();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
Long soId = Long.valueOf(request.getAttribute("soId").toString());
String orderType = CommonUtils.checkNull(request.getParamValue("orderType")); //订单类型
String payType = CommonUtils.checkNull(request.getParamValue("PAY_TYPE")); //付费方式
String dealerId = CommonUtils.checkNull(request.getParamValue("dealerId")); //订货单位ID
String dealerCode = CommonUtils.checkNull(request.getParamValue("dealerCode")); //订货单位CODE
String dealerName = CommonUtils.checkNull(request.getParamValue("dealerName")); //订货单位CODE
String sellerId = CommonUtils.checkNull(request.getParamValue("sellerId")); //销售单位ID
String sellerCode = CommonUtils.checkNull(request.getParamValue("sellerCode")); //销售单位CODE
String sellerName = CommonUtils.checkNull(request.getParamValue("sellerName")); //销售单位NAME
String buyerId = CommonUtils.checkNull(request.getParamValue("buyerId")); //订货人ID
String buyerName = CommonUtils.checkNull(request.getParamValue("buyerName")); //订货人
String consignees = CommonUtils.checkNull(request.getParamValue("RCV_ORG")); //接收单位
String consigneesId = CommonUtils.checkNull(request.getParamValue("RCV_ORGID")); //接收单位ID
String addr = CommonUtils.checkNull(request.getParamValue("ADDR")); //接收地址
String addrId = CommonUtils.checkNull(request.getParamValue("ADDR_ID")); //接收地址ID
String receiver = CommonUtils.checkNull(request.getParamValue("RECEIVER")); //接收人
String tel = CommonUtils.checkNull(request.getParamValue("TEL")); //接收人电话
String postCode = CommonUtils.checkNull(request.getParamValue("POST_CODE")); //接收邮编
String station = CommonUtils.checkNull(request.getParamValue("STATION")); //接收站
String transType = CommonUtils.checkNull(request.getParamValue("TRANS_TYPE")); //发运方式
String transpayType = CommonUtils.checkNull(request.getParamValue("transpayType")); //发运付费方式
Double amount = Double.valueOf(request.getAttribute("reCountMoney").toString()); //获取JAVA重新计算的金额
// String discount = CommonUtils.checkNull(request.getParamValue("DISCOUNT")); //折扣
String remark = CommonUtils.checkNull(request.getParamValue("remark")); //订单备注
String remark2 = CommonUtils.checkNull(request.getParamValue("REMARK2")); //备注
Double freight = Double.valueOf(CommonUtils.checkNull(request.getParamValue("freight")).replace(",", ""));//运费
String isLock = CommonUtils.checkNull(request.getParamValue("isLock"));
//mod by yuan 20131019新增内部领用单判断 众泰无内部领用单
// if (loginUser.getDealerId() == null) {
// if (!orderType.equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_09.toString())) {
// soCode = OrderCodeManager.getOrderCode(Constant.PART_CODE_RELATION_07, request.getParamValue("dealerId"));
// } else {
// soCode = OrderCodeManager.getOrderCode(Constant.PART_CODE_RELATION_38, request.getParamValue("dealerId"));
// }
// } else {
// soCode = OrderCodeManager.getOrderCode(Constant.PART_CODE_RELATION_11, request.getParamValue("dealerId"));
// }
//订单编码
String soCode = OrderCodeManager.getOrderCode(Constant.PART_CODE_RELATION_07, request.getParamValue("dealerId"));
request.setAttribute("soCode", soCode);
//如果运费产生改变 占用和释放也需要改变
Map<String, Object> mainMap = dao.queryPartDlrOrderMain(orderId);
amount = Arith.add(freight, amount);
//重新放入给资金使用
request.setAttribute("reCountMoney", amount);
//销售主订单
TtPartSoMainPO po = new TtPartSoMainPO();
po.setSoId(soId);
po.setSoCode(soCode);
po.setOrderId(Long.valueOf(orderId));
po.setOrderCode(orderCode);
po.setOrderType(Integer.valueOf(orderType));
po.setIsBatchso(Constant.PART_BASE_FLAG_NO);//默认否铺货
po.setSoFrom(Constant.CAR_FACTORY_SO_FORM_02);//订单生成
po.setPayType(Integer.valueOf(payType));//支付方式,目前只有现金
po.setDealerId(Long.valueOf(dealerId));//订货单位ID
po.setDealerCode(dealerCode);
po.setDealerName(dealerName);
po.setSellerId(Long.valueOf(sellerId));//销售单位ID
po.setSellerCode(sellerCode);
po.setSellerName(sellerName);
po.setSaleDate(new Date());//审核日期
if (buyerId != null && !"".equals(buyerId)) {
po.setBuyerId(Long.valueOf(buyerId));//订货人ID
}
po.setBuyerName(buyerName);
po.setConsigneesId(Long.valueOf(consigneesId));//接收单位ID
po.setConsignees(consignees);//接收单位
po.setAddr(addr);//接收地址
po.setAddrId(Long.valueOf(addrId));//接收地址ID
po.setReceiver(receiver);//接收人
po.setTel(tel);//接收人电话
po.setPostCode(postCode);//邮政编码
po.setStation(station);//到站名称
po.setTransType(transType);//发运方式
po.setTranspayType(Integer.valueOf(transpayType));//运费支付方式
po.setAmount(amount);//销售金额
po.setDiscount(discount);//折扣率
po.setRemark(remark);//订单备注
po.setRemark2(remark2);//备注
po.setWhId(Long.valueOf(whId));//仓库ID
po.setVer(1);//版本
po.setState(Constant.CAR_FACTORY_ORDER_CHECK_STATE_05);//生成销售单状态直接为财务审核通过
po.setFcauditDate(new Date());//财务审核日期
po.setSubmitDate(new Date());
po.setCreateBy(loginUser.getUserId());
po.setCreateDate(new Date());
if (isLock != null && isLock.equals("1")) {
po.setLockFreight(1);//运费锁定
}
if (freight != null) {
po.setFreight(freight);//运费
}
//是否免运费
if (freight != null && freight > 0) {
po.setIsTransfree(Constant.IF_TYPE_NO);
} else {
po.setIsTransfree(Constant.IF_TYPE_YES);
}
po.setAccountId(Long.valueOf(mainMap.get("ACCOUNT_ID").toString()));//账户ID
po.setCheckId(Long.valueOf(orderId));//校验ID(唯一不允许重复)
//插入销售订单主表数据
dao.insert(po);
} catch (Exception ex) {
throw ex;
}
}
private void insertPlanMain(String orderId) throws Exception {
try {
ActionContext act = ActionContext.getContext();
RequestWrapper request = act.getRequest();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
Long planId = CommonUtils.parseLong(SequenceManager.getSequence(""));
request.setAttribute("planId", planId);
//发运计划单号
String planCode = OrderCodeManager.getOrderCode(Constant.PART_CODE_RELATION_40, request.getParamValue("dealerId"));
String orderCode = CommonUtils.checkNull(request.getParamValue("orderCode")); //订单CODE
String dealerId = CommonUtils.checkNull(request.getParamValue("dealerId")); //订货单位ID
String dealerCode = CommonUtils.checkNull(request.getParamValue("dealerCode")); //订货单位CODE
String dealerName = CommonUtils.checkNull(request.getParamValue("dealerName")); //订货单位名称
String sellerId = CommonUtils.checkNull(request.getParamValue("sellerId")); //销售单位ID
String sellerCode = CommonUtils.checkNull(request.getParamValue("sellerCode")); //销售单位CODE
String sellerName = CommonUtils.checkNull(request.getParamValue("sellerName")); //销售单位NAME
String remark2 = CommonUtils.checkNull(request.getParamValue("REMARK2")); //备注
String whId = CommonUtils.checkNull(request.getParamValue("wh_id")); //出库仓库
String outType = CommonUtils.checkNull(request.getParamValue("OUT_TYPE")); //发运方式
String finalDate = CommonUtils.checkNull(request.getParamValue("planDate")); //随车最终发运日期
TtPartDplanMainPO po = new TtPartDplanMainPO();
po.setPlanId(planId);
po.setPlanCode(planCode);
po.setOrderId(CommonUtils.parseLong(orderId));
po.setOrderCode(orderCode);
po.setDealerId(CommonUtils.parseLong(dealerId));
po.setDealerCode(dealerCode);
po.setDealerName(dealerName);
po.setSellerId(CommonUtils.parseLong(sellerId));
po.setSellerCode(sellerCode);
po.setSellerName(sellerName);
po.setCreateDate(new Date());
po.setCreateBy(loginUser.getUserId());
po.setWhId(CommonUtils.parseLong(whId));
if (!"".equals(outType)) {
po.setOutType(CommonUtils.parseInteger(outType));
}
if (!"".equals(finalDate)) {
po.setFinalDate(CommonUtils.parseDTime(finalDate));
}
po.setRemark(remark2);
po.setState(Constant.PART_GX_ORDER_STATE_01);//广宣发运计划单状态为已保存
dao.insert(po);
} catch (Exception ex) {
throw ex;
}
}
/**
* 插入销售订单详细表
* @param orderId订单id
* @param orderType订单类型
* @param discount折扣
* @param whId库房
* @param dealerId订货单位ID
* @throws Exception
*/
private void insertOrderDetail(String orderId,String orderType,Double discount,String whId,String dealerId) throws Exception {
ActionContext act = ActionContext.getContext();
RequestWrapper request = act.getRequest();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
PartPlanConfirmDao partPlanConfirmDao = PartPlanConfirmDao.getInstance();
try {
//折扣后的金额
Double reCountMoney = 0d;
//销售单id
Long soId = Long.parseLong(SequenceManager.getSequence(""));
request.setAttribute("soId", soId);
//获取当前用户机构ID
String orgId = "";
PartWareHouseDao partWareHouseDao = PartWareHouseDao.getInstance();
List<OrgBean> beanList = partWareHouseDao.getOrgInfo(loginUser);
if (null != beanList || beanList.size() >= 0) {
orgId = beanList.get(0).getOrgId() + "";
}
//机构id
request.setAttribute("orgId", orgId);
//bo map对象
Map<String, Object> boMap = new HashMap();
//订单明细list
List<TtPartSoDtlPO> list = new ArrayList<TtPartSoDtlPO>();
//查询订单明细
List<Map<String, Object>> detailList = dao.queryPartDlrOrderDetail4SODTL(orderId);
//循环处理明细
String[] partIdArr = request.getParamValues("cb");//前端传入值
for (Map<String, Object> map : detailList) {
boolean flag = false;
for (int i = 0; i < partIdArr.length; i++) {
String partId = partIdArr[i];
if (partId.equals(map.get("PART_ID").toString())) {//如果前端传入选中的partid等于明细里面查询的partid
flag = true;
request.setAttribute("partMap", map);//销售订单信息
Double price = parseDouble(map.get("BUY_PRICE"));//销售单价
Double saleQty = Double.valueOf(request.getParamValue("saleQty_" + partId));//前台销售数量
Double realPrice = Arith.mul(price, discount);//折扣后单价
Double amount = Arith.mul(realPrice, saleQty);//行金额
reCountMoney = Arith.add(reCountMoney, amount);//折扣后行金额
String partCode = CommonUtils.checkNull(map.get("PART_CODE"));
String partOldCode = CommonUtils.checkNull(map.get("PART_OLDCODE"));
String partCname = CommonUtils.checkNull(map.get("PART_CNAME"));
String unit = CommonUtils.checkNull(map.get("UNIT"));
String isDirect = CommonUtils.checkNull(map.get("IS_DIRECT"));
String isPlan = CommonUtils.checkNull(map.get("IS_PLAN"));
String isLack = CommonUtils.checkNull(map.get("IS_LACK"));
String isReplaced = CommonUtils.checkNull(map.get("IS_REPLACED"));
String stockQty = CommonUtils.checkNull(map.get("STOCK_QTY"));
String minPackage = CommonUtils.checkNull(map.get("MIN_PACKAGE"));
String isHava = CommonUtils.checkNull(map.get("IS_HAVA"));
String remark = CommonUtils.checkNull(map.get("REMARK"));
String isGift = CommonUtils.checkNull(map.get("IS_GIFT"));
String venderId = CommonUtils.checkNull(request.getParamValue("VENDER_ID_" + partId));
//主销售单
TtPartSoDtlPO po = new TtPartSoDtlPO();
po.setSoId(soId);
po.setSlineId(Long.parseLong((i + 1 + soId) + ""));
po.setOrderId(Long.valueOf(orderId));
po.setPartId(Long.valueOf(partId));
po.setPartOldcode(partOldCode);
po.setPartCode(partCode);
po.setPartCname(partCname);
po.setUnit(unit);
if (!"".equals(venderId)) {
po.setVenderId(Long.valueOf(venderId));
TtPartMakerDefinePO venderList = partPlanConfirmDao.getMaker(venderId);
if (null != venderList) {
po.setVenderName(CommonUtils.checkNull(venderList.getMakerName()));
po.setVenderCode(CommonUtils.checkNull(venderList.getMakerCode()));
}
}
if (!"".equals(isDirect)) {
po.setIsDirect(Integer.valueOf(isDirect));//直发件,如机油
}
if (!"".equals(isPlan)) {
po.setIsPlan(Integer.valueOf(isPlan));//大件、占空间(如保险杠)
}
if (!"".equals(isLack)) {
po.setIsLack(Integer.valueOf(isLack));//紧缺件
}
po.setIsReplaced(Constant.IF_TYPE_NO);//是否替换件
po.setIsGift(Constant.IF_TYPE_NO);//是否赠品
po.setStockQty(Long.valueOf(stockQty));//当前库存
po.setMinPackage(Long.valueOf(minPackage));//最小包装量
po.setBuyQty(Long.valueOf(CommonUtils.checkNull(map.get("BUY_QTY"))));//订货数量
po.setSalesQty(Long.valueOf(request.getParamValue("saleQty_" + partId)));//销售数量
po.setBuyPrice(price);//销售单价
po.setBuyAmount(amount);//销售金额
po.setRemark(remark);
po.setCreateBy(loginUser.getUserId());
po.setCreateDate(new Date());
//销售数量小于订货数量则产生一般BO
if (po.getSalesQty() < Long.valueOf(map.get("BUY_QTY").toString())) {
//bo单
loadBoVo(boMap, price,orderId,orderType);
request.setAttribute("boStr", "1");
}
if (po.getSalesQty() == 0) {
continue;
}
if (!orderType.equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_04 + "")
&& !orderType.equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_12 + "")) {
//重新校验库存
Map<String, Object> stockMap = dao.getPartItemStock(whId, partId);
if (stockMap == null) {
BizException e = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "配件[" + partOldCode + "}库存不足!");
throw e;
}
String stockTty = CommonUtils.checkNull(stockMap.get("NORMAL_QTY"));
if (Long.valueOf(stockTty) < po.getSalesQty()) {
BizException e = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "配件[" + partOldCode + "]库存不足!当前可用库存为:" + stockTty + ",请刷新页面后重新确认!");
throw e;
}
}
//校验是否有多人操作 导致数量过多
/*if (!validatePlanSaleOrder(orderId, partId, po.getSalesQty(), po.getBuyQty())) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "销售数量不得大于订购数量!");
throw e1;
}*/
//单价和金额重新校验
if (po.getBuyPrice() == 0d || po.getBuyAmount() == 0d) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "配件【" + po.getPartOldcode() + "】销售数据出现异常,请联系管理员!");
throw e1;
}
list.add(po);
} else if (i == (partIdArr.length - 1) && !flag) {
//前端没选择配件 的全部生成BO
request.setAttribute("partMap", map);
//销售单价
Double price = parseDouble(map.get("BUY_PRICE"));
price = Arith.mul(price, discount);
loadBoVo(boMap, price,orderId,orderType);//生成bo单
request.setAttribute("boStr", "1");
}
}
}
//判断是否有明细,因前端审核时新增配件功能屏蔽
// String[] gift = request.getParamValues("gift");//获取前端name等于gift的控件,gift判断是否有明细
// if (null != gift) {
// for (int i = 0; i < gift.length; i++) {
// //获取数据生成订单明细
// Long lineId = Long.parseLong(SequenceManager.getSequence(""));
// String partId = gift[i];//配件编码
// Double price = parseDouble(0);
// Double saleQty = Double.valueOf(request.getParamValue("saleQty_" + partId));//销售数量
// Double realPrice = 0D;
// Double amount = 0D;
// Map<String, Object> partMap = dao.getPartDefine(partId);
// partMap.putAll(dao.getPartDefine(partId, dealerId));
// String partCode = CommonUtils.checkNull(partMap.get("PART_CODE"));
// String partOldCode = CommonUtils.checkNull(partMap.get("PART_OLDCODE"));
// String partCname = CommonUtils.checkNull(partMap.get("PART_CNAME"));
// String unit = CommonUtils.checkNull(partMap.get("UNIT"));
// String isDirect = CommonUtils.checkNull(partMap.get("IS_DIRECT"));
// String isPlan = CommonUtils.checkNull(partMap.get("IS_PLAN"));
// String isLack = CommonUtils.checkNull(partMap.get("IS_LACK"));
// String isReplaced = CommonUtils.checkNull(partMap.get("IS_REPLACED"));
// String minPackage = CommonUtils.checkNull(partMap.get("MIN_PACKAGE"));
// String isHava = CommonUtils.checkNull(partMap.get("IS_HAVA"));
// String remark = "赠品";
// String venderId = CommonUtils.checkNull(request.getParamValue("vender_" + partId));
//
// TtPartSoDtlPO po = new TtPartSoDtlPO();
// po.setSoId(soId);
// po.setSlineId(lineId);
// po.setOrderId(Long.valueOf(orderId));
// po.setPartId(Long.valueOf(partId));
// po.setPartOldcode(partOldCode);
// po.setPartCode(partCode);
// po.setPartCname(partCname);
// po.setUnit(unit);
// if (!"".equals(venderId)) {
// po.setVenderId(Long.valueOf(venderId));
// List<Map<String, Object>> venderList = partPlanConfirmDao.getVender(venderId, partId);
// if (null != venderList && venderList.size() > 0 && null != venderList.get(0)) {
// String venderName = CommonUtils.checkNull(venderList.get(0).get("VENDER_NAME"));
// po.setVenderName(venderName);
// }
// }
// if (!"".equals(isDirect)) {
// po.setIsDirect(Integer.valueOf(isDirect));
// }
// if (!"".equals(isPlan)) {
// po.setIsPlan(Integer.valueOf(isPlan));
// }
// if (!"".equals(isLack)) {
// po.setIsLack(Integer.valueOf(isLack));
// }
// po.setIsReplaced(Constant.IF_TYPE_YES);
// po.setIsGift(Constant.IF_TYPE_YES);
// po.setMinPackage(Long.valueOf(minPackage));
// po.setBuyQty(Long.valueOf(request.getParamValue("saleQty_" + partId)));
// po.setSalesQty(Long.valueOf(request.getParamValue("saleQty_" + partId)));
// //重新校验库存
// Map<String, Object> stockMap = dao.getPartItemStock(whId, partId);
// if (!CommonUtils.checkNull(request.getParamValue("orderType")).equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_04 + "") && stockMap == null) {
// BizException e = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "库存不足!");
// throw e;
// }
// String stockTty = CommonUtils.checkNull(stockMap.get("NORMAL_QTY"));
// po.setStockQty(Long.valueOf(stockTty));
// if (!CommonUtils.checkNull(request.getParamValue("orderType")).equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_TYPE_04 + "") && Long.valueOf(stockTty) < po.getSalesQty()) {
// BizException e = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "库存不足!");
// throw e;
// }
// po.setBuyPrice(price);
// po.setBuyAmount(amount);
// po.setRemark(remark);
// po.setCreateBy(loginUser.getUserId());
// po.setCreateDate(new Date());
// if (po.getSalesQty() == 0) {
// continue;
// }
//
// list.add(po);
//
// }
// }
//插入销售订单明细数
dao.insert(list);
request.setAttribute("boMap", boMap);//bo单map 存产生bo单的信息
request.setAttribute("reCountMoney", reCountMoney);
} catch (Exception ex) {
throw ex;
}
}
private void insertPlanDtl(String orderId) throws Exception {
try {
ActionContext act = ActionContext.getContext();
RequestWrapper request = act.getRequest();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
Long planId = (Long) request.getAttribute("planId");
String[] partIds = request.getParamValues("cb");//所有配件id
String outType = CommonUtils.checkNull(request.getParamValue("OUT_TYPE")); //发运方式
for (int i = 0; i < partIds.length; i++) {
String partId = partIds[i];
//验证当前配件的提报数量是否大于订货数量
Long reportedQty = 0l;//已经提报的数量
Long buyQty = Long.valueOf(CommonUtils.checkNull(request.getParamValue("buyQty_" + partId)));//订货数量
Long saleQty = Long.valueOf(CommonUtils.checkNull(request.getParamValue("saleQty_" + partId)));//提报数量
String partOldCode = CommonUtils.checkNull(request.getParamValue("partOldCode_" + partId));
Map<String, Object> map = dao.getReportedQty(orderId, partId);
if (map != null) {
reportedQty = ((BigDecimal) map.get("REPORTED_QTY")).longValue();
}
//如果大于订货数量
if (reportedQty + saleQty > buyQty) {
BizException e = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, partOldCode + "的审核数量不能大于" + (buyQty - reportedQty) + "!");
throw e;
}
Long dLineId = CommonUtils.parseLong(SequenceManager.getSequence(""));
String partCname = CommonUtils.checkNull(request.getParamValue("partCname_" + partId));
String partCode = CommonUtils.checkNull(request.getParamValue("partCode_" + partId));
String unit = CommonUtils.checkNull(request.getParamValue("unit_" + partId));
String minPackage = CommonUtils.checkNull(request.getParamValue("minPackage_" + partId));
String pkgNo = CommonUtils.checkNull(request.getParamValue("pkgNo_" + partId));
String remark = CommonUtils.checkNull(request.getParamValue("remark_" + partId));
TtPartDplanDtlPO po = new TtPartDplanDtlPO();
po.setDlineId(dLineId);
po.setPlanId(planId);
po.setPartId(CommonUtils.parseLong(partId));
po.setPartOldcode(partOldCode);
po.setPartCname(partCname);
po.setPartCode(partCode);
po.setUnit(unit);
po.setMinPackage(CommonUtils.parseLong(minPackage));
po.setBuyQty(buyQty);
po.setReportQty(saleQty);
po.setPkgNo(pkgNo);
po.setCreateDate(new Date());
po.setCreateBy(loginUser.getUserId());
po.setRemark(remark);
if (!"".equals(outType)) {
po.setTransType(CommonUtils.parseInteger(outType));
}
dao.insert(po);
}
} catch (Exception ex) {
throw ex;
}
}
// public boolean validatePlanSaleOrder(String orderId, String partId, Long saleQty, Long buyQty) {
// PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
// List<Map<String, Object>> soMainList = dao.getSoMain(orderId);
// //如果没做过 销售单越过
// if (null == soMainList) {
// if (soMainList.size() > 0) {
// String soIds = "";
// for (Map<String, Object> map : soMainList) {
// String soId = CommonUtils.checkNull(map.get("SO_ID"));
// soIds += "," + soId;
// }
// if (!"".equals(soIds)) {
// soIds = soIds.replaceFirst(",", "");
// }
// //做过销售单
// Long saledQty = dao.getSoDetailPartNum(soIds, partId);
//
// if ((saleQty + saledQty) > buyQty) {
// return false;
// }
// }
// }
// return true;
// }
/**
* 生成BO的集合
* @param boMap bomap对象
* @param price销售价
* @param orderId订单id
* @param orderCode订单编码
*/
private void loadBoVo(Map<String, Object> boMap, Double price,String orderId,String orderCode) {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
//判断bo单主表VO是否存在
if (boMap == null || null == boMap.get("mainVo")) {//无主表bo单主表实体类
Long boId = Long.parseLong(SequenceManager.getSequence(""));
String boCode = OrderCodeManager.getOrderCode(Constant.PART_CODE_RELATION_21);//一般BO
String soId = CommonUtils.checkNull(request.getAttribute("soId"));//销售单明细id
String remark = CommonUtils.checkNull(request.getParamValue("REMARK"));//订单备注
//bo单主表po
TtPartBoMainPO po = new TtPartBoMainPO();
po.setBoId(boId);
po.setBoCode(boCode);
po.setBoType("1");
po.setSoId(Long.valueOf(soId));
if (!"".equals(orderId)) {
po.setOrderId(Long.valueOf(orderId));
}
po.setOrderCode(orderCode);
if (!"".equals(remark)) {
po.setRemark(remark);
}
po.setCreateBy(loginUser.getUserId());
po.setCreateDate(new Date());
po.setState(Constant.CAR_FACTORY_SALES_MANAGER_BO_STATE_01);//BO单状态-已保存
po.setVer(1);
boMap.put("mainVo", po);
}
//判断bo单明细表实体类是否存在
if (boMap == null || null == boMap.get("detailVoList")) {
List<TtPartBoDtlPO> list = new ArrayList();
boMap.put("detailVoList", list);
}
//销售明细信息
Map<String, Object> partMap = (Map) request.getAttribute("partMap");
//bo单明细id
Long bolineId = Long.parseLong(SequenceManager.getSequence(""));
//bo单id
Long boId = ((TtPartBoMainPO) boMap.get("mainVo")).getBoId();
String partId = CommonUtils.checkNull(partMap.get("PART_ID"));
String partCode = CommonUtils.checkNull(partMap.get("PART_CODE"));
String partOldCode = CommonUtils.checkNull(partMap.get("PART_OLDCODE"));
String partCname = CommonUtils.checkNull(partMap.get("PART_CNAME"));
String unit = CommonUtils.checkNull(partMap.get("UNIT"));
String remark = CommonUtils.checkNull(partMap.get("REMARK"));
//bo单明细表po
TtPartBoDtlPO po = new TtPartBoDtlPO();
po.setBolineId(bolineId);
po.setBoId(boId);
po.setPartId(Long.valueOf(partId));
po.setPartCode(partCode);
po.setPartOldcode(partOldCode);
po.setBuyPrice(price);//采购单价
po.setPartCname(partCname);
po.setUnit(unit);
po.setBuyQty(Long.valueOf(partMap.get("BUY_QTY") == null ? "0" : partMap.get("BUY_QTY").toString()));//订货数量
po.setSalesQty(Long.valueOf(request.getParamValue("saleQty_" + partId) == null ? "0" : request.getParamValue("saleQty_" + partId)));//满足数量
//bo数量=订货数量-满足数量
Long boQty = Long.valueOf(partMap.get("BUY_QTY").toString()) - po.getSalesQty();
po.setBoQty(boQty);//bo数量
po.setBoOddqty(boQty);//剩余BO数量
po.setCreateBy(loginUser.getUserId());
po.setCreateDate(new Date());
if (!"".equals(remark)) {
po.setRemark(remark);
}
//bo单明细添加到bo单里
((List) boMap.get("detailVoList")).add(po);
}
/**
* 生成BO单,包括主表、明细表
* @param orderId 订单id
* @throws Exception
*/
private void createBoOrder(String orderId) throws Exception {
ActionContext act = ActionContext.getContext();
RequestWrapper request = act.getRequest();
// PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
// String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
//存在BO
if (request.getAttribute("boMap") != null && !((Map) request.getAttribute("boMap")).isEmpty()) {
Map<String, Object> boMap = (Map<String, Object>) request.getAttribute("boMap");
//bo主表
TtPartBoMainPO ttPartBoMainPO = (TtPartBoMainPO) boMap.get("mainVo");
dao.insert(ttPartBoMainPO);
//bo明细表
List<TtPartBoDtlPO> detailVoList = (List<TtPartBoDtlPO>) boMap.get("detailVoList");
for (int i = 0; i < detailVoList.size(); i++) {
dao.insert(detailVoList.get(i));
}
}
}
/**
* @param : @param orgAmt
* @param : @return
* @return :
* @throws : LastDate : 2013-4-3
* @Title :
* @Description:释放占用的资金
*/
// private void insertAccount() throws Exception {
// ActionContext act = ActionContext.getContext();
// AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
// RequestWrapper request = act.getRequest();
// PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
// try {
// //获取参数
// String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
// Map<String, Object> mainMap = dao.queryPartDlrOrderMain(orderId);
// Double orderAmount = Double.valueOf((mainMap.get("ORDER_AMOUNT") + "").replaceAll(",", ""));
// String accountId = CommonUtils.checkNull(mainMap.get("ACCOUNT_ID"));
// Double checkAmout = Double.valueOf(request.getAttribute("reCountMoney").toString());
// if (orderAmount == checkAmout) {
// return;
// }
// //更新预扣信息,关联销售单
// TtPartAccountRecordPO srcPo = new TtPartAccountRecordPO();
// srcPo.setSourceId(Long.valueOf(orderId));
// srcPo.setAccountId(Long.valueOf(accountId));
//
// TtPartAccountRecordPO updatePo = new TtPartAccountRecordPO();
// updatePo.setAmount(checkAmout);
// updatePo.setOrderId(Long.valueOf(request.getAttribute("soId").toString()));
// updatePo.setOrderCode(CommonUtils.checkNull(request.getAttribute("soCode").toString()));
//
// dao.update(srcPo, updatePo);
// } catch (Exception e) {
// throw e;
// }
// }
private Double parseDouble(Object obj) throws Exception {
ActionContext act = ActionContext.getContext();
String str = CommonUtils.checkNull(obj);
try {
if (str.indexOf(",") > -1) {
String[] strArr = str.split("\\,");
str = "";
for (int i = 0; i < strArr.length; i++) {
str += strArr[i];
}
}
return Double.valueOf(str);
} catch (Exception ex) {
BizException e = new BizException(act, ex, ErrorCodeConstant.SPECIAL_MEG, "数字转换错误!");
throw e;
}
}
//后修改发运类型为配置!!!
public Map<String, Object> getTransMap() throws Exception {
List<TtPartFixcodeDefinePO> list = CommonUtils.getPartUnitList(Constant.FIXCODE_TYPE_04);// 获取配件发运方式
Map<String, Object> transMap = new HashMap<String, Object>();
for (TtPartFixcodeDefinePO po : list) {
//list.fixValue }">${list.fixName
transMap.put(po.getFixValue(), po.getFixName());
}
return transMap;
}
/**
* 提交给车厂
*/
public void repToFactory() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
PartSoManageDao partSoManageDao = PartSoManageDao.getInstance();
try {
String dealerId = "";
String flag = "";
//判断是否为车厂 PartWareHouseDao
PartWareHouseDao partWareHouseDao = PartWareHouseDao.getInstance();
List<OrgBean> beanList = partWareHouseDao.getOrgInfo(loginUser);
if (null != beanList || beanList.size() >= 0) {
dealerId = beanList.get(0).getOrgId() + "";
}
String sellerId = Constant.OEM_ACTIVITIES;
String sellerCode = Constant.ORG_ROOT_CODE;
Map<String, Object> oemMap = dao.getOem(sellerCode, sellerId);
String sellerName = CommonUtils.checkNull(oemMap.get("COMPANY_NAME"));
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
//更新DTL中的单价
List<Map<String, Object>> detailList = dao.queryPartDlrOrderDetail(orderId);
Double orderAmount = 0D;
for (Map<String, Object> map : detailList) {
String partId = CommonUtils.checkNull(map.get("PART_ID"));
Double price = Double.valueOf(partSoManageDao.getPrice(dealerId, partId));
Double discount = Double.valueOf(dao.getDiscount(sellerId));
Double realPrice = Arith.mul(price, discount);
Double buyQty = Double.valueOf(CommonUtils.checkNull(map.get("BUY_QTY")));
Double amount = Arith.mul(buyQty, realPrice);
orderAmount += amount;
TtPartDlrOrderDtlPO oldDtlPo = new TtPartDlrOrderDtlPO();
oldDtlPo.setLineId(Long.valueOf(CommonUtils.checkNull(map.get("LINE_ID"))));
TtPartDlrOrderDtlPO newDtlPo = new TtPartDlrOrderDtlPO();
newDtlPo.setLineId(Long.valueOf(CommonUtils.checkNull(map.get("LINE_ID"))));
newDtlPo.setBuyPrice(realPrice);
newDtlPo.setBuyAmount(amount);
dao.update(oldDtlPo, newDtlPo);
}
TmDealerPO dealerPO = new TmDealerPO();
dealerPO.setDealerId(Long.valueOf(loginUser.getDealerId()));
//更新MAIN
//替换订货单位为供应中心,同时替换销售单位为主机厂
TtPartDlrOrderMainPO newPo = new TtPartDlrOrderMainPO();
//newPo.setOrderId(Long.valueOf(orderId));
newPo.setSellerId(Long.valueOf(sellerId)); //oemID
newPo.setSellerCode(sellerCode);
newPo.setSellerName(sellerName);
newPo.setOrderAmount(orderAmount);
newPo.setDealerId(Long.valueOf(loginUser.getDealerId()));//供应中心ID
newPo.setDealerCode(loginUser.getDealerCode());
newPo.setDealerName(((TmDealerPO) dao.select(dealerPO).get(0)).getDealerName());
newPo.setIsSuborder(Constant.IF_TYPE_YES);//下级订单标志
TtPartDlrOrderMainPO oldPo = new TtPartDlrOrderMainPO();
oldPo.setOrderId(Long.valueOf(orderId));
dao.update(oldPo, newPo);
//直发占用资金
Map<String, Object> mainMap = dao.queryPartDlrOrderMain(orderId);
String orderCode = CommonUtils.checkNull(mainMap.get("ORDER_CODE"));
//获取账户余额等
Map<String, Object> accountMap = dao.getAccount(dealerId, sellerId, "");
TtPartAccountRecordPO po = new TtPartAccountRecordPO();
if (null != accountMap) {
try {
//校验金额
if (orderAmount > Double.valueOf(CommonUtils.checkNull(accountMap.get("ACCOUNT_KY")).replace(",", ""))) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "账户金额不足!");
throw e1;
}
} catch (Exception ex) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "账户金额不足!!");
throw e1;
}
} else {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "账户错误,请联系管理员!");
throw e1;
}
po.setAccountId(Long.valueOf(accountMap.get("ACCOUNT_ID").toString()));
Long recordId = Long.parseLong(SequenceManager.getSequence(""));
po.setRecordId(recordId);
po.setChangeType(Constant.CAR_FACTORY_SALE_ACCOUNT_RECOUNT_TYPE_01);
po.setDealerId(Long.valueOf(dealerId));
po.setAmount(orderAmount);
po.setFunctionName("配件提报预占");
po.setSourceId(Long.valueOf(orderId));
po.setSourceCode(orderCode);
po.setOrderId(Long.valueOf(orderId));
po.setOrderCode(orderCode);
po.setCreateBy(loginUser.getUserId());
po.setCreateDate(new Date());
dao.insert(po);
POContext.endTxn(true);
act.setOutData("success", "操作成功!");
} catch (Exception e) {
POContext.endTxn(false);
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "生成销售单错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
public void getFreight() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
String dealerId = CommonUtils.checkNull(request.getParamValue("dealerId"));
String orderType = CommonUtils.checkNull(request.getParamValue("ORDER_TYPE"));
if ("".equals(orderType)) {
orderType = CommonUtils.checkNull(request.getParamValue("orderType"));
}
String money = CommonUtils.checkNull(request.getParamValue("money"));
String freight = dao.getFreight(dealerId, orderType, money);
act.setOutData("freight", freight);
act.setOutData("amountCount", money);
} catch (Exception e) {
POContext.endTxn(false);
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "获取运费错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
/**
* 订单驳回
*/
public void rebut() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
//释放预占资金
TtPartAccountRecordPO po = new TtPartAccountRecordPO();
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
String reason = CommonUtils.checkNull(request.getParamValue("reason"));
reason = URLDecoder.decode(reason, "UTF-8"); //转乱码 add zhumingwei 2014-08-15
//String reason1 = new String(reason.getBytes("ISO-8859-1"), "UTF-8");
Map<String, Object> mainMap = dao.queryPartDlrOrderMain(orderId);
if(mainMap!=null){
if (!(mainMap.get("STATE") + "").equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_02 + "")) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "订单状态已改变!请重新查询!");
throw e1;
}
}else{
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "未查询到订单信息!请重新查询!");
throw e1;
}
po.setSourceId(Long.valueOf(orderId));
//modify by yuan 20130921 start
/*List<PO> list = dao.select(po);
Double amount = 0D;
for(PO recordpo:list){
po = (TtPartAccountRecordPO)recordpo;
amount =Arith.add(amount,po.getAmount());
}*/
/*if(amount!=0D){
Long recordId = Long.parseLong(SequenceManager.getSequence(""));
po.setRecordId(recordId);
po.setChangeType(Constant.CAR_FACTORY_SALE_ACCOUNT_RECOUNT_TYPE_02);
po.setFunctionName("驳回释放");
po.setAmount(-(amount));//释放金额为 负数
po.setCreateBy(loginUser.getUserId());
po.setCreateDate(new Date());
dao.insert(po);
}*/
//end
//更新订单状态和驳回原因
TtPartDlrOrderMainPO oldPo = new TtPartDlrOrderMainPO();
oldPo.setOrderId(Long.valueOf(orderId));
TtPartDlrOrderMainPO srcPo = new TtPartDlrOrderMainPO();
srcPo.setOrderId(Long.valueOf(orderId));
TtPartDlrOrderMainPO newPo = new TtPartDlrOrderMainPO();
newPo.setOrderId(Long.valueOf(orderId));
newPo.setRebutReason(reason);
newPo.setSubmitDate(null);
newPo.setSubmitBy(null);
//增加是否下级订单判断
oldPo = (TtPartDlrOrderMainPO) dao.select(oldPo).get(0);
if (oldPo.getIsSuborder().equals(Constant.IF_TYPE_YES)) {//如果是转下级订单,还原采购单位和销售单位
TmDealerPO dealerPO = new TmDealerPO();
dealerPO.setDealerId(oldPo.getRcvOrgid());
newPo.setDealerId(oldPo.getRcvOrgid());
newPo.setDealerName(oldPo.getRcvOrg());
newPo.setDealerCode(((TmDealerPO) dao.select(dealerPO).get(0)).getDealerCode());
newPo.setSellerId(oldPo.getDealerId());
newPo.setSellerCode(oldPo.getDealerCode());
newPo.setSellerName(oldPo.getDealerName());
newPo.setIsSuborder(Constant.IF_TYPE_NO);
newPo.setUpdateDate(new Date());
newPo.setUpdateBy(loginUser.getUserId());
} else {
newPo.setState(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_01);//保存
}
po.setDealerId(oldPo.getDealerId());//删除占有资金
dao.delete(po);
dao.update(srcPo, newPo);
dao.rebutOrder(orderId);
//重新计算订单次数
ArrayList ins = new ArrayList();
ins.add(0, orderId);
dao.callProcedure("PKG_PART_TOOLS.P_DLRORDERNUM", ins, null);
act.setOutData("success", "驳回成功!");
} catch (Exception e) {
POContext.endTxn(false);
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "驳回失败,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
}
}
/**
* 广宣订单驳回
*/
public void rebutGxOrder() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
MarketPartDlrOrderDao dao = MarketPartDlrOrderDao.getInstance();
try {
//去除预占资金
//TtPartAccountRecordPO po = new TtPartAccountRecordPO();
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
String reason = CommonUtils.checkNull(request.getParamValue("reason"));
reason = URLDecoder.decode(reason, "UTF-8");
Map<String, Object> mainMap = dao.queryPartDlrOrderMain(orderId);
if (!(mainMap.get("STATE") + "").equals(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_02 + "")) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "订单状态已改变!请重新查询!");
throw e1;
}
//更新订单状态和驳回原因
TtPartDlrOrderMainPO oldPo = new TtPartDlrOrderMainPO();
oldPo.setOrderId(Long.valueOf(orderId));
TtPartDlrOrderMainPO srcPo = new TtPartDlrOrderMainPO();
srcPo.setOrderId(Long.valueOf(orderId));
TtPartDlrOrderMainPO newPo = new TtPartDlrOrderMainPO();
newPo.setOrderId(Long.valueOf(orderId));
newPo.setRebutReason(reason);
//增加是否下级订单判断
oldPo = (TtPartDlrOrderMainPO) dao.select(oldPo).get(0);
if (oldPo.getIsSuborder().equals(Constant.IF_TYPE_YES)) {//如果是转下级订单,还原采购单位和销售单位
TmDealerPO dealerPO = new TmDealerPO();
dealerPO.setDealerId(oldPo.getRcvOrgid());
newPo.setDealerId(oldPo.getRcvOrgid());
newPo.setDealerName(oldPo.getRcvOrg());
newPo.setDealerCode(((TmDealerPO) dao.select(dealerPO).get(0)).getDealerCode());
newPo.setSellerId(oldPo.getDealerId());
newPo.setSellerCode(oldPo.getDealerCode());
newPo.setSellerName(oldPo.getDealerName());
newPo.setIsSuborder(Constant.IF_TYPE_NO);
newPo.setUpdateDate(new Date());
newPo.setUpdateBy(loginUser.getUserId());
} else {
newPo.setState(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_01);//保存
}
//资金还原
StringBuffer sbSql = new StringBuffer();
List<Object> params = new ArrayList<Object>();
if (!"".equals(oldPo.getAccountId())) {
sbSql.append("UPDATE TT_SALES_FIN_ACC T\n");
sbSql.append(" SET T.AMOUNT = NVL(T.AMOUNT, 0) + " + oldPo.getOrderAmount() + ",\n");
sbSql.append(" T.FREEZE_AMOUNT = NVL(T.FREEZE_AMOUNT, 0) - " + oldPo.getOrderAmount() + "\n");
sbSql.append(" WHERE T.ACC_ID = " + oldPo.getAccountId() + "");
}
dao.update(sbSql.toString(), params);
request.setAttribute("mainAmount", oldPo.getOrderAmount());
orderFinAccFlow(request, act, oldPo.getDealerId());//财务扣款流水明细
dao.update(srcPo, newPo);
//dao.updateOrderNum(Long.valueOf(orderId));//修改订单次数
//this.saveHistory(request, act, Integer.valueOf(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_05));
act.setOutData("success", "驳回成功!");
} catch (Exception e) {
POContext.endTxn(false);
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "驳回失败,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
}
}
/**
* 财务扣款流水明细
*
* @param req
* @param act
*/
private void orderFinAccFlow(RequestWrapper req, ActionContext act, long dealerId) {
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
MarketPartDlrOrderDao dao = MarketPartDlrOrderDao.getInstance();
TtSaleFundsRoseDetailPO fundDetailPO = new TtSaleFundsRoseDetailPO();
String orderCode = CommonUtils.checkNull(req.getAttribute("orderCode"));
double mainAmount = Double.parseDouble(CommonUtils.checkNull(req.getAttribute("mainAmount")));
fundDetailPO.setRemark("广宣品订单:" + orderCode + "驳回释放冻结");
fundDetailPO.setDealerId(dealerId);
fundDetailPO.setDetailId(Long.parseLong(SequenceManager.getSequence("")));
fundDetailPO.setAmount(-mainAmount);
fundDetailPO.setCreateBy(logonUser.getUserId());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
fundDetailPO.setCreateDate(sdf.format(new Date()));
fundDetailPO.setFinType(Constant.ACCOUNT_TYPE_01);
fundDetailPO.setIsType(6);
dao.insert(fundDetailPO);
fundDetailPO.setDetailId(Long.parseLong(SequenceManager.getSequence("")));
fundDetailPO.setRemark("广宣品订单:" + orderCode + "返还可用余额");
fundDetailPO.setAmount(mainAmount);//扣除可用余额(-)
fundDetailPO.setIsType(5);
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
fundDetailPO.setCreateDate(sdf.format(new Date()));
dao.insert(fundDetailPO);
}
public void getGift() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
act.getResponse().setContentType("application/json");
//分页方法 begin
Integer curPage = request.getParamValue("curPage") != null ? Integer
.parseInt(request.getParamValue("curPage"))
: 1; // 处理当前页
PageResult<Map<String, Object>> ps = dao.getGift(request, curPage);
//如果数据量大 这样1可以避免赠品数据错误 2循环10次获取比join的快
if (ps != null && ps.getRecords() != null) {
List<Map<String, Object>> list = ps.getRecords();
for (Map<String, Object> map : list) {
String partId = CommonUtils.checkNull(map.get("PART_ID"));
Map<String, Object> partMap = dao.getPartDefine(partId, CommonUtils.checkNull(request.getParamValue("dealerId")));
map.putAll(partMap);
}
}
act.setOutData("ps", ps);
} catch (Exception e) {
POContext.endTxn(false);
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "查询赠品失败,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER_CHECK_QUERY);
}
}
private void saveQueryCondition() {
ActionContext act = ActionContext.getContext();
RequestWrapper request = act.getRequest();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
String orderCode = CommonUtils.checkNull(request.getParamValue("ORDER_CODE"));//订单号
String dealerName = CommonUtils.checkNull(request.getParamValue("DEALER_NAME"));//订货单位
String sellerName = CommonUtils.checkNull(request.getParamValue("SELLER_NAME"));//销售单位
String CstartDate = CommonUtils.checkNull(request.getParamValue("CstartDate"));// 制单日期 开始
String CendDate = CommonUtils.checkNull(request.getParamValue("CendDate"));// 制单日期 结束
String orderType = CommonUtils.checkNull(request.getParamValue("ORDER_TYPE"));//订单类型
String SstartDate = CommonUtils.checkNull(request.getParamValue("SstartDate"));//提交时间 开始
String SendDate = CommonUtils.checkNull(request.getParamValue("SendDate"));//提交时间 结束
String state = CommonUtils.checkNull(request.getParamValue("state"));//订单状态
String autoPreCheck = CommonUtils.checkNull(request.getParamValue("autoPreCheck"));//自动预审
String salerId = CommonUtils.checkNull(request.getParamValue("salerId"));
Map<String, Object> map = new HashMap<String, Object>();
map.put("orderCode", orderCode);
map.put("dealerName", dealerName);
map.put("sellerName", sellerName);
map.put("state", state);
map.put("autoPreCheck", autoPreCheck);
map.put("salerId", salerId);
map.put("CstartDate", CstartDate);
map.put("CendDate", CendDate);
map.put("orderType", orderType);
map.put("SstartDate", SstartDate);
map.put("SendDate", SendDate);
act.getSession().set("condition", map);
}
/**
* 生成bo单,整个订单生成bo单
* 关闭的action方法
*/
public void closeOrderAction() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
try {
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
String orderCode = CommonUtils.checkNull(request.getParamValue("orderCode"));
String whId = CommonUtils.checkNull(request.getParamValue("wh_id"));
//关闭销售单,生成bo单
closeOrder(orderId, whId);
//设置查询条件
saveQueryCondition();
act.setOutData("orderId", orderId);
act.setOutData("orderCode", orderCode);
act.setOutData("success", "强制关闭成功!");
act.setOutData("boStr", "1");
//act.setForword(PART_DIRECT_DLR_ORDER_CHECK_QUERY);
} catch (Exception e) {//异常方法
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_ORDER);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "关闭失败!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
//关闭的私有方法
private void closeOrder(String id, String whId) throws Exception {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
String name = "";
try {
//更新主订单状态 start
TtPartDlrOrderMainPO oldPo = new TtPartDlrOrderMainPO();
TtPartDlrOrderMainPO newPo = new TtPartDlrOrderMainPO();
TtPartAccountRecordPO recordPO = new TtPartAccountRecordPO();
recordPO.setSourceId(Long.valueOf(id));
try {
oldPo.setOrderId(Long.valueOf(id));
newPo.setOrderId(Long.valueOf(id));
newPo.setState(Constant.CAR_FACTORY_SALES_MANAGER_ORDER_STATE_07);
newPo.setWhId(Long.valueOf(whId));
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "数据出错!");
throw e1;
}
try {
dao.update(oldPo, newPo);
dao.delete(recordPO);//强制关闭时资金预占解除
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "主订单状态更新出错!");
throw e1;
}
//更新主订单状态 end
//生成bo start
//获取主订单数据
TtPartDlrOrderMainPO mainPo = new TtPartDlrOrderMainPO();
List<TtPartDlrOrderMainPO> mainList = new ArrayList<TtPartDlrOrderMainPO>();
try {
mainPo.setOrderId(Long.valueOf(id));
mainList = dao.select(mainPo);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "查询订单主数据出错!");
throw e1;
}
if (mainList.size() <= 0) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "订单不存在!");
throw e1;
}
mainPo = mainList.get(0);
//获取订单明细数据
TtPartDlrOrderDtlPO dtlPo = new TtPartDlrOrderDtlPO();
List<TtPartDlrOrderDtlPO> dtlList = new ArrayList<TtPartDlrOrderDtlPO>();
try {
dtlPo.setOrderId(Long.valueOf(id));
dtlList = dao.select(dtlPo);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "查询订单明细出错!");
throw e1;
}
if (dtlList.size() <= 0) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, "订单不存在配件明细!");
throw e1;
}
//生成bo主表数据
TtPartBoMainPO ttPartBoMainPO = new TtPartBoMainPO();
Long boId = Long.parseLong(SequenceManager.getSequence(""));
String boCode = OrderCodeManager.getOrderCode(Constant.PART_CODE_RELATION_21);
try {
ttPartBoMainPO.setBoId(boId);
ttPartBoMainPO.setBoType("1");
ttPartBoMainPO.setBoCode(boCode);
ttPartBoMainPO.setOrderCode(mainPo.getOrderCode());
ttPartBoMainPO.setOrderId(Long.valueOf(id));
ttPartBoMainPO.setCreateBy(loginUser.getUserId());
ttPartBoMainPO.setCreateDate(new Date());
ttPartBoMainPO.setState(Constant.CAR_FACTORY_SALES_MANAGER_BO_STATE_01);
ttPartBoMainPO.setVer(1);
ttPartBoMainPO.setRemark(mainPo.getRemark());
dao.insert(ttPartBoMainPO);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "BO主表数据出错!");
throw e1;
}
//生成bo明细数据
try {
for (TtPartDlrOrderDtlPO po : dtlList) {
TtPartBoDtlPO ttPartBoDtlPO = new TtPartBoDtlPO();
name = po.getPartCname();
Long bolineId = Long.parseLong(SequenceManager.getSequence(""));
ttPartBoDtlPO.setBolineId(bolineId);
ttPartBoDtlPO.setBoId(boId);
ttPartBoDtlPO.setPartId(po.getPartId());
ttPartBoDtlPO.setPartCode(po.getPartCode());
ttPartBoDtlPO.setPartOldcode(po.getPartOldcode());
ttPartBoDtlPO.setBuyPrice(po.getBuyPrice());
ttPartBoDtlPO.setBuyPrice1(po.getBuyPrice1());
ttPartBoDtlPO.setPartCname(po.getPartCname());
ttPartBoDtlPO.setUnit(po.getUnit());
ttPartBoDtlPO.setBuyQty(po.getBuyQty());
ttPartBoDtlPO.setSalesQty(0L);
ttPartBoDtlPO.setBoQty(po.getBuyQty());
ttPartBoDtlPO.setBoOddqty(po.getBuyQty());
ttPartBoDtlPO.setCreateBy(loginUser.getUserId());
ttPartBoDtlPO.setCreateDate(new Date());
ttPartBoDtlPO.setRemark(po.getRemark());//备注
dao.insert(ttPartBoDtlPO);
}
} catch (Exception e) {
String msg = "生成BO明细失败!";
if (!"".equals(name)) {
msg = "生成配件:" + name + "的BO失败!";
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, msg);
throw e1;
}
//
//更新BO单主表BO单商品总金额
dao.updateBOMainAmount(boId);
//获取BO单商品总金额
TtPartBoMainPO tmpMainPO = new TtPartBoMainPO();
tmpMainPO.setBoId(boId);
TtPartBoMainPO tmpMainPO2 = (TtPartBoMainPO) dao.select(tmpMainPO).get(0);
double amount = tmpMainPO2.getBoAmount();
//组织数据插入资金占用信息
//获取账户余额等
Map<String, Object> acountMap = dao.getAccount(mainPo.getDealerId() + "", mainPo.getSellerId() + "", null);
Long accountId = null;
if (null != acountMap) {
accountId = Long.valueOf(acountMap.get("ACCOUNT_ID").toString());
}
Map infoMap = new HashMap();
infoMap.put("dealerId", mainPo.getDealerId());
infoMap.put("accountId", accountId);
infoMap.put("sourceId", ttPartBoMainPO.getOrderId());
infoMap.put("sourceCode", ttPartBoMainPO.getOrderCode());
infoMap.put("boId", ttPartBoMainPO.getBoId());
infoMap.put("boCode", ttPartBoMainPO.getBoCode());
//infoMap.put("orderId", ttPartBoMainPO.getOrderId());
//infoMap.put("orderCode", ttPartBoMainPO.getOrderCode());
infoMap.put("amount", amount);
String funName = "BO单预占";
infoMap.put("funName", funName);
dao.insertAccountNew(loginUser, infoMap);
} catch (Exception e) {//异常方法
POContext.endTxn(false);
if (e instanceof BizException) {
throw e;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "关闭失败!");
throw e1;
}
}
public void addMarketOrder() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
//前台页面数据集合
Map<String, Object> dataMap = new HashMap();
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
try {
String dealerId = "";
String dealerCode = "";
String dealerName = "";
//判断是否为车厂 PartWareHouseDao
PartWareHouseDao partWareHouseDao = PartWareHouseDao.getInstance();
List<OrgBean> beanList = partWareHouseDao.getOrgInfo(loginUser);
if (null != beanList || beanList.size() >= 0) {
dealerId = beanList.get(0).getOrgId() + "";
dealerCode = beanList.get(0).getOrgCode();
dealerName = beanList.get(0).getOrgName();
}
if ("".equals(dealerId)) {
BizException e1 = new BizException(act, new RuntimeException(), ErrorCodeConstant.SPECIAL_MEG, " </br>此工号没有操作权限,请联系管理员!");
throw e1;
}
String orderType = CommonUtils.checkNull(request.getParamValue("orderType"));
//获取当前时间
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String now = sdf.format(date);
dataMap.put("name", loginUser.getName());
//获取账户
Map<String, Object> accountMap = dao.getAccount(dealerId, dealerId, "");
//折扣率
String discount = dao.getDiscount(dealerId);
List list = CommonUtils.getPartUnitList(Constant.FIXCODE_TYPE_04);// 获取配件发运方式
//品牌
List<Map<String, Object>> brandList = dao.getBrand();
//仓库
PurchasePlanSettingDao purchasePlanSettingDao = PurchasePlanSettingDao.getInstance();
List<Map<String, Object>> wareHouseList = purchasePlanSettingDao.getWareHouse(dealerId);
dataMap.put("now", now);
dataMap.put("dealerId", dealerId);
dataMap.put("dealerCode", dealerCode);
dataMap.put("dealerName", dealerName);
dataMap.put("discount", discount);
dataMap.put("orderType", orderType);
dataMap.put("createBy", loginUser.getName());
act.setOutData("accountMap", accountMap);
act.setOutData("transList", list);
act.setOutData("brandList", brandList);
act.setOutData("dataMap", dataMap);
act.setOutData("wareHouseList", wareHouseList);
act.setForword(PART_OEM_GX_ORDER_ADD);
} catch (Exception e) {
if (e instanceof BizException) {
BizException e1 = (BizException) e;
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_GXORDER_CHECK_QUERY);
return;
}
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "订单新增错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
act.setForword(PART_DLR_GXORDER_CHECK_QUERY);
}
}
/**
* 验收异常初始化
*/
public void detailDlrOrderEX() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
try {
String inId = CommonUtils.checkNull(request.getParamValue("IN_ID"));
act.setOutData("IN_ID", inId);
act.setForword(PART_DLR_ORDER_CHECK_DETAIL_EX);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "验收异常查询数据错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
/**
* @param :
* @return :
* @throws : LastDate : 2013-4-18
* @Title :
* @Description: 配件销售审核查询
*/
public void partDlrOrderEXQuery() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
try {
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
String inId = CommonUtils.checkNull(request.getParamValue("IN_ID"));
//分页方法 begin
Integer curPage = request.getParamValue("curPage") != null ? Integer
.parseInt(request.getParamValue("curPage"))
: 1; // 处理当前页
PageResult<Map<String, Object>> ps = null;
ps = dao.queryPartDlrOrderEX(request, curPage, Constant.PAGE_SIZE);
act.setOutData("ps", ps);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "配件验收异常查询数据错误,请联系管理员!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
public void updateOrderRemark() {
ActionContext act = ActionContext.getContext();
AclUserBean loginUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
RequestWrapper request = act.getRequest();
try {
String orderId = CommonUtils.checkNull(request.getParamValue("orderId"));
String remark = CommonUtils.checkNull(request.getParamValue("remark"));
PartDlrOrderDao dao = PartDlrOrderDao.getInstance();
TtPartDlrOrderMainPO dlrOrderMainPO = new TtPartDlrOrderMainPO();
dlrOrderMainPO.setOrderId(Long.valueOf(orderId));
TtPartDlrOrderMainPO updatePO = new TtPartDlrOrderMainPO();
updatePO.setRemark(remark);
dao.update(dlrOrderMainPO, updatePO);
act.setOutData("success", "修改成功!");
} catch (Exception e) {//异常方法
BizException e1 = new BizException(act, e, ErrorCodeConstant.SPECIAL_MEG, "关闭失败!");
logger.error(loginUser, e1);
act.setException(e1);
}
}
}
| [
"[email protected]"
]
| |
1d1a402d0cfcf7a8a7a289cc0acb354914e0080e | 55fc4ebd6f4ccf87e402bca39f76fe4716ae3ca0 | /mall-coupon/src/main/java/cn/huan/mall/coupon/entity/SpuBoundsEntity.java | 9d6e089464a4ec8b066a0065cae1673d935ddbfc | [
"Apache-2.0"
]
| permissive | HHVic/huan-mall | 127af0bc94fe3ea20d742f84e0cb008118e22cc5 | 50bea292304951049b2e374167d1a9d2b3b05baf | refs/heads/master | 2023-03-09T01:58:45.921550 | 2021-02-25T09:33:11 | 2021-02-25T09:33:11 | 305,991,563 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,004 | java | package cn.huan.mall.coupon.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 商品spu积分设置
*
* @author konghuan
* @email [email protected]
* @date 2020-09-15 01:55:13
*/
@Data
@TableName("sms_spu_bounds")
public class SpuBoundsEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId
private Long id;
/**
*
*/
private Long spuId;
/**
* 成长积分
*/
private BigDecimal growBounds;
/**
* 购物积分
*/
private BigDecimal buyBounds;
/**
* 优惠生效情况[1111(四个状态位,从右到左);0 - 无优惠,成长积分是否赠送;1 - 无优惠,购物积分是否赠送;2 - 有优惠,成长积分是否赠送;3 - 有优惠,购物积分是否赠送【状态位0:不赠送,1:赠送】]
*/
private Integer work;
}
| [
"[email protected]"
]
| |
a19a43e5167efc72130c445d8b61ec16f4e08b43 | ad446c047853c1a5080235c1f07732c41347562b | /src/com/company/smartDevice/environmental/safety/AlarmCo2.java | 334e05c39924d90bddc671b203bb2d0cafda28d2 | []
| no_license | kohanaya/smart-home | d6eff4f97423003d840f618a0001e7b6535a3c3b | 416426f07c947edf12b56670b6f09285bff209f3 | refs/heads/master | 2023-03-29T20:48:51.016214 | 2021-03-14T23:24:41 | 2021-03-14T23:24:41 | 345,206,522 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 200 | java | package com.company.smartDevice.environmental.safety;
import com.company.smartDevice.Device;
public class AlarmCo2 extends Device {
public AlarmCo2(String name) {
super(name);
}
}
| [
"[email protected]"
]
| |
5c052281c79c405d86e81ee4437c8359279041ee | 738aefec429ea9de2779f2a498cb051ee7881f73 | /Bank/src/P1/Transfer.java | 77c9c65c53f63f332e8ba0c7ddf48f5cadf9e2a2 | []
| no_license | Jishajoy22/BankApp | c16ecef76e369ed56391926a6d3d6c88e2cfeb19 | 96799842954caecb1f11145c82d228a33e1be47a | refs/heads/master | 2020-04-27T00:03:34.171285 | 2019-03-05T10:14:07 | 2019-03-05T10:14:07 | 173,922,661 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 859 | java | package P1;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class Transfer extends HttpServlet
{
String amt1;
int amt;
int accno;
boolean value;
public void service(HttpServletRequest request,HttpServletResponse response)
{
amt1=request.getParameter("amt");
amt=Integer.parseInt(amt1);
HttpSession session=request.getSession();
accno=(int)session.getAttribute("accno");
Model m=new Model();
m.setAccno(accno);
try
{
value=m.amountTransfer(amt);
if(value==true)
{
response.sendRedirect("/Bank/transfersuccess.html");
}
else
{
response.sendRedirect("/Bank/transferfail.html");
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
} | [
"Jisha Joy@Jisha_Joy"
]
| Jisha Joy@Jisha_Joy |
c535733864cd5f95c858028d2a0d917626e946c9 | 162f3254ef08fb450d072abe2ce490ef8644223c | /src/com/javaee/examples/java_multithreading_concurrency/block_sychronized_keyword/AppTest.java | c6ba98625a9db7ae28d3d06f8bdf4805303233d4 | []
| no_license | krishnabhat81/java-ee | 20e784283db683e80e86a8b6fa01eb06ed97ea91 | 112b18fcdb9f25353dd02629d6852e932125901b | refs/heads/master | 2021-01-20T10:05:49.325815 | 2017-09-10T22:46:26 | 2017-09-10T22:46:26 | 90,320,564 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 395 | java | package com.javaee.examples.java_multithreading_concurrency.block_sychronized_keyword;
/**
* Created by krishna1bhat on 9/4/17.
*/
public class AppTest {
public static void main(String... args){
new WorkerFirstRun().main();
//new WorkerFinal().main(); // check this for synchronized block - time taken is nearly 2 second and also list1 and list2 has all 2000 data
}
}
| [
"[email protected]"
]
| |
fa229dd55be4cc823e86b05a7305a79594f5ebe5 | fa3593ab382e9d3cedb702e29da91301446996a4 | /tester/weka/src/main/java/weka/classifiers/evaluation/output/prediction/AbstractOutput.java | cd87b8828c2e32ce5c81c0a3ad6dfc010c808144 | [
"MIT"
]
| permissive | Programming-Systems-Lab/kabu | bbf75615779b1205f2951e162e99d546312900da | 652815e7b003d9899d68807632207147a1fd743f | refs/heads/master | 2022-03-09T06:06:16.972245 | 2020-02-27T00:20:39 | 2020-02-27T00:20:39 | 15,849,390 | 0 | 1 | MIT | 2022-02-26T00:50:52 | 2014-01-12T19:48:03 | Java | UTF-8 | Java | false | false | 19,899 | java | /*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* AbstractOutput.java
* Copyright (C) 2009-2012 University of Waikato, Hamilton, New Zealand
*/
package weka.classifiers.evaluation.output.prediction;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Vector;
import weka.classifiers.Classifier;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.OptionHandler;
import weka.core.Range;
import weka.core.Utils;
import weka.core.WekaException;
import weka.core.converters.ConverterUtils.DataSource;
/**
* A superclass for outputting the classifications of a classifier.
* <p/>
* Basic use with a classifier and a test set:
* <pre>
* Classifier classifier = ... // trained classifier
* Instances testset = ... // the test set to output the predictions for
* StringBuffer buffer = ... // the string buffer to add the output to
* AbstractOutput output = new FunkyOutput();
* output.setHeader(...);
* output.printClassifications(classifier, testset);
* </pre>
*
* Basic use with a classifier and a data source:
* <pre>
* Classifier classifier = ... // trained classifier
* DataSource testset = ... // the data source to obtain the test set from to output the predictions for
* StringBuffer buffer = ... // the string buffer to add the output to
* AbstractOutput output = new FunkyOutput();
* output.setHeader(...);
* output.printClassifications(classifier, testset);
* </pre>
*
* In order to make the output generation easily integrate into GUI components,
* one can output the header, classifications and footer separately:
* <pre>
* Classifier classifier = ... // trained classifier
* Instances testset = ... // the test set to output the predictions for
* StringBuffer buffer = ... // the string buffer to add the output to
* AbstractOutput output = new FunkyOutput();
* output.setHeader(...);
* // print the header
* output.printHeader();
* // print the classifications one-by-one
* for (int i = 0; i < testset.numInstances(); i++) {
* output.printClassification(classifier, testset.instance(i), i);
* // output progress information
* if ((i+1) % 100 == 0)
* System.out.println((i+1) + "/" + testset.numInstances());
* }
* // print the footer
* output.printFooter();
* </pre>
*
* @author fracpete (fracpete at waikato dot ac dot nz)
* @version $Revision: 8034 $
*/
public abstract class AbstractOutput
implements Serializable, OptionHandler {
/** for serialization. */
private static final long serialVersionUID = 752696986017306241L;
/** the header of the dataset. */
protected Instances m_Header;
/** the buffer to write to. */
protected StringBuffer m_Buffer;
/** the file buffer to write to. */
protected StringBuffer m_FileBuffer;
/** whether to output the class distribution. */
protected boolean m_OutputDistribution;
/** the range of attributes to output. */
protected Range m_Attributes;
/** the number of decimals after the decimal point. */
protected int m_NumDecimals;
/** the file to store the output in. */
protected File m_OutputFile;
/** whether to suppress the regular output and only store in file. */
protected boolean m_SuppressOutput;
/**
* Initializes the output class.
*/
public AbstractOutput() {
m_Header = null;
m_OutputDistribution = false;
m_Attributes = null;
m_Buffer = null;
m_NumDecimals = 3;
m_OutputFile = new File(".");
m_FileBuffer = new StringBuffer();
m_SuppressOutput = false;
}
/**
* Returns a string describing the output generator.
*
* @return a description suitable for
* displaying in the GUI
*/
public abstract String globalInfo();
/**
* Returns a short display text, to be used in comboboxes.
*
* @return a short display text
*/
public abstract String getDisplay();
/**
* Returns an enumeration of all the available options..
*
* @return an enumeration of all available options.
*/
public Enumeration listOptions() {
Vector result;
result = new Vector();
result.addElement(new Option(
"\tThe range of attributes to print in addition to the classification.\n"
+ "\t(default: none)",
"p", 1, "-p <range>"));
result.addElement(new Option(
"\tWhether to turn on the output of the class distribution.\n"
+ "\tOnly for nominal class attributes.\n"
+ "\t(default: off)",
"distribution", 0, "-distribution"));
result.addElement(new Option(
"\tThe number of digits after the decimal point.\n"
+ "\t(default: " + getDefaultNumDecimals() + ")",
"decimals", 1, "-decimals <num>"));
result.addElement(new Option(
"\tThe file to store the output in, instead of outputting it on stdout.\n"
+ "\tGets ignored if the supplied path is a directory.\n"
+ "\t(default: .)",
"file", 1, "-file <path>"));
result.addElement(new Option(
"\tIn case the data gets stored in a file, then this flag can be used\n"
+ "\tto suppress the regular output.\n"
+ "\t(default: not suppressed)",
"suppress", 0, "-suppress"));
return result.elements();
}
/**
* Sets the OptionHandler's options using the given list. All options
* will be set (or reset) during this call (i.e. incremental setting
* of options is not possible).
*
* @param options the list of options as an array of strings
* @throws Exception if an option is not supported
*/
public void setOptions(String[] options) throws Exception {
String tmpStr;
setAttributes(Utils.getOption("p", options));
setOutputDistribution(Utils.getFlag("distribution", options));
tmpStr = Utils.getOption("decimals", options);
if (tmpStr.length() > 0)
setNumDecimals(Integer.parseInt(tmpStr));
else
setNumDecimals(getDefaultNumDecimals());
tmpStr = Utils.getOption("file", options);
if (tmpStr.length() > 0)
setOutputFile(new File(tmpStr));
else
setOutputFile(new File("."));
setSuppressOutput(Utils.getFlag("suppress", options));
}
/**
* Gets the current option settings for the OptionHandler.
*
* @return the list of current option settings as an array of strings
*/
public String[] getOptions() {
Vector<String> result;
result = new Vector<String>();
if (getAttributes().length() > 0) {
result.add("-p");
result.add(getAttributes());
}
if (getOutputDistribution())
result.add("-distribution");
if (getNumDecimals() != getDefaultNumDecimals()) {
result.add("-decimals");
result.add("" + getNumDecimals());
}
if (!getOutputFile().isDirectory()) {
result.add("-file");
result.add(getOutputFile().getAbsolutePath());
if (getSuppressOutput())
result.add("-suppress");
}
return result.toArray(new String[result.size()]);
}
/**
* Sets the header of the dataset.
*
* @param value the header
*/
public void setHeader(Instances value) {
m_Header = new Instances(value, 0);
}
/**
* Returns the header of the dataset.
*
* @return the header
*/
public Instances getHeader() {
return m_Header;
}
/**
* Sets the buffer to use.
*
* @param value the buffer
*/
public void setBuffer(StringBuffer value) {
m_Buffer = value;
}
/**
* Returns the current buffer.
*
* @return the buffer, can be null
*/
public StringBuffer getBuffer() {
return m_Buffer;
}
/**
* Sets the range of attributes to output.
*
* @param value the range
*/
public void setAttributes(String value) {
if (value.length() == 0)
m_Attributes = null;
else
m_Attributes = new Range(value);
}
/**
* Returns the range of attributes to output.
*
* @return the range
*/
public String getAttributes() {
if (m_Attributes == null)
return "";
else
return m_Attributes.getRanges();
}
/**
* Returns the tip text for this property.
*
* @return tip text for this property suitable for
* displaying in the GUI
*/
public String attributesTipText() {
return "The indices of the attributes to print in addition.";
}
/**
* Sets whether to output the class distribution or not.
*
* @param value true if the class distribution is to be output as well
*/
public void setOutputDistribution(boolean value) {
m_OutputDistribution = value;
}
/**
* Returns whether to output the class distribution as well.
*
* @return true if the class distribution is output as well
*/
public boolean getOutputDistribution() {
return m_OutputDistribution;
}
/**
* Returns the tip text for this property.
*
* @return tip text for this property suitable for
* displaying in the GUI
*/
public String outputDistributionTipText() {
return "Whether to ouput the class distribution as well (only nominal class attributes).";
}
/**
* Returns the default number of digits to output after the decimal point.
*
* @return the default number of digits
*/
public int getDefaultNumDecimals() {
return 3;
}
/**
* Sets the number of digits to output after the decimal point.
*
* @param value the number of digits
*/
public void setNumDecimals(int value) {
if (value >= 0)
m_NumDecimals = value;
else
System.err.println(
"Number of decimals cannot be negative (provided: " + value + ")!");
}
/**
* Returns the number of digits to output after the decimal point.
*
* @return the number of digits
*/
public int getNumDecimals() {
return m_NumDecimals;
}
/**
* Returns the tip text for this property.
*
* @return tip text for this property suitable for
* displaying in the GUI
*/
public String numDecimalsTipText() {
return "The number of digits to output after the decimal point.";
}
/**
* Sets the output file to write to. A directory disables this feature.
*
* @param value the file to write to or a directory
*/
public void setOutputFile(File value) {
m_OutputFile = value;
}
/**
* Returns the output file to write to. A directory if turned off.
*
* @return the file to write to or a directory
*/
public File getOutputFile() {
return m_OutputFile;
}
/**
* Returns the tip text for this property.
*
* @return tip text for this property suitable for
* displaying in the GUI
*/
public String outputFileTipText() {
return "The file to write the generated output to (disabled if path is a directory).";
}
/**
* Sets whether to the regular output is suppressed in case the output is
* stored in a file.
*
* @param value true if the regular output is to be suppressed
*/
public void setSuppressOutput(boolean value) {
m_SuppressOutput = value;
}
/**
* Returns whether to the regular output is suppressed in case the output
* is stored in a file.
*
* @return true if the regular output is to be suppressed
*/
public boolean getSuppressOutput() {
return m_SuppressOutput;
}
/**
* Returns the tip text for this property.
*
* @return tip text for this property suitable for
* displaying in the GUI
*/
public String suppressOutputTipText() {
return "Whether to suppress the regular output when storing the output in a file.";
}
/**
* Performs basic checks.
*
* @return null if everything is in order, otherwise the error message
*/
protected String checkBasic() {
if (m_Buffer == null)
return "Buffer is null!";
if (m_Header == null)
return "No dataset structure provided!";
if (m_Attributes != null)
m_Attributes.setUpper(m_Header.numAttributes() - 1);
return null;
}
/**
* Returns whether regular output is generated or not.
*
* @return true if regular output is generated
*/
public boolean generatesOutput() {
return m_OutputFile.isDirectory()
|| (!m_OutputFile.isDirectory() && !m_SuppressOutput);
}
/**
* If an output file was defined, then the string gets added to the file
* buffer, otherwise to the actual buffer.
*
* @param s the string to append
* @see #m_Buffer
* @see #m_FileBuffer
*/
protected void append(String s) {
if (generatesOutput())
m_Buffer.append(s);
if (!m_OutputFile.isDirectory())
m_FileBuffer.append(s);
}
/**
* Performs checks whether everything is correctly setup for the header.
*
* @return null if everything is in order, otherwise the error message
*/
protected String checkHeader() {
return checkBasic();
}
/**
* Performs the actual printing of the header.
*/
protected abstract void doPrintHeader();
/**
* Prints the header to the buffer.
*/
public void printHeader() {
String error;
if ((error = checkHeader()) != null)
throw new IllegalStateException(error);
doPrintHeader();
}
/**
* Performs the actual printing of the classification.
*
* @param classifier the classifier to use for printing the classification
* @param inst the instance to print
* @param index the index of the instance
* @throws Exception if printing of classification fails
*/
protected abstract void doPrintClassification(Classifier classifier, Instance inst, int index) throws Exception;
/**
* Preprocesses an input instance and its copy (that will get its class
* value set to missing for prediction purposes). Basically this only does
* something special in the case when the classifier is an InputMappedClassifier.
*
* @param inst the original instance to predict
* @param withMissing a copy of the instance to predict
* @param classifier the classifier that will be used to make the prediction
* @return the original instance unchanged or mapped (in the case of an InputMappedClassifier)
* and the withMissing copy with the class attribute set to missing value.
* @throws Exception if a problem occurs.
*/
protected Instance preProcessInstance(Instance inst, Instance withMissing,
Classifier classifier) throws Exception {
if (classifier instanceof weka.classifiers.misc.InputMappedClassifier) {
inst = (Instance)inst.copy();
inst =
((weka.classifiers.misc.InputMappedClassifier)classifier).
constructMappedInstance(inst);
int mappedClass =
((weka.classifiers.misc.InputMappedClassifier)classifier).
getMappedClassIndex();
withMissing.setMissing(mappedClass);
} else {
withMissing.setMissing(withMissing.classIndex());
}
return inst;
}
/**
* Prints the classification to the buffer.
*
* @param classifier the classifier to use for printing the classification
* @param inst the instance to print
* @param index the index of the instance
* @throws Exception if check fails or error occurs during printing of classification
*/
public void printClassification(Classifier classifier, Instance inst, int index) throws Exception {
String error;
if ((error = checkBasic()) != null)
throw new WekaException(error);
doPrintClassification(classifier, inst, index);
}
/**
* Prints the classifications to the buffer.
*
* @param classifier the classifier to use for printing the classifications
* @param testset the data source to obtain the test instances from
* @throws Exception if check fails or error occurs during printing of classifications
*/
public void printClassifications(Classifier classifier, DataSource testset) throws Exception {
int i;
Instances test;
Instance inst;
i = 0;
testset.reset();
test = testset.getStructure(m_Header.classIndex());
while (testset.hasMoreElements(test)) {
inst = testset.nextElement(test);
doPrintClassification(classifier, inst, i);
i++;
}
}
/**
* Prints the classifications to the buffer.
*
* @param classifier the classifier to use for printing the classifications
* @param testset the test instances
* @throws Exception if check fails or error occurs during printing of classifications
*/
public void printClassifications(Classifier classifier, Instances testset) throws Exception {
int i;
for (i = 0; i < testset.numInstances(); i++)
doPrintClassification(classifier, testset.instance(i), i);
}
/**
* Performs the actual printing of the footer.
*/
protected abstract void doPrintFooter();
/**
* Prints the footer to the buffer. This will also store the generated
* output in a file if an output file was specified.
*
* @throws Exception if check fails
*/
public void printFooter() throws Exception {
String error;
BufferedWriter writer;
if ((error = checkBasic()) != null)
throw new WekaException(error);
doPrintFooter();
// write output to file
if (!m_OutputFile.isDirectory()) {
try {
writer = new BufferedWriter(new FileWriter(m_OutputFile));
writer.write(m_FileBuffer.toString());
writer.newLine();
writer.flush();
writer.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* Prints the header, classifications and footer to the buffer.
*
* @param classifier the classifier to use for printing the classifications
* @param testset the data source to obtain the test instances from
* @throws Exception if check fails or error occurs during printing of classifications
*/
public void print(Classifier classifier, DataSource testset) throws Exception {
printHeader();
printClassifications(classifier, testset);
printFooter();
}
/**
* Prints the header, classifications and footer to the buffer.
*
* @param classifier the classifier to use for printing the classifications
* @param testset the test instances
* @throws Exception if check fails or error occurs during printing of classifications
*/
public void print(Classifier classifier, Instances testset) throws Exception {
printHeader();
printClassifications(classifier, testset);
printFooter();
}
/**
* Returns a fully configured object from the given commandline.
*
* @param cmdline the commandline to turn into an object
* @return the object or null in case of an error
*/
public static AbstractOutput fromCommandline(String cmdline) {
AbstractOutput result;
String[] options;
String classname;
try {
options = Utils.splitOptions(cmdline);
classname = options[0];
options[0] = "";
result = (AbstractOutput) Utils.forName(AbstractOutput.class, classname, options);
}
catch (Exception e) {
result = null;
}
return result;
}
}
| [
"[email protected]"
]
| |
fbe1ac768e73d6fce1fa0fc7eb4e717ddb9c952f | 36b1759fab4d38dd3e9f9f796ec3afcc388255cb | /kafkastream/fmap-server/src/main/java/ita/triglie/MatcherFactory.java | 3baed3de68de8d1c523ec3a7604b40032fdd6767 | []
| no_license | triglie/fmap | c2f9a9b729807e848b65071fc029619782855820 | ee9e99f0de5659d0c696806e87ee1dcc92e3eda9 | refs/heads/main | 2023-05-29T12:38:44.563827 | 2021-06-06T17:37:11 | 2021-06-06T17:37:11 | 370,102,365 | 6 | 3 | null | 2021-05-25T15:42:54 | 2021-05-23T16:29:20 | C++ | UTF-8 | Java | false | false | 1,141 | java | package ita.triglie;
import java.util.*;
public class MatcherFactory {
Map<String, List<String>> provinceMap = new HashMap<String, List<String>>() {{
put("Catania", Arrays.asList("catania", "siracusa", "ragusa", "enna", "caltanissetta"));
put("Palermo", Arrays.asList("palermo", "trapani", "agrigento"));
put("Messina", Arrays.asList("messina"));
}};
public String match(StationIdentifier identifier) throws Exception {
Matcher matcher = identifier.hasProgrammeIdentifier()
? new NationalMatcher()
: new ProvinceMatcher(this.getNearestProvinceWithStationData(identifier.getProvince()));
return matcher.match(identifier);
}
private String getNearestProvinceWithStationData(String province) throws Exception {
for (String provinceWithStationData : provinceMap.keySet()) {
List<String> nearProvinces = provinceMap.get(provinceWithStationData);
if (nearProvinces.contains(province.toLowerCase()))
return provinceWithStationData;
}
throw new Exception("Province not found");
}
}
| [
"[email protected]"
]
| |
e0a1bbee0fb4e9cd9a2eea38af13b5305281d641 | 9df45fd588b6edbf88fcdf5f35f0fd01883af6b7 | /itstack-demo-netty-1-03/src/test/java/org/itstack/demo/netty/server/test/ApiTest.java | a9284d00693332c3116a4b9eee917d14ff5621af | []
| no_license | MakenChan/itstack-demo-netty | dbe73a2a796f23c6598b578d841ac7b5e1782069 | 01352a859feb396961066827077565346e372bef | refs/heads/master | 2020-07-29T09:54:41.607341 | 2019-09-19T01:27:15 | 2019-09-19T01:27:15 | 209,753,422 | 1 | 0 | null | 2019-09-20T09:24:45 | 2019-09-20T09:24:43 | null | UTF-8 | Java | false | false | 204 | java | package org.itstack.demo.netty.server.test;
/**
* 虫洞栈:https://bugstack.cn
* 公众号:bugstack虫洞栈 {获取学习源码}
* Create by fuzhengwei on 2019
*/
public class ApiTest {
}
| [
"[email protected]"
]
| |
4479516420ef091a700cd7a2ae6323deba299cdb | 98d9c6475b5214e69438d860cc50ea254fb2ffa4 | /app/src/main/java/govacay/co/vacay/MainActivity.java | c6bdab28944ea75747e511969959583843cd5951 | []
| no_license | chanpyaung/Vacay | 51855f4ff05a5f41b46dee53ce8ca8c41a1e7ba7 | f1714b44f9b5e2ff0e9602c08d435ab8f2caa529 | refs/heads/master | 2022-06-17T17:39:54.107998 | 2015-10-08T06:08:02 | 2015-10-08T06:08:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,776 | java | package govacay.co.vacay;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
| [
"[email protected]"
]
| |
e227e68778d6f02ca877d9dc06db45db458aecbf | c198c6fbd59f1a4c7f6ff74dd95649b31a7f1a53 | /.metadata/.plugins/org.eclipse.core.resources/.history/d8/f179a3acd6fe00161a5efe1fc641ff0f | 30e18878676713b484f4dc3bd487f8feb014c1a5 | []
| no_license | Watsonlevens/2016_TwitterEpi | 436a75a8440e2b6c2146634bbc8513dd92ac9518 | 7b7e7b12b3a9122ef4b22baf6860da3fb319d7ac | refs/heads/master | 2023-03-15T12:26:37.131970 | 2017-09-20T14:39:27 | 2017-09-20T14:39:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,937 | /*
* Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.amazonaws.services.directconnect.model;
import java.io.Serializable;
import com.amazonaws.AmazonWebServiceRequest;
/**
* Container for the parameters to the {@link com.amazonaws.services.directconnect.AmazonDirectConnect#deleteConnection(DeleteConnectionRequest) DeleteConnection operation}.
* <p>
* Deletes the connection.
* </p>
* <p>
* Deleting a connection only stops the AWS Direct Connect port hour and data transfer charges. You need to cancel separately with the providers any
* services or charges for cross-connects or network circuits that connect you to the AWS Direct Connect location.
* </p>
*
* @see com.amazonaws.services.directconnect.AmazonDirectConnect#deleteConnection(DeleteConnectionRequest)
*/
public class DeleteConnectionRequest extends AmazonWebServiceRequest implements Serializable {
/**
* ID of the connection. <p>Example: dxcon-fg5678gh <p>Default: None
*/
private String connectionId;
/**
* ID of the connection. <p>Example: dxcon-fg5678gh <p>Default: None
*
* @return ID of the connection. <p>Example: dxcon-fg5678gh <p>Default: None
*/
public String getConnectionId() {
return connectionId;
}
/**
* ID of the connection. <p>Example: dxcon-fg5678gh <p>Default: None
*
* @param connectionId ID of the connection. <p>Example: dxcon-fg5678gh <p>Default: None
*/
public void setConnectionId(String connectionId) {
this.connectionId = connectionId;
}
/**
* ID of the connection. <p>Example: dxcon-fg5678gh <p>Default: None
* <p>
* Returns a reference to this object so that method calls can be chained together.
*
* @param connectionId ID of the connection. <p>Example: dxcon-fg5678gh <p>Default: None
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public DeleteConnectionRequest withConnectionId(String connectionId) {
this.connectionId = connectionId;
return this;
}
/**
* Returns a string representation of this object; useful for testing and
* debugging.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getConnectionId() != null) sb.append("ConnectionId: " + getConnectionId() );
sb.append("}");
return sb.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getConnectionId() == null) ? 0 : getConnectionId().hashCode());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (obj instanceof DeleteConnectionRequest == false) return false;
DeleteConnectionRequest other = (DeleteConnectionRequest)obj;
if (other.getConnectionId() == null ^ this.getConnectionId() == null) return false;
if (other.getConnectionId() != null && other.getConnectionId().equals(this.getConnectionId()) == false) return false;
return true;
}
}
| [
"[email protected]"
]
| ||
5b679258dbede590ae419ac247a57874aec3710a | 64b7ac9dbf7cb8f44639460b93ee5bc521bd97fc | /MSSql_Table_To_MongoDB_Collection.java | 7944597420931c5a823bd06db426a3d1be70ffc0 | []
| no_license | geopapyrus/sql-to-mongodb | 2d2e660f052d5ca164f70e0bfdc9829628a5b924 | 2916eb6677ecd4f054922262df3b6089a1d005ea | refs/heads/master | 2021-01-01T06:11:17.105826 | 2014-12-03T08:05:13 | 2014-12-03T08:05:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,464 | java | //Compile
//javac -classpath sqljdbc4.jar:json.jar:mongo-java-driver-2.12.4.jar:. MSSql_Table_To_MongoDB_Collection.java
//Run
//java -classpath sqljdbc4.jar:json.jar:mongo-java-driver-2.12.4.jar:. MSSql_Table_To_MongoDB_Collection mssql_table_name number_of_rows_at_a_time
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.MongoClient;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONException;
import java.sql.*;
import java.util.*;
public class MSSql_Table_To_MongoDB_Collection
{
public static void main(String[] args)
{
Connection connection = null;
MongoClient mongoClient = null;
DB db = null;
DBCollection coll = null;
try
{
mongoClient = new MongoClient( "localhost" , 27017 );
db=mongoClient.getDB( "teamwork" );
coll=db.getCollection(args[0]);
// the sql server driver string
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
// the sql server url
String url = "jdbc:sqlserver://server_host:1433;DatabaseName=database_name";
// get the sql server database connection
connection = DriverManager.getConnection(url,"username", "password");
System.out.println("Connected.");
String SQL2 = "SELECT COUNT(*) AS total FROM "+args[0];
Statement stmt2 = connection.createStatement();
ResultSet rs2 = stmt2.executeQuery(SQL2);
int total_rows=0;
if(rs2.next())
{
total_rows=rs2.getInt(1);
System.out.println("Importing "+rs2.getInt(1)+" rows...");
}
//how many rows to import at a time
int limit=Integer.parseInt(args[1]);
for(int k=0;k<total_rows/limit;k++)
{
long startTime = System.currentTimeMillis();
int start=k*limit;
int end=start+limit;
System.out.println("start: "+start);
// Create and execute an SQL statement that returns some data.
String SQL = "SELECT * FROM ( SELECT *, ROW_NUMBER() OVER (ORDER BY id) as row FROM "+args[0]+" ) a WHERE row > "+start+" and row <= "+end;
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(SQL);
JSONArray json = new JSONArray();
ResultSetMetaData rsmd = rs.getMetaData();
// Iterate through the data in the result set and display it.
while (rs.next())
{
int numColumns = rsmd.getColumnCount();
JSONObject obj = new JSONObject();
BasicDBObject doc = new BasicDBObject();
for (int i=1; i<numColumns+1; i++)
{
String column_name = rsmd.getColumnName(i);
String field_name=column_name;
if(field_name.equals("id")) field_name="_id";
doc.append(field_name, rs.getObject(column_name));
}
coll.update(new BasicDBObject("_id", doc.get("_id")),
new BasicDBObject("$set", doc), true, false);
}
long endTime = System.currentTimeMillis();
long totalTime = endTime - startTime;
System.out.println((double)totalTime/1000.0+"s");
}
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
System.exit(1);
}
catch (SQLException e)
{
e.printStackTrace();
System.exit(2);
}
catch (Exception e)
{
e.printStackTrace();
System.exit(2);
}
}
}
| [
"[email protected]"
]
| |
ec6963fd013a8203aaa2cdd7e23bbda6dd2e4086 | 688e4d50319d4e132b7576e4ab7b463eeeb32d5e | /app/src/main/java/com/mbokinala/windemereperiods/PeriodManager.java | 7ed47ba625485544d85808454c83bae25afdbb2d | []
| no_license | mbokinala/windemere-periods | e1fe566e911f58da925699b47fbf45b3bfdb5831 | 016b9032d6acfa22187c1c0063e4c8260ce7cce2 | refs/heads/master | 2021-07-10T00:45:27.934626 | 2017-10-09T02:09:44 | 2017-10-09T02:09:44 | 106,215,811 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,935 | java | package com.mbokinala.windemereperiods;
/**
* Created by ajonnakuti on 10/7/17.
*/
import android.util.Log;
import java.util.Calendar;
import java.util.HashMap;
public class PeriodManager {
public static final int REGULAR_SCHEDULE = 0;
public static final int WEDNESDAY_SCHEDULE = 1;
public static final int MINIMUM_SCHEDULE = 2;
private static int currentSchedule;
private static HashMap<String, Period> periods;
public static void setSchedule(int schedule) {
}
public static void setSchedule() {
Calendar now = Calendar.getInstance();
int dayOfWeek = now.get(Calendar.DAY_OF_WEEK);
if(dayOfWeek == 3) {
currentSchedule = WEDNESDAY_SCHEDULE;
} else {
currentSchedule = REGULAR_SCHEDULE;
}
}
private static void initSchedule() {
periods = null;
periods = new HashMap<String, Period>();
if(currentSchedule == REGULAR_SCHEDULE) {
periods.put("1st", new Period("7:53", "8:36"));
periods.put("2nd", new Period("8:40", "9:24"));
periods.put("3rd", new Period("9:28", "10:11"));
periods.put("Break", new Period("10:11", "10:18"));
periods.put("4th", new Period("10:18", "11:01"));
periods.put("5th", new Period("11:05", "11:48"));
periods.put("Lunch", new Period("11:48", "12:20"));
periods.put("7th", new Period("12:24", "13:07"));
periods.put("8th", new Period("13:11", "13:54"));
periods.put("Tutorial", new Period("13:58", "14:28"));
periods.put("9th", new Period("14:32", "15:15"));
}
}
public static String getPeriod(String time) {
setSchedule();
initSchedule();
String period = "Error";
Calendar now = Calendar.getInstance();
if(periods.get("1st").contains(time)) {
period = "1st";
} else if(periods.get("2nd").contains(time)) {
period = "2nd";
} else if(periods.get("3rd").contains(time)) {
period = "3rd";
} else if(periods.get("4th").contains(time)) {
period = "4th";
} else if(periods.get("5th").contains(time)) {
period = "5th";
} else if(periods.get("Lunch").contains(time)) {
period = "Lunch";
} else if(periods.get("7th").contains(time)) {
period = "7th";
} else if(periods.get("8th").contains(time)) {
period = "8th";
} else if(periods.get("Tutorial").contains(time)) {
period = "Tutorial";
} else if(periods.get("9th").contains(time)) {
period = "9th";
} else if (Period.timeToMinutes(time) < Period.timeToMinutes("15:15")) {
period = "Passing";
}
Log.d("Custom", "" + Period.timeToMinutes(time));
Log.d("Custom", "" + Period.timeToMinutes("3:15"));
return period;
}
public static int getMinutesRemaining() {
int minutesRemaining = -1;
Calendar now = Calendar.getInstance();
String period = getPeriod(now.get(Calendar.HOUR_OF_DAY) + ":" + now.get(Calendar.MINUTE));
if (!period.equals("School is Over") && !period.equals("Passing")) {
minutesRemaining = periods.get(period).getMinutesRemaining(now.get(Calendar.HOUR_OF_DAY) + ":" + now.get(Calendar.MINUTE));
}
return minutesRemaining;
}
public static String getTimings() {
String timings = "School is Over";
Calendar now = Calendar.getInstance();
String period = getPeriod(now.get(Calendar.HOUR_OF_DAY) + ":" + now.get(Calendar.MINUTE));
Log.d("Custom", "" + period);
if(!period.equals("School is Over") && (!period.equals("Passing"))) {
Period p = periods.get(period);
timings = p.getTimings();
}
return timings;
}
} | [
"[email protected]"
]
| |
d9201795b4ef92d23c8157621db70d3c19851077 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/24/24_b5286d1e433945c21c78f9366bdb57f0eb601537/ToolsTest1/24_b5286d1e433945c21c78f9366bdb57f0eb601537_ToolsTest1_s.java | 34d70fec53dfde83e619065350c0811872470296 | []
| no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 58,109 | java | package lcmc.utilities;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
import org.junit.After;
import org.junit.Before;
import java.util.Collection;
import java.util.Arrays;
import java.util.List;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.Vector;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.awt.Dimension;
import javax.swing.JPanel;
import javax.swing.JCheckBox;
import java.net.InetAddress;
import lcmc.Exceptions;
import lcmc.data.Host;
public final class ToolsTest1 extends TestCase {
@Before
protected void setUp() {
TestSuite1.initTestCluster();
TestSuite1.initTest();
}
@After
protected void tearDown() {
assertEquals("", TestSuite1.getStdout());
}
/* ---- tests ----- */
@Test
public void testCreateImageIcon() {
assertNull("not existing", Tools.createImageIcon("notexisting"));
assertFalse("".equals(TestSuite1.getStdout()));
TestSuite1.clearStdout();
assertNotNull("existing", Tools.createImageIcon("startpage_head.jpg"));
}
@Test
public void testGetRelease() {
final String release = Tools.getRelease();
assertNotNull("not null", release);
assertFalse("not empty", "".equals(release));
TestSuite1.realPrintln("release: " + release);
}
@Test
public void testInfo() {
Tools.info("info a");
assertEquals(TestSuite1.INFO_STRING + "info a\n",
TestSuite1.getStdout());
TestSuite1.clearStdout();
}
@Test
public void testSetDefaults() {
Tools.setDefaults();
}
@Test
public void testDebug() {
Tools.setDebugLevel(1);
Tools.debug(null, "test a");
assertTrue(TestSuite1.getStdout().indexOf("test a\n") > 0);
TestSuite1.clearStdout();
Tools.setDebugLevel(0);
Tools.decrementDebugLevel(); /* -1 */
TestSuite1.clearStdout();
Tools.debug(null, "test b");
assertEquals("", TestSuite1.getStdout());
Tools.incrementDebugLevel(); /* 0 */
TestSuite1.clearStdout();
Tools.debug(null, "test c");
assertTrue(TestSuite1.getStdout().indexOf("test c\n") > 0);
TestSuite1.clearStdout();
Tools.setDebugLevel(1); /* 1 */
TestSuite1.clearStdout();
Tools.debug(new Object(), "test d2", 2);
Tools.debug(new Object(), "test d1", 1);
Tools.debug(new Object(), "test d0", 0);
final Pattern p = Pattern.compile("^" + TestSuite1.DEBUG_STRING
+ "\\(1\\) \\[\\d+s\\] test d1 \\(java\\.lang\\.Object\\)\\s+"
+ TestSuite1.DEBUG_STRING + ".*"
+ "\\(0\\) \\[\\d+s\\] test d0 \\(java\\.lang\\.Object\\)\\s+");
final Matcher m = p.matcher(TestSuite1.getStdout());
assertTrue(m.matches());
TestSuite1.clearStdout();
Tools.setDebugLevel(-1);
}
@Test
public void testError() {
if (TestSuite1.INTERACTIVE) {
Tools.error("test error a / just click ok");
assertEquals(TestSuite1.ERROR_STRING
+ "test error a / just click ok\n",
TestSuite1.getStdout());
TestSuite1.clearStdout();
}
}
@Test
public void testSSHError() {
for (final Host host : TestSuite1.getHosts()) {
Tools.sshError(host, "cmd a", "ans a", "stack trace a", 2);
assertTrue(
TestSuite1.getStdout().indexOf("returned exit code 2") >= 0);
TestSuite1.clearStdout();
}
}
@Test
public void testConfirmDialog() {
if (TestSuite1.INTERACTIVE) {
assertTrue(
Tools.confirmDialog("title a", "click yes", "yes (click)", "no"));
assertFalse(
Tools.confirmDialog("title a", "click no", "yes", "no (click)"));
}
}
@Test
public void testExecCommandProgressIndicator() {
for (int i = 0; i < 1 * TestSuite1.getFactor(); i++) {
for (final Host host : TestSuite1.getHosts()) {
Tools.execCommandProgressIndicator(host,
"uname -a",
null, /* ExecCallback */
true, /* outputVisible */
"text h",
1000); /* command timeout */
}
}
TestSuite1.clearStdout();
}
@Test
public void testAppWarning() {
Tools.appWarning("warning a");
if (Tools.getDefault("AppWarning").equals("y")) {
assertEquals(TestSuite1.APPWARNING_STRING + "warning a\n",
TestSuite1.getStdout());
}
TestSuite1.clearStdout();
}
@Test
public void testInfoDialog() {
if (TestSuite1.INTERACTIVE) {
Tools.infoDialog("info a", "info1 a", "info2 a / CLICK OK");
}
}
@Test
public void testIsIp() {
assertTrue(Tools.isIp("127.0.0.1"));
assertTrue(Tools.isIp("0.0.0.0"));
assertTrue(Tools.isIp("0.0.0.1"));
assertTrue(Tools.isIp("255.255.255.255"));
assertTrue(Tools.isIp("254.255.255.255"));
assertFalse(Tools.isIp("localhost"));
assertFalse(Tools.isIp("127-0-0-1"));
assertFalse(Tools.isIp("256.255.255.255"));
assertFalse(Tools.isIp("255.256.255.255"));
assertFalse(Tools.isIp("255.255.256.255"));
assertFalse(Tools.isIp("255.255.255.256"));
assertFalse(Tools.isIp("255.255.255.1000"));
assertFalse(Tools.isIp("255.255.255.-1"));
assertFalse(Tools.isIp("255.255.255"));
assertFalse(Tools.isIp(""));
assertFalse(Tools.isIp("255.255.255.255.255"));
assertFalse(Tools.isIp("127.0.0.false"));
assertFalse(Tools.isIp("127.0.false.1"));
assertFalse(Tools.isIp("127.false.0.1"));
assertFalse(Tools.isIp("false.0.0.1"));
for (final Host host : TestSuite1.getHosts()) {
assertTrue(Tools.isIp(host.getIp()));
assertFalse(Tools.isIp(host.getHostname()));
}
}
@Test
public void testPrintStackTrace() {
Tools.printStackTrace();
assertFalse("".equals(TestSuite1.getStdout()));
TestSuite1.clearStdout();
Tools.printStackTrace("stack trace test");
assertTrue(TestSuite1.getStdout().startsWith("stack trace test"));
TestSuite1.clearStdout();
assertFalse("".equals(Tools.getStackTrace()));
}
@Test
public void testLoadFile() {
for (float i = 0; i < 0.01 * TestSuite1.getFactor(); i++) {
assertNull(Tools.loadFile("JUNIT_TEST_FILE_CLICK_OK",
TestSuite1.INTERACTIVE));
final String testFile = "/tmp/lcmc-test-file";
Tools.save(testFile, false);
final String file = Tools.loadFile(testFile,
TestSuite1.INTERACTIVE);
assertNotNull(file);
TestSuite1.clearStdout();
assertFalse("".equals(file));
}
}
@Test
public void testRemoveEverything() {
//TODO:
//Tools.removeEverything();
}
@Test
public void testGetDefault() {
if (TestSuite1.INTERACTIVE) {
assertEquals("JUNIT TEST JUNIT TEST, click ok",
Tools.getDefault("JUNIT TEST JUNIT TEST, click ok"));
assertTrue(TestSuite1.getStdout().indexOf("unresolved") >= 0);
TestSuite1.clearStdout();
}
assertEquals("", Tools.getDefault("SSH.PublicKey"));
assertEquals("", Tools.getDefault("SSH.PublicKey"));
assertEquals("22", Tools.getDefault("SSH.Port"));
}
@Test
public void testGetDefaultColor() {
if (TestSuite1.INTERACTIVE) {
assertEquals(
java.awt.Color.WHITE,
Tools.getDefaultColor("JUNIT TEST unknown color, click ok"));
TestSuite1.clearStdout();
}
assertEquals(java.awt.Color.BLACK,
Tools.getDefaultColor("TerminalPanel.Background"));
}
@Test
public void testGetDefaultInt() {
if (TestSuite1.INTERACTIVE) {
assertEquals(
0,
Tools.getDefaultInt("JUNIT TEST unknown int, click ok"));
TestSuite1.clearStdout();
}
assertEquals(100000,
Tools.getDefaultInt("Score.Infinity"));
}
@Test
public void testGetString() {
final String testString = "JUNIT TEST unknown string, click ok";
if (TestSuite1.INTERACTIVE) {
assertEquals(testString, Tools.getString(testString));
TestSuite1.clearStdout();
}
assertEquals("Linux Cluster Management Console",
Tools.getString("DrbdMC.Title"));
}
@Test
public void testGetErrorString() {
final String errorString = "the same string";
assertEquals(errorString, errorString);
}
@Test
public void testGetDistString() {
/* text, dist, version, arch */
assertNull(Tools.getDistString("none",
"none",
"none",
"none"));
assertEquals("no", Tools.getDistString("Support",
"none",
"none",
"none"));
assertEquals("no", Tools.getDistString("Support",
null,
null,
null));
assertEquals("debian", Tools.getDistString("Support",
"debian",
null,
null));
assertEquals("debian-SQUEEZE", Tools.getDistString("Support",
"debian",
"SQUEEZE",
null));
assertEquals("debian-SQUEEZE", Tools.getDistString("Support",
"debian",
"SQUEEZE",
"a"));
assertEquals("i586", Tools.getDistString("PmInst.install",
"suse",
null,
"i386"));
}
@Test
public void testGetDistCommand() {
/*
String text
String dist
String version
String arch
ConvertCmdCallback convertCmdCallback
boolean inBash
*/
assertEquals("undefined",
Tools.getDistCommand("undefined",
"debian",
"squeeze",
"i386",
null,
false));
assertEquals(TestSuite1.APPWARNING_STRING
+ "unknown command: undefined\n",
TestSuite1.getStdout());
TestSuite1.clearStdout();
assertEquals("undefined2;;;undefined3",
Tools.getDistCommand("undefined2;;;undefined3",
"debian",
"squeeze",
"i386",
null,
false));
assertEquals(TestSuite1.APPWARNING_STRING
+ "unknown command: undefined2\n"
+ TestSuite1.APPWARNING_STRING
+ "unknown command: undefined3\n",
TestSuite1.getStdout());
TestSuite1.clearStdout();
final lcmc.utilities.ConvertCmdCallback ccc =
new lcmc.utilities.ConvertCmdCallback() {
@Override
public String convert(final String command) {
return command.replaceAll(lcmc.configs.DistResource.SUDO,
"sudo ");
}
};
assertEquals("sudo /etc/init.d/corosync start",
Tools.getDistCommand("Corosync.startCorosync",
"debian",
"squeeze",
"i386",
ccc,
false));
assertEquals("sudo bash -c \"sudo /etc/init.d/corosync start\"",
Tools.getDistCommand("Corosync.startCorosync",
"debian",
"squeeze",
"i386",
ccc,
true));
assertEquals("sudo /etc/init.d/corosync start"
+ ";;;sudo /etc/init.d/corosync start",
Tools.getDistCommand("Corosync.startCorosync;;;"
+ "Corosync.startCorosync",
"debian",
"squeeze",
"i386",
ccc,
false));
assertEquals("undefined4"
+ ";;;sudo /etc/init.d/corosync start",
Tools.getDistCommand("undefined4;;;"
+ "Corosync.startCorosync",
"debian",
"squeeze",
"i386",
ccc,
false));
assertEquals(TestSuite1.APPWARNING_STRING
+ "unknown command: undefined4\n",
TestSuite1.getStdout());
TestSuite1.clearStdout();
assertNull(Tools.getDistCommand(null,
"debian",
"squeeze",
"i386",
ccc,
false));
assertNull(Tools.getDistCommand(null,
"debian",
"squeeze",
"i386",
ccc,
true));
assertNull(Tools.getDistCommand(null, null, null, null, null, true));
}
@Test
public void testGetKernelDownloadDir() {
/* String kernelVersion
String dist
String version
String arch
*/
assertNull(Tools.getKernelDownloadDir(null, null, null, null));
assertEquals("2.6.32-28",
Tools.getKernelDownloadDir("2.6.32-28-server",
"ubuntu",
"lucid",
"x86_64"));
assertEquals("2.6.32-28",
Tools.getKernelDownloadDir("2.6.32-28-server",
"ubuntu",
"lucid",
"i386"));
assertEquals("2.6.24-28",
Tools.getKernelDownloadDir("2.6.24-28-server",
"ubuntu",
"hardy",
"x86_64"));
assertEquals("2.6.32.27-0.2",
Tools.getKernelDownloadDir("2.6.32.27-0.2-default",
"suse",
"SLES11",
"x86_64"));
assertEquals("2.6.16.60-0.60.1",
Tools.getKernelDownloadDir("2.6.16.60-0.60.1-default",
"suse",
"SLES10",
"x86_64"));
assertEquals("2.6.18-194.8.1.el5",
Tools.getKernelDownloadDir("2.6.18-194.8.1.el5",
"redhatenterpriseserver",
"5",
"x86_64"));
assertEquals("2.6.32-71.18.1.el6.x86_64",
Tools.getKernelDownloadDir("2.6.32-71.18.1.el6.x86_64",
"redhatenterpriseserver",
"6",
"x86_64"));
assertEquals("2.6.26-2",
Tools.getKernelDownloadDir("2.6.26-2-amd64",
"debian",
"lenny",
"x86_64"));
assertEquals("2.6.32-5",
Tools.getKernelDownloadDir("2.6.32-5-amd64",
"debian",
"squeeze",
"x86_64"));
assertEquals("2.6.32-5",
Tools.getKernelDownloadDir("2.6.32-5-amd64",
"debian",
"unknown",
"x86_64"));
assertEquals("2.6.32-5-amd64",
Tools.getKernelDownloadDir("2.6.32-5-amd64",
"unknown",
"unknown",
"x86_64"));
assertNull(Tools.getKernelDownloadDir(null,
"unknown",
"unknown",
"x86_64"));
assertEquals("2.6.32-5-amd64",
Tools.getKernelDownloadDir("2.6.32-5-amd64",
null,
null,
"x86_64"));
}
@Test
public void testGetDistVersionString() {
/* String dist
String version */
assertEquals("LENNY", Tools.getDistVersionString("debian", "5.0.8"));
assertEquals("SQUEEZE", Tools.getDistVersionString("debian", "6.0"));
assertEquals("12", Tools.getDistVersionString(
"fedora",
"Fedora release 12 (Constantine)"));
assertEquals("13", Tools.getDistVersionString(
"fedora",
"Fedora release 13 (Goddard)"));
assertEquals("14",
Tools.getDistVersionString(
"fedora",
"Fedora release 14 (Laughlin)"));
assertEquals("5", Tools.getDistVersionString(
"redhat",
"CentOS release 5.5 (Final)"));
assertEquals("5", Tools.getDistVersionString(
"redhat",
"CentOS release 5.5 (Final)"));
assertEquals(
"6",
Tools.getDistVersionString(
"redhatenterpriseserver",
"Red Hat Enterprise Linux Server release 6.0 (Santiago)"));
assertEquals(
"5",
Tools.getDistVersionString(
"redhatenterpriseserver",
"Red Hat Enterprise Linux Server release 5.5 (Tikanga)"));
assertEquals("squeeze/sid/10.10", /* maverick */
Tools.getDistVersionString("ubuntu", "squeeze/sid/10.10"));
assertEquals("KARMIC",
Tools.getDistVersionString("ubuntu", "squeeze/sid/9.10"));
assertEquals("LUCID",
Tools.getDistVersionString("ubuntu", "squeeze/sid/10.04"));
assertEquals("HARDY",
Tools.getDistVersionString("ubuntu", "lenny/sid/8.04"));
assertEquals("SLES10",
Tools.getDistVersionString(
"suse",
"SUSE Linux Enterprise Server 10 (x86_64)"));
assertEquals("SLES11",
Tools.getDistVersionString(
"suse",
"SUSE Linux Enterprise Server 11 (x86_64)"));
assertEquals("OPENSUSE11_2",
Tools.getDistVersionString(
"suse",
"openSUSE 11.2 (x86_64)"));
assertEquals("OPENSUSE11_3",
Tools.getDistVersionString(
"suse",
"openSUSE 11.3 (x86_64)"));
assertEquals("OPENSUSE11_4",
Tools.getDistVersionString(
"suse",
"openSUSE 11.4 (x86_64)"));
assertEquals("2", Tools.getDistVersionString("openfiler",
"Openfiler NSA 2.3"));
}
@Test
public void testJoin() {
assertEquals("a,b", Tools.join(",", new String[]{"a", "b"}));
assertEquals("a", Tools.join(",", new String[]{"a"}));
assertEquals("", Tools.join(",", new String[]{}));
assertEquals("", Tools.join(",", (String[]) null));
assertEquals("ab", Tools.join(null, new String[]{"a", "b"}));
assertEquals("a,b,c", Tools.join(",", new String[]{"a", "b", "c"}));
assertEquals("", Tools.join("-", (Collection<String>) null));
assertEquals("a-b", Tools.join("-", Arrays.asList("a", "b")));
assertEquals("ab", Tools.join(null, Arrays.asList("a", "b")));
final List<String> bigArray = new ArrayList<String>();
for (int i = 0; i < 1000; i++) {
bigArray.add("x");
}
assertTrue(Tools.join(",", bigArray).length() == 2000 - 1);
assertEquals("a,b", Tools.join(",", new String[]{"a", "b"}, 2));
assertEquals("a,b", Tools.join(",", new String[]{"a", "b"}, 3));
assertEquals("a", Tools.join(",", new String[]{"a", "b"}, 1));
assertEquals("", Tools.join(",", new String[]{"a", "b"}, 0));
assertEquals("", Tools.join(",", new String[]{"a", "b"}, -1));
assertEquals("", Tools.join(",", null, 1));
assertEquals("a", Tools.join(",", new String[]{"a"}, 1));
assertEquals("", Tools.join(",", new String[]{}, 2));
assertEquals("", Tools.join(",", (String[]) null, 1));
assertEquals("a,b,c", Tools.join(",", new String[]{"a", "b", "c"}, 3));
assertTrue(Tools.join(",", bigArray.toArray(
new String[bigArray.size()]), 500).length() == 1000 - 1);
}
@Test
public void testUCFirst() {
assertEquals("Rasto", Tools.ucfirst("rasto"));
assertEquals("Rasto", Tools.ucfirst("Rasto"));
assertEquals("RASTO", Tools.ucfirst("RASTO"));
assertEquals("", Tools.ucfirst(""));
assertNull(Tools.ucfirst(null));
}
@Test
public void testEnumToStringArray() {
assertNull(Tools.enumToStringArray(null));
final String[] testString = Tools.enumToStringArray(
new Vector<String>(Arrays.asList("a", "b", "c")).elements());
Assert.assertArrayEquals(new String[]{"a", "b", "c"}, testString);
}
@Test
public void testGetIntersection() {
assertEquals(new HashSet<String>(Arrays.asList("b")),
Tools.getIntersection(
new HashSet<String>(Arrays.asList("a", "b")),
new HashSet<String>(Arrays.asList("b", "c"))));
assertEquals(new HashSet<String>(Arrays.asList("a", "b")),
Tools.getIntersection(
new HashSet<String>(Arrays.asList("a", "b")),
new HashSet<String>(Arrays.asList("a", "b"))));
assertEquals(new HashSet<String>(Arrays.asList("a", "b")),
Tools.getIntersection(
new HashSet<String>(Arrays.asList("a", "b")),
new HashSet<String>(Arrays.asList("b", "a"))));
assertEquals(new HashSet<String>(),
Tools.getIntersection(
new HashSet<String>(Arrays.asList("a", "b")),
new HashSet<String>(Arrays.asList("c", "d"))));
assertEquals(new HashSet<String>(Arrays.asList("a")),
Tools.getIntersection(
new HashSet<String>(Arrays.asList("a", "a")),
new HashSet<String>(Arrays.asList("a", "a"))));
assertEquals(new HashSet<String>(Arrays.asList("a", "c")),
Tools.getIntersection(
new HashSet<String>(Arrays.asList("a", "b", "c")),
new HashSet<String>(Arrays.asList("a", "d", "c"))));
assertEquals(null,
Tools.getIntersection(null, null));
assertEquals(new HashSet<String>(Arrays.asList("a", "b", "c")),
Tools.getIntersection(
new HashSet<String>(Arrays.asList("a", "b", "c")),
null));
assertEquals(new HashSet<String>(Arrays.asList("a", "b", "c")),
Tools.getIntersection(
null,
new HashSet<String>(Arrays.asList("a", "b", "c"))));
}
@Test
public void testHTML() {
assertEquals("<html><p>test\n</html>", Tools.html("test"));
assertEquals("<html><p>test<br>line2\n</html>",
Tools.html("test\nline2"));
assertEquals("<html>\n</html>", Tools.html(null));
}
@Test
public void testIsStringClass() {
assertTrue(Tools.isStringClass("string"));
assertTrue(Tools.isStringClass((String) null));
assertTrue(Tools.isStringClass((Object) null));
assertFalse(Tools.isStringClass(new Object()));
assertFalse(Tools.isStringClass(new StringBuilder()));
assertFalse(Tools.isStringClass(
new lcmc.gui.resources.StringInfo("name", "string", null)));
}
@Test
public void testIsStringInfoClass() {
assertFalse(Tools.isStringInfoClass("string"));
assertFalse(Tools.isStringInfoClass((String) null));
assertFalse(Tools.isStringInfoClass((Object) null));
assertFalse(Tools.isStringInfoClass(new Object()));
assertFalse(Tools.isStringInfoClass(new StringBuilder()));
assertTrue(Tools.isStringInfoClass(
new lcmc.gui.resources.StringInfo("name", "string", null)));
}
@Test
public void testEscapeConfig() {
assertNull(Tools.escapeConfig(null));
assertEquals("", Tools.escapeConfig(""));
assertEquals("\"\\\"\"", Tools.escapeConfig("\""));
assertEquals("text", Tools.escapeConfig("text"));
assertEquals("\"text with space\"",
Tools.escapeConfig("text with space"));
assertEquals("\"text with \\\"\"",
Tools.escapeConfig("text with \""));
assertEquals("\"just\\\"\"",
Tools.escapeConfig("just\""));
}
@Test
public void testStartProgressIndicator() {
for (int i = 0; i < 10 * TestSuite1.getFactor(); i++) {
Tools.startProgressIndicator(null);
Tools.startProgressIndicator("test");
Tools.startProgressIndicator("test2");
Tools.startProgressIndicator("test3");
Tools.startProgressIndicator(null, "test4");
Tools.startProgressIndicator("name", "test4");
Tools.startProgressIndicator("name2", "test4");
Tools.startProgressIndicator("name2", null);
Tools.startProgressIndicator(null, null);
for (final Host host : TestSuite1.getHosts()) {
Tools.startProgressIndicator(host.getName(), "test");
}
for (final Host host : TestSuite1.getHosts()) {
Tools.stopProgressIndicator(host.getName(), "test");
}
Tools.stopProgressIndicator(null, null);
Tools.stopProgressIndicator("name2", null);
Tools.stopProgressIndicator("name2", "test4");
Tools.stopProgressIndicator("name", "test4");
Tools.stopProgressIndicator(null, "test4");
Tools.stopProgressIndicator("test3");
Tools.stopProgressIndicator("test2");
Tools.stopProgressIndicator("test");
Tools.stopProgressIndicator(null);
}
}
@Test
public void testStopProgressIndicator() {
}
@Test
public void testProgressIndicatorFailed() {
for (int i = 0; i < 10 * TestSuite1.getFactor(); i++) {
Tools.progressIndicatorFailed(null, "fail3");
Tools.progressIndicatorFailed("name", "fail2");
Tools.progressIndicatorFailed("name", null);
Tools.progressIndicatorFailed("fail1");
Tools.progressIndicatorFailed(null);
Tools.progressIndicatorFailed("fail two seconds", 2);
for (final Host host : TestSuite1.getHosts()) {
Tools.progressIndicatorFailed(host.getName(), "fail");
}
}
TestSuite1.clearStdout();
}
@Test
public void testSetSize() {
final JPanel p = new JPanel();
Tools.setSize(p, 20, 10);
assertEquals(new Dimension(20, 10), p.getMaximumSize());
assertEquals(new Dimension(20, 10), p.getMinimumSize());
assertEquals(new Dimension(20, 10), p.getPreferredSize());
}
@Test
public void testCompareVersions() {
try {
assertEquals(-1, Tools.compareVersions("2.1.3", "2.1.4"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-1, Tools.compareVersions("2.1.3", "3.1.2"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-1, Tools.compareVersions("2.1.3", "2.2.2"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("2.1.3", "2.1.3.1"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-1, Tools.compareVersions("2.1.3.1", "2.1.4"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("2.1", "2.1.3"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("2", "2.1.3"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("2", "2.1"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("2.1.3", "2.1.3"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("2.1", "2.1"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("2", "2"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(1, Tools.compareVersions("2.1.4", "2.1.3"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(1, Tools.compareVersions("3.1.2", "2.1.3"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(1, Tools.compareVersions("2.2.2", "2.1.3"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("2.1.3.1", "2.1.3"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(1, Tools.compareVersions("2.1.4", "2.1.3.1"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("2.1.3", "2.1"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("2.1.3", "2"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("2.1", "2"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("8.3", "8.3.0"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-100, Tools.compareVersions("", ""));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions(null, null));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("", "2.1.3"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("2.1.3", ""));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions(null, "2.1.3"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("2.1.3", null));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("2.1.3", "2.1.a"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("a.1.3", "2.1.3"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("rc1", "8rc1"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("8rc1", "8rc"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("8rc1", "8rc"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("8rc", "8rc1"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("8rc1", "rc"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("rc", "8rc1"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("8r1", "8.3.1rc1"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("8.3.1", "8.3rc1.1"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(-100, Tools.compareVersions("8.3rc1.1", "8.3.1"));
assertFalse(true);
} catch (Exceptions.IllegalVersionException e) {
}
try {
assertEquals(1, Tools.compareVersions("8.3.10rc1", "8.3.9"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(1, Tools.compareVersions("8.3.10rc2", "8.3.10rc1"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(1, Tools.compareVersions("8.3.10", "8.3.10rc2"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(1, Tools.compareVersions("8.3.10",
"8.3.10rc99999999"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("8.3.10rc1", "8.3.10rc1"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("8.3rc1", "8.3rc1"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("8rc1", "8rc1"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-1, Tools.compareVersions("8.3.9", "8.3.10rc1"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-1, Tools.compareVersions("8.3.10rc1", "8.3.10rc2"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-1, Tools.compareVersions("8.3.10rc2", "8.3.10"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("8.3rc2", "8.3.0"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("8.3", "8.3.2"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("8.3.2", "8.3"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-1, Tools.compareVersions("8.3", "8.4"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(1, Tools.compareVersions("8.4", "8.3"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("8.4", "8.4"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-1, Tools.compareVersions("8.3", "8.4.5"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-1, Tools.compareVersions("8.3.5", "8.4"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-1, Tools.compareVersions("8.3", "8.4rc3"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("8.4", "8.4.0rc3"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("8.4.0rc3", "8.4"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(1, Tools.compareVersions("8.4rc3", "8.3"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("1.1.7-2.fc16", "1.1.7"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-1, Tools.compareVersions("1.1.7-2.fc16", "1.1.8"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(1, Tools.compareVersions("1.1.7-2.fc16", "1.1.6"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("1.7.0_03", "1.7"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(-1, Tools.compareVersions("1.6.0_26", "1.7"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(1, Tools.compareVersions("1.7", "1.6.0_26"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
try {
assertEquals(0, Tools.compareVersions("1.6.0_26", "1.6.0"));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
}
@Test
public void testCharCount() {
assertEquals(1, Tools.charCount("abcd", 'b'));
assertEquals(0, Tools.charCount("abcd", 'e'));
assertEquals(1, Tools.charCount("abcd", 'd'));
assertEquals(1, Tools.charCount("abcd", 'a'));
assertEquals(2, Tools.charCount("abcdb", 'b'));
assertEquals(5, Tools.charCount("ccccc", 'c'));
assertEquals(1, Tools.charCount("a", 'a'));
assertEquals(0, Tools.charCount("a", 'b'));
assertEquals(0, Tools.charCount("", 'b'));
assertEquals(0, Tools.charCount(null, 'b'));
}
@Test
public void testIsLinux() {
if (System.getProperty("os.name").indexOf("Windows") >= 0
|| System.getProperty("os.name").indexOf("windows") >= 0) {
assertFalse(Tools.isLinux());
}
if (System.getProperty("os.name").indexOf("Linux") >= 0
|| System.getProperty("os.name").indexOf("linux") >= 0) {
assertTrue(Tools.isLinux());
}
}
@Test
public void testIsWindows() {
if (System.getProperty("os.name").indexOf("Windows") >= 0
|| System.getProperty("os.name").indexOf("windows") >= 0) {
assertTrue(Tools.isWindows());
}
if (System.getProperty("os.name").indexOf("Linux") >= 0
|| System.getProperty("os.name").indexOf("linux") >= 0) {
assertFalse(Tools.isWindows());
}
}
@Test
public void testGetFile() {
final String testFile = "/help-progs/lcmc-gui-helper";
assertTrue(Tools.getFile(testFile).indexOf("#!") == 0);
assertNull(Tools.getFile(null));
assertNull(Tools.getFile("not_existing_file"));
}
@Test
public void testParseAutoArgs() {
Tools.parseAutoArgs(null);
Tools.parseAutoArgs("test");
TestSuite1.clearStdout();
}
@Test
public void testSleep() {
Tools.sleep(1);
Tools.sleep(1.1f);
}
@Test
public void testGetLatestVersion() {
if (TestSuite1.CONNECT_LINBIT) {
final String latestVersion = Tools.getLatestVersion();
assertNotNull(latestVersion);
try {
assertEquals(-1, Tools.compareVersions(latestVersion,
Tools.getRelease()));
} catch (Exceptions.IllegalVersionException e) {
assertFalse(true);
}
}
}
@Test
public void testOpenBrowser() {
if (TestSuite1.INTERACTIVE) {
Tools.openBrowser("http://www.google.com");
}
}
@Test
public void testHideMousePointer() {
Tools.hideMousePointer(new JPanel());
}
@Test
public void testIsNumber() {
assertTrue(Tools.isNumber("1"));
assertTrue(Tools.isNumber("-1"));
assertTrue(Tools.isNumber("0"));
assertTrue(Tools.isNumber("-0"));
assertTrue(Tools.isNumber("1235"));
assertTrue(Tools.isNumber("100000000000000000"));
assertTrue(Tools.isNumber("-100000000000000000"));
assertFalse(Tools.isNumber("0.1"));
assertFalse(Tools.isNumber("1 1"));
assertFalse(Tools.isNumber("-"));
assertFalse(Tools.isNumber(""));
assertFalse(Tools.isNumber("a"));
assertFalse(Tools.isNumber(null));
assertFalse(Tools.isNumber(".5"));
assertFalse(Tools.isNumber("a1344"));
assertFalse(Tools.isNumber("1344a"));
assertFalse(Tools.isNumber("13x44"));
}
@Test
public void testShellList() {
assertEquals("{'a','b'}", Tools.shellList(new String[]{"a", "b"}));
assertEquals("{'a','b','b'}",
Tools.shellList(new String[]{"a", "b", "b"}));
assertEquals("a", Tools.shellList(new String[]{"a"}));
assertNull(Tools.shellList(new String[]{}));
assertNull(Tools.shellList(null));
}
@Test
public void testAreEqual() {
assertTrue(Tools.areEqual(null, null));
assertTrue(Tools.areEqual("", ""));
assertTrue(Tools.areEqual("x", "x"));
assertFalse(Tools.areEqual("x", "a"));
assertFalse(Tools.areEqual("x", ""));
assertFalse(Tools.areEqual("", "x"));
assertFalse(Tools.areEqual(null, "x"));
assertFalse(Tools.areEqual("x", null));
}
@Test
public void testExtractUnit() {
Assert.assertArrayEquals(new Object[]{"10", "min"},
Tools.extractUnit("10min"));
Assert.assertArrayEquals(new Object[]{"0", "s"},
Tools.extractUnit("0s"));
Assert.assertArrayEquals(new Object[]{"0", ""},
Tools.extractUnit("0"));
Assert.assertArrayEquals(new Object[]{"5", ""},
Tools.extractUnit("5"));
Assert.assertArrayEquals(new Object[]{"", "s"},
Tools.extractUnit("s"));
Assert.assertArrayEquals(new Object[]{null, null},
Tools.extractUnit(null));
}
@Test
public void testGetRandomSecret() {
for (int i = 0; i < 10 * TestSuite1.getFactor(); i++) {
final String s = Tools.getRandomSecret(2000);
assertTrue(s.length() == 2000);
final int count = Tools.charCount(s, 'a');
assertTrue(count > 2 && count < 500);
}
}
@Test
public void testIsLocalIp() {
assertTrue(Tools.isLocalIp(null));
assertTrue(Tools.isLocalIp("127.0.0.1"));
assertTrue(Tools.isLocalIp("127.0.1.1"));
assertFalse(Tools.isLocalIp("127.0.0"));
assertFalse(Tools.isLocalIp("127.0.0.1.1"));
assertFalse(Tools.isLocalIp("127.0.0.a"));
assertFalse(Tools.isLocalIp("a"));
assertFalse(Tools.isLocalIp("a"));
try {
assertTrue(Tools.isLocalIp(
InetAddress.getLocalHost().getHostAddress()));
} catch (java.net.UnknownHostException e) {
fail();
}
for (final Host host : TestSuite1.getHosts()) {
assertFalse(Tools.isLocalIp(host.getIp()));
}
}
@Test
public void testConvertKilobytes() {
assertEquals("wrong", "aa", Tools.convertKilobytes("aa"));
assertEquals("negative", "-1000K", Tools.convertKilobytes("-1000"));
assertEquals("2G", Tools.convertKilobytes("2G"));
assertEquals("0K", Tools.convertKilobytes("0"));
assertEquals("1K", Tools.convertKilobytes("1"));
assertEquals("1023K", Tools.convertKilobytes("1023"));
assertEquals("1M", Tools.convertKilobytes("1024"));
assertEquals("1025K", Tools.convertKilobytes("1025"));
assertEquals("2047K", Tools.convertKilobytes("2047"));
assertEquals("2M", Tools.convertKilobytes("2048"));
assertEquals("2049K", Tools.convertKilobytes("2049"));
assertEquals("1048575K", Tools.convertKilobytes("1048575"));
assertEquals("1G", Tools.convertKilobytes("1048576"));
assertEquals("1023M", Tools.convertKilobytes("1047552"));
assertEquals("1048577K", Tools.convertKilobytes("1048577"));
assertEquals("1025M", Tools.convertKilobytes("1049600"));
assertEquals("1073741825K", Tools.convertKilobytes("1073741825"));
assertEquals("1023G", Tools.convertKilobytes("1072693248"));
assertEquals("1T", Tools.convertKilobytes("1073741824"));
assertEquals("1025G", Tools.convertKilobytes("1074790400"));
assertEquals("1050625M", Tools.convertKilobytes("1075840000"));
assertEquals("1073741827K", Tools.convertKilobytes("1073741827"));
assertEquals("1P", Tools.convertKilobytes("1099511627776"));
assertEquals("1024P", Tools.convertKilobytes("1125899906842624"));
assertEquals("10000P", Tools.convertKilobytes("10995116277760000"));
}
@Test
public void testConvertToKilobytes() {
assertEquals(10, Tools.convertToKilobytes("10k"));
assertEquals(5, Tools.convertToKilobytes("5K"));
assertEquals(6144, Tools.convertToKilobytes("6M"));
assertEquals(7168, Tools.convertToKilobytes("7m"));
assertEquals(8388608, Tools.convertToKilobytes("8G"));
assertEquals(9437184, Tools.convertToKilobytes("9g"));
assertEquals(10737418240L, Tools.convertToKilobytes("10T"));
assertEquals(11811160064L, Tools.convertToKilobytes("11t"));
assertEquals(13194139533312L, Tools.convertToKilobytes("12P"));
assertEquals(14293651161088L, Tools.convertToKilobytes("13p"));
assertEquals(1099511627776000000L,
Tools.convertToKilobytes("1000000P"));
//TODO:
//assertEquals(10995116277760000000L,
// Tools.convertToKilobytes("10000000"));
assertEquals(-1, Tools.convertToKilobytes("7"));
assertEquals(-1, Tools.convertToKilobytes(null));
assertEquals(-1, Tools.convertToKilobytes("P"));
assertEquals(-1, Tools.convertToKilobytes("-3"));
}
@Test
public void testGetUnixPath() {
assertEquals("/bin", Tools.getUnixPath("/bin"));
if (Tools.isWindows()) {
assertEquals("/bin/dir/file",
Tools.getUnixPath("d:\\bin\\dir\\file"));
}
}
@Test
public void testTrimText() {
assertNull(Tools.trimText(null));
assertEquals("x", Tools.trimText("x"));
final String x20 = " xxxxxxxxxxxxxxxxxxx";
assertEquals(x20 + x20 + x20 + x20,
Tools.trimText(x20 + x20 + x20 + x20));
assertEquals(x20 + x20 + x20 + x20 + "\n" + x20.trim(),
Tools.trimText(x20 + x20 + x20 + x20 + x20));
}
@Test
public void testWaitForSwing() {
for (int i = 0; i < 10 * TestSuite1.getFactor(); i++) {
Tools.waitForSwing();
}
}
@Test
public void testGetDirectoryPart() {
assertEquals("/usr/bin/", Tools.getDirectoryPart("/usr/bin/somefile"));
assertEquals("/usr/bin/", Tools.getDirectoryPart("/usr/bin/"));
assertEquals("somefile", Tools.getDirectoryPart("somefile"));
assertEquals("", Tools.getDirectoryPart(""));
assertNull(Tools.getDirectoryPart(null));
assertEquals("/", Tools.getDirectoryPart("/"));
}
@Test
public void testEscapeQuotes() {
assertEquals("test", Tools.escapeQuotes("test", 0));
assertEquals("test", Tools.escapeQuotes("test", -1));
assertNull(Tools.escapeQuotes(null, -1));
assertNull(Tools.escapeQuotes(null, 1));
assertEquals("test", Tools.escapeQuotes("test", 1));
assertEquals("test", Tools.escapeQuotes("test", 2));
assertEquals("test", Tools.escapeQuotes("test", 100));
assertEquals("\\\"\\$\\`test\\\\",
Tools.escapeQuotes("\"$`test\\", 1));
assertEquals("\\\\\\\"\\\\\\$\\\\\\`test\\\\\\\\",
Tools.escapeQuotes("\"$`test\\", 2));
}
@Test
public void testGetHostCheckBoxes() {
for (final Host host : TestSuite1.getHosts()) {
final Map<Host, JCheckBox> comps =
Tools.getHostCheckBoxes(host.getCluster());
assertNotNull(comps);
assertTrue(comps.size() == TestSuite1.getHosts().size());
assertTrue(comps.containsKey(host));
}
}
@Test
public void testVersionBeforePacemaker() {
final Host host = new Host();
host.setPacemakerVersion("1.1.5");
host.setHeartbeatVersion(null);
assertFalse(Tools.versionBeforePacemaker(host));
host.setPacemakerVersion(null);
host.setHeartbeatVersion("2.1.4");
assertTrue(Tools.versionBeforePacemaker(host));
host.setPacemakerVersion(null);
host.setHeartbeatVersion("2.1.3");
assertTrue(Tools.versionBeforePacemaker(host));
host.setPacemakerVersion(null);
host.setHeartbeatVersion(null);
assertFalse(Tools.versionBeforePacemaker(host));
host.setPacemakerVersion("1.0.9");
host.setHeartbeatVersion("3.0.2");
assertFalse(Tools.versionBeforePacemaker(host));
host.setPacemakerVersion("1.0.9");
host.setHeartbeatVersion("2.99.0");
assertFalse(Tools.versionBeforePacemaker(host));
host.setPacemakerVersion("1.0.9");
host.setHeartbeatVersion(null);
assertFalse(Tools.versionBeforePacemaker(host));
for (final Host h : TestSuite1.getHosts()) {
Tools.versionBeforePacemaker(h);
}
}
private String ssb(final String s) {
final StringBuffer sb = new StringBuffer(s);
Tools.chomp(sb);
return sb.toString();
}
@Test
public void testComp() {
assertEquals("", ssb(""));
assertEquals("\n", ssb("\n\n\n"));
assertEquals(" ", ssb(" "));
assertEquals("a", ssb("a"));
assertEquals("a\nb", ssb("a\nb"));
assertEquals(" a\n", ssb(" a\n"));
assertEquals(" a\n", ssb(" a\n\n"));
assertEquals(" a \n", ssb(" a \n"));
}
}
| [
"[email protected]"
]
| |
5f535074f6d44ed8e030663ff189d66e8cdcab82 | 858e03520d8daf4a6c769a0e3a4352ca19004897 | /ly-gateway/src/main/java/com/leyou/gateway/config/GlobalCorsConfig.java | 423a8bc3ed2dc45bb44930e289af10a9e85c6dbf | []
| no_license | Taurusbing/leyou-manage | 8d5d8020e5b49991f78b238bf7569fc2a26bf93c | b10a32a5856be93bfae2b02bea113bf5c40a01ba | refs/heads/master | 2022-11-28T13:49:29.975583 | 2019-05-29T09:50:01 | 2019-05-29T09:50:01 | 178,099,542 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,518 | java | package com.leyou.gateway.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
/**
* @author xubing
* @date 2019/3/26
*/
@Configuration
public class GlobalCorsConfig {
@Bean
public CorsFilter corsFilter(){
//1.添加CORS配置信息
CorsConfiguration config = new CorsConfiguration();
//1)允许的域,不要写*,否则cookie无法使用
config.addAllowedOrigin("http://manage.leyou.com");
//2)是否发送cookie信息
config.setAllowCredentials(true);
//3) 允许的请求方式
config.addAllowedMethod("OPTIONS");
config.addAllowedMethod("HEAD");
config.addAllowedMethod("GET");
config.addAllowedMethod("PUT");
config.addAllowedMethod("POST");
config.addAllowedMethod("DELETE");
config.addAllowedMethod("PATCH");
//4)允许的头信息
config.addAllowedHeader("*");
//2.添加映射路径,这里拦截一切请求
UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
configSource.registerCorsConfiguration("/**",config);
//返回新的CorsFilter
return new CorsFilter(configSource);
}
}
| [
"[email protected]"
]
| |
c48561c58f8cc3345fe65e690a48f21c00feebaa | 5d5fbb00bdfb822b2592796331a8a16bb50568ef | /src/ControlServer.java | 2f4031a068d04a33a860e5c3937deaca08f58800 | []
| no_license | Kephael/OWI-535-Java-Server-Software | eb9ccb1520acbf55a9869c579a3034ca551784e8 | 53c8c873660e5ada385060db926142eca18d7972 | refs/heads/master | 2021-01-23T02:43:41.194443 | 2017-03-24T03:04:12 | 2017-03-24T03:04:12 | 86,021,400 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 810 | java | import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import arm.ArmControl;
public class ControlServer {
public static void main(String[] args) {
if (args.length < 1){
System.out.println("Server must be launched with the port specified as an argument.");
System.exit(-1);
}
System.out.println("Server is listening on port " + args[0]);
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(Integer.parseInt(args[0]));
} catch (NumberFormatException | IOException e1) {
e1.printStackTrace();
}
while (true){
try {
Socket clientSocket = serverSocket.accept();
Thread controlThread = new Thread(new ControlThread(clientSocket));
controlThread.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
| [
"[email protected]"
]
| |
e9467d5d5b3f348e00587735b64b099f96c44a75 | fdd4cc6f8b5a473c0081af5302cb19c34433a0cf | /src/modules/agrega/ModificadorWeb/src/main/java/es/pode/modificador/presentacion/configurar/nombre/CrearModificacionBuscarFormImpl.java | ee81427f45c00d5b7f6d00a41f608222e95c450f | []
| no_license | nwlg/Colony | 0170b0990c1f592500d4869ec8583a1c6eccb786 | 07c908706991fc0979e4b6c41d30812d861776fb | refs/heads/master | 2021-01-22T05:24:40.082349 | 2010-12-23T14:49:00 | 2010-12-23T14:49:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,137 | java | // license-header java merge-point
package es.pode.modificador.presentacion.configurar.nombre;
public class CrearModificacionBuscarFormImpl
extends org.apache.struts.validator.ValidatorForm
implements java.io.Serializable
{
private java.lang.String idiomaBuscador;
private java.lang.Object[] idiomaBuscadorValueList;
private java.lang.Object[] idiomaBuscadorLabelList;
public CrearModificacionBuscarFormImpl()
{
}
/**
* Resets the given <code>idiomaBuscador</code>.
*/
public void resetIdiomaBuscador()
{
this.idiomaBuscador = null;
}
public void setIdiomaBuscador(java.lang.String idiomaBuscador)
{
this.idiomaBuscador = idiomaBuscador;
}
/**
*
*/
public java.lang.String getIdiomaBuscador()
{
return this.idiomaBuscador;
}
public java.lang.Object[] getIdiomaBuscadorBackingList()
{
java.lang.Object[] values = this.idiomaBuscadorValueList;
java.lang.Object[] labels = this.idiomaBuscadorLabelList;
if (values == null || values.length == 0)
{
return values;
}
if (labels == null || labels.length == 0)
{
labels = values;
}
final int length = java.lang.Math.min(labels.length, values.length);
java.lang.Object[] backingList = new java.lang.Object[length];
for (int i=0; i<length; i++)
{
backingList[i] = new LabelValue(labels[i], values[i]);
}
return backingList;
}
public java.lang.Object[] getIdiomaBuscadorValueList()
{
return this.idiomaBuscadorValueList;
}
public void setIdiomaBuscadorValueList(java.lang.Object[] idiomaBuscadorValueList)
{
this.idiomaBuscadorValueList = idiomaBuscadorValueList;
}
public java.lang.Object[] getIdiomaBuscadorLabelList()
{
return this.idiomaBuscadorLabelList;
}
public void setIdiomaBuscadorLabelList(java.lang.Object[] idiomaBuscadorLabelList)
{
this.idiomaBuscadorLabelList = idiomaBuscadorLabelList;
}
public void setIdiomaBuscadorBackingList(java.util.Collection items, java.lang.String valueProperty, java.lang.String labelProperty)
{
if (valueProperty == null || labelProperty == null)
{
throw new IllegalArgumentException("CrearModificacionBuscarFormImpl.setIdiomaBuscadorBackingList requires non-null property arguments");
}
this.idiomaBuscadorValueList = null;
this.idiomaBuscadorLabelList = null;
if (items != null)
{
this.idiomaBuscadorValueList = new java.lang.Object[items.size()];
this.idiomaBuscadorLabelList = new java.lang.Object[items.size()];
try
{
int i = 0;
for (java.util.Iterator iterator = items.iterator(); iterator.hasNext(); i++)
{
final java.lang.Object item = iterator.next();
this.idiomaBuscadorValueList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, valueProperty);
this.idiomaBuscadorLabelList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item, labelProperty);
}
}
catch (Exception ex)
{
throw new java.lang.RuntimeException("CrearModificacionBuscarFormImpl.setIdiomaBuscadorBackingList encountered an exception", ex);
}
}
}
/**
* @see org.apache.struts.validator.ValidatorForm#reset(org.apache.struts.action.ActionMapping,javax.servlet.http.HttpServletRequest)
*/
public void reset(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
{
this.idiomaBuscador = null;
}
public java.lang.String toString()
{
org.apache.commons.lang.builder.ToStringBuilder builder =
new org.apache.commons.lang.builder.ToStringBuilder(this);
builder.append("idiomaBuscador", this.idiomaBuscador);
return builder.toString();
}
/**
* Allows you to clean all values from this form. Objects will be set to <code>null</code>, numeric values will be
* set to zero and boolean values will be set to <code>false</code>. Backinglists for selectable fields will
* also be set to <code>null</code>.
*/
public void clean()
{
this.idiomaBuscador = null;
this.idiomaBuscadorValueList = null;
this.idiomaBuscadorLabelList = null;
}
/**
* Override to provide population of current form with request parameters when validation fails.
*
* @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
*/
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
{
final org.apache.struts.action.ActionErrors errors = super.validate(mapping, request);
if (errors != null && !errors.isEmpty())
{
// we populate the current form with only the request parameters
Object currentForm = request.getSession().getAttribute("form");
// if we can't get the 'form' from the session, try from the request
if (currentForm == null)
{
currentForm = request.getAttribute("form");
}
if (currentForm != null)
{
final java.util.Map parameters = new java.util.HashMap();
for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();)
{
final String name = String.valueOf(names.nextElement());
parameters.put(name, request.getParameter(name));
}
try
{
org.apache.commons.beanutils.BeanUtils.populate(currentForm, parameters);
}
catch (java.lang.Exception populateException)
{
// ignore if we have an exception here (we just don't populate).
}
}
}
return errors;
}
public final static class LabelValue
{
private java.lang.Object label = null;
private java.lang.Object value = null;
public LabelValue(Object label, java.lang.Object value)
{
this.label = label;
this.value = value;
}
public java.lang.Object getLabel()
{
return this.label;
}
public java.lang.Object getValue()
{
return this.value;
}
public java.lang.String toString()
{
return label + "=" + value;
}
}
} | [
"[email protected]"
]
| |
deccea72095085390a16af38c399b1f410ea44d7 | bbd7e1aa5fd483a692546bd6919ce32671c32336 | /universidad-api/src/main/java/universidad/alumno/application/dto/deserializer/ResponseBecadosDtoDeserializer.java | 459b6c679a09f4dacec7aeef070bcd602eaddd65 | []
| no_license | mmsf84/examen-final-dycs-18-1 | f94575f707bb4b528437737a66e6899827a3ad07 | a473f956f59d5e1f3bdf155e38e100b00a97834c | refs/heads/master | 2020-03-23T15:49:03.083779 | 2018-07-21T03:03:32 | 2018-07-21T03:03:32 | 141,776,517 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 940 | java | package universidad.alumno.application.dto.deserializer;
import java.io.IOException;
import java.math.BigDecimal;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import universidad.alumno.application.dto.BecadosDto;
import universidad.alumno.application.dto.ResponseBecadosDto;
import universidad.common.application.enumeration.AlumnoType;
public class ResponseBecadosDtoDeserializer extends JsonDeserializer<BecadosDto> {
@Override
public ResponseBecadosDto deserialize(JsonParser jsonParser, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
ResponseBecadosDto responseBecadosDto = null;
return responseBecadosDto;
}
}
| [
"[email protected]"
]
| |
7a8e1427cae81219651fbc8be3529ced7a240d8e | d46b64fa976eef5389e198203bc896d2521be7dd | /app/src/main/java/de/koelle/christian/common/testsupport/TestDataSet.java | 9c1a8fffdeecbb61b2895918d51ca12ebdbed530 | [
"Apache-2.0"
]
| permissive | koelleChristian/trickytripper | 5dbdbea7e61250ac4b9a00ed05c139c867c901ee | 287b843ebf6aea4f4276551511535a966109df73 | refs/heads/master | 2021-11-26T01:07:09.083418 | 2020-01-20T22:18:23 | 2020-01-20T22:18:23 | 3,173,086 | 46 | 22 | Apache-2.0 | 2022-12-30T09:42:07 | 2012-01-13T18:03:45 | Java | UTF-8 | Java | false | false | 350 | java | package de.koelle.christian.common.testsupport;
public enum TestDataSet {
/** Default test data set. */
DEFAULT,
/** Blank data pool. */
BLANK,
/** Blank data pool. */
PAYMENTS_ONE_WITHOUT_CHRISTIAN,
/** */
FIRST_PAYMENT_HIGHER_THAN_FIRST_DEBITOR,
/** */
FIRST_PAYMENT_LOWER_THAN_FIRST_DEBITOR,
/**/;
}
| [
"[email protected]"
]
| |
217924deaff487a3f1d4d85fc6bdbe93d3756a19 | 672e971778284583360127d5021f9d7e5175c175 | /src/main/java/org/jhipster/space/security/package-info.java | aa3dca40802fc164bb8654c177f1e79c641f88a0 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | oktadev/okta-jhipster-micronaut-example | 277a06d4e102db0f4ac3706db5ab60eb865ed633 | 46932f80ea96c7b47418de9158dcc6b8f4d99491 | refs/heads/main | 2023-03-16T02:33:14.182661 | 2021-03-08T15:38:39 | 2021-03-08T15:38:39 | 285,661,679 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 79 | java | /**
* Spring Security configuration.
*/
package org.jhipster.space.security;
| [
"[email protected]"
]
| |
35522e8325c4322f5ce8e650c8482af54092d7da | 642f1f62abb026dee2d360a8b19196e3ccb859a1 | /web/src/main/java/com/sun3d/why/model/ccp/CcpPoemUser.java | 929585ae2e8f63d1dbe126918736f399c2ace3a6 | []
| no_license | P79N6A/alibaba-1 | f6dacf963d56856817b211484ca4be39f6dd9596 | 6ec48f26f16d51c8a493b0eee12d90775b6eaf1d | refs/heads/master | 2020-05-27T08:34:26.827337 | 2019-05-25T07:50:12 | 2019-05-25T07:50:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 798 | java | package com.sun3d.why.model.ccp;
import java.util.Date;
public class CcpPoemUser {
private String userId;
private String poemId;
private Date createTime;
public CcpPoemUser() {
super();
}
public CcpPoemUser(String userId) {
super();
this.userId = userId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId == null ? null : userId.trim();
}
public String getPoemId() {
return poemId;
}
public void setPoemId(String poemId) {
this.poemId = poemId == null ? null : poemId.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
} | [
"[email protected]"
]
| |
3b17872b94246f59eb6d8c9f03ed2d3cae92a537 | f4c7bd5b7815bad88dc364a07d3aaf05c5263aba | /Labs/src/lab084.java | f678b8bf58b8faf3513a3a8b9570e90a224fa1cd | []
| no_license | nguyenntdev/PRO192x_2.1-A | a058a30abf9d594e0021ec1f2462349e36f7e754 | 59646aa9697136a308bfe8acc6809bef316039a5 | refs/heads/main | 2023-09-02T08:45:49.811962 | 2021-11-14T07:16:01 | 2021-11-14T07:16:01 | 411,559,650 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 191 | java | public class lab084 {
public class Point {
private int x;
private int y;
public boolean isVertical(Point p) {
return this.x == p.x;
}
}
}
| [
"[email protected]"
]
| |
2e4e2c340aff4d5ee62d7d0d59550ff3394df96b | b94b8ca4aa5b5d9053d3ffbb64170f2e13794cec | /src/main/java/com/uibuilder/controller/PageController.java | f31a49d5e9a770409d916395a4a796e49f291400 | []
| no_license | himanshuy48/Drag-n-Drop-Rest-API-App | 0e38984db24421f7e22b580bac07cc2ca88b77fa | 03a37ed47f1c4b8f4c6c6af4ae76a8d3b5f5bc13 | refs/heads/master | 2022-11-25T13:12:50.713138 | 2020-01-12T14:21:20 | 2020-01-12T14:21:20 | 233,397,598 | 1 | 0 | null | 2022-11-15T23:34:52 | 2020-01-12T13:34:02 | Java | UTF-8 | Java | false | false | 237 | java | package com.uibuilder.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/pages")
public class PageController {
}
| [
"[email protected]"
]
| |
a9bff70c3cc0c7299b073e8d78f7b50033a9609a | 32a659636016c0fb372d221ecc630d14bb79eab9 | /Implementing Iterable/src/Application.java | 6bcc2c0afd9cc9833949d03b21553cd30e30ceeb | []
| no_license | amankhatri/learnJAVA | 08b64a00d2b0c09ef79ed77e71c3d5e7dbe5e78b | ca89443ef867a4d5f77f5be9cb5e58ed17fa8751 | refs/heads/master | 2020-05-17T03:52:29.803985 | 2014-10-29T12:22:24 | 2014-10-29T12:22:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 472 | java |
public class Application {
public static void main(String[] args) {
/*we will create out own iterable class. */
Urlibrary urLibrary = new Urlibrary();
/*since Urlibrary class implements iterable over strings we would
* have to declare for loop as : for(type_of_variable name_of_Variable
* : name_of_object in this class)*/
for(String html: urLibrary){
System.out.println("html.length: "+html.length());
System.out.println("URL: " +html);
}
}
}
| [
"[email protected]"
]
| |
21f2841cd616cd99ec902e0e9893a8c9dc6cd524 | fe3de06cad8e7abd8d341616895db383282bd9e0 | /023-@ManytoOne/src/calistirma/HibernateDeneme.java | 76f8943b4e316015177b1b5ac72a7453afe43348 | []
| no_license | Rapter1990/Hibernate-Kaynak | 8afb5eeac69467ffc26c815cb841b2762bf25e98 | d93f25dddf7c137c5418d7f90cbe634107515126 | refs/heads/master | 2020-04-07T07:33:17.350031 | 2018-11-19T08:08:15 | 2018-11-19T08:08:15 | 158,180,764 | 0 | 0 | null | null | null | null | ISO-8859-9 | Java | false | false | 1,453 | java | package calistirma;
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import deneme.Meslek;
import deneme.Personel;
public class HibernateDeneme {
public static void main(String[] args) {
/////////////////////////////////////////////////
Personel personel = new Personel();
personel.setPersonelAdi("Noyan");
personel.setPersonelSoyadi("Germiyanoğlu");
personel.setPersonelkayitTarihi(new Date());
Meslek meslek1 = new Meslek();
meslek1.setMeslekAdi("Organizatör");
Meslek meslek2 = new Meslek();
meslek2.setMeslekAdi("Ekonomist");
///////////////////////////////////////////////////
personel.getMeslek().add(meslek1);
personel.getMeslek().add(meslek2);
///////////////////////////////////////////////////
meslek1.setPersonel(personel);
meslek2.setPersonel(personel);
///////////////////////////////////////////////////
// Hibernate
SessionFactory sessionFactory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
session.save(personel);
session.save(meslek1);
session.save(meslek2);
} catch (Exception e) {
e.printStackTrace();
}
session.getTransaction().commit();
session.close();
//
}
}
| [
"[email protected]"
]
| |
2b6c7cf25ecc63c07b7da49af3656328558b50a5 | 483ac68898bd1301c1cf5c291ae3816c93f8c54d | /ACWing/src/graph/有向图的强联通分量/受欢迎的牛.java | 769406a1d0e3090c6e76a45dd549f55cf4d9276c | [
"MIT"
]
| permissive | Departuers/Algorithm | c41528eba6159509abdf7067105f52c5562c812d | 96b0212fce85ae001de573c55042a30fca363f72 | refs/heads/master | 2023-01-14T03:33:48.386573 | 2020-11-13T06:36:33 | 2020-11-13T06:36:33 | 221,187,326 | 6 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,023 | java | package graph.有向图的强联通分量;
import java.util.Scanner;
/**
* tarjan求强联通分量
* https://www.luogu.com.cn/blog/zyb2624936151/tarjan
* O(n+m)
* 每头奶牛都梦想成为牛棚里的明星。被所有奶牛喜欢的奶牛就是一头明星奶牛。
* 所有奶牛都是自恋狂,每头奶牛总是喜欢自己的。奶牛之间的“喜欢”是可以传递的——如果 A喜欢 B,B 喜欢 C
* 那么 A 也喜欢 C。牛栏里共有 N头奶牛,给定一些奶牛之间的爱慕关系,请你算出有多少头奶牛可以当明星。
* 输入格式
* 第一行:两个用空格分开的整数:N 和 M。
* 接下来 M 行:每行两个用空格分开的整数:A 和 B,表示 A 喜欢 B。
* 输出格式
* 一行单独一个整数,表示明星奶牛的数量。
* 输入输出样例
* 输入
* 3 3
* 1 2
* 2 1
* 2 3
* 输出
* 1
* 显然,对于每个点,在反图上遍历一遍,看能不能到达其他所有点,O(n+m)每次
* 复杂负最终为O(n(n+m))
* 假设这个图是拓扑图,缩点后,那么肯定会走到一个出度为0的点
* 如果存在两个出度为0的点,那么无解
* 结论:如果只有一个强连通分量的缩点后的出度0,那么答案就是该强连通分量的点的数量
* 如果有大于一个强连通分量的出度为0,那么答案为0
* tanjan+缩点
* 拿Cpp写过了,JavaRe2个
*/
@SuppressWarnings("all")
public class 受欢迎的牛 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m = sc.nextInt();
int a, b;
while (m-- != 0) {
a = sc.nextInt();
b = sc.nextInt();
add(a, b);
}
for (int i = 1; i <= n; i++) {
if (dfn[i] == 0) {
tarjan(i);
}
}
//缩点
for (int i = 1; i <= n; i++) {//遍历所有点
for (int j = h[i]; j != 0; j = ne[j]) {//遍历i所有的邻边
int k = e[j];
a = id[i];
b = id[k];
if (a != b) {
dout[a]++;//出度
}
}
}
int zeros = 0, sum = 0;
for (int i = 1; i <= scc_cnt; i++) {
if (dout[i] == 0) {
zeros++;
sum = size[i];//出度为0的强连通分量,有多少个点
if (zeros > 1) {//拓扑图,缩点后,如果有超过一个出度为0的点,那么无解
sum = 0;
break;
}
}
}
System.out.println(sum);
}
static void tarjan(int u) {
dfn[u] = low[u] = ++time;//时间戳
stk[++top] = u;
in_stk[u] = true;//把u点放进栈中
for (int i = h[u]; i != 0; i = ne[i]) {
int j = e[i];
if (dfn[j] == 0) {
tarjan(j);
low[u] = Math.min(low[u], low[j]);
} else if (in_stk[j]) {
low[u] = Math.min(low[u], dfn[j]);
}
}
if (dfn[u] == low[u]) {//找到一个强连通分量的最高点
++scc_cnt;
int y = 0;
do {
y = stk[top--];
in_stk[y] = false;//出栈
id[y] = scc_cnt;//y属于哪一个强连通分量编号
size[scc_cnt]++;//数量++
} while (y != u);
}
}
static void add(int a, int b) {
e[idx] = b;
ne[idx] = h[a];
h[a] = idx++;
}
static int N = 10010, n, M = 50010, time, top, scc_cnt = 0, m, idx = 1;
static int[] h = new int[N];
static int[] e = new int[M];
static int[] ne = new int[M];
static int[] dfn = new int[N];
static int[] low = new int[N];
static int[] stk = new int[N];
static boolean[] in_stk = new boolean[N];
static int[] id = new int[N];
static int[] size = new int[N];
static int[] dout = new int[N];//出度
}
| [
"[email protected]"
]
| |
17acdab174ce1aeb60b9f533e33676389fb8b965 | 807316633f801c61b8c00373e09afe2803e8c893 | /src/avanlon/game/states/newpage/LaunchBattleMonster3.java | 6c5c23ba12362462fd354cd56be6a7ca3de659f6 | []
| no_license | Chroax/Chronicles-Game | 0152d33b3d51a732644d4b7f03fa27378e0038ab | 8a4225ffbc0c6a599d28cd1a15fdad350c278d68 | refs/heads/main | 2023-06-23T13:22:47.847159 | 2021-07-21T14:59:32 | 2021-07-21T14:59:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,614 | java | package avanlon.game.states.newpage;
import avanlon.framework.gui.WindowManager;
import avanlon.framework.resources.Monsters;
import avanlon.game.entity.Monster;
import avanlon.game.entity.Player.Player;
import avanlon.game.states.dungeonstates.BattleMonster;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Random;
public class LaunchBattleMonster3
{
public static JFrame frame = new JFrame();
public int totalMonster;
ArrayList<Monster> spawnMob;
private Random random = new Random();
public LaunchBattleMonster3(Player player, int totalMonster, int level)
{
spawnMob = new ArrayList<>();
for (int i = 0; i < totalMonster; i++)
{
switch (level)
{
case 1 ->
{
Monster monster = Monsters.monsterDungeonCave.get(random.nextInt(Monsters.monsterDungeonCave.size()));
spawnMob.add(new Monster(monster.getName(), monster.getHPMax(), monster.getMPMax(), monster.getMagDef(), monster.getPhyDef(), monster.getMovSpeed(), monster.getMagAtt(), monster.getPhyAtt(), monster.getExpDrop(), monster.getGoldDrop(), monster.getLevel()));
}
case 2 ->
{
Monster monster = Monsters.monsterDungeonForest.get(random.nextInt(Monsters.monsterDungeonForest.size()));
spawnMob.add(new Monster(monster.getName(), monster.getHPMax(), monster.getMPMax(), monster.getMagDef(), monster.getPhyDef(), monster.getMovSpeed(), monster.getMagAtt(), monster.getPhyAtt(), monster.getExpDrop(), monster.getGoldDrop(), monster.getLevel()));
}
case 3 ->
{
Monster monster = Monsters.monsterDungeonCastle.get(random.nextInt(Monsters.monsterDungeonCastle.size()));
spawnMob.add(new Monster(monster.getName(), monster.getHPMax(), monster.getMPMax(), monster.getMagDef(), monster.getPhyDef(), monster.getMovSpeed(), monster.getMagAtt(), monster.getPhyAtt(), monster.getExpDrop(), monster.getGoldDrop(), monster.getLevel()));
}
}
}
this.totalMonster = totalMonster;
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(WindowManager.WIDTH, WindowManager.HEIGHT);
frame.setLayout(null);
frame.add(new BattleMonster(player, totalMonster, level, spawnMob));
frame.setResizable(false);
frame.setVisible(true);
}
}
| [
"[email protected]"
]
| |
8182298eb39ca5904573d7c6ff836983167ee2b1 | 7b5b70528d063a3369bb773d91e6a8f6cf058b2d | /spring_aop/src/main/java/com/zyc/cglib/Increase.java | 47fdfcaf34c64f85779a324d859d77b401c4e1dc | [
"Apache-2.0"
]
| permissive | zyc460691495/Spring | 8993431ffdea1f350022bc446679ee064e82b97a | e3fbfb34474802a87f4b064e10a0160108760934 | refs/heads/main | 2023-08-17T15:01:37.603014 | 2023-08-04T08:06:15 | 2023-08-04T08:06:15 | 331,849,275 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 208 | java | package com.zyc.cglib;
public class Increase {
public void before(){
System.out.println("before........");
}
public void after(){
System.out.println("after.........");
}
}
| [
"[email protected]"
]
| |
317fc7044494bbdbe4be4224a6ed3d610718b00c | 22692d9e4d85012d32929c7909cbc72ec6304531 | /ssm_why/ssm_service/src/main/java/com/deyuan/service/IProductService.java | b1d5b95d413ff28a15bf9d8c2d938fa9f673634d | []
| no_license | whyjava1005/repo5 | 4f15a34f1b415a230036030d80d398341124a3f1 | 85e86c933559cb41164fc3ace1dcebae1fcfa991 | refs/heads/master | 2023-01-13T21:43:09.187860 | 2020-11-05T01:20:25 | 2020-11-05T01:20:25 | 310,152,188 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 249 | java | package com.deyuan.service;
import com.deyuan.pojo.Product;
import org.springframework.stereotype.Service;
import java.util.List;
public interface IProductService {
List<Product> findAll(int page,int size);
void save(Product product);
}
| [
"[email protected]"
]
| |
e2ec5e9d8f1101a0a41a0e456aa6411532d62183 | b09b3f7f622ca4c79ee0c3dfd23d2d16db97d35e | /CountDownLatchExample/src/com/concurrency/synchroniser/Boss.java | ce6dec4fe90a4774ca100edc9c1d80641e1714be | []
| no_license | skpandey11/Technical_Discussion_Code | 9f14fa6c03c2ebdf8c55080558a396f8bc223bbd | a314d9f1dcbe28ac90f6bda0c261b8d8f64d9518 | refs/heads/master | 2021-01-17T17:48:02.559473 | 2015-03-10T20:09:04 | 2016-06-08T16:56:06 | 60,443,190 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 530 | java | package com.concurrency.synchroniser;
import java.util.concurrent.CountDownLatch;
public class Boss implements Runnable{
private CountDownLatch downLatch;
public Boss(CountDownLatch downLatch){
this.downLatch = downLatch;
}
public void run() {
try {
this.downLatch.await();
} catch (InterruptedException e) {
}
System.out.println("workers live are finished, the boss began to check out! ");
}
}
| [
"[email protected]"
]
| |
ac81ee7bc40625b3ec28de53c7c0e1e82aa2d9d3 | 943402491ef8d27a233e5611956011deda51bf8b | /src/com/patientdata/SaveServlet.java | cfd7507b728144bba0663f2a7579984a1878de12 | []
| no_license | thepali/CRUD_Application | 393e63409e3b63c16ab677884e8fcff21b6d2dbc | 98dc81606c3cbebc14ae69452d53bf092f3879b6 | refs/heads/master | 2020-07-11T19:27:38.742229 | 2019-08-27T05:55:56 | 2019-08-27T05:55:56 | 204,626,600 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,373 | java | package com.patientdata;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class SaveServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
String name = request.getParameter("name");
String birthdate = request.getParameter("bdate");
String bloodgroup = request.getParameter("bgroup");
String gender = request.getParameter("gender");
String contact_number = request.getParameter("number");
String address = request.getParameter("address");
Patient p = new Patient();
p.set_name(name);
p.set_birthdate(birthdate);
p.set_bloodgroup(bloodgroup);
p.set_gender(gender);
p.set_cntnumber(contact_number);
p.set_address(address);
int status = PatientDao.save(p);
if(status>0)
{
pw.print("Record Saved Successfully!");
request.getRequestDispatcher("index.html").include(request, response);
}
else
{
pw.print("Sorry!Record is not saved.");
}
pw.close();
}
}
| [
"[email protected]"
]
| |
fbbfbe9172a0a6d8463473f4cd099dbe04d480db | d49bbeedf8073d0b4fc23672d24b484d8988024e | /BouncyCastle/core/src/main/java/com/distrimind/bouncycastle/crypto/generators/Argon2BytesGenerator.java | 474370bad5ed3a8bf0690ad0ef62cb540edd5e8a | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | sqf-ice/BouncyCastle | a6b34bd56fa7e5545e19dd8a1174d614b625a1e8 | 02bec112a39175ebe19dd22236d2b4d6558dfa8c | refs/heads/master | 2022-11-17T08:52:07.224092 | 2020-07-14T23:21:12 | 2020-07-14T23:21:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 23,066 | java | package com.distrimind.bouncycastle.crypto.generators;
import com.distrimind.bouncycastle.crypto.Digest;
import com.distrimind.bouncycastle.crypto.digests.Blake2bDigest;
import com.distrimind.bouncycastle.crypto.params.Argon2Parameters;
import com.distrimind.bouncycastle.util.Arrays;
import com.distrimind.bouncycastle.util.Pack;
import com.distrimind.bouncycastle.util.encoders.Hex;
/**
* Argon2 PBKDF - Based on the results of https://password-hashing.net/ and https://www.ietf.org/archive/id/draft-irtf-cfrg-argon2-03.txt
*/
public class Argon2BytesGenerator
{
private static final int ARGON2_BLOCK_SIZE = 1024;
private static final int ARGON2_QWORDS_IN_BLOCK = ARGON2_BLOCK_SIZE / 8;
private static final int ARGON2_ADDRESSES_IN_BLOCK = 128;
private static final int ARGON2_PREHASH_DIGEST_LENGTH = 64;
private static final int ARGON2_PREHASH_SEED_LENGTH = 72;
private static final int ARGON2_SYNC_POINTS = 4;
/* Minimum and maximum number of lanes (degree of parallelism) */
private static final int MIN_PARALLELISM = 1;
private static final int MAX_PARALLELISM = 16777216;
/* Minimum and maximum digest size in bytes */
private static final int MIN_OUTLEN = 4;
/* Minimum and maximum number of passes */
private static final int MIN_ITERATIONS = 1;
private Argon2Parameters parameters;
private Block[] memory;
private int segmentLength;
private int laneLength;
public Argon2BytesGenerator()
{
}
/**
* Initialise the Argon2BytesGenerator from the parameters.
*
* @param parameters Argon2 configuration.
*/
public void init(Argon2Parameters parameters)
{
this.parameters = parameters;
if (parameters.getLanes() < Argon2BytesGenerator.MIN_PARALLELISM)
{
throw new IllegalStateException("lanes must be greater than " + Argon2BytesGenerator.MIN_PARALLELISM);
}
else if (parameters.getLanes() > Argon2BytesGenerator.MAX_PARALLELISM)
{
throw new IllegalStateException("lanes must be less than " + Argon2BytesGenerator.MAX_PARALLELISM);
}
else if (parameters.getMemory() < 2 * parameters.getLanes())
{
throw new IllegalStateException("memory is less than: " + (2 * parameters.getLanes()) + " expected " + (2 * parameters.getLanes()));
}
else if (parameters.getIterations() < Argon2BytesGenerator.MIN_ITERATIONS)
{
throw new IllegalStateException("iterations is less than: " + Argon2BytesGenerator.MIN_ITERATIONS);
}
doInit(parameters);
}
public int generateBytes(char[] password, byte[] out)
{
return generateBytes(parameters.getCharToByteConverter().convert(password), out);
}
public int generateBytes(char[] password, byte[] out, int outOff, int outLen)
{
return generateBytes(parameters.getCharToByteConverter().convert(password), out, outOff, outLen);
}
public int generateBytes(byte[] password, byte[] out)
{
return generateBytes(password, out, 0, out.length);
}
public int generateBytes(byte[] password, byte[] out, int outOff, int outLen)
{
if (outLen < Argon2BytesGenerator.MIN_OUTLEN)
{
throw new IllegalStateException("output length less than " + Argon2BytesGenerator.MIN_OUTLEN);
}
initialize(password, outLen);
fillMemoryBlocks();
digest(out, outOff, outLen);
reset();
return outLen;
}
// Clear memory.
private void reset()
{
// Reset memory.
if (null != memory)
{
for (int i = 0; i < memory.length; i++)
{
Block b = memory[i];
if (null != b)
{
b.clear();
}
}
}
}
private void doInit(Argon2Parameters parameters)
{
/* 2. Align memory size */
/* Minimum memoryBlocks = 8L blocks, where L is the number of lanes */
int memoryBlocks = parameters.getMemory();
if (memoryBlocks < 2 * Argon2BytesGenerator.ARGON2_SYNC_POINTS * parameters.getLanes())
{
memoryBlocks = 2 * Argon2BytesGenerator.ARGON2_SYNC_POINTS * parameters.getLanes();
}
this.segmentLength = memoryBlocks / (parameters.getLanes() * Argon2BytesGenerator.ARGON2_SYNC_POINTS);
this.laneLength = segmentLength * Argon2BytesGenerator.ARGON2_SYNC_POINTS;
/* Ensure that all segments have equal length */
memoryBlocks = segmentLength * (parameters.getLanes() * Argon2BytesGenerator.ARGON2_SYNC_POINTS);
initMemory(memoryBlocks);
}
private void initMemory(int memoryBlocks)
{
this.memory = new Block[memoryBlocks];
for (int i = 0; i < memory.length; i++)
{
memory[i] = new Block();
}
}
private void fillMemoryBlocks()
{
FillBlock filler = new FillBlock();
Position position = new Position();
for (int i = 0; i < parameters.getIterations(); i++)
{
for (int j = 0; j < ARGON2_SYNC_POINTS; j++)
{
for (int k = 0; k < parameters.getLanes(); k++)
{
position.update(i, k, j, 0);
fillSegment(filler, position);
}
}
}
}
private void fillSegment(FillBlock filler, Position position)
{
Block addressBlock = null, inputBlock = null, zeroBlock = null;
boolean dataIndependentAddressing = isDataIndependentAddressing(position);
int startingIndex = getStartingIndex(position);
int currentOffset = position.lane * laneLength + position.slice * segmentLength + startingIndex;
int prevOffset = getPrevOffset(currentOffset);
if (dataIndependentAddressing)
{
addressBlock = filler.addressBlock.clear();
zeroBlock = filler.zeroBlock.clear();
inputBlock = filler.inputBlock.clear();
initAddressBlocks(filler, position, zeroBlock, inputBlock, addressBlock);
}
for (position.index = startingIndex; position.index < segmentLength; position.index++, currentOffset++, prevOffset++)
{
prevOffset = rotatePrevOffset(currentOffset, prevOffset);
long pseudoRandom = getPseudoRandom(filler, position, addressBlock, inputBlock, zeroBlock, prevOffset, dataIndependentAddressing);
int refLane = getRefLane(position, pseudoRandom);
int refColumn = getRefColumn(position, pseudoRandom, refLane == position.lane);
/* 2 Creating a new block */
Block prevBlock = memory[prevOffset];
Block refBlock = memory[((laneLength) * refLane + refColumn)];
Block currentBlock = memory[currentOffset];
if (isWithXor(position))
{
filler.fillBlockWithXor(prevBlock, refBlock, currentBlock);
}
else
{
filler.fillBlock(prevBlock, refBlock, currentBlock);
}
}
}
private boolean isDataIndependentAddressing(Position position)
{
return (parameters.getType() == Argon2Parameters.ARGON2_i) ||
(parameters.getType() == Argon2Parameters.ARGON2_id
&& (position.pass == 0)
&& (position.slice < ARGON2_SYNC_POINTS / 2)
);
}
private void initAddressBlocks(FillBlock filler, Position position, Block zeroBlock, Block inputBlock, Block addressBlock)
{
inputBlock.v[0] = intToLong(position.pass);
inputBlock.v[1] = intToLong(position.lane);
inputBlock.v[2] = intToLong(position.slice);
inputBlock.v[3] = intToLong(memory.length);
inputBlock.v[4] = intToLong(parameters.getIterations());
inputBlock.v[5] = intToLong(parameters.getType());
if ((position.pass == 0) && (position.slice == 0))
{
/* Don't forget to generate the first block of addresses: */
nextAddresses(filler, zeroBlock, inputBlock, addressBlock);
}
}
private boolean isWithXor(Position position)
{
return !(position.pass == 0 || parameters.getVersion() == Argon2Parameters.ARGON2_VERSION_10);
}
private int getPrevOffset(int currentOffset)
{
if (currentOffset % laneLength == 0)
{
/* Last block in this lane */
return currentOffset + laneLength - 1;
}
else
{
/* Previous block */
return currentOffset - 1;
}
}
private int rotatePrevOffset(int currentOffset, int prevOffset)
{
if (currentOffset % laneLength == 1)
{
prevOffset = currentOffset - 1;
}
return prevOffset;
}
private static int getStartingIndex(Position position)
{
if ((position.pass == 0) && (position.slice == 0))
{
return 2; /* we have already generated the first two blocks */
}
else
{
return 0;
}
}
private void nextAddresses(FillBlock filler, Block zeroBlock, Block inputBlock, Block addressBlock)
{
inputBlock.v[6]++;
filler.fillBlock(zeroBlock, inputBlock, addressBlock);
filler.fillBlock(zeroBlock, addressBlock, addressBlock);
}
/* 1.2 Computing the index of the reference block */
/* 1.2.1 Taking pseudo-random value from the previous block */
private long getPseudoRandom(FillBlock filler, Position position, Block addressBlock, Block inputBlock, Block zeroBlock, int prevOffset, boolean dataIndependentAddressing)
{
if (dataIndependentAddressing)
{
if (position.index % ARGON2_ADDRESSES_IN_BLOCK == 0)
{
nextAddresses(filler, zeroBlock, inputBlock, addressBlock);
}
return addressBlock.v[position.index % ARGON2_ADDRESSES_IN_BLOCK];
}
else
{
return memory[prevOffset].v[0];
}
}
private int getRefLane(Position position, long pseudoRandom)
{
int refLane = (int)(((pseudoRandom >>> 32)) % parameters.getLanes());
if ((position.pass == 0) && (position.slice == 0))
{
/* Can not reference other lanes yet */
refLane = position.lane;
}
return refLane;
}
private int getRefColumn(Position position, long pseudoRandom, boolean sameLane)
{
int referenceAreaSize;
int startPosition;
if (position.pass == 0)
{
startPosition = 0;
if (sameLane)
{
/* The same lane => add current segment */
referenceAreaSize = position.slice * segmentLength + position.index - 1;
}
else
{
/* pass == 0 && !sameLane => position.slice > 0*/
referenceAreaSize = position.slice * segmentLength + ((position.index == 0) ? (-1) : 0);
}
}
else
{
startPosition = ((position.slice + 1) * segmentLength) % laneLength;
if (sameLane)
{
referenceAreaSize = laneLength - segmentLength + position.index - 1;
}
else
{
referenceAreaSize = laneLength - segmentLength + ((position.index == 0) ? (-1) : 0);
}
}
long relativePosition = pseudoRandom & 0xFFFFFFFFL;
relativePosition = (relativePosition * relativePosition) >>> 32;
relativePosition = referenceAreaSize - 1 - ((referenceAreaSize * relativePosition) >>> 32);
return (int)(startPosition + relativePosition) % laneLength;
}
private void digest(byte[] out, int outOff, int outLen)
{
Block finalBlock = memory[laneLength - 1];
/* XOR the last blocks */
for (int i = 1; i < parameters.getLanes(); i++)
{
int lastBlockInLane = i * laneLength + (laneLength - 1);
finalBlock.xorWith(memory[lastBlockInLane]);
}
byte[] finalBlockBytes = finalBlock.toBytes();
hash(finalBlockBytes, out, outOff, outLen);
}
/**
* H0 = H64(p, τ, m, t, v, y, |P|, P, |S|, S, |L|, K, |X|, X)
* -> 64 byte (ARGON2_PREHASH_DIGEST_LENGTH)
*/
private byte[] initialHash(Argon2Parameters parameters, int outputLength, byte[] password)
{
Blake2bDigest blake = new Blake2bDigest(ARGON2_PREHASH_DIGEST_LENGTH * 8);
addIntToLittleEndian(blake, parameters.getLanes());
addIntToLittleEndian(blake, outputLength);
addIntToLittleEndian(blake, parameters.getMemory());
addIntToLittleEndian(blake, parameters.getIterations());
addIntToLittleEndian(blake, parameters.getVersion());
addIntToLittleEndian(blake, parameters.getType());
addByteString(blake, password);
addByteString(blake, parameters.getSalt());
addByteString(blake, parameters.getSecret());
addByteString(blake, parameters.getAdditional());
byte[] blake2hash = new byte[blake.getDigestSize()];
blake.doFinal(blake2hash, 0);
return blake2hash;
}
/**
* H' - hash - variable length hash function
*/
private void hash(byte[] input, byte[] out, int outOff, int outLen)
{
byte[] outLenBytes = new byte[4];
Pack.intToLittleEndian(outLen, outLenBytes, 0);
int blake2bLength = 64;
if (outLen <= blake2bLength)
{
Blake2bDigest blake = new Blake2bDigest(outLen * 8);
blake.update(outLenBytes, 0, outLenBytes.length);
blake.update(input, 0, input.length);
blake.doFinal(out, outOff);
}
else
{
Blake2bDigest digest = new Blake2bDigest(blake2bLength * 8);
byte[] outBuffer = new byte[blake2bLength];
/* V1 */
digest.update(outLenBytes, 0, outLenBytes.length);
digest.update(input, 0, input.length);
digest.doFinal(outBuffer, 0);
int halfLen = blake2bLength / 2, outPos = outOff;
System.arraycopy(outBuffer, 0, out, outPos, halfLen);
outPos += halfLen;
int r = ((outLen + 31) / 32) - 2;
for (int i = 2; i <= r; i++, outPos += halfLen)
{
/* V2 to Vr */
digest.update(outBuffer, 0, outBuffer.length);
digest.doFinal(outBuffer, 0);
System.arraycopy(outBuffer, 0, out, outPos, halfLen);
}
int lastLength = outLen - 32 * r;
/* Vr+1 */
digest = new Blake2bDigest(lastLength * 8);
digest.update(outBuffer, 0, outBuffer.length);
digest.doFinal(out, outPos);
}
}
private static void roundFunction(Block block,
int v0, int v1, int v2, int v3,
int v4, int v5, int v6, int v7,
int v8, int v9, int v10, int v11,
int v12, int v13, int v14, int v15)
{
F(block, v0, v4, v8, v12);
F(block, v1, v5, v9, v13);
F(block, v2, v6, v10, v14);
F(block, v3, v7, v11, v15);
F(block, v0, v5, v10, v15);
F(block, v1, v6, v11, v12);
F(block, v2, v7, v8, v13);
F(block, v3, v4, v9, v14);
}
private static void F(Block block, int a, int b, int c, int d)
{
fBlaMka(block, a, b);
rotr64(block, d, a, 32);
fBlaMka(block, c, d);
rotr64(block, b, c, 24);
fBlaMka(block, a, b);
rotr64(block, d, a, 16);
fBlaMka(block, c, d);
rotr64(block, b, c, 63);
}
/*designed by the Lyra PHC team */
/* a <- a + b + 2*aL*bL
* + == addition modulo 2^64
* aL = least 32 bit */
private static void fBlaMka(Block block, int x, int y)
{
final long m = 0xFFFFFFFFL;
final long xy = (block.v[x] & m) * (block.v[y] & m);
block.v[x] = block.v[x] + block.v[y] + 2 * xy;
}
private static void rotr64(Block block, int v, int w, long c)
{
final long temp = block.v[v] ^ block.v[w];
block.v[v] = (temp >>> c) | (temp << (64 - c));
}
private void initialize(byte[] password, int outputLength)
{
byte[] initialHash = initialHash(parameters, outputLength, password);
fillFirstBlocks(initialHash);
}
private static void addIntToLittleEndian(Digest digest, int n)
{
digest.update((byte)(n));
digest.update((byte)(n >>> 8));
digest.update((byte)(n >>> 16));
digest.update((byte)(n >>> 24));
}
private static void addByteString(Digest digest, byte[] octets)
{
if (octets != null)
{
addIntToLittleEndian(digest, octets.length);
digest.update(octets, 0, octets.length);
}
else
{
addIntToLittleEndian(digest, 0);
}
}
/**
* (H0 || 0 || i) 72 byte -> 1024 byte
* (H0 || 1 || i) 72 byte -> 1024 byte
*/
private void fillFirstBlocks(byte[] initialHash)
{
final byte[] zeroBytes = {0, 0, 0, 0};
final byte[] oneBytes = {1, 0, 0, 0};
byte[] initialHashWithZeros = getInitialHashLong(initialHash, zeroBytes);
byte[] initialHashWithOnes = getInitialHashLong(initialHash, oneBytes);
byte[] blockhashBytes = new byte[ARGON2_BLOCK_SIZE];
for (int i = 0; i < parameters.getLanes(); i++)
{
Pack.intToLittleEndian(i, initialHashWithZeros, ARGON2_PREHASH_DIGEST_LENGTH + 4);
Pack.intToLittleEndian(i, initialHashWithOnes, ARGON2_PREHASH_DIGEST_LENGTH + 4);
hash(initialHashWithZeros, blockhashBytes, 0, ARGON2_BLOCK_SIZE);
memory[i * laneLength + 0].fromBytes(blockhashBytes);
hash(initialHashWithOnes, blockhashBytes, 0, ARGON2_BLOCK_SIZE);
memory[i * laneLength + 1].fromBytes(blockhashBytes);
}
}
private byte[] getInitialHashLong(byte[] initialHash, byte[] appendix)
{
byte[] initialHashLong = new byte[ARGON2_PREHASH_SEED_LENGTH];
System.arraycopy(initialHash, 0, initialHashLong, 0, ARGON2_PREHASH_DIGEST_LENGTH);
System.arraycopy(appendix, 0, initialHashLong, ARGON2_PREHASH_DIGEST_LENGTH, 4);
return initialHashLong;
}
private long intToLong(int x)
{
return (long)(x & 0xffffffffL);
}
private static class FillBlock
{
Block R = new Block();
Block Z = new Block();
Block addressBlock = new Block();
Block zeroBlock = new Block();
Block inputBlock = new Block();
private void applyBlake()
{
/* Apply Blake2 on columns of 64-bit words: (0,1,...,15) , then
(16,17,..31)... finally (112,113,...127) */
for (int i = 0; i < 8; i++)
{
int i16 = 16 * i;
roundFunction(Z,
i16, i16 + 1, i16 + 2,
i16 + 3, i16 + 4, i16 + 5,
i16 + 6, i16 + 7, i16 + 8,
i16 + 9, i16 + 10, i16 + 11,
i16 + 12, i16 + 13, i16 + 14,
i16 + 15
);
}
/* Apply Blake2 on rows of 64-bit words: (0,1,16,17,...112,113), then
(2,3,18,19,...,114,115).. finally (14,15,30,31,...,126,127) */
for (int i = 0; i < 8; i++)
{
int i2 = 2 * i;
roundFunction(Z,
i2, i2 + 1, i2 + 16,
i2 + 17, i2 + 32, i2 + 33,
i2 + 48, i2 + 49, i2 + 64,
i2 + 65, i2 + 80, i2 + 81,
i2 + 96, i2 + 97, i2 + 112,
i2 + 113
);
}
}
private void fillBlock(Block X, Block Y, Block currentBlock)
{
if (X == zeroBlock)
{
R.copyBlock(Y);
}
else
{
R.xor(X, Y);
}
Z.copyBlock(R);
applyBlake();
currentBlock.xor(R, Z);
}
private void fillBlockWithXor(Block X, Block Y, Block currentBlock)
{
R.xor(X, Y);
Z.copyBlock(R);
applyBlake();
currentBlock.xor(R, Z, currentBlock);
}
}
private static class Block
{
private static final int SIZE = ARGON2_QWORDS_IN_BLOCK;
/* 128 * 8 Byte QWords */
private final long[] v;
private Block()
{
v = new long[SIZE];
}
void fromBytes(byte[] input)
{
if (input.length != ARGON2_BLOCK_SIZE)
{
throw new IllegalArgumentException("input shorter than blocksize");
}
for (int i = 0; i < SIZE; i++)
{
v[i] = Pack.littleEndianToLong(input, i * 8);
}
}
byte[] toBytes()
{
byte[] result = new byte[ARGON2_BLOCK_SIZE];
for (int i = 0; i < SIZE; i++)
{
Pack.longToLittleEndian(v[i], result, i * 8);
}
return result;
}
private void copyBlock(Block other)
{
System.arraycopy(other.v, 0, v, 0, SIZE);
}
private void xor(Block b1, Block b2)
{
for (int i = 0; i < SIZE; i++)
{
v[i] = b1.v[i] ^ b2.v[i];
}
}
public void xor(Block b1, Block b2, Block b3)
{
for (int i = 0; i < SIZE; i++)
{
v[i] = b1.v[i] ^ b2.v[i] ^ b3.v[i];
}
}
private void xorWith(Block other)
{
for (int i = 0; i < v.length; i++)
{
v[i] = v[i] ^ other.v[i];
}
}
public String toString()
{
StringBuffer result = new StringBuffer();
for (int i = 0; i < SIZE; i++)
{
result.append(Hex.toHexString(Pack.longToLittleEndian(v[i])));
}
return result.toString();
}
public Block clear()
{
Arrays.fill(v, 0);
return this;
}
}
private static class Position
{
int pass;
int lane;
int slice;
int index;
Position()
{
}
void update(int pass, int lane, int slice, int index)
{
this.pass = pass;
this.lane = lane;
this.slice = slice;
this.index = index;
}
}
}
| [
"[email protected]"
]
| |
05619c72c2f38694a96e07239427aec4469315c3 | df4abeb0ba23cdee9ddac36e89e3674cebc8139b | /international-system-units-lib/src/main/java/uk/co/jpereira/isu/Formulae.java | 98c8c67b7e1659a9785592ee7052a5d0a6b5ab54 | [
"Apache-2.0"
]
| permissive | joaopapereira/international-system-units | 604f69548ebac3593a9958b7ce61a405150b7275 | e5eb37481bd9885da36fdf3e60b6aa7819088ae6 | refs/heads/master | 2021-01-10T09:58:36.717403 | 2019-11-18T18:45:48 | 2019-11-18T18:45:48 | 36,687,168 | 0 | 0 | Apache-2.0 | 2020-10-13T07:32:11 | 2015-06-01T20:34:31 | Java | UTF-8 | Java | false | false | 935 | java | package uk.co.jpereira.isu;
import java.util.logging.Logger;
/**
* Created by blue on 01/05/2015.
*/
public abstract class Formulae<Precision> implements ISURepresentable<Precision>, Comparable<Formulae> {
protected final Logger logger;
/**
* Formulae constructor
*/
public Formulae() {
logger = Logger.getLogger(this.getClass().getPackage().getName());
}
public abstract String getPackageName();
/**
* Name of the unit of the resulting formulae
*
* @return String with the unit representation
*/
public abstract String resultUnit();
/**
* Compare to units using the names
*
* @param otherFormulae Other Formulae to compare to
*/
public int compareTo(Formulae otherFormulae) {
return getClass().getName().compareTo(otherFormulae.getClass().getName());
}
public boolean isReversible() {
return false;
}
}
| [
"[email protected]"
]
| |
f4cbe2447a27b8fbf2b067f758bba3e2ec5da053 | 877a151853aeb758803a4bc44024449dce60c48c | /ex8_10.java | f86372ddbf87e64397f9529d0f757ae7dc7ec516 | []
| no_license | toeysp130/JAVA | f76b25be4dbc442a5496563a14229acd68206884 | 4e41476fb93fae1319f752599d069bfb407e9d10 | refs/heads/master | 2021-06-23T10:47:31.814879 | 2021-05-23T04:41:14 | 2021-05-23T04:41:14 | 226,062,490 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 651 | java | import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import jdk.internal.platform.Container;
public class ex8_10 {
public static void main(String[] args) {
new MinMaxNumber();
}
}
class MinMaxNumber implements ActionListener{
JFrame window = new JFrame("Min Max Program");
JLabel label1,label2,label3;
JTextField number1,number2,number3;
JButton btn;
Container c = window.getContentPane();
JPanel panel1,panel2;
Font font = new Font("Tahoma" , Font.BOLD,16);
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
| [
"[email protected]"
]
| |
bf9713f00b6ccd733ea12a2131685dbe95f12d68 | 46a5338c5979c54e335af3d5a0523d5325845a0d | /javaScala/demo/src/JavaScala/src/main/java/_learn/jars/nettyInAction/demos/webSocketChatRoom/ChatServerInitializer.java | a7bb51da635dec09bb50c4f3c2fc37df20e146a4 | []
| no_license | fishsey/code | 658284367b8435fa233a473341b90d746330a873 | b4275042e18ee02eb29ee285df7dce6d4d31a0c4 | refs/heads/master | 2021-07-11T18:57:11.052981 | 2017-10-06T11:15:35 | 2017-10-06T11:15:35 | 105,975,719 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,236 | java | package _learn.jars.nettyInAction.demos.webSocketChatRoom;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.group.ChannelGroup;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
import io.netty.handler.stream.ChunkedWriteHandler;
/**
* @author <a href="mailto:[email protected]">Norman Maurer</a>
*/
public class ChatServerInitializer extends ChannelInitializer<Channel> {
private final ChannelGroup group;
public ChatServerInitializer(ChannelGroup group) {
this.group = group;
}
@Override
protected void initChannel(Channel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new HttpServerCodec());
pipeline.addLast(new HttpObjectAggregator(64 * 1024));
pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new HttpRequestHandler("/ws"));
pipeline.addLast(new WebSocketServerProtocolHandler("/ws"));
pipeline.addLast(new TextWebSocketFrameHandler(group));
}
}
| [
"[email protected]"
]
| |
036705c90e07767dbd543e80b849067993b44422 | a3e5bf8496252cdd9a192019b3eca1e3d690cf95 | /core/src/main/java/eu/alehem/tempserver/remote/core/workers/DatabaseFunction.java | 3d030ad70613b45f1ce01129e92411c21ed48d96 | []
| no_license | ahemberg/tempserver_remote_java | 479e9f36ea6d2669430a36b59fa3faabb3a6f65b | 31bc294ce645b7bf13d203bb7551e7adced66ad9 | refs/heads/master | 2022-11-07T10:09:09.695943 | 2021-09-05T10:23:54 | 2021-09-05T10:23:54 | 195,647,840 | 0 | 0 | null | 2022-10-04T23:59:04 | 2019-07-07T12:21:51 | Java | UTF-8 | Java | false | false | 3,102 | java | package eu.alehem.tempserver.remote.core.workers;
import com.google.protobuf.InvalidProtocolBufferException;
import eu.alehem.tempserver.remote.core.DatabaseManager;
import eu.alehem.tempserver.schema.proto.Tempserver;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.extern.log4j.Log4j2;
/**
* Takes a set of temperatures to be sent and makes sure it has the correct size by adding or
* removing entries from/to local storage
*/
@Log4j2
public class DatabaseFunction
implements Function<Set<Tempserver.Measurement>, Set<Tempserver.Measurement>> {
// TODO read from properties on boot
private static final int MAX_QUEUE_LEN = 10;
@Override
public Set<Tempserver.Measurement> apply(final Set<Tempserver.Measurement> measurements) {
try {
DatabaseManager.createDataBaseIfNotExists();
} catch (SQLException e) {
log.warn("Failed to create database!", e);
}
if (measurements.size() < MAX_QUEUE_LEN) {
log.debug("Measurement size shorter than maximum allowed. Trying to backfill");
log.debug("Measurements length before backfill " + measurements.size());
log.debug("Getting " + (MAX_QUEUE_LEN - measurements.size()));
measurements.addAll(getAndRemove(MAX_QUEUE_LEN - measurements.size()));
log.debug("Measurements length after backfill " + measurements.size());
} else if (measurements.size() > MAX_QUEUE_LEN) {
log.debug("Measurement size longer than maximum allowed. Moving some to db");
log.debug("Moving " + (measurements.size() - MAX_QUEUE_LEN) + " measurements");
log.debug("Measurements length before empty " + measurements.size());
final Set<Tempserver.Measurement> toSave =
new HashSet<>(
new ArrayList<>(measurements).subList(0, measurements.size() - MAX_QUEUE_LEN));
log.debug("toSaveSize " + measurements.size());
try {
DatabaseManager.insertMeasurements(toSave);
measurements.removeAll(toSave);
} catch (SQLException e) {
log.warn("Failed to save temperatures", e);
}
log.debug("Measurements length after emptying " + measurements.size());
} else {
log.debug("Queue length is exactly max queue length");
}
return measurements;
}
private Set<Tempserver.Measurement> getAndRemove(final int numberToGet) {
try {
log.debug("Populating queue from db");
final Set<Tempserver.Measurement> measurements = DatabaseManager.getMeasurements(numberToGet);
DatabaseManager.deleteMeasurements(
measurements.stream().map(Tempserver.Measurement::getId).collect(Collectors.toSet()));
final int entriesInDb = DatabaseManager.countMeasurementsInDb();
log.debug("Successfully populated from db. DB now has " + entriesInDb + " entries");
return measurements;
} catch (SQLException | InvalidProtocolBufferException e) {
log.warn("Failed to get from database", e);
return new HashSet<>();
}
}
}
| [
"[email protected]"
]
| |
28f5d422aa89fdf604538278e668dfa4e6c125dc | ce4dfcb878c549403379fbfa84dcc4e865cd74f8 | /CS201/src/MinMaxAvg.java | cca0550a2ba4f7aec3b255f451305f54a63a2cbf | []
| no_license | jiadar/java | 3829639b60bb97db30fe964bf3374b65f35aee1b | fb49aa25f9c73a5c06252f6dd18e2ebe88b16c36 | refs/heads/master | 2020-04-05T23:32:02.468982 | 2016-11-30T01:29:27 | 2016-11-30T01:29:27 | 70,830,329 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 847 | java |
public class MinMaxAvg {
public static void main(String[] args) {
int numbers[][] = {
{ 63, 82, 92, 76, 98 },
{ 98, 70, 65, 89, 91 },
{ 84, 99, 85, 59, 55 },
{ 89, 92, 94, 90, 96 },
{ 56, 35, 26, 17, 61 }
};
int min=0, max=0;
double avg=0;
for(int i=0; i<numbers.length; i++) {
System.out.print("Row #" + i + ": ");
for(int j=0;j<numbers[i].length; j++) {
System.out.print(numbers[i][j] + " ");
}
System.out.println("min= " + min + " max = " + max + " avg = " + avg);
}
for(int i=0; i<numbers.length; i++) {
System.out.print("Col #" + i + ": ");
for(int j=0;j<numbers[i].length; j++) {
System.out.print(numbers[j][i] + " ");
}
System.out.println("min= " + min + " max = " + max + " avg = " + avg);
}
}
} | [
"[email protected]"
]
| |
5d36e34f3ad5cca5bcc757e619e3b8531fb19132 | bd74e5d1a2ae5ac56f10fd34872d60906af1373b | /sm_flow/src/main/java/com/sm/flow/manager/dto/ClientCartDto.java | 79cf1f12a6a976b6db77539b506fe0dd1114569e | []
| no_license | mikekucherov/DevHack | 47cf428279d23e14a9efa39d1a9d37fe5e539561 | 9eae130ed9da65ff5db29b0901112e98b995b5e6 | refs/heads/main | 2023-05-11T19:15:18.662935 | 2021-06-06T07:50:33 | 2021-06-06T07:50:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,032 | java | package com.sm.flow.manager.dto;
import com.sm.flow.manager.model.ClientRole;
import lombok.Data;
import lombok.ToString;
import java.util.HashMap;
/**
* Карточка клиента
*/
@Data
@ToString
public class ClientCartDto {
/**
* Идентификатор клиента
*/
Long clientId;
/**
* Имя
*/
String firstName;
/**
* Фамилия
*/
String lastName;
/**
* Отчество
*/
String middleName;
/**
* Почта
*/
String email;
/**
* Роль
*/
ClientRole role;
/**
* Конфиги
*/
HashMap<String, Boolean> config;
public ClientCartDto(String clientId, String firstName, String lastName, String middleName, String email, ClientRole role) {
this.clientId = Long.valueOf(clientId);
this.firstName = firstName;
this.lastName = lastName;
this.middleName = middleName;
this.email = email;
this.role = role;
}
}
| [
"[email protected]"
]
| |
fa72e72d97f507d9c1df6e7425bcbd00156fcd1c | 248e2dfe84deaf22767d5a37b91e837fe9aace0c | /ohtu-viikko2/Verkkokauppa1/src/main/java/ohtu/verkkokauppa/Kauppa.java | fdb579365c502ef7da2598bf3067108d1c009a8b | []
| no_license | joomoz/Ohtu_2017 | 9812e39679021e28e4cb5adcf998be8f9a3773e4 | 81dd227e2984e01f705c6cb502984407aa05dc8d | refs/heads/master | 2021-01-21T12:00:37.601997 | 2017-05-19T05:54:11 | 2017-05-19T05:54:11 | 91,770,305 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,258 | java | package ohtu.verkkokauppa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class Kauppa {
private VarastoInterface varasto;
private PankkiInterface pankki;
private Ostoskori ostoskori;
private ViitegeneraattoriInterface viitegeneraattori;
private String kaupanTili;
@Autowired
public Kauppa(VarastoInterface v, PankkiInterface p, ViitegeneraattoriInterface vg) {
varasto = v;
pankki = p;
viitegeneraattori = vg;
kaupanTili = "33333-44455";
}
public void aloitaAsiointi() {
ostoskori = new Ostoskori();
}
public void poistaKorista(int id) {
Tuote t = varasto.haeTuote(id);
varasto.palautaVarastoon(t);
}
public void lisaaKoriin(int id) {
if (varasto.saldo(id)>0) {
Tuote t = varasto.haeTuote(id);
ostoskori.lisaa(t);
varasto.otaVarastosta(t);
}
}
public boolean tilimaksu(String nimi, String tiliNumero) {
int viite = viitegeneraattori.uusi();
int summa = ostoskori.hinta();
return pankki.tilisiirto(nimi, viite, tiliNumero, kaupanTili, summa);
}
}
| [
"[email protected]"
]
| |
c3ff2716e6d331eb0e921dd90070654b313ca109 | 0581eb85bfc26c12b155c8d7a06c5836fc30b410 | /modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/RevisionsTest.java | 5678653e37b3531d067180cb91e8dea92659d531 | [
"Apache-2.0"
]
| permissive | mojito317/cloudant-java-sdk | 8399c0f64022aac6bcdeec1b6e1792d4eecec4ae | 2acccec6b95592050b643aef55557f40f2d4d185 | refs/heads/master | 2022-12-24T02:59:42.425017 | 2020-09-03T13:19:03 | 2020-09-03T13:19:03 | 292,261,576 | 0 | 0 | Apache-2.0 | 2020-09-02T11:16:22 | 2020-09-02T11:16:21 | null | UTF-8 | Java | false | false | 1,962 | java | /*
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.ibm.cloud.cloudant.v1.model;
import com.ibm.cloud.cloudant.v1.model.Revisions;
import com.ibm.cloud.cloudant.v1.utils.TestUtilities;
import com.ibm.cloud.sdk.core.service.model.FileWithMetadata;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
/**
* Unit test class for the Revisions model.
*/
public class RevisionsTest {
final HashMap<String, InputStream> mockStreamMap = TestUtilities.createMockStreamMap();
final List<FileWithMetadata> mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata();
@Test
public void testRevisions() throws Throwable {
Revisions revisionsModel = new Revisions.Builder()
.ids(new java.util.ArrayList<String>(java.util.Arrays.asList("testString")))
.start(Long.valueOf("1"))
.build();
assertEquals(revisionsModel.ids(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
assertEquals(revisionsModel.start(), Long.valueOf("1"));
String json = TestUtilities.serialize(revisionsModel);
Revisions revisionsModelNew = TestUtilities.deserialize(json, Revisions.class);
assertTrue(revisionsModelNew instanceof Revisions);
assertEquals(revisionsModelNew.start(), Long.valueOf("1"));
}
} | [
"[email protected]"
]
| |
b77318d81adf0c13dcaa914aca04772ec4afb583 | 4d4123dd737ebf0b2b8f7abb4a467eb92b247de7 | /Nihar_Cls/FOR_LOOP_2/SERIES/FOR_3.java | 9b70e7c52b2c4e3e2f6922b3ed7f893ccd3614c3 | []
| no_license | iamNihar07/SmallJavaSnippets | d101fe3425b9e0ca2520636874dc395cc1d98850 | 346f36d10c1be4c579798404a1301d37976a9dcf | refs/heads/master | 2020-12-19T23:30:17.376924 | 2020-01-23T20:58:14 | 2020-01-23T20:58:14 | 235,883,676 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 193 | java |
package FOR_LOOP_2.SERIES;
public class FOR_3
{
void main(int a, int b)
{
int i;
for(i=a;i<=b;i++)
{
System.out.println(i);
}
}
} | [
"[email protected]"
]
| |
48a89da2bd38ded37472922519ca2210a45a7cf9 | 4691acca4e62da71a857385cffce2b6b4aef3bb3 | /spring-boot-modules/spring-boot-mvc-3/src/main/java/com/baeldung/springvalidation/SpringValidationApplication.java | ccfe990ce77518560cf825a39f27fba985ec0953 | [
"MIT"
]
| permissive | lor6/tutorials | 800f2e48d7968c047407bbd8a61b47be7ec352f2 | e993db2c23d559d503b8bf8bc27aab0847224593 | refs/heads/master | 2023-05-29T06:17:47.980938 | 2023-05-19T08:37:45 | 2023-05-19T08:37:45 | 145,218,314 | 7 | 11 | MIT | 2018-08-18T12:29:20 | 2018-08-18T12:29:19 | null | UTF-8 | Java | false | false | 354 | java | package com.baeldung.springvalidation;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringValidationApplication {
public static void main(String[] args) {
SpringApplication.run(SpringValidationApplication.class, args);
}
}
| [
"[email protected]"
]
| |
26beaa236f8e14927376b74c6667835f68a4810c | 162f3254ef08fb450d072abe2ce490ef8644223c | /src/com/javaee/examples/java_immutable_class/FinalClassExample.java | 0e30a1af7374f0b0d766b8c500ab751203e4c4c8 | []
| no_license | krishnabhat81/java-ee | 20e784283db683e80e86a8b6fa01eb06ed97ea91 | 112b18fcdb9f25353dd02629d6852e932125901b | refs/heads/master | 2021-01-20T10:05:49.325815 | 2017-09-10T22:46:26 | 2017-09-10T22:46:26 | 90,320,564 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,049 | java | package com.javaee.examples.java_immutable_class;
import java.util.HashMap;
import java.util.Iterator;
/**
* Created by krishna1bhat on 5/4/17.
*/
/*
* Immutable class is good for caching purpose and
* Inherently thread-safe
*/
/*
*1. Make the class as final so it can’t be extended. (or Make constructor private, public factory method)
*2. Make all fields final and private.
*3. Don’t provide setter methods for variables.
*4. Initialize all the fields via a constructor performing deep copy (Not Shallow Copy).
*5. Perform cloning of objects in the getter methods to return a copy rather than returning the actual object reference (mutable objects).
*/
//Immutable class example -- POJO
public final class FinalClassExample {
private final int id;
private final String name;
private final HashMap<String, String> testMap;
public int getId() {
return id;
}
public String getName() {
return name;
}
//Accessor function for mutable objects
public HashMap<String, String> getTestMap() {
//return testMap; //do not return reference, return a copy
return (HashMap<String, String>) testMap.clone();
}
//public setter method----
public FinalClassExample setName(String name){
return new FinalClassExample(this.id, name, this.getTestMap());
}
//Constructor with Deep Copy
public FinalClassExample(int id, String name, HashMap<String, String> testMap){
this.id = id;
this.name = name;
HashMap<String, String> tmpMap = new HashMap<>();
String key;
Iterator<String> iterator = testMap.keySet().iterator();
while(iterator.hasNext()){
key = iterator.next();
tmpMap.put(key, testMap.get(key));
}
this.testMap = tmpMap;
}
//Constructor with shallow copy -- test this
// public FinalClassExample(int id, String name, HashMap<String, String> testMap){
// this.id = id;
// this.name = name;
// this.testMap = testMap;
// }
}
| [
"[email protected]"
]
| |
834db72b8b31dfeea0e9a3f7d16299ef94cba96b | d3a5cd6a10aa14e68a011c3e957f639c729ed015 | /app/src/main/java/com/example/choco_music/fragments/LikeList_Fragment.java | 4669c77c466df4d40f1e07aee0c37e11421d1d98 | []
| no_license | pwnzzi/Choco_Music | f716224f1ac7d5cd9f4a9b120dfa4c4cc24a1b28 | 7f627ed73649e62256d52497da1a629b13ecb86c | refs/heads/master | 2020-11-27T21:20:17.095731 | 2020-03-01T08:01:29 | 2020-03-01T08:01:29 | 229,604,420 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,787 | java | package com.example.choco_music.fragments;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.choco_music.Audio.AudioApplication;
import com.example.choco_music.R;
import com.example.choco_music.adapters.Playlist_Apdapter;
import com.example.choco_music.model.ChartData;
import com.example.choco_music.model.Playlist_Database_OpenHelper;
import com.example.choco_music.model.RecyclerItemClickListener;
import java.util.ArrayList;
public class LikeList_Fragment extends androidx.fragment.app.Fragment {
private RecyclerView Play_list_View;
private ArrayList<ChartData> chartData;
Playlist_Database_OpenHelper openHelper;
private Playlist_Apdapter playlist_apdapter;
private LinearLayoutManager layoutManager;
private Button back_btn;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.likelist_fragment, container, false);
back_btn = view.findViewById(R.id.back_likelist_fragment);
back_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getFragmentManager().beginTransaction().setCustomAnimations(R.anim.anim_slide_in_left,R.anim.anim_slide_out_right).replace(R.id.user_fragment_layout,new UserList_Fragment()).commit();
}
});
init_recyclerview(view);
return view;
}
public void init_recyclerview(View view) {
Play_list_View = view.findViewById(R.id.play_list);
layoutManager = new LinearLayoutManager(getContext());
openHelper = new Playlist_Database_OpenHelper(getActivity());
chartData = openHelper.get_Music_chart();
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
Play_list_View.setLayoutManager(layoutManager);
playlist_apdapter = new Playlist_Apdapter();
playlist_apdapter.setData(chartData);
Play_list_View.setAdapter(playlist_apdapter);
Play_list_View.addOnItemTouchListener(new RecyclerItemClickListener(getContext(), Play_list_View,
new RecyclerItemClickListener.OnItemClickListener() {
@Override public void onItemClick(View view, int position) {
AudioApplication.getInstance().getServiceInterface().setPlayList(chartData);
AudioApplication.getInstance().getServiceInterface().play(position);
}
@Override public void onLongItemClick(final View view, final int position) {
AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
final AlertDialog alertDialog ;
builder.setTitle("좋아요를 취소 하시겠습니까?");
builder.setPositiveButton("삭제", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast myToast = Toast.makeText(view.getContext(),"좋아요를 취소하였습니다.",Toast.LENGTH_SHORT);
myToast.setGravity(Gravity.CENTER,0,0);
myToast.show();
Playlist_Database_OpenHelper playlist_database_openHelper = new Playlist_Database_OpenHelper(view.getContext());
chartData = playlist_database_openHelper.get_Music_chart();
playlist_database_openHelper.deleteData(chartData.get(position).getTitle());
refresh();
}
});
builder.setNegativeButton("취소", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog = builder.create();
alertDialog.show();
}
})
);
}
private void refresh(){
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.detach(this).attach(this).commit();
}
}
| [
"[email protected]"
]
| |
96678af056188de742a42802017aaf9943f20c4b | 716b175c89d619242f88be65f07701050a1f17d2 | /All Blue/src/com/MyAllBlue/Service/Impl/AdminServiceImpl.java | 645e0c3ed26fbffa41d039da5b7c338dee3ea784 | []
| no_license | wqp2018/Demo | 1f59d73b05c8f17818354e865cc5dbf3ebabfaed | cd080de7535401a77b5543946521f48bae35f02e | refs/heads/master | 2020-03-26T22:54:19.650567 | 2018-08-22T11:38:46 | 2018-08-22T11:38:46 | 145,495,405 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,180 | java | package com.MyAllBlue.Service.Impl;
import com.MyAllBlue.Dao.AdminDao;
import com.MyAllBlue.Model.*;
import com.MyAllBlue.Page.PageBean;
import com.MyAllBlue.Service.AdminService;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Transactional
public class AdminServiceImpl implements AdminService {
private AdminDao adminDao;
public void setAdminDao(AdminDao adminDao) {
this.adminDao = adminDao;
}
@Override
public AdminInfo loginCheck(String username, String password) {
AdminInfo admin = adminDao.loginCheck(username,password);
return admin;
}
@Override
public List<Category> getTypeList() {
List<Category> lists = adminDao.getTypeList();
return lists;
}
@Override
public List<Commod> commodMessage() {
List<Commod> list = adminDao.commodMessage();
return list;
}
@Override
public int commodCount(int commodType) {
int count = adminDao.commodCount(commodType);
return count;
}
@Override
public PageBean<Commod> findByType(int currentPage, int commodType) {
PageBean<Commod> pageBean = new PageBean<Commod>();
//设置当前页数
pageBean.setCurrentPage(currentPage);
//设置每页最大数
int maxSize = 3;
pageBean.setMaxSize(maxSize);
//设置获取到的货物列表
List<Commod> list = adminDao.findByType(currentPage,maxSize,commodType);
pageBean.setList(list);
//设置货物总数量
int totalSize = commodCount(commodType);
pageBean.setTotalSize(totalSize);
//设置最大页数
Double totalPageSize = Math.ceil((double) totalSize/maxSize);
pageBean.setTotalPage(totalPageSize.intValue());
return pageBean;
}
@Override
public PageBean<Commod> searchByCommodName(int currentPage,String commodName) {
PageBean<Commod> pageBean = new PageBean<Commod>();
//设置当前页数
pageBean.setCurrentPage(currentPage);
//设置每页最大值
int maxSize = 3;
pageBean.setMaxSize(maxSize);
//获取货物总数量
int totalSize = adminDao.countOfSearchName(commodName);
pageBean.setTotalSize(totalSize);
//设置总页数
Double totalPageSize = Math.ceil((double) totalSize/maxSize);
pageBean.setTotalPage(totalPageSize.intValue());
//查询到的结果列表
List<Commod> list = adminDao.searchByCommodName(currentPage,maxSize,commodName);
pageBean.setList(list);
return pageBean;
}
@Override
public void deleteCommod(int commodId) {
adminDao.deleteCommod(commodId);
}
@Override
public Commod getCommodById(int commodId) {
Commod commod = adminDao.getCommodById(commodId);
return commod;
}
@Override
public void updateCommod(int id, String updateName, int updatePrice, int updateHascount,String image) {
adminDao.updateCommod(id,updateName,updatePrice,updateHascount,image);
}
@Override
public PageBean<UserInfo> searchUserInfo(int currentPage) {
PageBean<UserInfo> pageBean = new PageBean<UserInfo>();
pageBean.setCurrentPage(currentPage);
//设置每页最大数
int maxSize = 3;
pageBean.setMaxSize(maxSize);
//获取用户总数量
int totalSize = adminDao.countOfUser();
pageBean.setTotalSize(totalSize);
//设置总页数
Double totalPageSize = Math.ceil((double) totalSize/maxSize);
pageBean.setTotalPage(totalPageSize.intValue());
//查询到的用户结果集
List<UserInfo> list = adminDao.getUserInfoList(currentPage,maxSize);
pageBean.setList(list);
return pageBean;
}
@Override
public void banUser(int userId) {
adminDao.banUser(userId);
}
@Override
public void openUser(int userId) {
adminDao.openUser(userId);
}
@Override
public PageBean<UserInfo> searchByUserName(int currentPage, String user) {
PageBean<UserInfo> pageBean = new PageBean<UserInfo>();
//设置当前页数
pageBean.setCurrentPage(currentPage);
//设置每页最大值
int maxSize = 3;
pageBean.setMaxSize(maxSize);
//获取按用户名查询到的总数量
int totalSize = adminDao.countOfSearchUserName(user);
pageBean.setTotalSize(totalSize);
//设置总页数
Double totalPageSize = Math.ceil((double) totalSize/maxSize);
pageBean.setTotalPage(totalPageSize.intValue());
//查询到的结果列表
List<UserInfo> list = adminDao.searchByUserName(currentPage,maxSize,user);
pageBean.setList(list);
return pageBean;
}
@Override
public PageBean<Orders_commods> getAllOrder(int currentPage) {
PageBean<Orders_commods> pageBean = new PageBean<Orders_commods>();
//设置当前页
pageBean.setCurrentPage(currentPage);
//设置每页最大值
int maxSize = 5;
//查询到的订单总数量
int totalSize = adminDao.getCountOfOrder();
pageBean.setTotalSize(totalSize);
//设置总页数
Double totalPageSize = Math.ceil((double) totalSize/maxSize);
pageBean.setTotalPage(totalPageSize.intValue());
//查询到的结果列表
List<Orders_commods> list = adminDao.getAllOrder(currentPage,maxSize);
pageBean.setList(list);
return pageBean;
}
@Override
public PageBean<Orders_commods> noDoOrder(int currentPage) {
PageBean<Orders_commods> pageBean = new PageBean<Orders_commods>();
//设置当前页
pageBean.setCurrentPage(currentPage);
//设置每页最大值
int maxSize = 5;
//查询到的订单总数量
int totalSize = adminDao.getCountOfNoDoOrder();
pageBean.setTotalSize(totalSize);
//设置总页数
Double totalPageSize = Math.ceil((double) totalSize/maxSize);
pageBean.setTotalPage(totalPageSize.intValue());
//查询到的结果列表
List<Orders_commods> list = adminDao.getNoDoOrder(currentPage,maxSize);
pageBean.setList(list);
return pageBean;
}
@Override
public Orders_commods getOrderById(Integer orderId) {
return adminDao.searchOrderById(orderId);
}
@Override
public void beginSend(Integer orderId) {
adminDao.beginSend(orderId);
}
@Override
public void endOrderById(Integer orderId) {
adminDao.endOrderById(orderId);
}
@Override
public List<Category> getAllType() {
return adminDao.getAllType();
}
@Override
public void addCommodMessage(String commodName, String image, int price, int hascount, Integer commodTypeId) {
adminDao.addCommodMessage(commodName,image,price,hascount,commodTypeId);
}
@Override
public void addCommodType(String commodTypeName) {
adminDao.addCommodType(commodTypeName);
}
}
| [
"[email protected]"
]
| |
2171068dc360281c261761baf2f821c97d7d733f | f567413ca65990c8e376723b6faf85f2a9e9939d | /src/main/java/com/zzia/wngn/design/prototype/PrototypeManager.java | e27d85ac904d318eaa8e79dfc41476b9b5d63908 | []
| no_license | wngn123/wngn-test | c7c6daa33535f98aaf6acdad0ead2a92472eb882 | ad4b639b14537464054585aa64dd50883d539412 | refs/heads/master | 2016-09-14T12:45:59.401186 | 2016-06-02T15:22:40 | 2016-06-02T15:22:40 | 59,181,575 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 329 | java | package com.zzia.wngn.design.prototype;
/**
* @author wanggang
* @title
* @date 2016/6/2 9:27
* @email [email protected]
* @descripe
*/
public class PrototypeManager {
public static Prototype prototype = new ConcretePrototype();
public static Prototype getPrototype() {
return prototype.clone();
}
}
| [
"[email protected]"
]
| |
8f2c90536e7ed7445b4e5b17bf935c0c3d59494c | 2e036f17f80e31d7f9b13732ea6ec2a492bbd2d4 | /Chapter1ArrayString/question1_19/Question.java | 5b120830e7ff1e3b845bdcaf0c9cc2907ea82644 | []
| no_license | AkiraKane/Interview-3 | 8b43238347696d5c19ba3c7fc5c104a250297997 | 081a8c51aa992f0aa35854f83e2f6cb6c7b32e57 | refs/heads/master | 2020-04-01T16:58:09.725250 | 2015-05-11T05:57:06 | 2015-05-11T05:57:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,158 | java | /**
1.19 3SUM closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
For example, given array S = {-1 2 1 -4}, and target = 1.
The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
(leetcode16)
(leetcodecpp2.1.9)
*/
package question1_19;
import java.util.Arrays;
public class Question {
public static int threeSumClosest(int[] array, int sum) {
// sort the array
Arrays.sort(array);
int closestThreeSum = Integer.MAX_VALUE;
for(int i=0; i< array.length-2; i++){
int newClosestThreeSum = array[i] + twoSumClosest(array, i+1, sum-array[i]);
if(newClosestThreeSum==sum){
return newClosestThreeSum;
} else {
if(Math.abs(newClosestThreeSum-sum) < Math.abs(closestThreeSum-sum)){
closestThreeSum=newClosestThreeSum;
}
}
}
return closestThreeSum;
}
public static int twoSumClosest(int[] array, int left, int sum){
int right = array.length-1;
int closestSum = array[left]+array[right];
while(left<right){
int s = array[left]+array[right];
if(s==sum){
return sum;
} else if(s<sum) {
if(closestSum>sum){
return (Math.abs(s-sum)<=Math.abs(closestSum-sum)) ? s : closestSum;
} else {
closestSum = s;
}
left++;
} else {
if(closestSum<sum){
return (Math.abs(s-sum)<=Math.abs(closestSum-sum)) ? s : closestSum;
} else {
closestSum = s;
}
right--;
}
}
return closestSum;
}
public static void main(String[] args) {
int[] S = {-1, 0, 1, 2, -1, -4};
System.out.println("closest three sum is: " + threeSumClosest(S, 1));
}
}
| [
"[email protected]"
]
| |
59b18cee1932dc4bd40cb5b130b990755fb12c46 | 104b421e536d1667a70f234ec61864f9278137c4 | /code/org/apache/james/mime4j/field/address/parser/AddressListParserVisitor.java | 37f42e5914ed7f76a52c688df9b1453dafd2e2f6 | []
| no_license | AshwiniVijayaKumar/Chrome-Cars | f2e61347c7416d37dae228dfeaa58c3845c66090 | 6a5e824ad5889f0e29d1aa31f7a35b1f6894f089 | refs/heads/master | 2021-01-15T11:07:57.050989 | 2016-05-13T05:01:09 | 2016-05-13T05:01:09 | 58,521,050 | 1 | 0 | null | 2016-05-11T06:51:56 | 2016-05-11T06:51:56 | null | UTF-8 | Java | false | false | 1,366 | java | package org.apache.james.mime4j.field.address.parser;
public abstract interface AddressListParserVisitor
{
public abstract Object visit(ASTaddr_spec paramASTaddr_spec, Object paramObject);
public abstract Object visit(ASTaddress paramASTaddress, Object paramObject);
public abstract Object visit(ASTaddress_list paramASTaddress_list, Object paramObject);
public abstract Object visit(ASTangle_addr paramASTangle_addr, Object paramObject);
public abstract Object visit(ASTdomain paramASTdomain, Object paramObject);
public abstract Object visit(ASTgroup_body paramASTgroup_body, Object paramObject);
public abstract Object visit(ASTlocal_part paramASTlocal_part, Object paramObject);
public abstract Object visit(ASTmailbox paramASTmailbox, Object paramObject);
public abstract Object visit(ASTname_addr paramASTname_addr, Object paramObject);
public abstract Object visit(ASTphrase paramASTphrase, Object paramObject);
public abstract Object visit(ASTroute paramASTroute, Object paramObject);
public abstract Object visit(SimpleNode paramSimpleNode, Object paramObject);
}
/* Location: C:\Users\ADMIN\Desktop\foss\dex2jar-2.0\classes-dex2jar.jar!\org\apache\james\mime4j\field\address\parser\AddressListParserVisitor.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | [
"ASH ABHI"
]
| ASH ABHI |
dfa249fc9bed5952f6a1be91d31e8f0f671bea8c | f31bd4fec0a3d01c75716043e71294c79c94b0d5 | /de.vogella.android.animation/src/de/vogella/android/animation/AnimationExampleActivity.java | baebbe65dbfd19d079d1d75cdfdbd10092ee321e | []
| no_license | luiz158/vogella | bafa6f5babadcd3c13776f4371d5a4dad55a99d6 | 91b77ac0939655eb643e0dad386d586f1bc04377 | refs/heads/master | 2021-01-16T18:05:00.632838 | 2012-10-30T23:34:42 | 2012-10-30T23:34:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,024 | java | package de.vogella.android.animation;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
public class AnimationExampleActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void startAnimation(View view) {
float dest = 0;
ImageView aniView = (ImageView) findViewById(R.id.imageView1);
switch (view.getId()) {
case R.id.Button01:
dest = 360;
if (aniView.getRotation() == 360) {
dest = 0;
}
// ObjectAnimator animation1 = ObjectAnimator.ofFloat(aniView,
// "rotation", dest);
// animation1.setDuration(2000);
// animation1.start();
aniView.animate().rotation(dest).setDuration(1000);
// Show how to load an animation from XML
// Animation animation1 = AnimationUtils.loadAnimation(this,
// R.anim.myanimation);
// animation1.setAnimationListener(this);
// animatedView1.startAnimation(animation1);
break;
case R.id.Button02:
// Shows how to define a animation via code
// Also use an Interpolator (BounceInterpolator)
Paint paint = new Paint();
TextView aniTextView = (TextView) findViewById(R.id.textView1);
float measureTextCenter = paint.measureText(aniTextView.getText()
.toString());
dest = 0 - measureTextCenter;
if (aniTextView.getX() < 0) {
dest = 0;
}
ObjectAnimator animation2 = ObjectAnimator.ofFloat(aniTextView,
"x", dest);
animation2.setDuration(2000);
animation2.start();
break;
case R.id.Button03:
// Demonstrate fading and adding an AnimationListener
dest = 1;
if (aniView.getAlpha() > 0) {
dest = 0;
}
ObjectAnimator animation3 = ObjectAnimator.ofFloat(aniView,
"alpha", dest);
animation3.setDuration(2000);
animation3.start();
break;
case R.id.Button04:
ObjectAnimator fadeOut = ObjectAnimator.ofFloat(aniView, "alpha",
0f);
fadeOut.setDuration(2000);
ObjectAnimator mover = ObjectAnimator.ofFloat(aniView,
"translationX", -500f, 0f);
mover.setDuration(2000);
ObjectAnimator fadeIn = ObjectAnimator.ofFloat(aniView, "alpha",
0f, 1f);
fadeIn.setDuration(2000);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(mover).with(fadeIn).after(fadeOut);
animatorSet.start();
break;
default:
break;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.mymenu, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent = new Intent(this, HitActivity.class);
startActivity(intent);
return true;
}
} | [
"[email protected]"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.