blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 410 | content_id stringlengths 40 40 | detected_licenses listlengths 0 51 | license_type stringclasses 2 values | repo_name stringlengths 5 132 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 80 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 131 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 3 9.45M | extension stringclasses 32 values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 313 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ae6fa4a2137415b23b2080d9db44e09ac0ab8755 | 2c157b25446c1858e2bb384f24bc9dd15455746a | /android/slideshare/SlideShare/src/main/java/com/hyperfine/slideshare/MainActivity.java | 52a459190cb57415ee5459a752570c79b2838cc9 | [] | no_license | robbear/hfgame | c00268e6c78ca8efe637983e721c31a0ffe312be | 6d43255c03042bf78e703879047f9e1461d442b4 | refs/heads/master | 2020-04-11T09:12:24.912377 | 2013-10-26T23:49:48 | 2013-10-26T23:49:48 | 8,708,253 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,398 | java | package com.hyperfine.slideshare;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import java.util.UUID;
import static com.hyperfine.slideshare.Config.D;
import static com.hyperfine.slideshare.Config.E;
public class MainActivity extends Activity {
public final static String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
if(D)Log.d(TAG, "MainActivity.onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SharedPreferences prefs = getSharedPreferences(SSPreferences.PREFS, Context.MODE_PRIVATE);
String userUuidString = prefs.getString(SSPreferences.PREFS_USERUUID, null);
if (userUuidString == null) {
UUID uuid = UUID.randomUUID();
if(D)Log.d(TAG, String.format("MainActivity.onCreate - generated USERUUID=%s and setting PREFS_USERUUID", uuid.toString()));
SharedPreferences.Editor editor = prefs.edit();
editor.putString(SSPreferences.PREFS_USERUUID, uuid.toString());
editor.commit();
}
else {
if(D)Log.d(TAG, String.format("MainActivity.onCreate - USERUUID=%s", userUuidString));
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if(D)Log.d(TAG, "MainActivity.onCreateOptionsMenu");
super.onCreateOptionsMenu(menu);
// BUGBUG
MenuItem csa = menu.add("Create slides");
csa.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Intent intent = new Intent(MainActivity.this, CreateSlidesActivity.class);
MainActivity.this.startActivity(intent);
return true;
}
});
// BUGBUG
MenuItem psa = menu.add("Play slides");
psa.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Intent intent = new Intent(MainActivity.this, PlaySlidesActivity.class);
MainActivity.this.startActivity(intent);
return true;
}
});
// BUGBUG - test menu item
MenuItem trp = menu.add("TestRecordPlay");
trp.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Intent intent = new Intent(MainActivity.this, TestRecordPlayActivity.class);
MainActivity.this.startActivity(intent);
return true;
}
});
// BUGBUG - test menu item
MenuItem tip = menu.add("TestImagePicker");
tip.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Intent intent = new Intent(MainActivity.this, TestImagePickerActivity.class);
MainActivity.this.startActivity(intent);
return true;
}
});
return true;
}
}
| [
"robbear@hyperfine.com"
] | robbear@hyperfine.com |
5bef3f946ee7cebeb369dcd477db1199272fda66 | 08dd8cb229682837850b9ce70bbd15a40b81d881 | /javaSourceFiles/HadoopQ2/src/hadoopq2/HadoopJobControl.java | 94c39f672b9f2ba0030a04958071849a92357817 | [
"MIT"
] | permissive | shyammk/MapReduceFundamentals | 39dcb5f92c156aaa3568a539a6b5264d7ad5190a | cfa756d03770e140a0115a89140fe11288697c1d | refs/heads/master | 2020-03-22T18:55:16.249018 | 2018-07-10T22:43:11 | 2018-07-10T22:43:11 | 140,491,587 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,550 | java | package hadoopq2;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Counters;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
public class HadoopJobControl {
//Counters for the use case in Hadoop Q2
public static enum WORDCOUNT_COUNTER {
KEY_WORDS_UNIQUE_TO_A_FILE,
};
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
Job job = Job.getInstance(conf, "COMP47470-Hadoop Q2");
job.setJarByClass(HadoopJobControl.class);
job.setMapperClass(HadoopMapper.class);
// job.setCombinerClass(HadoopReducer.class);
job.setReducerClass(HadoopReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
boolean flag = job.waitForCompletion(true);
Counters jobCounters = job.getCounters();
Counter counter = jobCounters.findCounter(
WORDCOUNT_COUNTER.KEY_WORDS_UNIQUE_TO_A_FILE);
System.out.println("No. of Words Unique to a specific File: " +
counter.getValue());
if (flag == true) {
System.exit(0);
}
}
}
| [
"shyam.kizhakekara@ucdconnect.ie"
] | shyam.kizhakekara@ucdconnect.ie |
c8da782e6e12c61fbb5fb324bde4278c34f91f6c | ff5e8a90821f3ec0d3ebc8c1163364e57b6c94b4 | /demo/src/com/example/demo/MainActivity.java | 1b50027d0a773757e878616b98779ed80d7268d0 | [] | no_license | MagLoir/MSP430-Android | 4cab4915c4bff01d91127a8349f69d07e69338cc | 87a13060e014c94a6412864ac42a107ed5f787fb | refs/heads/master | 2021-05-10T14:26:33.616846 | 2015-08-19T11:09:13 | 2015-08-19T11:09:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,111 | java | package com.example.demo;
import lib.BluetoothDisabled;
import lib.Board;
import lib.NoBluetoothSupported;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class MainActivity extends TabActivity {
public Board board;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
board = new Board("20:13:01:24:01:46");
} catch (BluetoothDisabled e) {
this.finish();
} catch (NoBluetoothSupported e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
addTabSpec("led", "LED", R.drawable.ic_launcher,LedButton.class);
addTabSpec("pwm", "PWM", R.drawable.ic_launcher,Pwm.class);
addTabSpec("buttons", "BUT", R.drawable.ic_launcher,Buttons.class);
addTabSpec("pot", "ADC", R.drawable.ic_launcher,Pot.class);
addTabSpec("srl", "SRL", R.drawable.ic_launcher,Srl.class);
addTabSpec("off", "OFF", R.drawable.ic_launcher,Offline.class);
addTabSpec("i2c", "I2C", R.drawable.ic_launcher,I2c.class);
addTabSpec("spi", "SPI", R.drawable.ic_launcher,Spi.class);
addTabSpec("lcd", "LCD", R.drawable.ic_launcher,Lcd.class);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
private void addTabSpec(String tag, String labelId, int iconId, Class<? extends Activity> activityClass){
Drawable icon = getResources().getDrawable(iconId);
Intent intent = new Intent().setClass(this, activityClass);
intent.putExtra("board", board);
TabHost tabHost = getTabHost();
TabSpec tabSpec = tabHost //
.newTabSpec(tag) //
.setIndicator(labelId, icon) //
.setContent(intent);
tabHost.addTab(tabSpec);
}
public void onDestroy() {
board.destroy();
super.onDestroy();
}
}
| [
"read.the.disclaimer@gmail.com"
] | read.the.disclaimer@gmail.com |
5d6f8bbeb6c01d958196fb1b5e8925a835e36a8a | e34d31ab7a01728416ae78d1d5d1c02876443540 | /src/day9/observerpattern/ObserverPatternDemo.java | f2e4a58c6ea8b030bc15207bb16945db403033f3 | [] | no_license | kademika/jd-oct14-ivan.sadovsky | 2e03e2fe5f806f6b3837199001d6b43e12d66f0d | 13deaeb93309ac9fb4a31d8bdc832db82ae6773d | refs/heads/master | 2021-01-01T06:44:56.492700 | 2015-03-23T17:49:06 | 2015-03-23T17:49:06 | 26,881,039 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 558 | java | package day9.observerpattern;
public class ObserverPatternDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println();
ConcreteSubject cs = new ConcreteSubject();
Observer o1 = new ConcreteObserver();
Observer o2 = new ConcreteObserver();
cs.addObserver(o1);
cs.addObserver(o2);
for (int i = 0; i < 10; i ++) {
cs.doTheJob();
System.out.println();
}
cs.removeObserver(o2);
for (int i = 0; i < 10; i++) {
cs.doTheJob();
}
}
}
| [
"I@Ivan"
] | I@Ivan |
a0eb2f4ae5dcaf6078608b19214803aadba4a918 | 309e58d8b7eb916dc8206ca315d2d1e413a522dc | /src/main/java/com/souza/controller/PedidoItensController.java | 2a0d52bc17f71eeffffb89b284ac44414436e615 | [
"Apache-2.0"
] | permissive | nicolasMoreira144/CasdastroProdutos | cf4f7942604c9279782aa481e268db21c50f929e | 112da2086735c8e5861e9111e97647d94b3c8ee5 | refs/heads/master | 2021-04-17T01:06:04.327602 | 2020-03-23T10:34:03 | 2020-03-23T10:34:03 | 249,398,933 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,722 | java | package com.souza.controller;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.souza.dtos.PedidoItensDto;
import com.souza.entities.Pedido;
import com.souza.entities.PedidoItens;
import com.souza.entities.Produto;
import com.souza.response.Response;
import com.souza.service.PedidoItensService;
import com.souza.service.PedidoService;
import com.souza.service.ProdutoService;
@Controller
@CrossOrigin
@RequestMapping("/pedidoItens")
public class PedidoItensController {
private static final Logger log = LoggerFactory.getLogger(PedidoItensController.class);
@Autowired
private PedidoItensService pedidoItensService;
@Autowired
private PedidoService pedidoService;
@Autowired
private ProdutoService produtoService;
@PostMapping("/inserir")
public ResponseEntity<Response<PedidoItensDto>> cadastrar(@Valid @RequestBody PedidoItensDto pedidoItensDto,
BindingResult result) throws NoSuchAlgorithmException {
log.info("Cadastrando itens do pedido: {}", pedidoItensDto.toString());
Response<PedidoItensDto> response = new Response<PedidoItensDto>();
Optional<Pedido> pedidoOpt = this.pedidoService.buscarPorId(pedidoItensDto.getId_pedido());
Optional<Produto> produtoOpt = this.produtoService.buscarPorId(pedidoItensDto.getId_produto());
if (!pedidoOpt.isPresent())
result.addError(new ObjectError("PedidoItens", "pedido não existe."));
if (!produtoOpt.isPresent())
result.addError(new ObjectError("PedidoItens", "produto não existe."));
if (result.hasErrors()) {
log.error("Erro validando dados itens do produto : {}", result.getAllErrors());
result.getAllErrors().forEach(error -> response.getErrors().add(error.getDefaultMessage()));
return ResponseEntity.badRequest().body(response);
}
Pedido pedido = pedidoOpt.get();
Produto produto = produtoOpt.get();
PedidoItens pedidoItens = this.converterDtoParaPedidoItens(pedidoItensDto, pedido, produto);
this.pedidoItensService.salvar(pedidoItens);
response.setData(pedidoItensDto);
return ResponseEntity.ok(response);
}
@GetMapping("/buscar/{id}")
public ResponseEntity<Response<PedidoItensDto>> buscar(@PathVariable("id") Long id) {
log.info("Buscando itens do pedido: {}", id);
Response<PedidoItensDto> response = new Response<PedidoItensDto>();
Optional<PedidoItens> pedidoItensOpt = this.pedidoItensService.buscarPorId(id);
if (!pedidoItensOpt.isPresent()) {
log.info("Erro ao buscar devido pedido itens ID: {} ser inválido.", id);
response.getErrors().add("Erro ao remover pedido itens. pedido itens não encontrado com o id " + id);
return ResponseEntity.badRequest().body(response);
}
PedidoItens pedidoItensPesquisado = pedidoItensOpt.get();
PedidoItensDto pedidoItensDto = this.pedidoItensDto(pedidoItensPesquisado);
response.setData(pedidoItensDto);
return ResponseEntity.ok(response);
}
@PutMapping("/editar/{id}")
public ResponseEntity<Response<PedidoItensDto>> editar(@PathVariable("id") Long id, @Valid @RequestBody PedidoItensDto pedidoItensDto, BindingResult result) {
log.info("Editando itens do pedido por id: {}", id);
Response<PedidoItensDto> response = new Response<PedidoItensDto>();
Optional<PedidoItens> pedidoItensOpt = this.pedidoItensService.buscarPorId(id);
Optional<Pedido> pedidoOpt = this.pedidoService.buscarPorId(pedidoItensDto.getId_pedido());
Optional<Produto> produtoOpt = this.produtoService.buscarPorId(pedidoItensDto.getId_produto());
if (!pedidoItensOpt.isPresent()) {
result.addError(new ObjectError("PedidoItens", "pedido itens não existe."));
}
if (!pedidoOpt.isPresent())
result.addError(new ObjectError("PedidoItens", "pedido não existe."));
if (!produtoOpt.isPresent())
result.addError(new ObjectError("PedidoItens", "produto não existe."));
if (result.hasErrors()) {
log.error("Erro validando itens do pedido : {}", result.getAllErrors());
result.getAllErrors().forEach(error -> response.getErrors().add(error.getDefaultMessage()));
return ResponseEntity.badRequest().body(response);
}
Produto produto = produtoOpt.get();
Pedido pedido = pedidoOpt.get();
PedidoItens pedidoItensPesquisado = pedidoItensOpt.get();
pedidoItensPesquisado = converterDtoParaPedidoItens(pedidoItensDto, pedido, produto );
pedidoItensService.editar(pedidoItensPesquisado);
response.setData(pedidoItensDto);
return ResponseEntity.ok(response);
}
@GetMapping("/todos")
public ResponseEntity<Response<PedidoItensDto>> buscar() {
log.info("Listando todos itens pedidos : ");
Response<PedidoItensDto> response = new Response<PedidoItensDto>();
List<PedidoItens> listPedidoItens = this.pedidoItensService.buscarTodos();
List<PedidoItensDto> listProdutoDto = new ArrayList<>();
int indice = -1;
for(PedidoItens p : listPedidoItens) {
listProdutoDto.add(++indice, pedidoItensDto(p));
}
response.setListData(listProdutoDto);
return ResponseEntity.ok(response);
}
@DeleteMapping("/apagar/{id}")
public ResponseEntity<Response<String>> remover(@PathVariable("id") Long id) {
log.info("Removendo todos itens pedido: {}", id);
Response<String> response = new Response<String>();
Optional<PedidoItens> pedidoItens = this.pedidoItensService.buscarPorId(id);
if (!pedidoItens.isPresent()) {
log.info("Erro ao remover devido itens pedido ID: {} ser inválido.", id);
response.getErrors().add("Erro ao remover itens pedido. itens pedido não encontrado para o id " + id);
return ResponseEntity.badRequest().body(response);
}
this.pedidoItensService.excluir(id);
log.info("Pedidos itens removido: {}", id);
return ResponseEntity.ok(new Response<String>());
}
private PedidoItensDto pedidoItensDto (PedidoItens pedidoItens) {
PedidoItensDto pedidoItensDto = new PedidoItensDto();
pedidoItensDto.setId(pedidoItens.getId());
pedidoItensDto.setId_pedido(pedidoItens.getPedido().getId());
pedidoItensDto.setId_produto(pedidoItens.getProduto().getId());
pedidoItensDto.setNomeProduto(pedidoItens.getNomeProduto());
pedidoItensDto.setQuantidade(pedidoItens.getQuantidade());
pedidoItensDto.setSubTotal(pedidoItens.getSubTotal());
pedidoItensDto.setValor(pedidoItens.getValor());
return pedidoItensDto;
}
private PedidoItens converterDtoParaPedidoItens(PedidoItensDto pedidoItensDto , Pedido pedido, Produto produto){
PedidoItens pedidoItens = new PedidoItens();
pedidoItens.setId(pedidoItensDto.getId());
pedidoItens.setPedido(pedido);
pedidoItens.setProduto(produto);
pedidoItens.setNomeProduto(pedidoItensDto.getNomeProduto());
pedidoItens.setQuantidade(pedidoItensDto.getQuantidade());
pedidoItens.setSubTotal(pedidoItensDto.getSubTotal());
pedidoItens.setValor(pedidoItensDto.getValor());
return pedidoItens;
}
}
| [
"nicolassouza144@gmail.com"
] | nicolassouza144@gmail.com |
2d3f11ce70725811a7b12a77e839199e3ff29bf0 | 762c5a04114dbf39153584f4f1ad4b0dce312a63 | /TestingAmazon/src/test/java/productpage/TC_product_09.java | ea95ea118bcb138ebd513e7012f0f791a72340c9 | [] | no_license | suryarajan361/Automation-Testing | b6637adba48ac7cd5e0fb32765c5d3319eec5fdf | 84d8d28452c329de533619c5ae695c1da5812128 | refs/heads/master | 2023-06-23T19:01:36.763735 | 2021-07-24T13:45:35 | 2021-07-24T13:45:35 | 387,985,618 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,216 | java | package productpage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import io.github.bonigarcia.wdm.WebDriverManager;
public class TC_product_09
{
WebDriver cDriver;
@BeforeMethod
void setUp()
{
WebDriverManager.chromedriver().setup();
cDriver= new ChromeDriver();
}
@Test(description="Product page is visible to user")
void checkProduct(){
cDriver.get("https://www.amazon.in/");
WebElement productElement=cDriver.findElement(By.xpath("//div[@class='a-section a-spacing-none aok-relative']"));
Boolean b_productElement= productElement.isDisplayed();
if(b_productElement)
{
System.out.println("Test cases passed");
System.out.println("Product page is visible");
}
else
{
System.out.println("test is failed");
}
}
@AfterTest
void tearDown()
{
cDriver.close();
cDriver.quit();
}
} | [
"Dell@DESKTOP-Q2B064J"
] | Dell@DESKTOP-Q2B064J |
0f2c4e0671d00253e27fe99d93b57c697fd286ec | 0e92120c318a465d9c4e948fc174d8fa4341a129 | /spring-diagnose-server/src/main/java/com/github/isagron/springdiagnoseserver/clients/DdwManagementClient.java | 1dc84fb60d443c7fbe5ebee4ec1b4b13ff353590 | [] | no_license | isagron/spring-diagnose-driven-workflow | 586546ce819677bc84b70eb86a7171ec49157aee | 9fce6c2f53448910215a80c2c1e31931f946dbbe | refs/heads/master | 2020-05-27T18:14:17.994878 | 2019-05-26T22:34:48 | 2019-05-26T22:34:48 | 188,738,033 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,576 | java | package com.github.isagron.springdiagnoseserver.clients;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.innon.ddw.client.management.DdwManagementApi;
import com.innon.ddw.client.management.elements.DdwExecutionRequestRecordDto;
import com.innon.ddw.client.management.elements.MatchableItemDto;
import com.innon.ddw.client.management.elements.WorkflowConfigurationDto;
import com.innon.ddw_common.matcher.Matchable;
import com.innon.ddw_common.matcher.impl.MatchPair;
import org.springframework.stereotype.Service;
@Service
public class DdwManagementClient implements DdwManagementApi {
@Override
public MatchableItemDto findMatch(Map<String, String> matchInfo, List<Matchable> candidates) {
return null;
}
@Override
public Object getObj(String objGetterIdentifier, Object objectGetterInfo) {
return null;
}
@Override
public MatchPair connectDiagnoseToOperationService(Matchable item1, Matchable item2) {
return null;
}
@Override
public String exec(Collection<String> diagnoseTopics, String objGetterIdentifier, Object objectGetterInfo, HashMap<String, Object> additionalInfo, WorkflowConfigurationDto configurationProperties) {
return null;
}
@Override
public DdwExecutionRequestRecordDto getRequestExecutionRecord(String requestId) {
return null;
}
@Override
public void shutdown() {
}
@Override
public String getWorkflowStageTopic(String requestId) {
return null;
}
}
| [
"innon12310@gmail.com"
] | innon12310@gmail.com |
5d0aad132e3707be0e00be4ce9a3f95747a44b63 | 9a071ea50a278ffa3997b77607edd5e8f40e9d7a | /micolorerp/src/main/java/com/micolor/entity/userinterface/InterfaceLogsErr.java | 18b157bec53b0b87ce19ef6c9cc19017e4ae2b4d | [] | no_license | chm1024/Ark_ERP | 091a06b92dd9c558a27b1e4b1fdb3425a7420629 | 7870bc3c4985035b071f1ae6648b23a26d40401f | refs/heads/master | 2021-01-12T05:09:53.812885 | 2017-01-03T01:41:54 | 2017-01-03T01:41:54 | 77,873,367 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,382 | java | package com.micolor.entity.userinterface;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Table;
/**
* Created by liusi on 2016/12/1.
*/
@Entity
@Table(name = "interface_logs_err")
public class InterfaceLogsErr implements java.io.Serializable{
@javax.persistence.Id
@Column(name = "ID")
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid")
private String id;
@Column(name = "LOG_ID")
private String logId;
@Column(name = "INTERFACE_CODE")
private String interfaceCode;
@Column(name = "INTERFACE_NAME")
private String interfaceName;
@Column(name = "PRIMARY_COLUMN")
private String primaryColumn;
@Column(name = "PRIMARY_KEY")
private String primaryKey;
@Column(name = "ERR_CODE")
private String errCode;
@Column(name = "ERR_MSG")
private String errMsg;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLogId() {
return logId;
}
public void setLogId(String logId) {
this.logId = logId;
}
public String getInterfaceCode() {
return interfaceCode;
}
public void setInterfaceCode(String interfaceCode) {
this.interfaceCode = interfaceCode;
}
public String getInterfaceName() {
return interfaceName;
}
public void setInterfaceName(String interfaceName) {
this.interfaceName = interfaceName;
}
public String getPrimaryColumn() {
return primaryColumn;
}
public void setPrimaryColumn(String primaryColumn) {
this.primaryColumn = primaryColumn;
}
public String getPrimaryKey() {
return primaryKey;
}
public void setPrimaryKey(String primaryKey) {
this.primaryKey = primaryKey;
}
public String getErrCode() {
return errCode;
}
public void setErrCode(String errCode) {
this.errCode = errCode;
}
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
}
| [
"noreply@github.com"
] | chm1024.noreply@github.com |
935f471d4927a4a6c75062ce2180eab61c315b55 | a870dc7e107ecaacd79ab3e2c50d9e6770665240 | /src/main/java/com/github/sheigutn/pushbullet/http/defaults/get/ListBlocksRequest.java | 6865a2d0ce12622cb0e880eed7d439ff6bd15d55 | [
"MIT"
] | permissive | Osndok/pushbullet-java-8 | 37f77f113ca88a3ed901ac6c6de4c6be85da07ce | 6bd296505403d91d67d8ff6cebed12af6d9eb485 | refs/heads/master | 2020-04-13T03:25:07.382386 | 2018-12-23T23:36:12 | 2018-12-23T23:37:10 | 162,931,097 | 0 | 0 | MIT | 2018-12-23T23:30:42 | 2018-12-23T23:30:42 | null | UTF-8 | Java | false | false | 307 | java | package com.github.sheigutn.pushbullet.http.defaults.get;
import com.github.sheigutn.pushbullet.http.Urls;
import com.github.sheigutn.pushbullet.http.defaults.ListItemsRequest;
public class ListBlocksRequest extends ListItemsRequest {
public ListBlocksRequest() {
super(Urls.BLOCKS);
}
}
| [
"fb020198@gmail.com"
] | fb020198@gmail.com |
044ed05c210b1688f75d0b3f1b1f731551da5f79 | c1567afe19aa52c2fcd434e5b9268fe156bae3af | /juyoujia/app/src/main/java/com/idougong/jyj/module/adapter/UserCouponAdapter.java | 6ae8da72ddcc61a616c1511271ffa8070a31fc48 | [] | no_license | lihuangmeiji/jyj | 24e7fbe77e78162364fe45e5a150c65f5d4d6f18 | f1cdf5219d1914a21d763bec91af990c44103723 | refs/heads/master | 2022-09-24T09:01:41.294178 | 2020-06-03T03:44:39 | 2020-06-03T03:44:39 | 268,759,289 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,716 | java | package com.idougong.jyj.module.adapter;
import android.graphics.Color;
import android.view.View;
import android.widget.TextView;
import com.blankj.utilcode.util.EmptyUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.idougong.jyj.R;
import com.idougong.jyj.model.CouponsBean;
import com.idougong.jyj.model.UserCouponBean;
import com.idougong.jyj.utils.TextUtil;
import com.idougong.jyj.utils.TimeFormater;
public class UserCouponAdapter extends BaseQuickAdapter<CouponsBean, BaseViewHolder> {
public UserCouponAdapter(int layoutResId) {
super(layoutResId);
}
@Override
protected void convert(BaseViewHolder baseViewHolder, CouponsBean userCouponBean) {
if (!EmptyUtils.isEmpty(userCouponBean.getValidStartTime())) {
if (EmptyUtils.isEmpty(userCouponBean.getValidEndTime())) {
baseViewHolder.setText(R.id.tv_coupon_validperiod, "有效期:" + TimeUtils.date2String(TimeUtils.string2Date(userCouponBean.getValidStartTime()), "yyyy.MM.dd") +
"-永久");
} else {
baseViewHolder.setText(R.id.tv_coupon_validperiod, "有效期:" + TimeUtils.date2String(TimeUtils.string2Date(userCouponBean.getValidStartTime()), "yyyy.MM.dd") +
"-" + TimeUtils.date2String(TimeUtils.string2Date(userCouponBean.getValidEndTime()), "yyyy.MM.dd"));
}
}
if (userCouponBean.getCouponType() == 1) {
baseViewHolder.setText(R.id.tv_couponwithAmount, "满" + userCouponBean.getWithAmount() + "元可用");
baseViewHolder.setText(R.id.tv_couponinfo, TextUtil.FontHighlighting(mContext, "¥", userCouponBean.getUsedAmount() + " ", "满减券", R.style.tv_couponinfo1, R.style.tv_couponinfo2, R.style.tv_couponinfo3));
} else if (userCouponBean.getCouponType() == 2) {
baseViewHolder.setText(R.id.tv_couponinfo, TextUtil.FontHighlighting(mContext, (userCouponBean.getUsedProportion() * 10) + "折 ", "折扣券", R.style.tv_couponinfo2, R.style.tv_couponinfo3));
baseViewHolder.setText(R.id.tv_couponwithAmount, userCouponBean.getMaxWithAmount() + "元内可用");
}
TextView tv_cou_deception = baseViewHolder.getView(R.id.tv_cou_deception);
if (!EmptyUtils.isEmpty(userCouponBean.getDeception())) {
tv_cou_deception.setVisibility(View.VISIBLE);
tv_cou_deception.setText(userCouponBean.getDeception());
} else {
tv_cou_deception.setVisibility(View.GONE);
}
if (userCouponBean.isEnable()) {
if (userCouponBean.getCouponType() == 1) {
baseViewHolder.setBackgroundRes(R.id.ll_couponitem, R.mipmap.yhj_bg_ky);
baseViewHolder.setTextColor(R.id.tv_couponinfo, mContext.getResources().getColor(R.color.color72_sc));
baseViewHolder.setTextColor(R.id.tv_coupon_validperiod, mContext.getResources().getColor(R.color.color72_sc));
baseViewHolder.setTextColor(R.id.tv_couponwithAmount, mContext.getResources().getColor(R.color.color72_sc));
tv_cou_deception.setBackgroundResource(R.drawable.bg_shape_ellipse_yellowish);
tv_cou_deception.setTextColor(mContext.getResources().getColor(R.color.color78_sc));
} else if (userCouponBean.getCouponType() == 2) {
baseViewHolder.setBackgroundRes(R.id.ll_couponitem, R.mipmap.bg_couponvalid1);
baseViewHolder.setTextColor(R.id.tv_couponinfo, mContext.getResources().getColor(R.color.color74_sc));
baseViewHolder.setTextColor(R.id.tv_coupon_validperiod, mContext.getResources().getColor(R.color.color74_sc));
baseViewHolder.setTextColor(R.id.tv_couponwithAmount, mContext.getResources().getColor(R.color.color74_sc));
tv_cou_deception.setBackgroundResource(R.drawable.bg_shape_ellipse);
tv_cou_deception.setTextColor(mContext.getResources().getColor(R.color.color78_sc));
}
} else {
baseViewHolder.setBackgroundRes(R.id.ll_couponitem, R.mipmap.bg_couponinvalid);
baseViewHolder.setTextColor(R.id.tv_couponinfo, Color.parseColor("#999999"));
baseViewHolder.setTextColor(R.id.tv_coupon_validperiod, Color.parseColor("#999999"));
baseViewHolder.setTextColor(R.id.tv_couponwithAmount, Color.parseColor("#8C8C8C"));
tv_cou_deception.setBackgroundResource(R.drawable.bg_shape_ellipse_gray);
tv_cou_deception.setTextColor(mContext.getResources().getColor(R.color.tabwd));
}
}
}
| [
"1329996096@qq.com"
] | 1329996096@qq.com |
f09737ab76f5c58b424871e6d75b8b6cd0087259 | 2c2078c1b80933bb305f6bbace3a49ab0c7501d5 | /app/src/main/java/edu/tju/ina/things/fragments/MenuFragment.java | caabdd1d4e72bb76a33ad9b830b9966f3746ef4f | [] | no_license | zeplios/TjuThings | 1b7ee2008c608b2e340f14e8ab89326732ce0177 | ee55632caad6bc3df3715c2775fb032b5798fcf1 | refs/heads/master | 2021-01-10T01:46:18.986022 | 2015-09-29T16:19:02 | 2015-09-29T16:19:02 | 43,377,396 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,450 | java | package edu.tju.ina.things.fragments;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import edu.tju.ina.things.InfoApplication;
import edu.tju.ina.things.R;
import edu.tju.ina.things.adapter.LeftMenuAdapter;
import edu.tju.ina.things.net.HttpClient;
import edu.tju.ina.things.ui.LoginActivity;
import edu.tju.ina.things.ui.MenuMainActivity;
import edu.tju.ina.things.ui.ModifyAvatarActivity;
import edu.tju.ina.things.ui.PersonalSettingActivity;
import edu.tju.ina.things.util.LoginManager;
import edu.tju.ina.things.util.Utils;
public class MenuFragment extends ListFragment {
private int currentSelected = 0;
private Activity context;
@ViewInject(R.id.user_avatar) ImageView avatar;
@ViewInject(R.id.user_name) TextView name;
@SuppressLint("InflateParams")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_menu, null);
ViewUtils.inject(this, v);
context = getActivity();
LeftMenuAdapter adapter = new LeftMenuAdapter(getActivity());
setListAdapter(adapter);
return v;
}
@Override
public void onListItemClick(ListView lv, View v, int position, long id) {
if (position == lv.getCount() - 1) {
Utils.toast(context, "已退出登录");
InfoApplication.currentUser = null;
HttpClient.clearCookie();
LoginManager lm = new LoginManager(getActivity());
lm.clearSp();
onResume();
}
currentSelected = position;
Fragment newContent = FragmentFactory.createInstance(position);
if (newContent != null)
switchFragment(newContent);
}
// the meat of switching the above fragment
private void switchFragment(Fragment fragment) {
if (context instanceof MenuMainActivity) {
MenuMainActivity mma = (MenuMainActivity) context;
mma.switchContent(fragment);
}
}
public int getCurrentSelected() {
return currentSelected;
}
@Override
public void onResume() {
super.onResume();
if (InfoApplication.currentUser != null) {
InfoApplication.setNameAndAvatar(name, avatar);
name.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, PersonalSettingActivity.class);
context.startActivity(intent);
}
});
avatar.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, ModifyAvatarActivity.class);
context.startActivity(intent);
}
});
} else {
name.setText(context.getResources().getString(R.string.left_menu_login_hint));
avatar.setImageResource(R.drawable.menu_login);
name.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, LoginActivity.class);
startActivity(intent);
}
});
}
}
}
| [
"zhfchdev@gmail.com"
] | zhfchdev@gmail.com |
044f776a715bb807e19dd08cf6b5f4701493c8f5 | c2b70206f1c5a49c31b37283b169a52d163cdd9e | /src/main/java/Vehicles.java | f0767b8729a206d4cc8d236cf164d89d128a32e3 | [] | no_license | davinaSanders/HomeworkInterfacePractice | 11afa709b83c5fe3b42d493d168cb220cda17b6e | 9bf48787414e00c36baa9f449489620d340e05f3 | refs/heads/master | 2020-03-19T01:36:09.826370 | 2018-05-31T08:44:34 | 2018-05-31T08:44:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 486 | java | public abstract class Vehicles {
protected String type;
protected int healthValue;
public Vehicles(String type, int healthValue) {
this.type = type;
this.healthValue = healthValue;
}
public String getType() {
return this.type;
}
public int getHealthValue(){
return this.healthValue;
}
public String destroy(Kaiju kaiju){
kaiju.setHealthValue(0);
return kaiju.getName() + " is dead!";
}
}
| [
"davina.kuhnel@gmail.com"
] | davina.kuhnel@gmail.com |
e50e103d158b30f4d3d2e335137fd6191d41b01f | 0a731b47d9957eb1abe141175b66b465edeb36cd | /DemoApp-master/src/main/java/com/thinkxfactor/demoApp/entity/car.java | f122c0ad5ce04ea6c1cfb1a9891fe0616dea4268 | [] | no_license | Namratabhatt/SPRING-BOOT-APPLICATION | e8b540a8d27204d3b9edad38ae90f58645b83693 | 458ad1b35f6f2887b294d1280387ecc0524ccfa4 | refs/heads/master | 2021-03-15T17:00:10.778053 | 2020-03-12T15:22:04 | 2020-03-12T15:22:04 | 246,867,002 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 610 | java | package com.thinkxfactor.demoApp.entity;
import com.thinkxfactor.demoApp.entity.engine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class car
{
private String name;
@Autowired
private engine eng;
public car()
{
System.out.println("Car created");
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void printInfo()
{
System.out.println(this.name + this.eng.getModel());
}
}
| [
"noreply@github.com"
] | Namratabhatt.noreply@github.com |
a6cad5f01307d0c51eb2c35656ace9a2a11a9feb | 882a1a28c4ec993c1752c5d3c36642fdda3d8fad | /src/test/java/com/microsoft/bingads/v12/api/test/entities/criterions/adgroup/location_intent/write/BulkAdGroupLocationIntentCriterionWriteStatusTest.java | 050113878593c5a4b523224162b1fa31d836fce7 | [
"MIT"
] | permissive | BazaRoi/BingAds-Java-SDK | 640545e3595ed4e80f5a1cd69bf23520754c4697 | e30e5b73c01113d1c523304860180f24b37405c7 | refs/heads/master | 2020-07-26T08:11:14.446350 | 2019-09-10T03:25:30 | 2019-09-10T03:25:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,832 | java | package com.microsoft.bingads.v12.api.test.entities.criterions.adgroup.location_intent.write;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import com.microsoft.bingads.internal.functionalinterfaces.BiConsumer;
import com.microsoft.bingads.v12.api.test.entities.criterions.adgroup.location_intent.BulkAdGroupLocationIntentCriterionTest;
import com.microsoft.bingads.v12.bulk.entities.BulkAdGroupLocationIntentCriterion;
import com.microsoft.bingads.v12.campaignmanagement.AdGroupCriterionStatus;
@RunWith(Parameterized.class)
public class BulkAdGroupLocationIntentCriterionWriteStatusTest extends BulkAdGroupLocationIntentCriterionTest {
@Parameter(value = 1)
public AdGroupCriterionStatus propertyValue;
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(
new Object[][]{
{"Active", AdGroupCriterionStatus.ACTIVE},
{"Deleted", AdGroupCriterionStatus.DELETED},
{"Paused", AdGroupCriterionStatus.PAUSED},
{null, null}
}
);
}
@Test
public void testWrite() {
testWriteProperty(
"Status",
datum,
propertyValue,
new BiConsumer<BulkAdGroupLocationIntentCriterion, AdGroupCriterionStatus>() {
@Override
public void accept(BulkAdGroupLocationIntentCriterion c, AdGroupCriterionStatus v) {
c.getBiddableAdGroupCriterion().setStatus(v);
}
}
);
}
}
| [
"qitia@microsoft.com"
] | qitia@microsoft.com |
001345e68790a13e9d0f93c437dd56835583ca54 | 68eab9a5332af12f44437d220d7acff09b1c43f1 | /src/questions/LinkedList/FlattenAMultilevelLinkedListLevelWise.java | 59a52054620271b82da4aef556601ab964fba492 | [] | no_license | iamrk1811/InterviewQuestion500 | 74d1706d251cf64b0660c967d9595040bdd0287b | 984770a4adfead7a25fe9f746d2bd71446e21c06 | refs/heads/master | 2023-05-02T16:21:33.926635 | 2021-05-18T18:52:19 | 2021-05-18T18:52:19 | 351,079,398 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 661 | java | package questions.LinkedList;
public class FlattenAMultilevelLinkedListLevelWise {
// Q - https://www.geeksforgeeks.org/flatten-a-linked-list-with-next-and-child-pointers/
public ListNode solve(ListNode head) {
ListNode start = head;
ListNode tail = head;
while (tail.next != null) {
tail = tail.next;
}
while (start != null) {
if (start.bottom != null) {
tail.next = start.bottom;
while (tail.next != null) {
tail = tail.next;
}
start = start.next;
}
}
return head;
}
}
| [
"rakibrk1811@gmail.com"
] | rakibrk1811@gmail.com |
f8f165be19891f5a466d46af85e2c1ac1ebaf56d | 794fdaf0cd66a3b10bff75b4c568626552886f1f | /jeeplat/src/main/java/com/jeeplat/modules/cms/entity/FileTpl.java | 5621aef1043b05a9eab77a6f183152ae92962292 | [
"Apache-2.0"
] | permissive | lbyoo/JeePlat | d4a0b64812f80dca9d42247de1f90eaef85f086a | d8af19713bce469c0ae2d58a6a8740f10570aff9 | refs/heads/master | 2021-06-20T23:00:19.233596 | 2017-08-12T04:52:59 | 2017-08-12T04:52:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,199 | java | package com.jeeplat.modules.cms.entity;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.Date;
/**
* User: songlai
* Date: 13-8-22
* Time: 上午9:44
*/
public class FileTpl {
private File file;
// 应用的根目录
private String root;
public FileTpl(File file, String root) {
this.file = file;
this.root = root;
}
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getRoot() {
return root;
}
public void setRoot(String root) {
this.root = root;
}
public String getName() {
String ap = file.getAbsolutePath().substring(root.length());
ap = ap.replace(File.separatorChar, '/');
// 在resin里root的结尾是带'/'的,这样会导致getName返回的名称不以'/'开头。
if (!ap.startsWith("/")) {
ap = "/" + ap;
}
return ap;
}
public String getParent(){
String ap = file.getParent().substring(root.length());
ap = ap.replace(File.separatorChar, '/');
// 在resin里root的结尾是带'/'的,这样会导致getName返回的名称不以'/'开头。
if (!ap.startsWith("/")) {
ap = "/" + ap;
}
return ap;
}
public String getPath() {
String name = getName();
return name.substring(0, name.lastIndexOf('/'));
}
public String getFilename() {
return file.getName();
}
public String getSource() {
if (file.isDirectory()) {
return null;
}
try {
return FileUtils.readFileToString(this.file, "UTF-8");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public long getLastModified() {
return file.lastModified();
}
public Date getLastModifiedDate() {
return new Timestamp(getLastModified());
}
public long getLength() {
return file.length();
}
public int getSize() {
return (int) (getLength() / 1024) + 1;
}
public boolean isDirectory() {
return file.isDirectory();
}
}
| [
"lijian@bogon"
] | lijian@bogon |
f6fbfd252cf802b36e37aa7f4297f2b57fe4efe1 | bb83080e433833ecae85c430450675cfc0fdc7bf | /java/basic/code20/FileOutputStreamDemo4.java | cd73acf05e36f73b8e49c4534fb8498d6414b328 | [] | no_license | huxiaohe/learn | 66a6a40a3709feb777851492ff7b55b406eb0b45 | b4fa2480c5c48f3f6ab8ef7110f704c17d604970 | refs/heads/master | 2020-03-13T05:49:10.527729 | 2017-01-05T06:03:48 | 2017-01-05T06:03:48 | null | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 1,610 | java | package com.test;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/*
* 加入异常处理的字节输出流操作
*/
public class FileOutputStreamDemo4 {
public static void main(String[] args) {
// 分开做异常处理
// FileOutputStream fos = null;
// try {
// fos = new FileOutputStream("fos4.txt");
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
//
// try {
// fos.write("java".getBytes());
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// try {
// fos.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// 一起做异常处理
// try {
// FileOutputStream fos = new FileOutputStream("fos4.txt");
// fos.write("java".getBytes());
// fos.close();
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }
// 改进版
// 为了在finally里面能够看到该对象就必须定义到外面,为了访问不出问题,还必须给初始化值
FileOutputStream fos = null;
try {
// fos = new FileOutputStream("z:\\fos4.txt");
fos = new FileOutputStream("fos4.txt");
fos.write("java".getBytes());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// 如果fos不是null,才需要close()
if (fos != null) {
// 为了保证close()一定会执行,就放到这里了
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
| [
"caopeng8787@163.com"
] | caopeng8787@163.com |
60dd56c647978414db468d190494961b45508016 | 350ca0471d643d7b4af3d576506cfa66db4ae138 | /app/src/main/java/com/autoever/apay_user_app/ui/account/register/auth/CellPhoneAuthFragmentProvider.java | fb3e890f7617828824dba932cb3fe5b49c220e44 | [] | no_license | myhency/apay-user-app-mvvm | 4b057e5a4a6c218e045f70dd3bff13fd056f1b0d | ac92b388ef2196658e7aa60e53f082ae633e31c3 | refs/heads/master | 2022-12-11T17:00:00.098757 | 2020-09-20T02:02:47 | 2020-09-20T02:02:47 | 278,596,429 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 306 | java | package com.autoever.apay_user_app.ui.account.register.auth;
import dagger.Module;
import dagger.android.ContributesAndroidInjector;
@Module
public abstract class CellPhoneAuthFragmentProvider {
@ContributesAndroidInjector
abstract CellPhoneAuthFragment provideCellPhoneAuthFragmentFactory();
}
| [
"hency.yeo@gmail.com"
] | hency.yeo@gmail.com |
7d23e64950571309d52adec03d93661230fb0d96 | 0543ba69a36e8593ffb11611c20d951dd3f62d2d | /src/main/java/com/catalog/service/TypeService.java | fbcab6529e6bb2e2e86e99d8e596e21092bdbdf2 | [] | no_license | IgorSabo/mediaCatalogLatest | 360e41a915c5559c8a933ec2f1f0c1769e12568d | c2b89db16191a114819e71aebe1137d3fb88e08a | refs/heads/master | 2023-02-12T07:30:38.357749 | 2021-01-08T20:21:56 | 2021-01-08T20:21:56 | 327,687,208 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 196 | java | package com.catalog.service;
import com.catalog.model.Type;
import java.util.ArrayList;
/**
* Created by Gile on 9/26/2016.
*/
public interface TypeService {
ArrayList<Type> findAll();
}
| [
"EvoTiJakaLozinka12"
] | EvoTiJakaLozinka12 |
7644c51a7b93d6e3d5e617ac6cbb85730d7deae1 | 15d1f883e3f1227043c802cbe71731a8709890b3 | /nectaropc/src/com/ngs/entity/Candidatemaster.java | 60c5d1b58cdce52493773e7163e976390ce9e8a3 | [] | no_license | kmakarand/Litmus | 1d91045e94630b9a559a47e3db32d150e70621a9 | d989cf8cbebe0ecc5cacb73fef450cb81f07acdb | refs/heads/master | 2020-05-18T04:00:32.725232 | 2019-04-30T00:06:20 | 2019-04-30T00:06:20 | 184,161,085 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,657 | java | package com.ngs.entity;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.*;
import com.ntw.Emp;
/**
* Candidatemaster entity. @author MyEclipse Persistence Tools
*/
@Entity
@NamedQueries({
@NamedQuery(name="Userdetails-Candidatemaster.sql3",
query="select c from Candidatemaster c where c.clientId=?1 and c.scheduleId=?2 order by c.candidateId"),
@NamedQuery(name="RegistrationKey-Candidatemaster.sql2",
query="SELECT cm FROM Candidatemaster cm WHERE cm.candidateId=:cid"),
@NamedQuery(name="RegistrationKey-Candidatemaster.sql7",
query="SELECT cm.candidateId FROM Candidatemaster cm WHERE cm.candidateId=:cid"),
@NamedQuery(name="RegistrationKey-Candidatemaster.sql8",
query="SELECT cm.clientId FROM Candidatemaster cm WHERE cm.candidateId=:cid"),
@NamedQuery(name="AddressManager-Candidatemaster.sql1",
query="SELECT cm.firstName,cm.lastName FROM Candidatemaster cm WHERE cm.candidateId=:cid"),
@NamedQuery(name="Analysis-Candidatemaster.sql1",
query="SELECT cm.firstName,cm.lastName,cm.candidateId from Candidatemaster cm where cm.candidateId =:cid"),
@NamedQuery(name="CandidateList-Candidatemaster.sql1",
query="select s.scheduleDate,c.candidateId,c.firstName,c.lastName,c.clientId,s.scheduleId,clm.clientName " +
"from Candidatemaster c, Schedule s,Clientmaster clm "+
"where s.scheduleDate>=?1 and s.scheduleDate<=?2 and c.scheduleId=s.scheduleId and c.clientId=clm.clientId " +
"group by c.candidateId,s.scheduleDate,c.firstName,clm.clientName, " +
"c.lastName,c.clientId,s.scheduleId order by s.scheduleDate,c.candidateId"),
@NamedQuery(name="Assigncenter-Candidatemaster.sql1",
query="SELECT A FROM Candidatemaster A,Usergroupxref B WHERE A.username=B.username and B.groupId=?1" +
"ORDER BY A.firstName"),
@NamedQuery(name="Monthly_Summary-Candidatemaster.sql1",
query="SELECT cm FROM Candidatemaster cm WHERE cm.scheduleId IN (?1) AND cm.clientId=?2"),
@NamedQuery(name="Monthly_Summary-Candidatemaster.sql2",
query=("SELECT cm FROM Candidatemaster cm WHERE cm.scheduleId IN (SELECT s.scheduleId FROM Schedule s " +
"WHERE s.scheduleDate>=?1 and s.scheduleDate<=?2 and s.scheduleDate <= CURRENT_DATE) and " +
"cm.candidateId >3 and cm.scheduleId>0 and cm.clientId>0"))
})
@Table(name = "CandidateMaster", catalog = "nectar", uniqueConstraints = @UniqueConstraint(columnNames = "Username"))
public class Candidatemaster implements java.io.Serializable {
// Fields
private Integer candidateId;
private Integer scheduleId;
private String username;
private String password;
private String typeOfUser;
private String firstName;
private String lastName;
private Date dateOfBirth;
private Integer sex;
private String designation;
private Integer clientId;
private String email;
private Integer experience;
private Integer centreOfRegistration;
private Date dateOfRegistration;
private Integer isTableCreated;
private String hintQuestion;
private String hintAnswer;
private Integer status;
// Constructors
/** default constructor */
public Candidatemaster() {
}
/** minimal constructor */
public Candidatemaster(Integer scheduleId, String username,
String typeOfUser, String firstName, String lastName,
Date dateOfBirth, Integer sex, String email,
Integer centreOfRegistration, Date dateOfRegistration,
Integer isTableCreated, String hintQuestion, String hintAnswer,
Integer status) {
this.scheduleId = scheduleId;
this.username = username;
this.typeOfUser = typeOfUser;
this.firstName = firstName;
this.lastName = lastName;
this.dateOfBirth = dateOfBirth;
this.sex = sex;
this.email = email;
this.centreOfRegistration = centreOfRegistration;
this.dateOfRegistration = dateOfRegistration;
this.isTableCreated = isTableCreated;
this.hintQuestion = hintQuestion;
this.hintAnswer = hintAnswer;
this.status = status;
}
/** full constructor */
public Candidatemaster(Integer scheduleId, String username,
String password, String typeOfUser, String firstName,
String lastName, Date dateOfBirth, Integer sex, String designation,
Integer clientId, String email, Integer experience,
Integer centreOfRegistration, Date dateOfRegistration,
Integer isTableCreated, String hintQuestion, String hintAnswer,
Integer status) {
this.scheduleId = scheduleId;
this.username = username;
this.password = password;
this.typeOfUser = typeOfUser;
this.firstName = firstName;
this.lastName = lastName;
this.dateOfBirth = dateOfBirth;
this.sex = sex;
this.designation = designation;
this.clientId = clientId;
this.email = email;
this.experience = experience;
this.centreOfRegistration = centreOfRegistration;
this.dateOfRegistration = dateOfRegistration;
this.isTableCreated = isTableCreated;
this.hintQuestion = hintQuestion;
this.hintAnswer = hintAnswer;
this.status = status;
}
// Property accessors
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "CandidateID", unique = true, nullable = false)
public Integer getCandidateId() {
return this.candidateId;
}
//@OneToMany(mappedBy="objCandidatemaster")
List<Addressdetails> listAddressdetails= new ArrayList<Addressdetails>();
public void setCandidateId(Integer candidateId) {
this.candidateId = candidateId;
}
@Column(name = "ScheduleID", nullable = false)
public Integer getScheduleId() {
return this.scheduleId;
}
public void setScheduleId(Integer scheduleId) {
this.scheduleId = scheduleId;
}
@Column(name = "Username", unique = true, nullable = false, length = 40)
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
@Column(name = "password", length = 50)
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(name = "TypeOfUser", nullable = false, length = 2)
public String getTypeOfUser() {
return this.typeOfUser;
}
public void setTypeOfUser(String typeOfUser) {
this.typeOfUser = typeOfUser;
}
@Column(name = "FirstName", nullable = false, length = 20)
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@Column(name = "LastName", nullable = false, length = 20)
public String getLastName() {
return this.lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Temporal(TemporalType.DATE)
@Column(name = "DateOfBirth", nullable = false, length = 10)
public Date getDateOfBirth() {
return this.dateOfBirth;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
@Column(name = "Sex", nullable = false)
public Integer getSex() {
return this.sex;
}
public void setSex(Integer sex) {
this.sex = sex;
}
@Column(name = "Designation", length = 50)
public String getDesignation() {
return this.designation;
}
public void setDesignation(String designation) {
this.designation = designation;
}
@Column(name = "ClientID")
public Integer getClientId() {
return this.clientId;
}
public void setClientId(Integer clientId) {
this.clientId = clientId;
}
@Column(name = "Email", nullable = false, length = 30)
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
@Column(name = "Experience")
public Integer getExperience() {
return this.experience;
}
public void setExperience(Integer experience) {
this.experience = experience;
}
@Column(name = "CentreOfRegistration", nullable = false)
public Integer getCentreOfRegistration() {
return this.centreOfRegistration;
}
public void setCentreOfRegistration(Integer centreOfRegistration) {
this.centreOfRegistration = centreOfRegistration;
}
@Temporal(TemporalType.DATE)
@Column(name = "DateOfRegistration", nullable = false, length = 10)
public Date getDateOfRegistration() {
return this.dateOfRegistration;
}
public void setDateOfRegistration(Date dateOfRegistration) {
this.dateOfRegistration = dateOfRegistration;
}
@Column(name = "isTableCreated", nullable = false)
public Integer getIsTableCreated() {
return this.isTableCreated;
}
public void setIsTableCreated(Integer isTableCreated) {
this.isTableCreated = isTableCreated;
}
@Column(name = "HintQuestion", nullable = false)
public String getHintQuestion() {
return this.hintQuestion;
}
public void setHintQuestion(String hintQuestion) {
this.hintQuestion = hintQuestion;
}
@Column(name = "HintAnswer", nullable = false, length = 15)
public String getHintAnswer() {
return this.hintAnswer;
}
public void setHintAnswer(String hintAnswer) {
this.hintAnswer = hintAnswer;
}
@Column(name = "Status", nullable = false)
public Integer getStatus() {
return this.status;
}
public void setStatus(Integer status) {
this.status = status;
}
public List<Addressdetails> getAddressdetails() {
return listAddressdetails;
}
public void setAddressdetails(Addressdetails objAddressdetails) {
this.listAddressdetails = listAddressdetails;
}
} | [
"hp@hp-PC"
] | hp@hp-PC |
d1a77c03e493adfff8ab6e489f88997c4d9177b0 | 81e48d2c89f80702124ecfb4bd56ef060ae58028 | /Car Service Station/src/main/java/com/ramakhutla/ethan/repository/InventoryRepository.java | a7f3508daf82ee6bf26c9f735373d3f44b264b23 | [] | no_license | umkhuru/Backend | fa34331c3b45d086ec62d6d24eb4e096c4fe05ba | b8c6ea5c9f92300c5f453f44a4243b16410bf864 | refs/heads/master | 2021-01-13T17:06:06.599578 | 2016-10-31T12:35:41 | 2016-10-31T12:35:41 | 72,432,857 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 332 | java | package com.ramakhutla.ethan.repository;
import com.ramakhutla.ethan.domain.Inventory;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
/**
* Created by Ethon on 2016/10/28.
*/
@Repository
public interface InventoryRepository extends CrudRepository<Inventory,Long>{
}
| [
"etiramakhutla@hotmail.com"
] | etiramakhutla@hotmail.com |
b5e875d714ecf7b4cefd648a19af6cb03758e558 | 9847af75e759004d5e1d3611914e06fb830f356b | /prograwomaven/DoublyNode.java | f6e55616123d9b5d84f506e7ebc61c1a6e899a36 | [] | no_license | Tuanis99/Progra1-JPS | 6720698ed6ee8613842e740be92f30ad7c415321 | 5d9ac7692950810591bc95bab075f20fc5b358f9 | refs/heads/master | 2020-05-03T11:31:34.378787 | 2019-03-30T19:37:46 | 2019-03-30T19:37:46 | 178,603,096 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,109 | 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 prograwomaven;
/**
*
* @author luisg
*/
public class DoublyNode {
//Declaracion de variables
public Object element;
public DoublyNode next;
public DoublyNode previous;
//Constructores
public DoublyNode() {
}
public DoublyNode(Object element) {
this.element = element;
this.next = null;
this.previous = null;
}
//métodos
public Object getElement() {
return this.element;
}
public void setElement(Object element) {
this.element = element;
}
public DoublyNode getNext() {
return this.next;
}
public void setNext(DoublyNode next) {
this.next = next;
}
public DoublyNode getPrevious() {
return this.previous;
}
public void setPrevious(DoublyNode previous) {
this.previous = previous;
}
}
| [
"noreply@github.com"
] | Tuanis99.noreply@github.com |
c0a4d21631526c7318ab147f7da5c6f2f6154e63 | b78fa7f9cecdaa3788e4ac615101bc5ea14b8cf4 | /app/src/main/java/com/example/pancho/w5/model/Wspd.java | 30d835e5c1c4532ed212892663599de9ddd44ba2 | [] | no_license | francisco-villegas/W5 | 1f8182616d4b01e48b8c66d60525c508bc8fc868 | f3a96081e8b2c1777fb8d675acbe30d010a3c77e | refs/heads/master | 2021-01-22T04:04:51.902010 | 2017-10-02T03:20:26 | 2017-10-02T03:20:26 | 102,262,691 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 588 | java |
package com.example.pancho.w5.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Wspd {
@SerializedName("english")
@Expose
private String english;
@SerializedName("metric")
@Expose
private String metric;
public String getEnglish() {
return english;
}
public void setEnglish(String english) {
this.english = english;
}
public String getMetric() {
return metric;
}
public void setMetric(String metric) {
this.metric = metric;
}
}
| [
"francisco_7766@hotmail.com"
] | francisco_7766@hotmail.com |
7be34e421f66352ffcd6f50457141a341fe242af | 469d56f522cc3254b919f7895c65cf8077f7037f | /spring-boot-mybatis-readandwrite/src/main/java/com/lhf/springboot/annotation/Master.java | baf134b277e3e2b57ebf1e54b065b05b29b023cd | [] | no_license | guojieem/lhf_spring_boot_study | 98d496313070a5898418d2b7072729a5a9f59112 | 627a5b9313cd8163aeb9d1346ea854323dee61bc | refs/heads/master | 2023-06-18T02:36:30.316242 | 2021-07-21T11:47:50 | 2021-07-21T11:47:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 308 | java | package com.lhf.springboot.annotation;
/**
* @ClassName: Master
* @Author: liuhefei
* @Description: 特殊情况是某些情况下我们需要强制读主库,针对这种情况,我们定义一个主键,用该注解标注的就读主库。
* @Date: 2019/8/28 16:53
*/
public @interface Master {
}
| [
"v_feiheliu@tencent.com"
] | v_feiheliu@tencent.com |
cf5996377ee1e3feaf9b42edd8ac5bce7037e2d7 | 2a1f28857aa6b0e0ff37a60fa42faf069d73f64e | /270a4/Controller.java | c7d87ccf0b19363607596f519d19e5dd63fea214 | [] | no_license | yu-gu/OO-Design-and-Implementation | 294b575ea86f233b015286674b450d78f99b2b76 | 08e90010a131b61cf581bcc44c9de0474ad52950 | refs/heads/master | 2021-08-28T00:31:46.461058 | 2017-12-10T21:39:09 | 2017-12-10T21:39:09 | 113,118,155 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,417 | java | package startup;
import interfaces.*;
import commands.*;
/**
* Class to obtain and handle a sequence of user commands using console interface.
*/
public class Controller {
/** The interface for person who make operations */
private Interface interfaces = new Interface();
/**
* Process the command given by the user
*
* @param cmdId
* @precond cmdId != null cmdId must be number given
*/
public void handle(int cmdId) {
switch (cmdId) {
case 1:
addPassenger();
break;
case 2:
bookPassenger();
break;
case 3:
displayEmptySeats();
break;
case 0:
break;
default:
interfaces.sendMessage("****Illegal command number ("
+ cmdId + ") entered. " + "Please try again.");
}
}
/**
* add a passenger to the systems
*
* @precond passenger cannot exist in the system already
*/
public void addPassenger(){
String name = interfaces.getName();
String telNumber = interfaces.getTelNumber();
addPassenger addnewPassenger = new addPassenger();
addnewPassenger.addPassengers(name, telNumber);
if (addnewPassenger.wasSuccessful()){
interfaces.sendMessage("add Passenger successful");
}else{
interfaces.sendMessage(addnewPassenger.getErrorMessage());
}
}
/**
* add a regular booking for a passenger
*/
public void bookPassenger(){
String name = interfaces.getName();
int FlightNumber = interfaces.getFlightNumber();
bookPassenger booknewPassenger = new bookPassenger();
booknewPassenger.bookPassengers(name, FlightNumber);
if (booknewPassenger.wasSuccessful()){
interfaces.sendMessage("book Passenger successful");
}else{
interfaces.sendMessage(booknewPassenger.getErrorMessage());
}
}
/**
* display the seats that are empty
*/
public void displayEmptySeats(){
int flightnumber = interfaces.getFlightNumber();
displayEmptySeats EmptySeats = new displayEmptySeats();
EmptySeats.displayEmptySeat(flightnumber);
if (EmptySeats.wasSuccessful()){
interfaces.sendMessage("display empty seats successful");
}else{
interfaces.sendMessage(EmptySeats.getErrorMessage());
}
}
}
| [
"yug242@mail.usask.ca"
] | yug242@mail.usask.ca |
13f3df07e07cc249127c53766618585ebf9140d9 | e95908f3927bbfcdda59b613bed5ca4788b29457 | /src/DiagnosticTest/Walk.java | 5283f7f86f770462892f13cc3004d8954f6087e5 | [] | no_license | mekanhan/AutoBoot | c408ed9e738bb7b729eb45e7c9a2f0bf7b64aad0 | f08b60f8784e01f6c4ff678891bcd4cb0c7e89be | refs/heads/master | 2022-11-20T04:56:53.523329 | 2020-07-17T08:23:40 | 2020-07-17T08:23:40 | 280,330,213 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 458 | java | package DiagnosticTest;
//interface Walk {
// public default int getSpeed() {
// return 5;
// }
//}
//
//interface Run {
// public default int getSpeed() {
// return 10;
// }
//}
//
//public class Animal implements Run, Walk {
//
// public int getSpeed() {
// return 6;
// }
//
// public static void main(String args[ ]) {
// Animal an = new Animal();
// System.out.println(an.getSpeed());
// }
//} | [
"mekjanhan@gmail.com"
] | mekjanhan@gmail.com |
27d800e6a21e95bf64356da4ee21166d77de30cd | 32624efb387552ba3d19137dabbe6aa8b5430fd1 | /cs3220HW4/src/hw4/servlet/Download.java | 6ccabe74d95257254ed6e99f32203c4286b53eaf | [] | no_license | kaghi123/WebProjects | ff30ff0d18312aa98f67610ca93bcdbee26df74a | 0e3ce9dd7392c38ad24926dfc3a7843f8df620d0 | refs/heads/master | 2021-05-08T00:28:24.500347 | 2017-10-21T02:27:22 | 2017-10-21T02:27:22 | 107,745,134 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,700 | java | package hw4.servlet;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/Download")
public class Download extends HttpServlet {
private static final long serialVersionUID = 1L;
public Download() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Get the path to the file and create a java.io.File object
String path = getServletContext()
.getRealPath( "/WEB-INF/files/" );
File file = new File( path );
// Set the response headers. File.length() returns the size of the file
// as a long, which we need to convert to a String.
response.setContentType( "" );
response.setHeader( "Content-Length", "" + file.length() );
response.setHeader( "Content-Disposition",
"inline; filename=" + file.getName() );
// Binary files need to read/written in bytes.
FileInputStream in = new FileInputStream( file );
OutputStream out = response.getOutputStream();
byte buffer[] = new byte[2048];
int bytesRead;
while( (bytesRead = in.read( buffer )) > 0 )
out.write( buffer, 0, bytesRead );
in.close();
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
| [
"kaghi1@yahoo.com"
] | kaghi1@yahoo.com |
dbd15928ce31c4e4baca8b72909d5ce155c11f0d | faef64408ce7ce49836a0877d677d4385d364107 | /order/src/main/java/com/customer/order/entity/FoodItem.java | 514b3cbe1a9f18f6873892f6f83358b83bbc6fc8 | [] | no_license | RameshCR/SpringBoot301 | a8e4a0c2b5ec0b690fa9fbb510923d44098d603f | 40f67fa878e628cd8dda1d6564743531070d8004 | refs/heads/master | 2020-07-10T14:13:07.634783 | 2019-08-31T09:11:14 | 2019-08-31T09:11:14 | 204,282,098 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,801 | java | package com.customer.order.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.customer.order.enums.CuisineType;
import com.customer.order.enums.FoodType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Getter
@Setter
@NoArgsConstructor
@ApiModel(description = " Used for Food Item Entity ")
public class FoodItem implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Enumerated(EnumType.STRING)
private FoodType foodType;
@Enumerated(EnumType.STRING)
private CuisineType cuisineType;
@ApiModelProperty(notes = "food item name")
private String itemName;
private BigDecimal itemPrice;
private boolean isActive = true;
@Override
public int hashCode() {
return new HashCodeBuilder().append(getId()).toHashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
FoodItem other = (FoodItem) obj;
return new EqualsBuilder().append(getId(), other.getId()).isEquals();
}
@Override
public String toString() {
return "FoodItem [id=" + id + ", foodType=" + foodType + ", cuisineType=" + cuisineType + ", itemName="
+ itemName + ", itemPrice=" + itemPrice + "]";
}
}
| [
"racr@empoweredbenefits.com"
] | racr@empoweredbenefits.com |
3cde162a06100454c2ce4c37cc0d79c3ec3f5fd3 | 0584777d8ca2d8f56e7058b26fa757cb02ab633f | /HelloWorld/src/api/object/SystemTimeExample.java | 8ef01fc45fdeffcb5925b7c7b56f6645af9f5228 | [] | no_license | dhdyd227/ObjectClass | 1c64f6b4efba17a5cd1803ffefd5f1db55caa6e4 | caf56bd3903c62c43dafa1fff1f3840ea72bd1f9 | refs/heads/master | 2020-12-18T20:36:21.741868 | 2020-01-22T06:57:15 | 2020-01-22T06:57:15 | 235,514,026 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 403 | java | package api.object;
public class SystemTimeExample {
public static void main(String[] args) {
long time1 = System.nanoTime();
int sum = 0;
for(int i=1;i<1000000;i++) {
sum +=i;
}
long time2 = System.nanoTime();
System.out.println("1~1000000까지의 합: "+sum);
System.out.println("계산에"+ (time2-time1)+"나노초가 소요되었습니다.");
}
}
| [
"koy@DESKTOP-UJ7RTDT"
] | koy@DESKTOP-UJ7RTDT |
e12daf5afce45f18b510f1dc795022508ea27a31 | c22ae72a971f0858b29abe8d86f64ae6c85cb7d9 | /BankApplication/src/handler/WithdrawHandler.java | d77fa175082d7ebbfe52a195b852323721590eae | [] | no_license | NyoMeHan/Banking_JavaServlet | ca3fc8ee29938c641c0d3088f6cd80200e341bc8 | 222566a9d6b45bc75a17ba9c55a792520f339088 | refs/heads/master | 2020-05-20T10:50:33.741061 | 2014-05-16T13:35:39 | 2014-05-16T13:35:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,769 | java | package handler;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import businesslogic.CustomerBankAccountBL;
import dto.CurrentUser;
import dto.TransactionBankAccountDetails;
import java.util.Date;
public class WithdrawHandler implements Handler{
@Override
public String handleRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String result = "fail";
String accountNumber = (String)request.getParameter("accountNumber");
//int accountId = Integer.parseInt((String)request.getParameter("accountId"));
double amount = Double.parseDouble(request.getParameter("amount"));
CurrentUser cu = (CurrentUser)request.getSession().getAttribute("currentUser");
int customerId = cu.getId();
String status = request.getParameter("status");
java.sql.Date transactionDate = new java.sql.Date(new java.util.Date().getTime());
String fromCustomerNumber = accountNumber;
String toCustomerNumber = accountNumber;
//int fromCustomerId = accountId;
// int toCustomerId = accountId;
TransactionBankAccountDetails transaction = new TransactionBankAccountDetails();
transaction.setFromAccountNumber(accountNumber);
transaction.setToAccountNumber(accountNumber);
transaction.setAmount(amount);
transaction.setCustomerId(customerId);
transaction.setTransactionDate(transactionDate);
transaction.setStatus(status);
// transaction.setFrom_id(fromCustomerId);
// transaction.setTo_id(toCustomerId);
result = new CustomerBankAccountBL().withdrawAmount(transaction);
return result;
}
}
| [
"nyomehan@gmail.com"
] | nyomehan@gmail.com |
eb5d3fe7320d23799d04bc1c4c039b7402062796 | 7c194bda7f7879d9cc0ae419e8df5d4703ac9b1d | /src/com/saeyan/controller/action/BoardUpdateAction.java | cc84ca1ea84532838532e78b080e7740b8af10ab | [] | no_license | rin0210/jsp_20200518_web-study-11_board | 232cb12a3e407b4400756f341a4b19c8e466ee00 | 31d0b5fc0fe8438634214c224217bdecc0afaa74 | refs/heads/master | 2022-08-02T00:56:09.439471 | 2020-06-09T05:50:14 | 2020-06-09T05:50:14 | 265,759,105 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 926 | java | package com.saeyan.controller.action;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.saeyan.dao.BoardDAO;
import com.saeyan.dto.BoardVO;
public class BoardUpdateAction implements Action {
@Override
public void execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
BoardVO bVo = new BoardVO();
bVo.setNum(Integer.parseInt(request.getParameter("num")));
bVo.setName(request.getParameter("name"));
bVo.setPass(request.getParameter("pass"));
bVo.setEmail(request.getParameter("email"));
bVo.setTitle(request.getParameter("title"));
bVo.setContent(request.getParameter("content"));
BoardDAO bDao = BoardDAO.getInstance();
bDao.updateBoard(bVo);
new BoardListAction().execute(request, response);
}
}
| [
"PC@PC-PC"
] | PC@PC-PC |
a41495af4f21f725f8a541e9e1d13a07a27dae17 | 9f467ae373d12ae4f6b1fe6576e2289790d44f84 | /flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/utils/DummyStreamExecutionEnvironment.java | 23d70d2a94408cd83ced76ee8cf7ca157eb8de93 | [
"Apache-2.0",
"BSD-3-Clause",
"ISC",
"MIT",
"OFL-1.1"
] | permissive | espv/flink-plus-wrapper | e012aec26e46512d5145ea844cf85d2bec5f61df | d410581beabc4ce7f1de2f159059260235d17e73 | refs/heads/master | 2023-01-28T19:59:08.740942 | 2021-08-24T09:31:18 | 2021-08-24T09:31:18 | 244,843,748 | 1 | 0 | Apache-2.0 | 2022-12-14T20:46:01 | 2020-03-04T08:15:01 | Java | UTF-8 | Java | false | false | 10,785 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.flink.table.planner.utils;
import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.JobExecutionResult;
import org.apache.flink.api.common.cache.DistributedCache;
import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.dag.Transformation;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.runtime.state.AbstractStateBackend;
import org.apache.flink.runtime.state.StateBackend;
import org.apache.flink.streaming.api.CheckpointingMode;
import org.apache.flink.streaming.api.TimeCharacteristic;
import org.apache.flink.streaming.api.environment.CheckpointConfig;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.graph.StreamGraph;
import org.apache.flink.table.planner.delegation.PlannerBase;
import org.apache.flink.table.sinks.StreamTableSink;
import org.apache.flink.table.sources.TableSource;
import com.esotericsoftware.kryo.Serializer;
import java.io.Serializable;
import java.util.List;
/**
* This is dummy {@link StreamExecutionEnvironment}, only used for {@link PlannerBase#explain(List, boolean)} method.
*
* <P>{@link Transformation}s will be added into a {@link StreamExecutionEnvironment} when translating ExecNode to plan,
* and they will be cleared only when calling {@link StreamExecutionEnvironment#execute()} method.
*
* <p>{@link PlannerBase#explain(List, boolean)} method will not only print logical plan but also execution plan,
* translating will happen in explain method. If calling explain method before execute method, the transformations in
* StreamExecutionEnvironment is dirty, and execution result may be incorrect.
*
* <p>All set methods (e.g. `setXX`, `enableXX`, `disableXX`, etc) are disabled to prohibit changing configuration,
* all get methods (e.g. `getXX`, `isXX`, etc) will be delegated to real StreamExecutionEnvironment.
* `execute`, `getStreamGraph`, `getExecutionPlan` methods are also disabled, while `addOperator` method is enabled to
* let `explain` method add Transformations to this StreamExecutionEnvironment.
*
* <p>This class could be removed once the {@link TableSource} interface and {@link StreamTableSink} interface
* are reworked.
*/
public class DummyStreamExecutionEnvironment extends StreamExecutionEnvironment {
private final StreamExecutionEnvironment realExecEnv;
public DummyStreamExecutionEnvironment(StreamExecutionEnvironment realExecEnv) {
this.realExecEnv = realExecEnv;
}
@Override
public ExecutionConfig getConfig() {
return realExecEnv.getConfig();
}
@Override
public List<Tuple2<String, DistributedCache.DistributedCacheEntry>> getCachedFiles() {
return realExecEnv.getCachedFiles();
}
@Override
public StreamExecutionEnvironment setParallelism(int parallelism) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, setParallelism method is unsupported.");
}
@Override
public StreamExecutionEnvironment setMaxParallelism(int maxParallelism) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, setMaxParallelism method is unsupported.");
}
@Override
public int getParallelism() {
return realExecEnv.getParallelism();
}
@Override
public int getMaxParallelism() {
return realExecEnv.getMaxParallelism();
}
@Override
public StreamExecutionEnvironment setBufferTimeout(long timeoutMillis) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, setBufferTimeout method is unsupported.");
}
@Override
public long getBufferTimeout() {
return realExecEnv.getBufferTimeout();
}
@Override
public StreamExecutionEnvironment disableOperatorChaining() {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, disableOperatorChaining method is unsupported.");
}
@Override
public boolean isChainingEnabled() {
return realExecEnv.isChainingEnabled();
}
@Override
public CheckpointConfig getCheckpointConfig() {
return realExecEnv.getCheckpointConfig();
}
@Override
public StreamExecutionEnvironment enableCheckpointing(long interval) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, enableCheckpointing method is unsupported.");
}
@Override
public StreamExecutionEnvironment enableCheckpointing(long interval, CheckpointingMode mode) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, enableCheckpointing method is unsupported.");
}
@Override
public StreamExecutionEnvironment enableCheckpointing(long interval, CheckpointingMode mode, boolean force) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, enableCheckpointing method is unsupported.");
}
@Override
public StreamExecutionEnvironment enableCheckpointing() {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, enableCheckpointing method is unsupported.");
}
@Override
public long getCheckpointInterval() {
return realExecEnv.getCheckpointInterval();
}
@Override
public boolean isForceCheckpointing() {
return realExecEnv.isForceCheckpointing();
}
@Override
public CheckpointingMode getCheckpointingMode() {
return realExecEnv.getCheckpointingMode();
}
@Override
public StreamExecutionEnvironment setStateBackend(StateBackend backend) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, setStateBackend method is unsupported.");
}
@Override
public StreamExecutionEnvironment setStateBackend(AbstractStateBackend backend) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, setStateBackend method is unsupported.");
}
@Override
public StateBackend getStateBackend() {
return realExecEnv.getStateBackend();
}
@Override
public void setRestartStrategy(RestartStrategies.RestartStrategyConfiguration restartStrategyConfiguration) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, setRestartStrategy method is unsupported.");
}
@Override
public RestartStrategies.RestartStrategyConfiguration getRestartStrategy() {
return realExecEnv.getRestartStrategy();
}
@Override
public void setNumberOfExecutionRetries(int numberOfExecutionRetries) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, setNumberOfExecutionRetries method is unsupported.");
}
@Override
public int getNumberOfExecutionRetries() {
return realExecEnv.getNumberOfExecutionRetries();
}
@Override
public <T extends Serializer<?> & Serializable> void addDefaultKryoSerializer(Class<?> type, T serializer) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, addDefaultKryoSerializer method is unsupported.");
}
@Override
public void addDefaultKryoSerializer(Class<?> type, Class<? extends Serializer<?>> serializerClass) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, addDefaultKryoSerializer method is unsupported.");
}
@Override
public <T extends Serializer<?> & Serializable> void registerTypeWithKryoSerializer(Class<?> type, T serializer) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, registerTypeWithKryoSerializer method is unsupported.");
}
@Override
public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer> serializerClass) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, registerTypeWithKryoSerializer method is unsupported.");
}
@Override
public void registerType(Class<?> type) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, registerType method is unsupported.");
}
@Override
public void setStreamTimeCharacteristic(TimeCharacteristic characteristic) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, setStreamTimeCharacteristic method is unsupported.");
}
@Override
public TimeCharacteristic getStreamTimeCharacteristic() {
return realExecEnv.getStreamTimeCharacteristic();
}
@Override
public JobExecutionResult execute() throws Exception {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, execute method is unsupported.");
}
@Override
public JobExecutionResult execute(String jobName) throws Exception {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, execute method is unsupported.");
}
@Override
public JobExecutionResult execute(StreamGraph streamGraph) throws Exception {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, execute method is unsupported.");
}
@Override
public void registerCachedFile(String filePath, String name) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, registerCachedFile method is unsupported.");
}
@Override
public void registerCachedFile(String filePath, String name, boolean executable) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, registerCachedFile method is unsupported.");
}
@Override
public StreamGraph getStreamGraph() {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, getStreamGraph method is unsupported.");
}
@Override
public StreamGraph getStreamGraph(String jobName) {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, getStreamGraph method is unsupported.");
}
@Override
public String getExecutionPlan() {
throw new UnsupportedOperationException(
"This is a dummy StreamExecutionEnvironment, getExecutionPlan method is unsupported.");
}
}
| [
"espenvol@ifi.uio.no"
] | espenvol@ifi.uio.no |
c43bc1b5ae002c2d415dfa65cec8a5fd5182c2e3 | 704c6bfe2c88d4bffcc92c0cac590e687ac27688 | /android_dp_analysis_book_java/src/com/android/dp/book/chapter07/refactor/TaxiStrategy.java | 77b488668b5a626173df7846d5aed0eae38fdb08 | [] | no_license | hehonghui/android_dp_analysis_code | 2220069be400a951039b037b5d1f4a3a43e3f32b | 4fdf2a34292cf6f3472e67fdabf5c84ad6e23cf5 | refs/heads/master | 2020-04-12T22:02:25.420657 | 2016-07-21T09:42:21 | 2016-07-21T09:42:21 | 41,721,534 | 138 | 68 | null | null | null | null | UTF-8 | Java | false | false | 1,417 | java | /*
* The MIT License (MIT)
*
* Copyright (c) 2014-2015 Umeng, Inc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.android.dp.book.chapter07.refactor;
// 出租车计算策略
public class TaxiStrategy implements CalculateStrategy {
// 价格我们简单计算为 公里数 * 2
@Override
public int calculatePrice(int km) {
return km * 2;
}
}
| [
"bboyfeiyu@gmail.com"
] | bboyfeiyu@gmail.com |
bc7cebc9bc94cc4c0b2ddc7add154e66bbaf82c3 | d92029894a4f238e106432d61306958a8407fbb4 | /src/main/java/com/worldpay/offersapi/domain/entity/Merchant.java | 1adab055886ebbaf0a248c0930d8f81fdc30b256 | [] | no_license | KasunDon/OffersAPI | cc6fe4cb71f6d5cfd11e50be66b737472c8c6625 | cb42604ba1675c2cb398204daa07ab6488ae06ab | refs/heads/master | 2021-09-02T00:23:54.727429 | 2017-12-29T10:23:23 | 2017-12-29T11:13:45 | 115,712,533 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 204 | java | package com.worldpay.offersapi.domain.entity;
public class Merchant {
private int id;
public Merchant(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
| [
"kasunpdon@gmail.com"
] | kasunpdon@gmail.com |
d6efb36c9d674fa13ed470364445c2be7d0d8d26 | 013da895c3b75ce1320776d5b80bb43ad78b3ea5 | /Inheritance/Basics.java | 4aff9f1ebfe855db64c28b71fde874c45b9dd258 | [] | no_license | ayush0418/Java | a1e7372869257d96501ec7ba94a1c0891645dcfb | 478757a3b7c45fdda4f50dff3070fe5883fc3c74 | refs/heads/main | 2023-05-25T14:46:00.173152 | 2021-06-01T15:53:19 | 2021-06-01T15:53:19 | 332,198,465 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,201 | java | class Base{
public int x;
public int getX() { return x; }
public void setX(int x) {
System.out.println("I am in Parent Class and setting X now");
this.x = x;
}
}
//base class is inherited by a new class "Derived"
class Derived extends Base{ // "extends" keyword is used for inherit the properties of other class.
public int y;
public int getY() { return y; }
public void setY(int y) {
System.out.println("I am in Child Class and setting Y now");
this.y = y;
}
}
public class Basics {
public static void main(String[] args) {
// Creating an Object of base class
Base ob1 = new Base();
ob1.setX(4); //We can't set Y in base class
System.out.println(ob1.getX());
// Creating an object of derived class
Derived ob2 = new Derived();
ob2.setX(43); //We can set both X and Y in derived class because derived class has properties of base class also.
System.out.println(ob2.getX());
Derived ob3 = new Derived();
ob3.setY(18);
System.out.println(ob3.getY());
}
}
| [
"noreply@github.com"
] | ayush0418.noreply@github.com |
46c5d5760bbceeb699dc18e5734ac594c2b4141f | 14aac3e1cfa0257ae097a0ddb08c1b1cb5650d0f | /src/test/java/com/weatherapi/it/JokeControllerItTests.java | 52f475b7595ce8f4b1fff2ced2584f4a772b52eb | [] | no_license | apanashchenko/weather-api | 7d7508fe9497ddbdd4a7c900160da3c5decdedee | 8a920f757e6764df2372cc76d4074a0577f0bf0f | refs/heads/master | 2020-07-09T13:41:30.186375 | 2019-10-22T12:35:00 | 2019-10-22T12:35:00 | 203,984,541 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,272 | java | package com.weatherapi.it;
import com.weatherapi.model.Joke;
import com.weatherapi.model.JokeValue;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Created by alpa on 2019-08-29
*/
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class JokeControllerItTests extends BaseItTest {
@Test
public void canGetJokeTest() {
this.webClient.get()
.uri(uriBuilder -> uriBuilder.path("/joke").build())
.exchange()
.expectStatus()
.isOk()
.expectBody(Joke.class)
.value(response -> {
assertThat(response.getType()).isEqualToIgnoringCase("success");
JokeValue value = response.getValue();
assertThat(value.getId()).isNotEqualTo(0);
assertThat(value.getJoke()).isNotNull().isNotEmpty();
assertThat(value.getCategories()).isNullOrEmpty();
});
}
}
| [
"alpa@ciklum.com"
] | alpa@ciklum.com |
0cdcd1ac06e4e15855c9b5eda6a33860c34e2b17 | 28a5a4f56bc798e34eaa8d4faec3176c7a915666 | /chatRoom/src/net/guoquan/network/chat/chatRoom/server/Handler.java | 954b61793aa09e966cf869f5bf24186089815081 | [] | no_license | guoquan/lobbytalk | 941c12372e7cb7fbb69ab4bab742ede63b71488a | 26e9b2a61f01eb3558767a9d68762d51efc487bc | refs/heads/master | 2021-01-22T05:15:46.721866 | 2008-11-02T12:14:16 | 2008-11-02T12:14:16 | 32,121,669 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 103 | java | package net.guoquan.network.chat.chatRoom.server;
public interface Handler extends Runnable {
}
| [
"guoquan@guoquan.net@2166485e-a836-11dd-8af2-493fb0bb9f7c"
] | guoquan@guoquan.net@2166485e-a836-11dd-8af2-493fb0bb9f7c |
5f76543a23119ad2e04d1e90e992a35a6426f695 | 316e7b55e04379c5534f1ec5ade1e7855671051b | /Lindley.RTM/src/pe/lindley/ficha/ws/bean/ActualizarComercialResponse.java | e667de123ed41e413385bce2f59c67865a3d6adb | [] | no_license | jels1988/msonicdroid | 5a4d118703b1b3449086a67f9f412ca5505f90e9 | eb36329e537c4963e1f6842d81f3c179fc8670e1 | refs/heads/master | 2021-01-10T09:02:11.276309 | 2013-07-18T21:16:08 | 2013-07-18T21:16:08 | 44,779,314 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 146 | java | package pe.lindley.ficha.ws.bean;
import pe.lindley.util.ResponseBase;
public class ActualizarComercialResponse extends ResponseBase{
}
| [
"mzegarra@gmail.com"
] | mzegarra@gmail.com |
bd5efc3f44d76c9c8b189575be348bec51b6d8bd | ee65ee8d11ee71533a4e305b95e29eac3c386142 | /src/xenoteo/com/github/lab7_8_9/ao/request/ConsumerRequest.java | 1788e8c9d54c403409ffa38ba453fc7bdaac112e | [] | no_license | xenoteo/Concurrent-Computing | f1337db8b5aebb76ea48580d9d6d7301a985e24b | 0e9e4cb01b1d98457ddefb4b7b6be3848fb555b6 | refs/heads/main | 2023-02-04T20:26:38.838550 | 2020-12-22T19:02:44 | 2020-12-22T19:02:44 | 304,124,269 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 863 | java | package xenoteo.com.github.lab7_8_9.ao.request;
import xenoteo.com.github.lab7_8_9.ao.Buffer;
import xenoteo.com.github.lab7_8_9.ao.future.ConsumerFuture;
import xenoteo.com.github.lab7_8_9.ao.future.Future;
/**
* Method request for consumers.
*/
public class ConsumerRequest implements MethodRequest{
private final Buffer buffer;
private final ConsumerFuture future;
private final int n;
public ConsumerRequest(Buffer buffer, int n){
this.buffer = buffer;
future = new ConsumerFuture();
this.n = n;
}
@Override
public boolean guard() {
return buffer.hasEnoughElements(n);
}
@Override
public void execute() {
buffer.consume(this);
future.finish();
}
public Future getFuture() {
return future;
}
public int getN() {
return n;
}
}
| [
"fedorovxa@gmail.com"
] | fedorovxa@gmail.com |
bd7040f2de433a7c1c5a4399caf536a583117178 | 54cbf87434d5107019e219b889554e77a695e82b | /app/src/main/java/com/example/heyikun/heheshenghuo/controller/user/UserMiBaoVerifyFragment.java | a85429c411e5e02270110bdae247a41e24caf6cb | [] | no_license | zhangchao1215/HeheTong | f7a5adff400db5938ebab91d711f7a0a37fc95ef | 5db688e04a92e32ecbbea30b3273a0c45dcdae36 | refs/heads/master | 2020-04-13T18:35:45.526530 | 2018-12-28T06:17:40 | 2018-12-28T06:17:40 | 163,379,186 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,572 | java | package com.example.heyikun.heheshenghuo.controller.user;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.example.heyikun.heheshenghuo.R;
import com.example.heyikun.heheshenghuo.modle.base.BaseFragment;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
import butterknife.Unbinder;
/**
* Created by hyk on 2017/9/28.
* 1:创建人hyk : 张超
* <p>
* 2:创建时间2017/9/28
* <p>
* 3:类描述: 进行验证密保
* <p>
* 4:类功能: 进行替换显示
*/
public class UserMiBaoVerifyFragment extends BaseFragment {
@BindView(R.id.MiBao_questionTextOne)
TextView MiBaoQuestionTextOne;
@BindView(R.id.MiBao_mTextSelectorOne)
TextView MiBaoMTextSelectorOne;
@BindView(R.id.MiMao_question_One)
RelativeLayout MiMaoQuestionOne;
@BindView(R.id.MiBao_answerOne_edit)
EditText MiBaoAnswerOneEdit;
@BindView(R.id.MiBao_questionTextTwo)
TextView MiBaoQuestionTextTwo;
@BindView(R.id.MiBao_mTextSelectorTwo)
TextView MiBaoMTextSelectorTwo;
@BindView(R.id.MiMao_question_Two)
RelativeLayout MiMaoQuestionTwo;
@BindView(R.id.MiBao_answerTwo_edit)
EditText MiBaoAnswerTwoEdit;
@BindView(R.id.MiBao_questionTextThree)
TextView MiBaoQuestionTextThree;
@BindView(R.id.MiBao_mTextSelectorThree)
TextView MiBaoMTextSelectorThree;
@BindView(R.id.MiMao_question_Three)
RelativeLayout MiMaoQuestionThree;
@BindView(R.id.MiBao_answerThree_edit)
EditText MiBaoAnswerThreeEdit;
@BindView(R.id.MiBao_mButSubmit)
Button MiBaoMButSubmit;
Unbinder unbinder;
private PopupWindow ppw;
private PopupWindow popupWindow;
private ListView listView;
private String[] MiBaoqeustion = {"您最喜欢的历史人物姓名是", "您家的地址是", "您配偶的姓名是?", "您小学班主任的姓名是",
"您第一次旅行的目的地是哪里?", "您暗恋的第一个人的姓名是?", "您大学的宿舍号是? ",
"对您影响最大人的姓名是?", "您的第一个宠物叫什么? ", "您的工号是? "};
private List<String> mList;
private int mquestionid;
private String questionEditOne;
private String questionEditTwo;
private String questionEditThree;
private FragmentManager manager;
private FragmentTransaction transaction;
@Override
protected int getLayoutId() {
return R.layout.activity_include_mibao_message;
}
@Override
protected void initData() {
}
@Override
protected void initView(View view) {
init();
manager = getFragmentManager();
transaction = manager.beginTransaction();
}
@Override
protected void initListener() {
}
private void init() {
mList = new ArrayList<>();
for (int i = 0; i < MiBaoqeustion.length; i++) {
mList.add(MiBaoqeustion[i]);
}
//使EditText不可编辑
MiBaoAnswerOneEdit.setEnabled(false);
MiBaoAnswerTwoEdit.setEnabled(false);
MiBaoAnswerThreeEdit.setEnabled(false);
questionEditOne = MiBaoAnswerOneEdit.getText().toString().trim();
questionEditTwo = MiBaoAnswerTwoEdit.getText().toString().trim();
questionEditThree = MiBaoAnswerThreeEdit.getText().toString();
//Edittext的滑动监听,让button变换颜色
MiBaoAnswerOneEdit.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (MiBaoAnswerOneEdit.getText().length() > 0) {
MiBaoMButSubmit.setBackground(getResources().getDrawable(R.drawable.queding_but));
} else {
MiBaoMButSubmit.setBackground(getResources().getDrawable(R.drawable.next_but));
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
@OnClick({R.id.MiMao_question_One, R.id.MiMao_question_Two, R.id.MiMao_question_Three, R.id.MiBao_mButSubmit})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.MiMao_question_One:
showPopupWindow(view);
break;
case R.id.MiMao_question_Two:
showPopupWindow(view);
break;
case R.id.MiMao_question_Three:
showPopupWindow(view);
break;
case R.id.MiBao_mButSubmit:
questionEditOne = MiBaoAnswerOneEdit.getText().toString().trim();
questionEditTwo = MiBaoAnswerTwoEdit.getText().toString().trim();
questionEditThree = MiBaoAnswerThreeEdit.getText().toString();
if (questionEditOne.isEmpty()) {
Toast.makeText(getContext(), "问题一不能为空", Toast.LENGTH_SHORT).show();
} else if (questionEditTwo.isEmpty()) {
Toast.makeText(getContext(), "问题二不能为空", Toast.LENGTH_SHORT).show();
} else if (questionEditThree.isEmpty()) {
Toast.makeText(getContext(), "问题三不能为空", Toast.LENGTH_SHORT).show();
} else {
// mPopWindow();
//在这一步对已经填写的问题进行验证,如果不对就不让替换到下一页面,进行验证手机
transaction.replace(R.id.mEmail_FrameLayout, new UserSettingNewNumberFragment());
transaction.commit();
}
break;
}
}
// TODO: 2017/9/27 弹出ppw,并给里面的listview设置点击事件 。
private void showPopupWindow(View v) {
mquestionid = v.getId();
View view = LayoutInflater.from(getContext()).inflate(R.layout.activity_question_listview, null);
listView = (ListView) view.findViewById(R.id.MiBao_Listview);
listView.setAdapter(new MyListView(mList));
ppw = new PopupWindow(view, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
//设置背景颜色
ppw.setBackgroundDrawable(new BitmapDrawable());
//设置外部可点击
ppw.setOutsideTouchable(true);
ppw.setFocusable(true);
ppw.setClippingEnabled(false);
ppw.showAsDropDown(v, 50, 0, Gravity.CENTER);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String str = mList.get(position);
if (mquestionid == R.id.MiMao_question_One) {
MiBaoQuestionTextOne.setText(str);
MiBaoAnswerOneEdit.setEnabled(true);
} else if (mquestionid == R.id.MiMao_question_Two) {
MiBaoQuestionTextTwo.setText(str);
MiBaoAnswerTwoEdit.setEnabled(true);
} else if (mquestionid == R.id.MiMao_question_Three) {
MiBaoQuestionTextThree.setText(str);
MiBaoAnswerThreeEdit.setEnabled(true);
}
ppw.dismiss();
}
});
}
// TODO: 2017/9/27 弹出ppw 提交设置的密保问题,在调回到最当初的页面
private void mPopWindow() {
backgroundAlpha(0.4f);
View view = LayoutInflater.from(getContext()).inflate(R.layout.activity_user_ppw_iknow, null);
Button button = (Button) view.findViewById(R.id.mBut_IKnow);
TextView Tv = (TextView) view.findViewById(R.id.mText_LoginPwd);
Tv.setText("请牢记您的密保答案");
popupWindow = new PopupWindow(view, WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
true);
//设置背景颜色
popupWindow.setBackgroundDrawable(new BitmapDrawable());
//设置外部不可点击
popupWindow.setOutsideTouchable(false);
popupWindow.setFocusable(true);
popupWindow.setClippingEnabled(false);
//popupwindow的弹出位置
popupWindow.showAtLocation(getView().findViewById(R.id.MiBao_ppw_TitleLinear), Gravity.CENTER, 0, 0);
//里面button的点击事件
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
backgroundAlpha(1f);
Intent intent = new Intent(getContext(), AccountSecurityActivity.class);
startActivity(intent);
}
});
popupWindow.setOnDismissListener(new poponDismissListener());
}
// TODO: 2017/9/15 这是设置 背景为半透明
public void backgroundAlpha(float bgAlpha) {
WindowManager.LayoutParams lp = getActivity().getWindow().getAttributes();
lp.alpha = bgAlpha; //0.0-1.0
getActivity().getWindow().setAttributes(lp);
}
class poponDismissListener implements PopupWindow.OnDismissListener {
@Override
public void onDismiss() {
// TODO Auto-generated method stub
//Log.v("List_noteTypeActivity:", "我是关闭事件");
backgroundAlpha(1f);
}
}
// TODO: 2017/9/27 listview的内部类适配器
class MyListView extends BaseAdapter {
private List<String> list;
public MyListView(List<String> list) {
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) {
MyHodler hodler = null;
if (convertView == null) {
hodler = new MyHodler();
convertView = LayoutInflater.from(getContext()).inflate(R.layout.activity_user_mibao_item, null);
hodler.mText = (TextView) convertView.findViewById(R.id.MiBao_questionItemText);
convertView.setTag(hodler);
} else {
hodler = (MyHodler) convertView.getTag();
}
String s = mList.get(position);
hodler.mText.setText(s);
return convertView;
}
class MyHodler {
private TextView mText;
}
}
}
| [
"670290530@qq.com"
] | 670290530@qq.com |
f5823feec01650794df7306b00d24cabb9ba5efd | 7173721d06667129f452f1c16170314f2c3d72b5 | /ant-impl/src/main/java/com/intellij/lang/ant/validation/AntMissingPropertiesFileInspection.java | 42b037f9c4918496e549f0a4a2562fa40b5887ce | [
"Apache-2.0"
] | permissive | consulo/consulo-apache-ant | 52f6238c3e7026fd882d9047e53f408b50c7214e | 4ec82d1a536af775ff9b84f3b2aad4f2be177cf3 | refs/heads/master | 2023-08-22T13:29:44.398532 | 2023-06-12T06:54:43 | 2023-06-12T06:54:43 | 12,987,813 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,076 | java | /*
* Copyright 2000-2009 JetBrains s.r.o.
*
* 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.intellij.lang.ant.validation;
import javax.annotation.Nonnull;
import com.intellij.lang.ant.AntBundle;
import com.intellij.lang.ant.dom.AntDomProperty;
import com.intellij.lang.properties.psi.PropertiesFile;
import consulo.language.psi.PsiFileSystemItem;
import consulo.xml.util.xml.DomElement;
import consulo.xml.util.xml.highlighting.DomElementAnnotationHolder;
import consulo.xml.util.xml.highlighting.DomHighlightingHelper;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
public class AntMissingPropertiesFileInspection extends AntInspection {
@NonNls private static final String SHORT_NAME = "AntMissingPropertiesFileInspection";
@Nls
@Nonnull
public String getDisplayName() {
return AntBundle.message("ant.missing.properties.file.inspection");
}
@NonNls
@Nonnull
public String getShortName() {
return SHORT_NAME;
}
protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) {
if (element instanceof AntDomProperty) {
final AntDomProperty property = (AntDomProperty)element;
final String fileName = property.getFile().getStringValue();
if (fileName != null) {
final PsiFileSystemItem file = property.getFile().getValue();
if (!(file instanceof PropertiesFile)) {
holder.createProblem(property.getFile(), AntBundle.message("file.doesnt.exist", fileName));
}
}
}
}
}
| [
"vistall.valeriy@gmail.com"
] | vistall.valeriy@gmail.com |
92122455dd73395819fa919070c702c79436e659 | 7e682c397eadec69d0006ed8722fb58230eb0288 | /m/src/dao/mypage/myBoard/myBoardDaoImpl.java | f80e2c9ae989a5d3c33882254ccfe6f80d9041d1 | [] | no_license | gmlrud1211/Web_semi | 17323b88e80b235548416b1b596c0c2584fb6a20 | d14a91064960565eb95f79cdda64b7cfa8a7ef1b | refs/heads/master | 2020-04-17T21:27:24.831022 | 2019-04-29T06:59:32 | 2019-04-29T06:59:32 | 166,950,473 | 1 | 4 | null | 2019-04-24T16:01:41 | 2019-01-22T07:45:04 | Java | UTF-8 | Java | false | false | 2,977 | java | package dao.mypage.myBoard;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import dto.Message;
import dto.MyBoard;
import util.DBConn;
import util.Paging;
public class myBoardDaoImpl implements myBoardDao {
private Connection conn = DBConn.getConnection();
private PreparedStatement ps;
private ResultSet rs;
@Override
public MyBoard selectBoardByBno(int b_no) {
String sql = "";
sql +="SELECT * FROM board";
sql +=" WHERE b_no=?";
MyBoard mb = new MyBoard();
try {
ps = conn.prepareStatement(sql);
ps.setInt(1, b_no);
rs = ps.executeQuery();
while(rs.next()) {
mb.setB_no(rs.getInt("b_no"));
mb.setU_no(rs.getInt("u_no"));
mb.setB_head(rs.getString("b_head"));
mb.setB_title(rs.getString("b_title"));
mb.setB_upcount(rs.getInt("b_upcount"));
mb.setB_count(rs.getInt("b_count"));
mb.setB_date(rs.getDate("b_date"));
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if(rs!=null) rs.close();
if(ps!=null) ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return mb;
}
@Override
public int cntMyBoard(int u_no) {
String sql = "";
sql +="SELECT COUNT(*) FROM board";
sql +=" WHERE u_no=?";
int cnt=0;
try {
ps = conn.prepareStatement(sql);
ps.setInt(1, u_no);
rs = ps.executeQuery();
rs.next();
cnt = rs.getInt(1);
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if(rs!=null) rs.close();
if(ps!=null) ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return cnt;
}
@Override
public List selectMyBoardPagingList(int u_no, Paging paging) {
String sql = "";
sql += "SELECT * FROM (";
sql += " SELECT rownum rnum, B.* FROM(";
sql += " SELECT * FROM board";
sql += " WHERE u_no=?";
sql += " ORDER BY b_no";
sql += " ) B";
sql += " ORDER BY rnum";
sql += ") R";
sql += " WHERE rnum BETWEEN ? AND ?";
List<MyBoard> mbList = new ArrayList<>();
try {
ps = conn.prepareStatement(sql);
ps.setInt(1, u_no);
ps.setInt(2, paging.getStartNo());
ps.setInt(3, paging.getEndNo());
rs = ps.executeQuery();
while(rs.next()) {
MyBoard mb = new MyBoard();
mb.setB_no(rs.getInt("b_no"));
mb.setU_no(rs.getInt("u_no"));
mb.setB_head(rs.getString("b_head"));
mb.setB_title(rs.getString("b_title"));
mb.setB_upcount(rs.getInt("b_upcount"));
mb.setB_count(rs.getInt("b_count"));
mb.setB_date(rs.getDate("b_date"));
mbList.add(mb);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if(rs!=null) rs.close();
if(ps!=null) ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return mbList;
}
}
| [
"gmlrud1211@naver.com"
] | gmlrud1211@naver.com |
bdde9af53c8a9c3eb62e0e32d8a58257bdb9b280 | 63177fab51bebef02adca1150e899d155b80a329 | /src/main/java/com/mwave/SpringKeycloak/SecurityConfig.java | 87eebe9e4feaa659f2a357856ed1ef0c42ad0ea7 | [] | no_license | ricardogayer/spring-keycloak | e68b52c34b7ffd536f5dcb36b0f0732681e4e583 | 6db02f596295484562edb9fb8f034cf0f4844372 | refs/heads/main | 2023-02-17T10:42:43.078004 | 2021-01-21T02:04:52 | 2021-01-21T02:04:52 | 330,677,237 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,430 | java | package com.mwave.SpringKeycloak;
import org.keycloak.adapters.KeycloakConfigResolver;
import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver;
import org.keycloak.adapters.springsecurity.KeycloakSecurityComponents;
import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider;
import org.keycloak.adapters.springsecurity.client.KeycloakClientRequestFactory;
import org.keycloak.adapters.springsecurity.client.KeycloakRestTemplate;
import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper;
import org.springframework.security.core.session.SessionRegistryImpl;
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
import org.springframework.security.web.server.SecurityWebFilterChain;
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(jsr250Enabled = true, prePostEnabled = true)
@ComponentScan(basePackageClasses = KeycloakSecurityComponents.class)
public class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
@Autowired
public KeycloakClientRequestFactory keycloakClientRequestFactory;
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
http.csrf().disable()
.authorizeRequests()
.antMatchers("/public/**","/actuator/**").permitAll()
.anyRequest()
.authenticated()
;
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();
keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper());
auth.authenticationProvider(keycloakAuthenticationProvider);
}
@Bean
@Override
protected SessionAuthenticationStrategy sessionAuthenticationStrategy() {
return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl());
}
@Bean
public KeycloakConfigResolver KeycloakConfigResolver() {
return new KeycloakSpringBootConfigResolver();
}
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public KeycloakRestTemplate keycloakRestTemplate() {
return new KeycloakRestTemplate(keycloakClientRequestFactory);
}
}
| [
"ricardo.r.gayer@gmail.com"
] | ricardo.r.gayer@gmail.com |
47fb8686660882a374d4d27c6c995710b3acdcb1 | 0ef22423f520792e2427d9976659a9762eacd003 | /FMS/src/com/syntelinc/fms/logic/mappers/EmployeeMapper.java | d1218f683fe82d6c6a2766813bbd64c911eff8a1 | [] | no_license | hy8246/FMS | a8af1dfbfa096c8a71a0b80b2818e093ceb3d94e | b814c96e0a38d4a5239a506e1b777c5794be43fc | refs/heads/master | 2020-04-02T08:30:26.055689 | 2018-10-23T02:43:30 | 2018-10-23T02:43:30 | 154,247,484 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 764 | java | package com.syntelinc.fms.logic.mappers;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.jdbc.core.RowMapper;
import com.syntelinc.fms.logic.Employee;
import com.syntelinc.fms.logic.queries.LocationQuery;
public class EmployeeMapper implements RowMapper<Employee>{
@Override
public Employee mapRow(ResultSet rs, int arg1) throws SQLException {
Employee e = new Employee();
e.setEmployeeID(rs.getInt("eid"));
e.setEmployeeName(rs.getString("ename"));
e.setEmployeeEmail(rs.getString("email"));
e.setAuthType(rs.getString("eauthtype"));
int homeLocID = rs.getInt("e_home_loc");
e.setEmployeeHomeLocation(new LocationQuery().getLocationByID(homeLocID));
return e;
}
}
| [
"hy8246@gmail.com"
] | hy8246@gmail.com |
33fe7264ab98a6adff2c799a1b9118bdad29384c | 978f9e569ab48a8ce131ccbcf26f5aaeab260162 | /gwt263/src/main/java/be/nmine/client/views/widget/BootstrapTextBox.java | e3c8a8bb7c5708c5ce39bfcd37cbb53d393a02d4 | [] | no_license | nmine/poc | d3d724b47180bc8f0fc77395824bf68e814b1ece | fdc581c43b129627a1822f5a4c36f78e3e1243d2 | refs/heads/master | 2020-06-06T20:24:07.360864 | 2014-02-11T17:09:04 | 2014-02-11T17:09:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,039 | java | package be.nmine.client.views.widget;
import be.nmine.client.views.event.ChangeColorEvent;
import be.nmine.client.views.event.ChangeColorEventHandler;
import be.nmine.client.views.event.HasChangeColorEventHandlers;
import com.google.gwt.event.dom.client.HasKeyUpHandlers;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.uibinder.client.UiConstructor;
import com.google.gwt.user.client.ui.TextBox;
public class BootstrapTextBox extends
AbstractBootstrapValueBox<TextBox, String> implements HasKeyUpHandlers,
HasChangeColorEventHandlers {
private EventBus eventBus;
@UiConstructor
public BootstrapTextBox(String label) {
super(new TextBox(), label);
getValuebox().addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
// Ignore return presses - workaround for Google Chrome
// very first time you are in a textbox and press enter, it
// refreshes the page.
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
event.preventDefault();
}
}
});
}
@Override
public String getValue() {
return super.getValue() != null && super.getValue().trim().length() > 0 ? super
.getValue().trim() : null;
}
public EventBus getEventBus() {
return eventBus;
}
public void updateMask(String mask) {
setMask(mask);
addMask(getValuebox().getElement(), mask, maskReverse);
}
@Override
public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
return valuebox.addKeyUpHandler(handler);
}
@Override
public HandlerRegistration addHasChangeColorEventHandler(
ChangeColorEventHandler handler) {
return addHandler(handler, ChangeColorEvent.getType());
}
public void setEventBus(EventBus eventBus) {
this.eventBus = eventBus;
}
}
| [
"nicolas.mine11@gmail.com"
] | nicolas.mine11@gmail.com |
b4925ba4367981532ec7087573ccd1dede378a8e | 4ddaca5dae1ac44ecbb8030734b4cb77cd16becd | /Leetcode/Solution_978_LongestTurbulentArray.java | 9eadb593f4802426af45f67832b546bc6ef6c012 | [
"Apache-2.0"
] | permissive | dgr8akki/DS-Algo-Made-Easy-With-Aakash | 55aad8cb22226322773871df4be2b53d12ec366a | ccb6f6323af47858a6647b72fbde79fe81538eb9 | refs/heads/develop | 2021-06-28T06:09:06.239674 | 2020-10-27T14:26:08 | 2020-10-27T14:26:08 | 144,481,699 | 9 | 0 | Apache-2.0 | 2020-10-05T09:13:49 | 2018-08-12T16:14:25 | Java | UTF-8 | Java | false | false | 423 | java | package Leetcode;
class Solution_978_LongestTurbulentArray {
public int maxTurbulenceSize(int[] A) {
int pre = 0, cur = 0, len = 1, res = 1;
for (int i = 1; i < A.length; i++) {
cur = Integer.compare(A[i], A[i - 1]);
if (cur * pre == -1)
len++;
else if (cur == 0)
len = 1;
else
len = 2;
res = Math.max(res, len);
pre = cur;
}
return res;
}
}
| [
"pahujaaakash5@gmail.com"
] | pahujaaakash5@gmail.com |
6585a5f3537dc86b75e7dcd3e1a9ae6442ebfe7f | decf3197d3453f18f6ea37de2659a1025c5015c0 | /src/org/campus02/ecom/BasketDataLoader.java | f90816b15c91c809785ed5b36f7b2f314e881db9 | [] | no_license | LooterLghtBringr/PR2_ECommerce | 47924d98f1b4308b5a7bc2bd9144cab8bfb13220 | c70f48c7981c57bf1bc14a87052ec351349866b6 | refs/heads/master | 2023-04-22T10:50:39.963751 | 2021-05-06T23:11:19 | 2021-05-06T23:11:19 | 365,059,235 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,704 | java | package org.campus02.ecom;
import com.google.gson.Gson;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
public class BasketDataLoader {
public static ArrayList<BasketData> load(String path) throws DataFileException {
ArrayList<BasketData> basketData = null;
try
{
basketData = new ArrayList<>();
File f = new File(path);
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
String line = "";
while((line = br.readLine()) != null)
{
BasketData bd = new Gson().fromJson(line, BasketData.class);
basketData.add(bd);
}
}
catch (Exception e)
{
throw new DataFileException("Error", e);
}
return basketData;
}
public static ArrayList<BasketData> load(String path, Comparator<BasketData> comparator) throws DataFileException {
ArrayList<BasketData> basketData = null;
try
{
basketData = new ArrayList<>();
File f = new File(path);
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
String line = "";
while((line = br.readLine()) != null)
{
BasketData bd = new Gson().fromJson(line, BasketData.class);
basketData.add(bd);
}
Collections.sort(basketData, comparator);
}
catch (Exception e)
{
throw new DataFileException("Error", e);
}
return basketData;
}
}
| [
"skedelj.mario@gmx.at"
] | skedelj.mario@gmx.at |
74e0055434ec17b183c5fb9136a4476cafa7706e | a0450e9d6005cef113b83bafe6e591d15c835ed8 | /src/main/java/com/enat/sharemanagement/config/BatchConfiguration.java | 47715099320571438db601336ba4a9a6d2d56ef2 | [] | no_license | birhaneTinsae/share-management | 66dddc5a343bcdf453ade5fc6e70c7096af52c75 | 006c8028e4bc2fd875cb42ae9c8e54ed91f545be | refs/heads/master | 2023-03-22T23:05:32.409132 | 2021-01-29T09:08:09 | 2021-01-29T09:08:09 | 330,198,878 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,802 | java | package com.enat.sharemanagement.config;
import com.enat.sharemanagement.batch.AttendanceInput;
import com.enat.sharemanagement.batch.AttendanceItemProcessor;
import com.enat.sharemanagement.batch.AttendanceOutput;
import com.enat.sharemanagement.batch.JobCompletionNotificationListener;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.JobScope;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.database.BeanPropertyItemSqlParameterSourceProvider;
import org.springframework.batch.item.database.JdbcBatchItemWriter;
import org.springframework.batch.item.database.builder.JdbcBatchItemWriterBuilder;
import org.springframework.batch.item.file.FlatFileItemReader;
import org.springframework.batch.item.file.MultiResourceItemReader;
import org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder;
import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.ResourcePatternUtils;
import javax.sql.DataSource;
import java.io.IOException;
@Configuration
@EnableBatchProcessing
public class BatchConfiguration {
//
// public final JobBuilderFactory jobBuilderFactory;
//
// public final StepBuilderFactory stepBuilderFactory;
//// @Value("${storage.active}")
//// private String path;
//// private ResourceLoader resourceLoader;
//
// public BatchConfiguration(JobBuilderFactory jobBuilderFactory,
// StepBuilderFactory stepBuilderFactory,
// ResourceLoader resourceLoader) {
// this.jobBuilderFactory = jobBuilderFactory;
// this.stepBuilderFactory = stepBuilderFactory;
//// this.resourceLoader = resourceLoader;
// }
//
// @Bean
// @JobScope
// public FlatFileItemReader<AttendanceInput> reader() {
// return new FlatFileItemReaderBuilder<AttendanceInput>()
// .name("pinItemReader")
//// .linesToSkip(8)
// .delimited()
// .names("serialNo", "code", "denomination", "status", "expireAt", "createdAt", "purchaseOrderId","active")
// .fieldSetMapper(new BeanWrapperFieldSetMapper<>() {{
// setTargetType(AttendanceInput.class);
// }})
// .build();
// }
//
//// @Bean
//// @JobScope
//// public MultiResourceItemReader<AttendanceInput> multiResourceItemReader() {
//// MultiResourceItemReader<AttendanceInput> multiResourceItemReader = new MultiResourceItemReader<>();
//// // multiResourceItemReader.setResources(loadResources());
////// FileSystemResource resource = new FileSystemResource("/home/birhane/pins-file/active/*.csv");
////// Resource[] resources = {resource};
////// System.out.println(path);
//// multiResourceItemReader.setResources(loadResources());
//// // multiResourceItemReader.setResources(resources);
//// multiResourceItemReader.setDelegate(reader());
//// return multiResourceItemReader;
//// }
//
// @Bean(name = "jdbcWriter")
// public JdbcBatchItemWriter<AttendanceOutput> writer(DataSource dataSource) {
// return new JdbcBatchItemWriterBuilder<AttendanceOutput>()
// .itemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>())
// .sql("INSERT INTO pins (serial_no, code,denomination,status,expire_at,created_at,updated_at,created_by,purchase_order_id,active,status_change_count) VALUES (:serialNo, :code,:denomination,:status,:expireAt,:createdAt,:updatedAt,:createdBy,:purchaseOrderId,:active,0)")
// .dataSource(dataSource)
// .build();
// }
//
// @Bean
// public AttendanceItemProcessor processor() {
// return new AttendanceItemProcessor();
// }
//
//
// @Bean
// public Job importUserJob(JobCompletionNotificationListener listener, Step step1) {
// return jobBuilderFactory.get("importPinsJob")
// .incrementer(new RunIdIncrementer())
// .listener(listener)
// .flow(step1)
// .end()
// .build();
// }
//
//// @Bean
//// public Step step1(@Qualifier("jdbcWriter") ItemWriter<AttendanceOutput> itemWriter) {
//// return stepBuilderFactory.get("step1")
//// .<AttendanceInput, AttendanceOutput>chunk(100)
//// .reader(multiResourceItemReader())
//// .processor(processor())
//// .writer(itemWriter)
//// .build();
//// }
//
//// public Resource[] loadResources() {
//// try {
////
//// return ResourcePatternUtils.getResourcePatternResolver(resourceLoader)
//// .getResources(storageProperties.getPinFiles());//getResources("classpath:/input/*.csv");
//// } catch (IOException ex) {
//// // Logger.getLogger(BatchConfiguration.class.getName()).log(Level.SEVERE, null, ex);
//// }
//// return null;
//// }
}
| [
"birhane.tinsaa@gmail.com"
] | birhane.tinsaa@gmail.com |
7080fdf1b51ae0a88f3c61e7276023b60fdf675f | ea7abd6f26565d34297fea65d19e1d18de59974b | /src/com/zhuoer/util/util.java | 657940e1c8020b6ae0557a6cffdfa2a152d174c5 | [] | no_license | Wanlanhua/zhuoer | 67c6a3cae11bdfd8077140a14cd211e343b5850a | e7c6079bd156f93046c4f8393fd7cdc7607400be | refs/heads/master | 2020-09-15T23:03:53.396565 | 2019-11-23T11:32:10 | 2019-11-23T11:32:10 | 223,578,186 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,529 | java | package com.zhuoer.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class util {
private static final String URL="jdbc:mysql://localhost:3306/zhuoer_database?useUnicode=true&characterEncoding=UTF-8";
private static final String USER ="root";
// private static final String PASSWORD="3183328947";
private static final String PASSWORD="g,2?x!8;y";
private static Connection conn=null;
static
{
try {
Class.forName("com.mysql.jdbc.Driver");//��������
conn= DriverManager.getConnection(URL, USER, PASSWORD);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Connection getconn()
{
return conn;
}
public static void closeConn(ResultSet rs,PreparedStatement pstmt,Connection conn)
{
if(rs!=null)
{
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(pstmt!=null)
{
try {
pstmt.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(conn!=null)
{
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
| [
"2968035392.com"
] | 2968035392.com |
7d7a2567cc71b12125d1e328e6bac12e1acbea9f | 5130ffc3fbf7c5a4952226122b01d6a422594bf6 | /login-api/src/main/java/at/vulperium/login/enums/RolleUndBerechtigung.java | d8e733c7bfb4114824ba36b3843bda5a609f3c5c | [] | no_license | tellrug/login-app | d3c663a341f2cc41bc4a3b246a838e02cbe5e9de | 68991fe758011637ae3e551cbd15f64833269cb7 | refs/heads/master | 2021-05-15T05:20:29.130709 | 2018-01-11T21:37:10 | 2018-01-11T21:37:10 | 117,005,759 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 215 | java | package at.vulperium.login.enums;
import java.io.Serializable;
/**
* Created by 02ub0400 on 11.07.2017.
*/
public interface RolleUndBerechtigung extends Serializable {
String getBezeichnung();
}
| [
"0625267@gmail.com"
] | 0625267@gmail.com |
24078ae47ab5443c7d3f2bdc4e32ba61d23ed9dd | 601df01523a255b11587f1517e55947e2f1ee090 | /FastCampus/src/chapter02/ch15/Tex.java | 9c09a8a0d2eee2046c5c92971f2d2a606ac4b68a | [] | no_license | xjvmdutl/FastCampus | 576b05973ebc9e2c04d294b4be197ca8b1fc1c6a | af39a71669763c5a2b632d0c43b1d7f4131e141c | refs/heads/master | 2023-06-19T23:48:05.263305 | 2021-07-19T07:33:31 | 2021-07-19T07:33:31 | 381,668,025 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 319 | java | package chapter02.ch15;
public class Tex {
String companyName;
int money;
public Tex(String companyName) {
this.companyName = companyName;
}
public void take(int money) {
this.money += money;
}
public void showTexInfo() {
System.out.println(companyName + "택시 수입은 "+money+"원 입니다.");
}
}
| [
"widn45@naver.com"
] | widn45@naver.com |
d940149d2b0439c2007f51fd9baaa0b6a0ad3031 | 0c62ebdc7c11a1b75bf87c338da03f6ec4e0951f | /Hotel/src/org/sistemahotel/dao/interfaces/TelefoneDAO.java | 9f2870ed5225fbf8b1fe8909d8bdd02a005d6cc3 | [] | no_license | ricardoalvim-edu/hotel | 32ddb70cb7e632f0a921433bfc158224f598e46b | ce075ce0c84f57bd94c39b280493181f747d3197 | refs/heads/master | 2021-05-03T08:44:38.068117 | 2015-11-23T23:57:14 | 2015-11-23T23:57:14 | 45,407,863 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 366 | 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 org.sistemahotel.dao.interfaces;
import org.sistemahotel.Model.Telefone;
/**
*
* @author GILIARD
*/
public interface TelefoneDAO extends DAO<Telefone,Integer> {
}
| [
"ricardo.ricardo815@gmail.com"
] | ricardo.ricardo815@gmail.com |
b590432ee9a07cff74f21cd6b3b3b395758c73e9 | 11cab7ac80ebcff14fe7595adc054b0cde308e9e | /SliderEndSilencer/src/WindowChooser.java | 18f7515ae94bf9a49bfaf7c82fef8541dc117010 | [] | no_license | kdai11830/sliderend-silencer | 1829130d8da6fab29c4fad163ef1fc8162f03793 | 696407887899b8bd7e5b85c17dbe1f6799ea67a7 | refs/heads/master | 2021-01-20T03:11:28.228179 | 2017-08-27T18:34:07 | 2017-08-27T18:34:07 | 101,353,634 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,994 | java |
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.JFileChooser;
public class WindowChooser extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private String osuPath;
private JPanel contentPane;
JFileChooser fileChooser = new JFileChooser(osuPath);
File dir;
/**
* Create the frame.
*/
public WindowChooser() {
readFromProperty(System.getProperty("user.dir"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 571, 367);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
FileFilter filter = new FileNameExtensionFilter("OSU File", "osu");
fileChooser.setApproveButtonText("Select");
fileChooser.setToolTipText("Select OSU File");
fileChooser.setFileFilter(filter);
fileChooser.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try {
fileChooserActionPerformed(evt);
} catch (IOException e) {
Logger.getLogger(WindowChooser.class.getName()).log(Level.SEVERE, null, e);
}
}
});
dir = new File(osuPath);
fileChooser.setCurrentDirectory(dir);
contentPane.add(fileChooser, BorderLayout.CENTER);
}
// choose file
private void fileChooserActionPerformed(ActionEvent evt) throws IOException {
if (evt.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) {
if(fileExists()) {
// write to property file and send data to new window
osuPath = fileChooser.getSelectedFile().getPath().replace(fileChooser.getSelectedFile().getName(), "");
writeToPropertyFile(System.getProperty("user.dir"));
// WindowDraw window = new WindowDraw(fileChooser.getSelectedFile());
// window.setVisible(true);
this.dispose();
} else {
// error message
JOptionPane.showMessageDialog(fileChooser, "Please select OSU file.");
}
} else if (evt.getActionCommand() .equals(JFileChooser.CANCEL_SELECTION)) {
System.exit(0);
}
}
// check if file exists
private boolean fileExists() {
File file = fileChooser.getSelectedFile();
return file.exists()
&& file.isFile()
&& file.toString().substring(file.toString().indexOf(".")).contains("osu");
}
// remember directory location on application startup
private void readFromProperty(String path) {
Properties prop = new Properties();
InputStream input = null;
try {
input = new FileInputStream(path + "\\config.properties");
prop.load(input);
osuPath = prop.getProperty("osuPath");
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
// save directory in property
private void writeToPropertyFile(String path) {
Properties prop = new Properties();
OutputStream output = null;
try {
FileInputStream input = new FileInputStream(path + "\\config.properties");
prop.load(input);
prop.setProperty("osuPath", osuPath);
input.close();
// save properties to project root folder
output = new FileOutputStream(path + "\\config.properties");
prop.store(output, null);
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
| [
"noreply@github.com"
] | kdai11830.noreply@github.com |
b256375f389eb672d674c778d1760bfa0cef02c5 | 722cbb3c477c4cef3266603184e0df8ce6270ca7 | /src/main/java/seedu/address/logic/parser/LocationCommandParser.java | f87eb883a99ee895cd14d6a05a376ee6c36d1463 | [
"MIT"
] | permissive | CS2103AUG2017-T15-B3/main | 21e314931e378e61d6e298facc74ed05b762b25f | c10e097bfe433cde1f27b41fcb595d7c2b8ed142 | refs/heads/master | 2021-08-16T16:43:27.502067 | 2017-11-20T04:33:36 | 2017-11-20T04:33:36 | 104,058,933 | 5 | 2 | null | 2017-11-19T16:53:30 | 2017-09-19T10:05:31 | Java | UTF-8 | Java | false | false | 1,164 | java | package seedu.address.logic.parser;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import seedu.address.commons.core.index.Index;
import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.logic.commands.LocationCommand;
import seedu.address.logic.parser.exceptions.ParseException;
//@@author DarrenCzen
/**
* Parses input arguments and creates a new AccessCommand object
*/
public class LocationCommandParser implements Parser<LocationCommand> {
/**
* Parses the given {@code String} of arguments in the context of the LocationCommand
* and returns an LocationCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
@Override
public LocationCommand parse(String args) throws ParseException {
try {
Index index = ParserUtil.parseIndex(args);
return new LocationCommand(index);
} catch (IllegalValueException ive) {
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, LocationCommand.MESSAGE_USAGE));
}
}
}
| [
"zen_darren@hotmail.com"
] | zen_darren@hotmail.com |
4c95d00e68728bfd667ef1a0ae6a53b8633d3cf6 | 321846825aa23c7977cb804b3631410d2c0e8415 | /src/com/Planegame/Myplane.java | 1ba914c599d0c43ba04f7ab65cbb07e7baa048a0 | [] | no_license | pxyao16/PlaneGame | 0cd552bf7f33fe727724e733ae3dd54105c3920b | 1e85be2064027cd650f59514408d6e6f60bd735c | refs/heads/master | 2020-06-14T02:07:32.306972 | 2016-12-16T11:27:08 | 2016-12-16T11:27:08 | 76,648,838 | 0 | 1 | null | null | null | null | GB18030 | Java | false | false | 2,165 | java | package com.Planegame;
public class Myplane {
/**
* @param args
*/
private int x;
private int y;
private int width;
private int height;
private String path;
private boolean isFire;
private int atk=40; //我方初始攻击
private int power=1;//炮弹初始威力
private int maxlife=200;//我方最大生命值
public int getMaxlife() {
return maxlife;
}
public void setMaxlife(int maxlife) {
this.maxlife = maxlife;
}
private int life=0; //我方生命
private boolean iseffect=true;
private int bulletspeed=15; //越小越快
private int credit=0;//我的积分
public int getCredit() {
return credit;
}
public void setCredit(int credit) {
this.credit = credit;
}
public int getBulletspeed() {
return bulletspeed;
}
public void setBulletspeed(int bulletspeed) {
this.bulletspeed = bulletspeed;
}
public int getLife() {
return life;
}
public void setLife(int life) {
if(life<=0){
setIseffect(false);
}
this.life = life;
}
public boolean isIseffect() {
return iseffect;
}
public void setIseffect(boolean iseffect) {
this.iseffect = iseffect;
}
public int getPower() {
return power;
}
public void setPower(int power) {
this.power = power;
}
public int getAtk() {
return atk;
}
public void setAtk(int atk) {
this.atk = atk;
}
public Myplane(){
x=PlaneFrame.width/2-40;
y=PlaneFrame.height-80;
width=45;
height=45;
path="/myplane_02.png";
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
if(x<0||x>PlaneFrame.width)
setIseffect(false);
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
if(y<0||y<PlaneFrame.height)
setIseffect(false);
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public boolean isFire() {
return isFire;
}
public void setFire(boolean isFire) {
this.isFire = isFire;
}
}
| [
"pxyao@163.com"
] | pxyao@163.com |
bd2a00328135406ff08f02a3406379734ec86116 | fac569f3238b8ff0828c2f36d5e03bdb0e7f7710 | /hw2-team10/src/main/java/edu/cmu/lti/bio/bdutt/casconsumers/GeneTaggingCasConsumer.java | 2e268a5ec5b875d2ddb05d2c654a84f0da346b0c | [] | no_license | bharat-dutt/hw2-team10 | f08774d9e93a42b5b811d2122098b2c69d73b51c | 8f3494c20d7303d062b9af1885ffac14232dcb53 | refs/heads/master | 2021-01-15T16:52:03.451428 | 2012-12-10T21:41:56 | 2012-12-10T21:41:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,584 | java | package edu.cmu.lti.bio.bdutt.casconsumers;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.CASException;
import org.apache.uima.cas.FSIterator;
import org.apache.uima.collection.CasConsumer_ImplBase;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceProcessException;
import edu.cmu.lti.bio.bdutt.types.Gene;
public class GeneTaggingCasConsumer extends CasConsumer_ImplBase {
/**
* This method is overriden version of the processCas method in CasConsumer_ImplBase
* It accepts the gene annotations and writes it to the output file
* @param aCas the global CAS context
*/
@Override
public void processCas(CAS aCAS) throws ResourceProcessException {
// TODO Auto-generated method stub
JCas jcas;
try {
jcas = aCAS.getJCas();
} catch (CASException e) {
throw new ResourceProcessException(e);
}
try
{
String OutputFile = (String) getConfigParameterValue("OutputFile");
BufferedWriter outputFile = new BufferedWriter(new FileWriter(OutputFile));
FSIterator iter = jcas.getAnnotationIndex(Gene.type).iterator();
while(iter.hasNext())
{
Gene FinalAnnotate = (Gene)iter.next();
outputFile.write(FinalAnnotate.getID() +"|"+ FinalAnnotate.getStartSpan() +" "+FinalAnnotate.getEndSpan()+"|"+ FinalAnnotate.getName() + "\n");
}
}
catch(IOException ioE)
{
ioE.printStackTrace();
}
}
}
| [
"alkeshku@andrew.cmu.edu"
] | alkeshku@andrew.cmu.edu |
b4c47914220a35687d35957c1c47e38288a0ee22 | a326abf95d5e8721c5b6d8b5c4322d833efbaff6 | /src/main/java/br/com/pbtech/rules/mutators/ArrayDeclaration.java | a408f640e33883540a0f9dcb0fcfbc2a1c717cbf | [
"MIT"
] | permissive | amandatrololo/sonar-stryker-plugin | ca9c01c510027bd410b749f3e649cc096aa1ba83 | a1859cbfe503ecb569f70e7b80983105e458b16b | refs/heads/master | 2023-03-14T06:43:32.403516 | 2021-03-05T11:06:32 | 2021-03-05T11:06:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,047 | java | package br.com.pbtech.rules.mutators;
import br.com.pbtech.rules.DefaultRuleDefinition;
import br.com.pbtech.rules.csharp.mutators.CsRule;
import br.com.pbtech.rules.js.mutators.JsRule;
import org.sonar.api.rule.RuleKey;
import static br.com.pbtech.constantes.Languages.CSHARP_KEY;
import static br.com.pbtech.constantes.Languages.JAVASCRIPT_KEY;
import static br.com.pbtech.constantes.Metricas.*;
public class ArrayDeclaration implements JsRule, CsRule {
private final RuleKey ARRAY_DECLARATION_JS = RuleKey.of(REPOSITORY_KEY_JS, "stryker.rule.js.array_declaration");
private final RuleKey ARRAY_DECLARATION_CS = RuleKey.of(REPOSITORY_KEY_CS, "stryker.rule.cs.array_declaration");
private final Double GAP = 10.0;
private final String RULE_NAME = "Stryker - Array Declaration";
private final String PATH_TO_HTML_DESCRIPTION = "br/com/pbtech/rules/ArrayDeclaration.html";
@Override
public void define(Context context) {
NewRepository jsRepository = context
.createRepository(REPOSITORY_KEY_JS, JAVASCRIPT_KEY)
.setName(REPOSITORY_NAME);
NewRepository csharpRepository = context
.createRepository(REPOSITORY_KEY_CS, CSHARP_KEY)
.setName(REPOSITORY_NAME);
DefaultRuleDefinition defaultRuleDefinition = new DefaultRuleDefinition();
defaultRuleDefinition.createDefinition(jsRepository, ARRAY_DECLARATION_JS.rule(), RULE_NAME, PATH_TO_HTML_DESCRIPTION);
defaultRuleDefinition.createDefinition(csharpRepository, ARRAY_DECLARATION_CS.rule(), RULE_NAME, PATH_TO_HTML_DESCRIPTION);
jsRepository.done();
csharpRepository.done();
}
@Override
public RuleKey getOperatorJs() {
return this.ARRAY_DECLARATION_JS;
}
@Override
public String getRuleName() {
return this.RULE_NAME;
}
@Override
public Double getGap() {
return this.GAP;
}
@Override
public RuleKey getOperatorCs() {
return this.ARRAY_DECLARATION_CS;
}
}
| [
"deividbatfish2@gmail.com"
] | deividbatfish2@gmail.com |
8cf5cd2cb4d42c8e0e6a2fad90fdcbdbf1405475 | 0bd57c831c8247ed2bd8c026c8ceb44c786a166c | /server/src/test/java/io/swagger/api/PPRCodesApiControllerIntegrationTest.java | bf346ca637eb99339275127539463e92a3784935 | [] | no_license | thepanacealab/AEOLUS-SmartAPI | 0b682c9be114dcbcd733040bbeffba70db2a16b5 | 7bdc3fed97d125483f69e5b541548dfe022f7db7 | refs/heads/master | 2020-04-27T14:56:19.046017 | 2019-12-17T13:01:57 | 2019-12-17T13:01:57 | 174,425,586 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 917 | java | package io.swagger.api;
import io.swagger.model.PRRWrapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertEquals;
@RunWith(SpringRunner.class)
@SpringBootTest
public class PPRCodesApiControllerIntegrationTest {
@Autowired
private PPRCodesApi api;
@Test
public void pprCodesTest() throws Exception {
String drugCode = "drugCode_example";
String outcomeCode = "outcomeCode_example";
ResponseEntity<PRRWrapper> responseEntity = api.pprCodes(drugCode, outcomeCode);
assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
}
}
| [
"noreply@github.com"
] | thepanacealab.noreply@github.com |
9b5711cc8b7f832acd8ae919d6b8d208e73b8081 | 16c2acd5479d1bd350151a18ae1ca9757833e5ee | /Java_015/src/com/callor/applications/Array_055.java | 0187a2c24d4f65274704e3c6114544999749f1ca | [] | no_license | parkjuyoung12/Biz_2021_01_java | c698397cdc7f1705fb39dfa710c0a154667aa595 | 27e1a9cb53118681cbe1dbebd0e52881d0191dee | refs/heads/master | 2023-03-20T01:29:58.918366 | 2021-03-16T00:26:18 | 2021-03-16T00:26:18 | 334,861,752 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 807 | java | package com.callor.applications;
import java.util.Random;
import java.util.Scanner;
public class Array_055 {
public static void main(String[] args) {
Random rnd = new Random();
Scanner scan = new Scanner(System.in);
// 배열 100개 선언
int[] intNums = new int[100];
for (int index = 0; index < intNums.length; index++) {
intNums[index] = rnd.nextInt(100) + 1; // 1~100까지의 난수
}
System.out.println("정수 1~ 10 중에 입력 ");
System.out.println(">>");
int keyNum = scan.nextInt();
int pos = 0;
for (pos = 0; pos < intNums.length; pos++) {
if (intNums[pos] == keyNum) {
break;
}
}
if (pos < intNums.length) {
System.out.println(pos + " 위치에서 최초 발견");
} else {
System.out.println("배열에 찾은 값이 없음");
}
}
}
| [
"zhseltm@naver.com"
] | zhseltm@naver.com |
fe82e29ba2c968fff9bc4a349391529d9f535bdf | af4803e253c4d0a82ad41d48aea87fefc3d6f8aa | /app/src/main/java/co/smilers/model/ApiResponse.java | 7f70587ea0bdd8c3fbe86c0ed7fd3cb92a2c4520 | [] | no_license | ajgroupware/SmilersApp | 6e5bb1f9a5b10be5b767d8efdefc040da4e497c3 | 4874a1946dd61a1a90b8d88c881ed9934d2e15a7 | refs/heads/master | 2021-07-15T11:36:39.337956 | 2019-02-08T03:44:45 | 2019-02-08T03:44:45 | 147,550,602 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,375 | java | /**
* Smiller
* Api de servicios REST para la aplicación [https://www.smilers.co](https://www.smilers.co).
*
* OpenAPI spec version: 1.0.0
* Contact: apps@groupware.com.co
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package co.smilers.model;
import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName;
@ApiModel(description = "")
public class ApiResponse {
@SerializedName("code")
private Integer code = null;
@SerializedName("type")
private String type = null;
@SerializedName("message")
private String message = null;
/**
**/
@ApiModelProperty(value = "")
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
/**
**/
@ApiModelProperty(value = "")
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
/**
**/
@ApiModelProperty(value = "")
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ApiResponse apiResponse = (ApiResponse) o;
return (this.code == null ? apiResponse.code == null : this.code.equals(apiResponse.code)) &&
(this.type == null ? apiResponse.type == null : this.type.equals(apiResponse.type)) &&
(this.message == null ? apiResponse.message == null : this.message.equals(apiResponse.message));
}
@Override
public int hashCode() {
int result = 17;
result = 31 * result + (this.code == null ? 0: this.code.hashCode());
result = 31 * result + (this.type == null ? 0: this.type.hashCode());
result = 31 * result + (this.message == null ? 0: this.message.hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ApiResponse {\n");
sb.append(" code: ").append(code).append("\n");
sb.append(" type: ").append(type).append("\n");
sb.append(" message: ").append(message).append("\n");
sb.append("}\n");
return sb.toString();
}
}
| [
"alrodriguez@heinsohn.com.co"
] | alrodriguez@heinsohn.com.co |
2177f7ad8809558ed4db18894c8c6e575e40288b | 7bffe59537f65838054dd54b02fe9582337a52b7 | /Java/flames/Flames1.java | 54588030854c68626675de94c6c84c045a9e8517 | [
"MIT"
] | permissive | tuhiniris/Competitive-Coding | b4bf62c71736b71c70026c2f668d8b1996e04417 | 0fa2244d3a826d1ebc948fd65b5d5ca8cd0aa8c4 | refs/heads/main | 2023-06-28T23:13:31.950558 | 2021-07-23T11:27:33 | 2021-07-23T11:27:33 | 388,428,441 | 0 | 0 | MIT | 2021-07-22T10:52:53 | 2021-07-22T10:52:53 | null | UTF-8 | Java | false | false | 799 | java | import java.util.*;
public class Flames1
{
public static void main(String[] args)
{
int x = 0;
System.out.println("Enter Name of Premi :");
Scanner sc=new Scanner(System.in);
String Male = sc.nextLine();
Male=Male.toLowerCase();
System.out.println("Enter Name of Premika :");
String Female = sc.nextLine();
Female=Female.toLowerCase();
for(int i=0; i<Male.length();i++)
{
for(int j=0; j<Female.length();j++)
{
if(Male.charAt(i) == Female.charAt(j))
{
Male.replace(i, i+1, "0"); // replacing matching characters into "0"
Female.replace(j,j+1,"0");
}
}
}
System.out.println(Male+" "+Female);
sc.close();
}
} | [
"roymananjay@gmail.com"
] | roymananjay@gmail.com |
45d1a56a6c0bd75cf085c82ea2cdbd6cb3d4e676 | 564ad5ad00c78a66915196bbd8f09b2f74602b6a | /MytestCompany/app/src/main/java/com/zqr/snake/mytest/PathAnimView/PathAnimView.java | 90db544d017e5156479ea543bd38ae5e758fcad1 | [] | no_license | zqrverygood/zqr-testdemo | 261da04f14da3b8906a19fdb89b0223068fcbcba | 25c04a31ea4c6bdfbf55b1a5c7ab78ff73b73c7e | refs/heads/master | 2021-01-19T11:49:07.749263 | 2017-04-12T07:53:27 | 2017-04-12T07:53:27 | 87,997,028 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,901 | java | package com.zqr.snake.mytest.PathAnimView;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
/**
* 介绍:一个路径动画的View
* 利用源Path绘制“底”
* 利用动画Path 绘制 填充动画
* <p>
* 通过mPathAnimHelper 对SourcePath做动画:
* 一个SourcePath 内含多段Path,循环取出每段Path,并做一个动画,
* <p>
* 作者:zhangxutong
* 邮箱:zhangxutong@imcoming.com
* 时间: 2016/11/2.
*/
public class PathAnimView extends View {
protected Path mSourcePath;//需要做动画的源Path
protected Path mAnimPath;//用于绘制动画的Path
protected Paint mPaint;
protected int mColorBg = Color.GRAY;//背景色
protected int mColorFg = Color.WHITE;//前景色 填充色
protected PathAnimHelper mPathAnimHelper;//Path动画工具类
protected int mPaddingLeft, mPaddingTop;
public PathAnimView(Context context) {
this(context, null);
}
public PathAnimView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public PathAnimView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
/**
* GET SET FUNC
**/
public Path getSourcePath() {
return mSourcePath;
}
/**
* 这个方法可能会经常用到,用于设置源Path
*
* @param sourcePath
* @return
*/
public PathAnimView setSourcePath(Path sourcePath) {
mSourcePath = sourcePath;
initAnimHelper();
return this;
}
public Paint getPaint() {
return mPaint;
}
public PathAnimView setPaint(Paint paint) {
mPaint = paint;
return this;
}
public int getColorBg() {
return mColorBg;
}
public PathAnimView setColorBg(int colorBg) {
mColorBg = colorBg;
return this;
}
public int getColorFg() {
return mColorFg;
}
public PathAnimView setColorFg(int colorFg) {
mColorFg = colorFg;
return this;
}
public PathAnimHelper getPathAnimHelper() {
return mPathAnimHelper;
}
public PathAnimView setPathAnimHelper(PathAnimHelper pathAnimHelper) {
mPathAnimHelper = pathAnimHelper;
return this;
}
public Path getAnimPath() {
return mAnimPath;
}
/**
* INIT FUNC
**/
protected void init() {
//Paint
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(3);
//动画路径只要初始化即可
mAnimPath = new Path();
//初始化动画帮助类
initAnimHelper();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mPaddingLeft = getPaddingLeft();
mPaddingTop = getPaddingTop();
}
/**
* 初始化动画帮助类
*/
protected void initAnimHelper() {
mPathAnimHelper = getInitAnimHeper();
//mPathAnimHelper = new PathAnimHelper(this, mSourcePath, mAnimPath, 1500, true);
}
/**
* 子类可通过重写这个方法,返回自定义的AnimHelper
*
* @return
*/
protected PathAnimHelper getInitAnimHeper() {
return new PathAnimHelper(this, mSourcePath, mAnimPath);
}
/**
* draw FUNC
**/
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//平移
canvas.translate(mPaddingLeft, mPaddingTop);
//先绘制底,
mPaint.setColor(mColorBg);
// Log.e("44444444","1......"+mSourcePath);
canvas.drawPath(mSourcePath, mPaint);
//再绘制前景,mAnimPath不断变化,不断重绘View的话,就会有动画效果。
mPaint.setColor(mColorFg);
canvas.drawPath(mAnimPath, mPaint);
}
/**
* 设置动画 循环
*/
public PathAnimView setAnimInfinite(boolean infinite) {
mPathAnimHelper.setInfinite(infinite);
return this;
}
/**
* 设置动画 总时长
*/
public PathAnimView setAnimTime(long animTime) {
mPathAnimHelper.setAnimTime(animTime);
return this;
}
/**
* 执行循环动画
*/
public void startAnim() {
mPathAnimHelper.startAnim();
}
/**
* 停止动画
*/
public void stopAnim() {
mPathAnimHelper.stopAnim();
}
/**
* 清除并停止动画
*/
public void clearAnim() {
stopAnim();
mAnimPath.reset();
mAnimPath.lineTo(0, 0);
invalidate();
}
}
| [
"772791008@qq.com"
] | 772791008@qq.com |
ddfd9cd7777486f6cf9702baf5cc83d0b4d2dca6 | 630bf2713beab3a0939f3783b2eec37455184f2b | /src/ppj/werner/e15/Calculator.java | 43cf534d7d9ea69077ca60c56cb868f5432644de | [] | no_license | OleksandrBieliakov/ppj | 54bec6c5e3f0e197ed0160a8ac38173f3f76e3d1 | 339d4ed2bd11c49f75b6eabf72cf8acb21d3bd6f | refs/heads/master | 2020-09-27T03:19:43.895140 | 2019-12-06T21:58:12 | 2019-12-06T21:58:12 | 226,416,366 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 276 | java | package ppj.werner.e15;
public class Calculator extends CalculatingMachine {
public Calculator(String name) {
super(name);
}
@Override
public String calculate(double x, double y) {
return super.calculate(x, y) + "; '-':" + (x - y);
}
}
| [
"bel9k@ukr.net"
] | bel9k@ukr.net |
39f016b5797756e603918c264f57a702ee6c4e0f | e5cd4054c0c4ba4738f6fdbe8333676b47343e79 | /play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/RiskLevel.java | 6e7c288d65d2d4a4c58f7cf3db1e95e6d392a5f1 | [
"Apache-2.0"
] | permissive | toder34/android_packages_apps_GmsCore | d532906cba7dcba467f7f441ec31af957102deed | f10214ef8ab64e8d1fd896d97e7d3dd3e1a8ad64 | refs/heads/master | 2022-12-12T10:57:05.489966 | 2020-09-10T14:56:43 | 2020-09-10T14:56:43 | 294,638,180 | 2 | 0 | Apache-2.0 | 2020-09-11T08:27:49 | 2020-09-11T08:27:48 | null | UTF-8 | Java | false | false | 754 | java | /*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.0
* Notice: Portions of this file are reproduced from work created and shared by Google and used
* according to terms described in the Creative Commons 4.0 Attribution License.
* See https://developers.google.com/readme/policies for details.
*/
package com.google.android.gms.nearby.exposurenotification;
public @interface RiskLevel {
int RISK_LEVEL_INVALID = 0;
int RISK_LEVEL_LOWEST = 1;
int RISK_LEVEL_LOW = 2;
int RISK_LEVEL_LOW_MEDIUM = 3;
int RISK_LEVEL_MEDIUM = 4;
int RISK_LEVEL_MEDIUM_HIGH = 5;
int RISK_LEVEL_HIGH = 6;
int RISK_LEVEL_VERY_HIGH = 7;
int RISK_LEVEL_HIGHEST = 8;
}
| [
"git@larma.de"
] | git@larma.de |
bd0c614506fd07324a5866dd8a6592b525339848 | fa56047dc883db13f15bdd9a6f8cb995d310ea7e | /systemtests/src/main/java/io/enmasse/systemtest/ConnectTimeoutException.java | 96d05a6f684f9a1cc6afb2436e9fa15b967e43e9 | [
"Apache-2.0"
] | permissive | klenkes74/enmasse | 34d71140fd8c8ab3b5062174c974f5d6b3faeb14 | 2f075a01384e94e6011b014391ad99afd36617cf | refs/heads/master | 2023-07-19T12:01:01.835959 | 2018-02-10T09:44:05 | 2018-02-10T09:44:05 | 108,978,967 | 0 | 0 | Apache-2.0 | 2023-07-16T08:35:35 | 2017-10-31T10:18:01 | Java | UTF-8 | Java | false | false | 824 | java | /*
* Copyright 2017 Red Hat Inc.
*
* 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 io.enmasse.systemtest;
import java.util.concurrent.TimeoutException;
public class ConnectTimeoutException extends TimeoutException {
public ConnectTimeoutException(String message) {
super(message);
}
}
| [
"lulf@pvv.ntnu.no"
] | lulf@pvv.ntnu.no |
2c35ab9fc73c39de5053a820b1286fb280a8996a | b5b5bfa11a329cd38f6a19eecc7373a11868ee5f | /rgn-function-java/src/main/java/ragna/c04/AssetUtilRefactored.java | 33123bb0b2ad48b0f4e5895fca32202c4811cb09 | [] | no_license | ragnarokkrr/rgn-doodling | 8eedd30fb1310b5d42957d8760f8d91c293b4f45 | af4958f7334f9a04d93be7f44a8f1d7fce3114f4 | refs/heads/master | 2023-03-03T18:37:19.121644 | 2022-08-29T17:06:25 | 2022-08-29T17:06:25 | 17,333,410 | 0 | 1 | null | 2023-03-02T01:20:29 | 2014-03-02T07:40:14 | Java | UTF-8 | Java | false | false | 1,055 | java | package ragna.c04;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import ragna.c04.Asset.AssetType;
// Refactoring to Separate a Key Concern
public class AssetUtilRefactored {
static final List<Asset> ASSETS = Arrays.asList(
new Asset(AssetType.BOND, 1000),
new Asset(AssetType.BOND, 2000),
new Asset(AssetType.STOCK, 3000),
new Asset(AssetType.STOCK, 4000)
);
public static int totalAssetValues(final List<Asset> assets,
final Predicate<Asset> assetSelector) {
return assets.stream().filter(assetSelector).mapToInt(Asset::getValue).sum();
}
public static void main(String[] args) {
System.out.println("Total of assets: " + totalAssetValues(ASSETS, asset -> true));
System.out.println("Total of bonds: " + totalAssetValues(ASSETS, asset -> asset.getType() == AssetType.BOND));
System.out.println("Total of stock: " + totalAssetValues(ASSETS, asset -> asset.getType() == AssetType.STOCK));
}
}
| [
"nilseu.junior@aurea.com"
] | nilseu.junior@aurea.com |
dba864f38d15179103b46210d8f4a4a5e633e03e | a2a2d5286fa1a2e39fc864c2431bb32932e39c44 | /uicdm/src/main/java/ucar/nc2/ui/op/CoordSysTable.java | 51948c75955098f926a2394ec6bd14e498b58ccc | [
"BSD-3-Clause"
] | permissive | gknauth/netcdf-java | 7902c1466dc21134f67dd046b4d1a62979fb35bf | e979e6bc206ab291e057dec2885a6c75cef837ec | refs/heads/master | 2020-07-19T01:15:43.589986 | 2019-09-03T21:49:14 | 2019-09-03T22:32:16 | 206,348,469 | 0 | 1 | BSD-3-Clause | 2019-09-04T15:11:56 | 2019-09-04T15:11:56 | null | UTF-8 | Java | false | false | 31,726 | java | /*
* Copyright (c) 1998-2019 University Corporation for Atmospheric Research/Unidata
* See LICENSE for license information.
*/
package ucar.nc2.ui.op;
import javax.annotation.Nullable;
import ucar.ma2.Array;
import ucar.ma2.ArrayChar;
import ucar.ma2.ArrayDouble;
import ucar.ma2.ArrayObject;
import ucar.ma2.DataType;
import ucar.ma2.IndexIterator;
import ucar.nc2.Attribute;
import ucar.nc2.Dimension;
import ucar.nc2.NCdumpW;
import ucar.nc2.Structure;
import ucar.nc2.Variable;
import ucar.nc2.constants.CDM;
import ucar.nc2.dt.radial.RadialCoordSys;
import ucar.nc2.ft2.coverage.adapter.DtCoverageCSBuilder;
import ucar.nc2.time.*;
import ucar.ui.widget.BAMutil;
import ucar.ui.widget.IndependentWindow;
import ucar.ui.widget.PopupMenu;
import ucar.ui.widget.TextHistoryPane;
import ucar.nc2.dataset.*;
import ucar.nc2.constants._Coordinate;
import ucar.nc2.constants.AxisType;
import ucar.nc2.dt.grid.*;
import ucar.unidata.util.Parameter;
import ucar.util.prefs.PreferencesExt;
import ucar.ui.prefs.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Formatter;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
/**
* A Swing widget to examine Coordinate Systems.
*
* @author caron
*/
public class CoordSysTable extends JPanel {
private PreferencesExt prefs;
private NetcdfDataset ds;
private BeanTable varTable, csTable, axisTable;
private JSplitPane split, split2;
private TextHistoryPane infoTA;
private IndependentWindow infoWindow, attWindow;
private Formatter parseInfo = new Formatter();
public CoordSysTable(PreferencesExt prefs, JPanel buttPanel) {
this.prefs = prefs;
if (buttPanel != null) {
AbstractAction attAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
showAtts();
}
};
BAMutil.setActionProperties(attAction, "FontDecr", "global attributes", false, 'A', -1);
BAMutil.addActionToContainer(buttPanel, attAction);
}
varTable = new BeanTable(VariableBean.class, (PreferencesExt) prefs.node("VariableBeans"), false);
varTable.addListSelectionListener(e -> {
VariableBean vb = (VariableBean) varTable.getSelectedBean();
if (null != vb.coordSysBean)
csTable.setSelectedBean(vb.coordSysBean);
});
csTable = new BeanTable(CoordinateSystemBean.class, (PreferencesExt) prefs.node("CoordinateSystemBean"), false);
csTable.addListSelectionListener(e -> {
CoordinateSystemBean csb = (CoordinateSystemBean) csTable.getSelectedBean();
setSelectedCoordinateAxes(csb.coordSys);
});
axisTable = new BeanTable(AxisBean.class, (PreferencesExt) prefs.node("CoordinateAxisBean"), false);
PopupMenu varPopup = new PopupMenu(varTable.getJTable(), "Options");
varPopup.addAction("Show Declaration", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
VariableBean vb = (VariableBean) varTable.getSelectedBean();
Variable v = ds.findVariable(vb.getName());
if (v == null)
return;
infoTA.clear();
infoTA.appendLine(v.toString());
infoTA.appendLine(showMissing(v));
infoTA.gotoTop();
infoWindow.show();
}
});
varPopup.addAction("Try as Grid", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
VariableBean vb = (VariableBean) varTable.getSelectedBean();
VariableEnhanced v = (VariableEnhanced) ds.findVariable(vb.getName());
if (v == null)
return;
infoTA.clear();
infoTA.appendLine(tryGrid(v));
infoTA.gotoTop();
infoWindow.show();
}
});
varPopup.addAction("Try as Coverage", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
VariableBean vb = (VariableBean) varTable.getSelectedBean();
VariableEnhanced v = (VariableEnhanced) ds.findVariable(vb.getName());
if (v == null)
return;
infoTA.clear();
infoTA.appendLine(tryCoverage(v));
infoTA.gotoTop();
infoWindow.show();
}
});
PopupMenu csPopup = new PopupMenu(csTable.getJTable(), "Options");
csPopup.addAction("Show CoordSys", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
CoordinateSystemBean csb = (CoordinateSystemBean) csTable.getSelectedBean();
CoordinateSystem coordSys = csb.coordSys;
infoTA.clear();
infoTA.appendLine("Coordinate System = " + coordSys.getName());
for (CoordinateAxis axis : coordSys.getCoordinateAxes()) {
infoTA.appendLine(" " + axis.getAxisType() + " " + axis.writeCDL(true, false));
}
infoTA.appendLine(" Coordinate Transforms");
for (CoordinateTransform ct : coordSys.getCoordinateTransforms()) {
infoTA.appendLine(" " + ct.getName() + " type=" + ct.getTransformType());
for (Parameter p : ct.getParameters()) {
infoTA.appendLine(" " + p);
}
if (ct instanceof ProjectionCT) {
ProjectionCT pct = (ProjectionCT) ct;
if (pct.getProjection() != null) {
infoTA.appendLine(" impl.class= " + pct.getProjection().getClass().getName());
// pct.getProjection();
}
}
if (ct instanceof VerticalCT) {
VerticalCT vct = (VerticalCT) ct;
infoTA.appendLine(" VerticalCT= " + vct);
}
}
infoTA.gotoTop();
infoWindow.show();
}
});
PopupMenu axisPopup = new PopupMenu(axisTable.getJTable(), "Options");
axisPopup.addAction("Show Declaration", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
AxisBean bean = (AxisBean) axisTable.getSelectedBean();
if (bean == null)
return;
VariableDS axis = (VariableDS) ds.findVariable(bean.getName());
if (axis == null)
return;
infoTA.clear();
infoTA.appendLine(axis.toString());
infoTA.appendLine(showMissing(axis));
infoTA.gotoTop();
infoWindow.show();
}
});
axisPopup.addAction("Show Values", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
AxisBean bean = (AxisBean) axisTable.getSelectedBean();
if (bean == null)
return;
infoTA.clear();
showValues(bean.axis);
infoTA.gotoTop();
infoWindow.show();
}
});
axisPopup.addAction("Show Value Differences", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
AxisBean bean = (AxisBean) axisTable.getSelectedBean();
if (bean == null)
return;
infoTA.clear();
showValueDiffs(bean.axis);
infoTA.gotoTop();
infoWindow.show();
}
});
axisPopup.addAction("Show Values as Date", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
AxisBean bean = (AxisBean) axisTable.getSelectedBean();
if (bean == null)
return;
infoTA.clear();
showValuesAsDates(bean.axis);
infoTA.gotoTop();
infoWindow.show();
}
});
// the info window
infoTA = new TextHistoryPane();
infoWindow = new IndependentWindow("Extra Information", BAMutil.getImage("nj22/NetcdfUI"), infoTA);
infoWindow.setBounds((Rectangle) prefs.getBean("InfoWindowBounds", new Rectangle(300, 300, 500, 300)));
split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, varTable, csTable);
split.setDividerLocation(prefs.getInt("splitPos", 500));
split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, split, axisTable);
split2.setDividerLocation(prefs.getInt("splitPos2", 500));
setLayout(new BorderLayout());
add(split2, BorderLayout.CENTER);
}
public void summaryInfo(Formatter f) {
if (ds == null)
return;
f.format("%s%n", ds.getLocation());
int ngrids = 0;
for (Object varo : varTable.getBeans()) {
VariableBean varBean = (VariableBean) varo;
if (varBean.getDataType().trim().equalsIgnoreCase("grid"))
ngrids++;
}
int ncoordSys = csTable.getBeans().size();
int ncoords = axisTable.getBeans().size();
f.format(" ngrids=%d, ncoords=%d, ncoordSys=%d%n", ngrids, ncoords, ncoordSys);
}
private BeanTable attTable;
public void showAtts() {
if (ds == null)
return;
if (attTable == null) {
// global attributes
attTable = new BeanTable(AttributeBean.class, (PreferencesExt) prefs.node("AttributeBeans"), false);
PopupMenu varPopup = new PopupMenu(attTable.getJTable(), "Options");
varPopup.addAction("Show Attribute", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
AttributeBean bean = (AttributeBean) attTable.getSelectedBean();
if (bean != null) {
infoTA.setText(bean.att.toString());
infoTA.gotoTop();
infoWindow.show();
}
}
});
attWindow = new IndependentWindow("Global Attributes", BAMutil.getImage("nj22/NetcdfUI"), attTable);
attWindow.setBounds((Rectangle) prefs.getBean("AttWindowBounds", new Rectangle(300, 100, 500, 800)));
}
List<AttributeBean> attlist = new ArrayList<>();
for (Attribute att : ds.getGlobalAttributes()) {
attlist.add(new AttributeBean(att));
}
attTable.setBeans(attlist);
attWindow.show();
}
private void showValues(CoordinateAxis axis) {
try {
if (axis instanceof CoordinateAxis1D && axis.isNumeric()) {
CoordinateAxis1D axis1D = (CoordinateAxis1D) axis;
printArray("midpoints=", axis1D.getCoordValues());
if (!axis1D.isInterval()) {
printArray("edges=", axis1D.getCoordEdges());
} else {
printArray("bound1=", axis1D.getBound1());
printArray("bound2=", axis1D.getBound2());
Formatter f = new Formatter();
double[] mid = axis1D.getCoordValues();
double[] b1 = axis1D.getBound1();
double[] b2 = axis1D.getBound2();
for (int i = 0; i < b1.length; i++) {
f.format("%f (%f,%f) = %f%n", mid[i], b1[i], b2[i], b2[i] - b1[i]);
}
infoTA.appendLine(f.toString());
}
} else if (axis instanceof CoordinateAxis2D && axis.isNumeric()) {
infoTA.appendLine(NCdumpW.printVariableData(axis, null));
showValues2D((CoordinateAxis2D) axis);
} else {
infoTA.appendLine(NCdumpW.printVariableData(axis, null));
}
} catch (IOException e1) {
e1.printStackTrace();
infoTA.appendLine(e1.getMessage());
}
}
private void showValues2D(CoordinateAxis2D axis2D) {
Formatter f = new Formatter();
if (axis2D.isInterval()) {
ArrayDouble.D2 coords = axis2D.getCoordValuesArray();
ArrayDouble.D3 bounds = axis2D.getCoordBoundsArray();
if (bounds == null) {
infoTA.appendLine("No bounds for interval " + axis2D.getFullName());
return;
}
int count = 0;
IndexIterator coordIter = coords.getIndexIterator();
IndexIterator boundsIter = bounds.getIndexIterator();
while (coordIter.hasNext()) {
double coordValue = coordIter.getDoubleNext();
if (!boundsIter.hasNext())
break;
double bounds1 = boundsIter.getDoubleNext();
if (!boundsIter.hasNext())
break;
double bounds2 = boundsIter.getDoubleNext();
f.format("%3d: %f (%f,%f) len=%f mid=%f%n", count, coordValue, bounds1, bounds2, bounds2 - bounds1,
(bounds2 + bounds1) / 2);
count++;
}
} else {
ArrayDouble.D2 coords = axis2D.getCoordValuesArray();
IndexIterator coordIter = coords.getIndexIterator();
while (coordIter.hasNext()) {
double coordValue = coordIter.getDoubleNext();
f.format("%f%n", coordValue);
}
}
infoTA.appendLine(f.toString());
}
private void showValueDiffs(CoordinateAxis axis) {
if (!axis.isNumeric())
return;
try {
if (axis instanceof CoordinateAxis1D) {
CoordinateAxis1D axis1D = (CoordinateAxis1D) axis;
double[] mids = axis1D.getCoordValues();
double[] diffs = new double[mids.length];
for (int i = 0; i < mids.length - 1; i++)
diffs[i] = mids[i + 1] - mids[i];
printArrays("midpoint differences", mids, diffs);
} else if (axis instanceof CoordinateAxis2D) {
CoordinateAxis2D axis2D = (CoordinateAxis2D) axis;
ArrayDouble.D2 mids = axis2D.getCoordValuesArray();
int[] shape = mids.getShape();
ArrayDouble.D2 diffx = (ArrayDouble.D2) Array.factory(DataType.DOUBLE, new int[] {shape[0], shape[1] - 1});
for (int j = 0; j < shape[0]; j++) {
for (int i = 0; i < shape[1] - 1; i++) {
double diff = mids.get(j, i + 1) - mids.get(j, i);
diffx.set(j, i, diff);
}
}
infoTA.appendLine(NCdumpW.toString(diffx, "diff in x", null));
ArrayDouble.D2 diffy = (ArrayDouble.D2) Array.factory(DataType.DOUBLE, new int[] {shape[0] - 1, shape[1]});
for (int j = 0; j < shape[0] - 1; j++) {
for (int i = 0; i < shape[1]; i++) {
double diff = mids.get(j + 1, i) - mids.get(j, i);
diffy.set(j, i, diff);
}
}
infoTA.appendLine("\n\n\n");
infoTA.appendLine(NCdumpW.toString(diffy, "diff in y", null));
}
} catch (Exception e1) {
e1.printStackTrace();
infoTA.appendLine(e1.getMessage());
}
}
private void showValuesAsDates(CoordinateAxis axis) {
String units = axis.getUnitsString();
String cal = getCalendarAttribute(axis);
CalendarDateUnit cdu = CalendarDateUnit.of(cal, units);
try {
infoTA.appendLine(units);
infoTA.appendLine(NCdumpW.printVariableData(axis, null));
if (axis.getDataType().isNumeric()) {
if (axis instanceof CoordinateAxis2D) {
showDates2D((CoordinateAxis2D) axis, cdu);
} else if (axis instanceof CoordinateAxis1D) { // 1D
showDates1D((CoordinateAxis1D) axis, cdu);
} else { // > 2D
Array data = axis.read();
IndexIterator ii = data.getIndexIterator();
while (ii.hasNext()) {
double val = ii.getDoubleNext();
infoTA.appendLine(makeCalendarDateStringOrMissing(cdu, val));
}
}
} else { // must be iso dates
Array data = axis.read();
Formatter f = new Formatter();
if (data instanceof ArrayChar) {
ArrayChar dataS = (ArrayChar) data;
ArrayChar.StringIterator iter = dataS.getStringIterator();
while (iter.hasNext())
f.format(" %s%n", iter.next());
infoTA.appendLine(f.toString());
} else if (data instanceof ArrayObject) {
IndexIterator iter = data.getIndexIterator();
while (iter.hasNext())
f.format(" %s%n", iter.next());
infoTA.appendLine(f.toString());
}
}
} catch (Exception ex) {
ex.printStackTrace();
infoTA.appendLine(ex.getMessage());
}
}
private void showDates2D(CoordinateAxis2D axis2D, CalendarDateUnit cdu) {
Formatter f = new Formatter();
int count = 0;
if (axis2D.isInterval()) {
ArrayDouble.D2 coords = axis2D.getCoordValuesArray();
ArrayDouble.D3 bounds = axis2D.getCoordBoundsArray();
if (bounds == null) {
infoTA.appendLine("No bounds for interval " + axis2D.getFullName());
return;
}
IndexIterator coordIter = coords.getIndexIterator();
IndexIterator boundsIter = bounds.getIndexIterator();
while (coordIter.hasNext()) {
double coordValue = coordIter.getDoubleNext();
if (!boundsIter.hasNext())
break;
double bounds1 = boundsIter.getDoubleNext();
if (!boundsIter.hasNext())
break;
double bounds2 = boundsIter.getDoubleNext();
f.format("%3d: %s (%s,%s)%n", count++, makeCalendarDateStringOrMissing(cdu, coordValue),
makeCalendarDateStringOrMissing(cdu, bounds1), makeCalendarDateStringOrMissing(cdu, bounds2));
}
} else {
ArrayDouble.D2 coords = axis2D.getCoordValuesArray();
IndexIterator coordIter = coords.getIndexIterator();
while (coordIter.hasNext()) {
double coordValue = coordIter.getDoubleNext();
f.format("%3d: %s%n", count++, makeCalendarDateStringOrMissing(cdu, coordValue));
}
}
infoTA.appendLine(f.toString());
}
private String makeCalendarDateStringOrMissing(CalendarDateUnit cdu, double value) {
if (Double.isNaN(value))
return "missing";
return cdu.makeCalendarDate(value).toString();
}
private String getCalendarAttribute(VariableEnhanced vds) {
Attribute cal = vds.findAttribute("calendar");
return (cal == null) ? null : cal.getStringValue();
}
private void showDates1D(CoordinateAxis1D axis1D, CalendarDateUnit cdu) {
if (!axis1D.isInterval()) {
for (double val : axis1D.getCoordValues()) {
if (Double.isNaN(val))
infoTA.appendLine(" N/A");
else
infoTA.appendLine(" " + cdu.makeCalendarDate(val));
}
} else { // is interval
Formatter f = new Formatter();
double[] b1 = axis1D.getBound1();
double[] b2 = axis1D.getBound2();
for (int i = 0; i < b1.length; i++)
f.format(" (%f, %f) == (%s, %s)%n", b1[i], b2[i], cdu.makeCalendarDate((b1[i])), cdu.makeCalendarDate((b2[i])));
infoTA.appendLine(f.toString());
}
}
private void printArray(String title, double[] vals) {
Formatter sbuff = new Formatter();
sbuff.format(" %s=", title);
for (double val : vals) {
sbuff.format(" %f", val);
}
sbuff.format("%n");
infoTA.appendLine(sbuff.toString());
}
private void printArrays(String title, double[] vals, double[] vals2) {
Formatter sbuff = new Formatter();
sbuff.format(" %s%n", title);
for (int i = 0; i < vals.length; i++) {
sbuff.format(" %3d: %10.2f %10.2f%n", i, vals[i], vals2[i]);
}
sbuff.format("%n");
infoTA.appendLine(sbuff.toString());
}
public PreferencesExt getPrefs() {
return prefs;
}
public void save() {
varTable.saveState(false);
csTable.saveState(false);
axisTable.saveState(false);
prefs.putBeanObject("InfoWindowBounds", infoWindow.getBounds());
prefs.putInt("splitPos", split.getDividerLocation());
prefs.putInt("splitPos2", split2.getDividerLocation());
prefs.putBeanObject("InfoWindowBounds", infoWindow.getBounds());
if (attWindow != null)
prefs.putBeanObject("AttWindowBounds", attWindow.getBounds());
}
public void clear() {
this.ds = null;
varTable.clearBeans();
axisTable.clearBeans();
csTable.clearBeans();
}
public void setDataset(NetcdfDataset ds) {
this.ds = ds;
parseInfo = new Formatter();
List<CoordinateSystemBean> csList = getCoordinateSystemBeans(ds);
List<VariableBean> beanList = new ArrayList<>();
List<AxisBean> axisList = new ArrayList<>();
setVariables(ds.getVariables(), axisList, beanList, csList);
varTable.setBeans(beanList);
axisTable.setBeans(axisList);
csTable.setBeans(csList);
}
private void setVariables(List<Variable> varList, List<AxisBean> axisList, List<VariableBean> beanList,
List<CoordinateSystemBean> csList) {
for (Variable aVarList : varList) {
VariableEnhanced v = (VariableEnhanced) aVarList;
if (v instanceof CoordinateAxis)
axisList.add(new AxisBean((CoordinateAxis) v));
else
beanList.add(new VariableBean(v, csList));
if (v instanceof Structure) {
List<Variable> nested = ((Structure) v).getVariables();
setVariables(nested, axisList, beanList, csList);
}
}
}
private List<CoordinateSystemBean> getCoordinateSystemBeans(NetcdfDataset ds) {
List<CoordinateSystemBean> vlist = new ArrayList<>();
for (CoordinateSystem elem : ds.getCoordinateSystems()) {
vlist.add(new CoordinateSystemBean(elem));
}
return vlist;
}
private void setSelectedCoordinateAxes(CoordinateSystem cs) {
List axesList = cs.getCoordinateAxes();
if (axesList.size() == 0)
return;
CoordinateAxis axis = (CoordinateAxis) axesList.get(0);
List beans = axisTable.getBeans();
for (Object bean1 : beans) {
AxisBean bean = (AxisBean) bean1;
if (bean.axis == axis) {
axisTable.setSelectedBean(bean);
return;
}
}
}
private String tryGrid(VariableEnhanced v) {
Formatter buff = new Formatter();
buff.format("%s:", v.getFullName());
List<CoordinateSystem> csList = v.getCoordinateSystems();
if (csList.size() == 0)
buff.format(" No Coord System found");
else {
for (CoordinateSystem cs : csList) {
buff.format("%s:", cs.getName());
if (GridCoordSys.isGridCoordSys(buff, cs, v)) {
buff.format("GRID OK%n");
} else {
buff.format(" NOT GRID");
}
}
}
return buff.toString();
}
private String tryCoverage(VariableEnhanced v) {
Formatter buff = new Formatter();
buff.format("%s%n", v);
List<CoordinateSystem> csList = v.getCoordinateSystems();
if (csList.size() == 0)
buff.format(" No Coord System found");
else {
for (CoordinateSystem cs : csList) {
buff.format("%nCoordSys: %s%n", cs);
Formatter errlog = new Formatter();
String result = DtCoverageCSBuilder.describe(ds, cs, errlog);
buff.format(" coverage desc: %s%n", result);
buff.format(" coverage errlog: %s%n", errlog);
}
}
return buff.toString();
}
private String showMissing(Variable v) {
if (!(v instanceof VariableDS))
return "";
VariableDS ve = (VariableDS) v;
Formatter buff = new Formatter();
buff.format("%s:", v.getFullName());
buff.format("enhanceMode= %s%n", ve.getEnhanceMode());
ve.showScaleMissingProxy(buff);
return buff.toString();
}
public class VariableBean {
// static public String editableProperties() { return "title include logging freq"; }
VariableEnhanced ve;
CoordinateSystemBean coordSysBean;
String name, desc, units;
String dims, shape;
// no-arg constructor
public VariableBean() {}
// create from a dataset
public VariableBean(VariableEnhanced v, List<CoordinateSystemBean> csList) {
this.ve = v;
name = v.getFullName();
desc = v.getDescription();
units = v.getUnitsString();
// collect dimensions
boolean first = true;
StringBuilder lens = new StringBuilder();
StringBuilder names = new StringBuilder();
for (Dimension dim : v.getDimensions()) {
if (!first) {
lens.append(",");
names.append(",");
}
String name = dim.isShared() ? dim.getShortName() : "anon";
names.append(name);
lens.append(dim.getLength());
first = false;
}
dims = names.toString();
shape = lens.toString();
// sort by largest size first
if (v.getCoordinateSystems().size() > 0) {
List<CoordinateSystem> css = new ArrayList<>(v.getCoordinateSystems());
css.sort((o1, o2) -> o2.getCoordinateAxes().size() - o1.getCoordinateAxes().size());
CoordinateSystem cs = css.get(0);
for (CoordinateSystemBean csBean : csList)
if (cs == csBean.coordSys)
coordSysBean = csBean;
}
}
public String getName() {
return name;
}
public String getDims() {
return dims;
}
public String getShape() {
return shape;
}
public String getDescription() {
return (desc == null) ? "null" : desc;
}
public String getUnits() {
return (units == null) ? "null" : units;
}
@Nullable
public String getAbbrev() {
Attribute att = ve.findAttributeIgnoreCase(CDM.ABBREV);
return (att == null) ? null : att.getStringValue();
}
public String getCoordSys() {
return (coordSysBean == null) ? "" : coordSysBean.getCoordSys();
}
public String getDataType() {
return (coordSysBean == null) ? "" : coordSysBean.getDataType();
}
public String getCoverage() {
if (coordSysBean == null)
return "";
boolean complete = coordSysBean.coordSys.isComplete(ve);
return complete ? coordSysBean.getCoverage() : "Incomplete " + coordSysBean.getCoverage();
}
}
public class CoordinateSystemBean {
// static public String editableProperties() { return "title include logging freq"; }
CoordinateSystem coordSys;
private String name, ctNames, dataType = "", coverageType;
private int domainRank, rangeRank;
private boolean isGeoXY, isLatLon, isProductSet, isRegular;
// no-arg constructor
public CoordinateSystemBean() {}
public CoordinateSystemBean(CoordinateSystem cs) {
this.coordSys = cs;
setCoordSys(cs.getName());
setGeoXY(cs.isGeoXY());
setLatLon(cs.isLatLon());
setProductSet(cs.isProductSet());
setRegular(cs.isRegular());
setDomainRank(cs.getDomain().size());
setRangeRank(cs.getCoordinateAxes().size());
coverageType = DtCoverageCSBuilder.describe(ds, cs, null);
if (GridCoordSys.isGridCoordSys(parseInfo, cs, null)) {
addDataType("grid");
}
if (RadialCoordSys.isRadialCoordSys(parseInfo, cs)) {
addDataType("radial");
}
StringBuilder buff = new StringBuilder();
List ctList = cs.getCoordinateTransforms();
for (int i = 0; i < ctList.size(); i++) {
CoordinateTransform ct = (CoordinateTransform) ctList.get(i);
if (i > 0)
buff.append(" ");
buff.append(ct.getTransformType());
if (ct instanceof VerticalCT)
buff.append("(").append(((VerticalCT) ct).getVerticalTransformType()).append(")");
if (ct instanceof ProjectionCT) {
ProjectionCT pct = (ProjectionCT) ct;
if (pct.getProjection() != null) {
buff.append("(").append(pct.getProjection().getClassName()).append(")");
}
}
}
setCoordTransforms(buff.toString());
}
public String getCoordSys() {
return name;
}
public void setCoordSys(String name) {
this.name = name;
}
public boolean isGeoXY() {
return isGeoXY;
}
public void setGeoXY(boolean isGeoXY) {
this.isGeoXY = isGeoXY;
}
public boolean getLatLon() {
return isLatLon;
}
public void setLatLon(boolean isLatLon) {
this.isLatLon = isLatLon;
}
public boolean isProductSet() {
return isProductSet;
}
public void setProductSet(boolean isProductSet) {
this.isProductSet = isProductSet;
}
public boolean isRegular() {
return isRegular;
}
public void setRegular(boolean isRegular) {
this.isRegular = isRegular;
}
public int getDomainRank() {
return domainRank;
}
public void setDomainRank(int domainRank) {
this.domainRank = domainRank;
}
public int getRangeRank() {
return rangeRank;
}
public void setRangeRank(int rangeRank) {
this.rangeRank = rangeRank;
}
public String getCoordTransforms() {
return ctNames;
}
public void setCoordTransforms(String ctNames) {
this.ctNames = ctNames;
}
public String getDataType() {
return dataType;
}
void addDataType(String dt) {
dataType = dataType + " " + dt;
}
public boolean isImplicit() {
return coordSys.isImplicit();
}
public String getCoverage() {
return coverageType;
}
}
public static class AttributeBean {
private Attribute att;
// no-arg constructor
public AttributeBean() {}
// create from a dataset
public AttributeBean(Attribute att) {
this.att = att;
}
public String getName() {
return att.getShortName();
}
public String getValue() {
Array value = att.getValues();
return NCdumpW.toString(value, null, null);
}
}
public static class AxisBean {
// static public String editableProperties() { return "title include logging freq"; }
CoordinateAxis axis;
CoordinateSystem firstCoordSys = null;
String name, desc, units, axisType = "", positive = "", incr = "";
String dims, shape;
boolean isIndCoord;
boolean isLayer;
boolean isInterval;
// no-arg constructor
public AxisBean() {}
// create from a dataset
public AxisBean(CoordinateAxis v) {
this.axis = v;
setName(v.getFullName());
setCoordVar(v.isIndependentCoordinate());
setDescription(v.getDescription());
setUnits(v.getUnitsString());
// collect dimensions
StringBuilder lens = new StringBuilder();
StringBuilder names = new StringBuilder();
List dims = v.getDimensions();
for (int j = 0; j < dims.size(); j++) {
Dimension dim = (Dimension) dims.get(j);
if (j > 0) {
lens.append(",");
names.append(",");
}
String name = dim.isShared() ? dim.getShortName() : "anon";
names.append(name);
lens.append(dim.getLength());
}
setDims(names.toString());
setShape(lens.toString());
AxisType at = v.getAxisType();
if (at != null)
setAxisType(at.toString());
String p = v.getPositive();
if (p != null)
setPositive(p);
if (v instanceof CoordinateAxis1D) {
CoordinateAxis1D v1 = (CoordinateAxis1D) v;
if (v1.isRegular())
setRegular(Double.toString(v1.getIncrement()));
}
isLayer = (null != axis.findAttribute(_Coordinate.ZisLayer));
isInterval = axis.isInterval();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isIndCoord() {
return isIndCoord;
}
public void setCoordVar(boolean isIndCoord) {
this.isIndCoord = isIndCoord;
}
public boolean isContig() {
return axis.isContiguous();
}
/*
* public boolean isLayer() {
* return isLayer;
* }
*/
public boolean isInterval() {
return isInterval;
}
public String getShape() {
return shape;
}
public void setShape(String shape) {
this.shape = shape;
}
public String getAxisType() {
return axisType;
}
public void setAxisType(String axisType) {
this.axisType = axisType;
}
public String getDims() {
return dims;
}
public void setDims(String dims) {
this.dims = dims;
}
public String getDescription() {
return desc;
}
public void setDescription(String desc) {
this.desc = desc;
}
public String getUnits() {
return units;
}
public void setUnits(String units) {
this.units = (units == null) ? "null" : units;
}
public String getPositive() {
return positive;
}
public void setPositive(String positive) {
this.positive = positive;
}
public String getRegular() {
return incr;
}
public void setRegular(String incr) {
this.incr = incr;
}
}
}
| [
"67096+lesserwhirls@users.noreply.github.com"
] | 67096+lesserwhirls@users.noreply.github.com |
544660aef69b119bcbe1ae2374a47073c85b0366 | 440c0a79fa1288786e4a50066ea85feb6fe65b1f | /practise/src/main/java/com/gui/practise/design_model/singleton/HungrySingleton.java | 95b80b56d5375ecf0bdf71b8cb66bfe9b3697c54 | [] | no_license | williamjava/java_practise | 0b04089777c3ffc0250bfef9817974096308e013 | d1d4b3dc55721f12c463bd8dfc79a9f61e2d32a8 | refs/heads/master | 2022-06-22T06:28:51.051633 | 2021-06-03T09:52:38 | 2021-06-03T09:52:38 | 84,616,740 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 626 | java | package com.gui.practise.design_model.singleton;
/**
* 饿汉式(类初始化的时候便创建类的实例)
*
* 最简单的方式,线程安全。
*
* 存在的问题:无论这个类是否被使用,都会创建一个实例
*
* @author wuhoujian
*
*/
public class HungrySingleton {
// 1.系统初始化的时候,马上实例化
private static HungrySingleton singleton = new HungrySingleton();
// 2.私有的构造方法
private HungrySingleton() {
}
// 3.公共的访问实例的方法
public static HungrySingleton getInstance() {
System.out.println(singleton);
return singleton;
}
}
| [
"wuhoujian@126.com"
] | wuhoujian@126.com |
6415b929f28d55543ffa0c714307b5b3e7afabec | 7af9a322cbbab1eac9c70ade4b1be266c3392665 | /src/test/java/week06d01/ListSelectorTest.java | 978d89346c8395655d47b7d51229fe8c0c2c3e65 | [] | no_license | henimia/training-solutions | 3ac8335120f5fa0b8979997bb29933a0683ded12 | 6fdbfd49baac584266b86c9dc35a9f6a7d1826eb | refs/heads/master | 2023-03-25T04:25:14.148219 | 2021-03-16T10:01:15 | 2021-03-16T10:01:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 543 | java | package week06d01;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ListSelectorTest {
ListSelector listSelector = new ListSelector();
@Test
public void testTextToConvert() {
assertEquals("[almakörte]", listSelector.textToConvert(Arrays.asList("alma", "banán", "körte", "szilva")));
}
@Test
public void testTextToConvertNullList() {
assertEquals("", listSelector.textToConvert(Arrays.asList()));
}
}
| [
"66733574+manikola@users.noreply.github.com"
] | 66733574+manikola@users.noreply.github.com |
b596b6f92f2085507072754fb416ef22e45358ca | b456a89a96958d9483488e06ff62c90b79a4092b | /app/src/main/java/allgoritm/com/youla/utils/rx/CompositeDisposablesMap.java | 9c8ee2f1819c0f8ca0aa5fd284040bdc51f6e8be | [] | no_license | xvar/AdMobDemo | 284d331a73f63a527d30f68b2354d634b4fded5a | 6c2d2870f5b7b677310da1043a438d978bf6b7c7 | refs/heads/master | 2020-06-20T19:43:26.949966 | 2019-07-24T08:02:07 | 2019-07-24T08:02:07 | 197,226,015 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,567 | java | package allgoritm.com.youla.utils.rx;
import io.reactivex.disposables.Disposable;
import java.util.HashMap;
import java.util.Map;
public class CompositeDisposablesMap {
private final Map<String, Disposable> subscriptions;
public CompositeDisposablesMap() {
subscriptions = new HashMap<>();
}
public synchronized void put(String key, Disposable subscription) {
clear(key);
subscriptions.put(key, subscription);
}
public synchronized boolean isDisposed(String key) {
return !containsKey(key) || subscriptions.get(key).isDisposed();
}
public synchronized void clear(String key) {
if (subscriptions.containsKey(key)) {
clearSubscription(subscriptions.get(key));
subscriptions.remove(key);
}
}
public synchronized boolean containsKey(String key) {
return subscriptions.containsKey(key);
}
private synchronized void clearSubscription(Disposable subscription) {
if (subscription != null && !subscription.isDisposed()) {
subscription.dispose();
}
}
public synchronized void clearAll() {
for (Map.Entry<String, Disposable> entry : subscriptions.entrySet()) {
clearSubscription(entry.getValue());
}
subscriptions.clear();
}
public synchronized Boolean isAllDisposed() {
for (Disposable d:
subscriptions.values()) {
if (!d.isDisposed()) {
return false;
}
}
return true;
}
}
| [
"a.khaiminov@corp.mail.ru"
] | a.khaiminov@corp.mail.ru |
aa416f5b5abb4f6b12a69f93ca3aa345ab02194b | 95f99ee8ecd561a70ede8fa7ffcd2e297a8e40ec | /src/main/java/io/thejunct/galactiquest/database/PlayerData.java | 4ebafbace537266e776e78e9b731e8265d0834a5 | [] | no_license | TheJunction/Galactiquest | 6403086a5894e1bad6521e972114719d6b94d255 | 8d9c3129a9d705aed3dd60fafab60e022c89f815 | refs/heads/master | 2021-05-15T23:02:14.162770 | 2017-02-12T05:36:34 | 2017-02-12T05:36:34 | 106,880,178 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,146 | java | /*
* Copyright (c) 2017 The Junction Network. All Rights Reserved.
* Created by PantherMan594.
*/
package io.thejunct.galactiquest.database;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* Created by david on 10/22.
*
* @author david
*/
@SuppressWarnings({"unchecked", "MismatchedQueryAndUpdateOfCollection", "SqlNoDataSourceInspection", "SqlResolve"})
public class PlayerData extends Database {
private Map<String, String> lastname = new HashMap<>();
private Map<String, String> station = new HashMap<>();
public PlayerData() {
super("SQLite", "playerdata", "(" +
"`uuid` varchar(32) NOT NULL," +
"`lastname` varchar(32) NOT NULL," +
"`inSpaceShip` int(1) NOT NULL," +
"`station` varchar(32) NOT NULL", "uuid");
}
public boolean createDataNotExist(String uuid) {
if (getData("uuid", uuid, "uuid") != null) {
return true;
}
Player p = Bukkit.getPlayer(UUID.fromString(uuid));
Connection conn = getSQLConnection();
try (
PreparedStatement ps = conn.prepareStatement("INSERT INTO " + dbName +
" (uuid, lastname, inSpaceShip, station) " +
"VALUES (?,?,?,?);")
) {
setValues(ps, uuid, p != null ? p.getName() : "", 0, "");
ps.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
private Map<String, Map> getData() {
Map<String, Map> data = new HashMap<>();
data.put("lastname", lastname);
data.put("station", station);
return data;
}
private Object getData(String uuid, String label) {
if (getData().containsKey(label)) {
if (!getData().get(label).containsKey(uuid)) {
getData().get(label).put(uuid, getData("uuid", uuid, label));
}
return getData().get(label).get(uuid);
}
return getData("uuid", uuid, label);
}
private void setData(String uuid, String label, Object labelVal) {
if (getData().containsKey(label)) {
getData().get(label).put(uuid, labelVal);
}
setData("uuid", uuid, label, labelVal);
}
public String getName(String uuid) {
return (String) getData(uuid, "lastname");
}
public void setName(String uuid, String name) {
setData(uuid, "lastname", name);
}
public boolean inSpaceShip(String uuid) {
return (int) getData(uuid, "inSpaceShip") == 1;
}
public void setSpaceShip(String uuid, boolean inSpaceShip) {
setData(uuid, "inSpaceShip", inSpaceShip ? 1 : 0);
}
public String getStation(String uuid) {
return (String) getData(uuid, "station");
}
public void setStation(String uuid, String name) {
setData(uuid, "station", name);
}
}
| [
"me@pantherman594.com"
] | me@pantherman594.com |
6da44c95002bf3d0e7d4f9e8cd741488ba38e38d | 5f8d9e5fbebb3d5188463bb5ab7e0cdd32f62e9d | /AndroidLearnMiddle/app/src/main/java/com/example/androidlearnmiddle/RecycleView/Adapter/AddAndDelAdapter.java | cb6c840db82010934262b12cef1e0a40658fa818 | [] | no_license | xicaiZhou/AdroidLearnMiddle | 70f24bc620cdedcd754c4b15191a9218afd3e2da | 76d5ee69aca4375681dc34f7058c919ba1bce29c | refs/heads/master | 2020-06-19T04:23:40.035195 | 2020-03-13T07:00:36 | 2020-03-13T07:00:36 | 196,561,382 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,979 | java | package com.example.androidlearnmiddle.RecycleView.Adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.androidlearnmiddle.R;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
public class AddAndDelAdapter extends RecyclerView.Adapter {
private Context context;
private OnItemClick onItemClick;
private List<String> data;
public AddAndDelAdapter(Context context, OnItemClick onItemClick, List<String> data) {
this.context = context;
this.onItemClick = onItemClick;
this.data = data;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
return new AddAndDelAdapter.addAndDelViewHolder(LayoutInflater.from(context).inflate(R.layout.layou_rv_vertical,viewGroup,false));
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, final int i) {
((addAndDelViewHolder)viewHolder).tv.setText(data.get(i));
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onItemClick.onClick(i);
}
});
}
@Override
public int getItemCount() {
return data.size();
}
static class addAndDelViewHolder extends RecyclerView.ViewHolder{
public TextView tv;
public addAndDelViewHolder(@NonNull View itemView) {
super(itemView);
tv = itemView.findViewById(R.id.rv_vertical_tv);
}
}
public interface OnItemClick{
void onClick(int pos);
}
public void refresh(List<String> data){
this.data = data;
notifyDataSetChanged();
}
}
| [
"zhouxicaijob@163.com"
] | zhouxicaijob@163.com |
c4650d2587bebd2ab846c4e6256747b775fbd58b | f38afb90f0c4949a777689cb551c96ece307187e | /app/src/main/java/com/yanyl/baijia/news/atys/JieShaoActivity.java | 3e3ab33e5b595f2b58e6e16ac43cb9623a6f106f | [] | no_license | yanyonglei/BaijiaDemo | 0709495eac31c8c2180fd84da8b98bcce25964aa | 88c39108ec27d02b1b342fbc818166456ba5f0b3 | refs/heads/master | 2020-01-23T21:59:14.342436 | 2016-11-25T02:39:08 | 2016-11-25T02:39:08 | 74,718,945 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,979 | java | package com.yanyl.baijia.news.atys;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import com.yanyl.baijia.news.R;
import com.yanyl.baijia.news.common.Const;
import com.yanyl.baijia.news.util.Util;
/**
* Created by yanyl on 2016/10/24.
* 游戏介绍的界面
*/
public class JieShaoActivity extends BaseActivity implements View.OnClickListener {
//游戏开始控件
private Button mBeginBtn;
//游戏退出控件
private Button mBackBtn;
//游戏介绍控件
private Button mJieShaoBtn;
//进入游戏控件
private ImageView mEnterView;
//退出 游戏介绍
private ImageView mBackView;
@Override
protected void onCreate( Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_jieshao);
//初始化控件
initViews();
}
private void initViews() {
mBeginBtn= (Button) findViewById(R.id.id_btn_begin);
mBackBtn= (Button) findViewById(R.id.id_btn_back);
mJieShaoBtn= (Button) findViewById(R.id.id_btn_jieshao);
mEnterView= (ImageView) findViewById(R.id.id_img_enter);
mBackView= (ImageView) findViewById(R.id.id_img_back);
mBeginBtn.setOnClickListener(this);
mBackBtn.setOnClickListener(this);
mJieShaoBtn.setOnClickListener(this);
mEnterView.setOnClickListener(this);
mBackView.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.id_btn_begin:
//开始游戏
begin();
break;
case R.id.id_btn_back:
back();
break;
case R.id.id_btn_jieshao:
//初始化弹出对话框
initDialog();
break;
case R.id.id_img_enter:
Util.enterIntent(this,GameActivity.class);
break;
case R.id.id_img_back:
back();
break;
}
}
private void initDialog() {
final AlertDialog dialog=new AlertDialog.Builder(JieShaoActivity.this).create();
View view=getLayoutInflater().inflate(R.layout.dialog,null);
//确定按钮
Button mButtonQd= (Button) view.findViewById(R.id.id_queding);
//取消按钮
Button mButtonCancel= (Button) view.findViewById(R.id.id_cancel);
mButtonQd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
mButtonCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.setView(view);
dialog.show();
}
private void back() {
Util.backIntent(JieShaoActivity.this);
}
private void begin() {
final AlertDialog dialog=new AlertDialog.Builder(JieShaoActivity.this).create();
View view=getLayoutInflater().inflate(R.layout.dialog_class,null);
Button mButtonDiff= (Button) view.findViewById(R.id.id_diff);
Button mButtonEasy= (Button) view.findViewById(R.id.id_easy);
Button mButtonCancel= (Button) view.findViewById(R.id.id_cancel);
mButtonDiff.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(JieShaoActivity.this,GameActivity.class);
//设置游戏的难易等级
intent.putExtra("grid", Const.DIFFERICAT);
startActivity(intent);
overridePendingTransition(R.anim.in_from_right,
R.anim.out_to_left);
dialog.dismiss();
}
});
mButtonEasy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(JieShaoActivity.this,GameActivity.class);
//设置游戏的难易等级
intent.putExtra("grid",Const.EASY);
startActivity(intent);
overridePendingTransition(R.anim.in_from_right,
R.anim.out_to_left);
dialog.dismiss();
}
});
mButtonCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.setView(view);
dialog.show();
}
}
| [
"1339447312@qq.com"
] | 1339447312@qq.com |
0a12d918380f5eccc7ca13f83ac4e526adacfbb1 | be5bebbfe48de33b331197fb0e6576f80ce677ff | /NoDistance/src/com/project/schoolservice/BookSearch.java | 4d22630558e93bd0385b1fa1071d73557c8c77cb | [] | no_license | AlexMagic/No_Distance | a365a3c6b526caf43b6263ec3859992df640dddb | 8d914f572423f5293708c4ca5498158d06e5d04c | refs/heads/master | 2021-01-13T00:49:07.420132 | 2015-12-22T06:09:51 | 2015-12-22T06:09:51 | 48,410,463 | 2 | 0 | null | null | null | null | GB18030 | Java | false | false | 13,776 | java | package com.project.schoolservice;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewTreeObserver.OnScrollChangedListener;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.project.R;
public class BookSearch {
private Activity mActivity;
private Context mContext;
private View book_search;
private View loadmore;
private EditText editText;
private ImageButton mClear;
private Button btn_search;
private ListView listView;
private BookListAdapter adapter;
private InputMethodManager manager;
private ProgressBar mLoadmore;
private ProgressBar mProgressBar;
private int nextPageNum;
private ArrayList bookno=new ArrayList();
private ArrayList stitle=new ArrayList();
private ArrayList booknoSingle=new ArrayList();
private ArrayList save=new ArrayList();
private ArrayList<BookListItem> list = new ArrayList<BookListItem>();
private String globalLink;//全局链接
private int ten = 1;
private int indexNum = 0;
private Handler handler = new Handler(){
public void handleMessage(Message msg) {
System.out.println("22222222");
if(msg.what==1){
Toast.makeText(mActivity, "加载成功", Toast.LENGTH_LONG).show();
if(save.size()%10==0 ){
loadmore.setVisibility(View.VISIBLE);
loadmore.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
mProgressBar.setVisibility(View.VISIBLE);
mLoadmore.setVisibility(View.VISIBLE);
getContent(globalLink);
// mLoadmore.setVisibility(View.GONE);
}
});
listView.addFooterView(loadmore);
}else{
listView.removeFooterView(loadmore);
}
for(int i=0;i<save.size();i++){
BookListItem item=list.get(i);
item.setSave((String)save.get(i));
}
System.out.println("save.size()-----:"+save.size());
mProgressBar.setVisibility(View.GONE);
mLoadmore.setVisibility(View.GONE);
adapter = new BookListAdapter(mContext, list);
listView = (ListView) book_search.findViewById(R.id.book_list);
listView.setAdapter(adapter);
listView.setSelection(ten-11);
adapter.notifyDataSetChanged();
}
// if(msg.what==0){
// getContent(globalLink);
// adapter.notifyDataSetChanged();
// loadmore.setVisibility(View.GONE);
// }
};
};
public BookSearch(Activity mActivity , Context mContext){
this.mActivity = mActivity;
this.mContext = mContext;
// mSchoolService = new SchoolService(mContext, mActivity);
book_search = LayoutInflater.from(mContext).inflate(R.layout.book_search, null);
loadmore = LayoutInflater.from(mContext).inflate(R.layout.loadmore, null);
// adapter = new
setUpView();
setListner();
}
private void setUpView() {
manager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
// mProgressBar = (ProgressBar) book_search.findViewById(R.id.loading);
editText = (EditText) book_search.findViewById(R.id.search_book_edit);
mClear = (ImageButton) book_search.findViewById(R.id.book_searchclear);
btn_search = (Button) book_search.findViewById(R.id.btn_search_result);
listView = (ListView) book_search.findViewById(R.id.book_list);
mLoadmore = (ProgressBar) loadmore.findViewById(R.id.loadmore);
mProgressBar = (ProgressBar) book_search.findViewById(R.id.loading);
// adapter = new BookListAdapter(mContext, list);
// listView.setAdapter(adapter);
}
private void setListner() {
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(editText.getText().length()>0){
mClear.setVisibility(View.VISIBLE);
}else
mClear.setVisibility(View.INVISIBLE);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
if(editText.getText().length()>0){
mClear.setVisibility(View.VISIBLE);
}else
mClear.setVisibility(View.INVISIBLE);
}
@Override
public void afterTextChanged(Editable s) {
}
});
mClear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
editText.setText("");
}
});
btn_search.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
//获取书列表
hideKeyboard();
save.clear();
list.clear();
indexNum=0;
mProgressBar.setVisibility(View.VISIBLE);
nextPageNum = 1;
String bookname = editText.getText().toString();
System.out.println("bookname-------:"+bookname);
if("".equals(bookname)){
System.out.println("kong");
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(mActivity, "输入书名不能为空", Toast.LENGTH_LONG).show();
return ;
}
});
}else{
String input = bookname.trim().replace(" ", "+");
String url = "http://opac.szpt.edu.cn:8991/F/?request="+input+"&func=find-b&adjacent=N&local_base=SZY01&filter_code_1=WLN&filter_code_4=WFM&find_code=WRD";
getContent(url);
}
}
});
listView.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
}
});
// listView.setOnScrollListener(this);
}
//获取学校图书查询网站的html的内容
public void getContent(final String url){
new Thread(new Runnable() {
@Override
public void run() {
String html = getHtmlByUrl(url);
if(html!=null && !"".equals(html)){
Document doc = Jsoup.parse(html.replace(" ",""));
Elements mylink=doc.select("a");
for(int kk=36;kk<mylink.size();kk++){
// System.out.println("myLink----:"+ mylink.text());
if(mylink.get(kk).toString().contains("hint")){
String allk="";
String[] my=mylink.get(kk).toString().replace("/ ","/").split(" ");
if(my.length>1){
for(int c=1;c<my.length;c++)
{
// System.out.println("my--------:"+my[c]);
if(my[c-1].contains("LXDZW"))
{
allk+="留仙洞"+my[c].substring(0,4);
}else if(my[c-1].contains("DLTK")){
allk+="西丽湖"+my[c].substring(0,4);
}else{
allk+="其他库"+my[c].substring(0,4);
}
System.out.println("allk---: " + allk);
}
}
save.add(allk);
}
}
//下一页
Element links = doc.select("a[href]").first();
String nextLink=links.toString();
// System.out.println("nextLink---:"+nextLink);
Log.v("nn", nextLink);
int end=nextLink.indexOf("?");
nextLink=nextLink.substring(9, end);
// System.out.println("nextLink----:"+nextLink);
int skil=Integer.parseInt(nextLink.substring(nextLink.length()-5));
skil+=39;//下一页的链接随机号码增加39
nextLink=nextLink.substring(0,nextLink.length()-5);
nextLink+=skil;
nextLink+="?func=short-jump&jump=";
ten+=10;
nextLink+=ten;//跳页加 10条
globalLink=nextLink;
System.out.println("globalLink---:"+globalLink);
Log.v("nn", globalLink);
//获取作者,索书号,出版社,日期
int i=0;//循环变量
Elements es = doc.getElementsByAttributeValue("class","content");//获取class为content的标签内容
Elements title=doc.getElementsByAttributeValue("class","itemtitle");
String one="";
Log.v("ssss",String.valueOf(es.size()));
System.out.println(es.size());
try
{
for (Element ele:es)
{
if(es.size()>i)
{
String getno=new String(es.get(i).text().getBytes("ISO-8859-1"),"utf-8");
// System.out.println("getno----:"+getno);
if(i%6==1&&i!=61&&i!=122&&i!=183&&i!=244)
{
booknoSingle.add(getno.trim()+" ");//加空格防止空指针
//Log.v("sssss", getno);
}
one+=getno.trim()+"\n";
i++;
if(i%6==0)
{
System.out.println("one--:"+one);
// Map<String , Object> info = new HashMap<String, Object>();
BookListItem item = new BookListItem();
String[] temp = one.split("\n");
for (int j = 0; j < temp.length; j++) {
switch(j){
case 0:
if(temp[j]!=null)
item.setWriter(temp[j]);
else
item.setWriter(" ");
break;
case 1:
if(temp[j]!=null)
item.setIndex(temp[j]);
else
item.setIndex(" ");
break;
case 2:
if(temp[j]!=null)
item.setPublish(temp[j]);
else
item.setPublish(" ");
break;
case 3:
if(temp[j]!=null)
item.setYear(temp[j]);
else
item.setYear(" ");
break;
}
}
list.add(item);
// bookno.add(one.trim()+"\n");
one="";
}
}
}
//获取书名
int j=0;
for(Element ele:title)
{
// BookListItem temp;
String gettitle=new String(title.get(j).text().getBytes("ISO-8859-1"),"utf-8");
System.out.println("gettitle-----:"+gettitle);
BookListItem item=list.get(indexNum);
item.setBookName(gettitle);
// list.add(item);
// stitle.add(gettitle);
indexNum++;
j++;
}
} catch (UnsupportedEncodingException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("here");
handler.sendEmptyMessage(1);
}
}
}).start();
}
public void setBookInfo(){
BookListItem item = new BookListItem();
List<Map<String,Object>> listItems=new ArrayList<Map<String,Object>>();
for(int a=0;a<bookno.size();a++){
Map<String,Object> listItem=new HashMap<String,Object>();
listItem.put("title",stitle.get(a));
System.out.println("title:"+stitle.get(a));
listItem.put("bookno",(bookno.get(a).toString()+save.get(a).toString()));
System.out.println("bookno----:"+(bookno.get(a).toString()+save.get(a).toString()));
listItems.add(listItem);
}
}
/**
* 根据URL获得所有的html信息
* @param url
* @return
*/
public static String getHtmlByUrl(String url){
String html = null;
HttpClient httpClient = new DefaultHttpClient();//创建httpClient对象
HttpGet httpget = new HttpGet(url);//以get方式请求该URL
try {
HttpResponse responce = httpClient.execute(httpget);//得到responce对象
int resStatu = responce.getStatusLine().getStatusCode();//返回码
if (resStatu==HttpStatus.SC_OK) {//200正常 其他就不对
//获得相应实体
HttpEntity entity = responce.getEntity();
if (entity!=null) {
html = EntityUtils.toString(entity);//获得html源代码
}
}
} catch (Exception e) {
System.out.println("访问【"+url+"】出现异常!");
e.printStackTrace();
} finally {
httpClient.getConnectionManager().shutdown();
}
return html;
}
/**
* 隐藏软键盘
*/
private void hideKeyboard() {
if (mActivity.getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
if (mActivity.getCurrentFocus() != null)
manager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
public View getView(){
return book_search;
}
// private int lastItem;
//
// public void onScrollStateChanged(AbsListView view, int scrollState) {
// if(save.size()%10==0 && scrollState == OnScrollListener.SCROLL_STATE_IDLE){
// //下拉到空闲是,且最后一个item的数等于数据的总数时,进行更新
// if(lastItem == save.size() && scrollState == this.SCROLL_STATE_IDLE){
//// Log.i(TAG, "拉到最底部");
// loadmore.setVisibility(view.VISIBLE);
//
// handler.sendEmptyMessage(0);
// }
// }
// }
//
//
// @Override
// public void onScroll(AbsListView view, int firstVisibleItem,
// int visibleItemCount, int totalItemCount) {
// // TODO Auto-generated method stub
// lastItem = firstVisibleItem + visibleItemCount - 1;
// }
}
| [
"327393059@qq.com"
] | 327393059@qq.com |
5cc7b1853175222c541e373f9d44ecfc0972fc14 | 43c3d32e40ca360370b15ce745dc2e65f689f763 | /src/main/java/com/unionx/core/web/function/DataDictFunction.java | 1b471622ce6e4c920bc2ac0517de5f677a666bc6 | [] | no_license | LhuiF/rxst | f8435053757504422b36f5fa55139e9358d2f31a | 534570b98335672bf176d316816b97c82baab423 | refs/heads/master | 2021-01-19T14:10:27.753890 | 2017-04-13T06:19:09 | 2017-04-13T06:19:09 | 88,131,551 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,271 | java | package com.unionx.core.web.function;
import com.unionx.sys.dict.service.DictService;
import com.unionx.core.util.JsonUtils;
import com.unionx.core.util.SpringContextUtil;
import com.unionx.sys.dict.vo.DictItem;
import lombok.extern.slf4j.Slf4j;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author songjunjie HouShuangYang
*/
@Slf4j
public class DataDictFunction {
/**
* 根据字典代码返回字典项列表
* @param dictCode 字典代码
* @return
*/
public static List getDictItem(String dictCode) {
List<DictItem> list = null;
try {
DictService dictService = SpringContextUtil.getBean("dictService", DictService.class);
list = dictService.findDictItem(dictCode,null);
} catch (Exception e) {
log.error("", e);
return null;
}
return list;
}
/**
* 根据字典code,返回一个json字符串.例如:{"1":"男","2":"女"}
* @param dictCode
* @return
*/
public static String getJsonMap(String dictCode) {
List<DictItem> list = null;
Map map = new HashMap<>();
try {
DictService dictService = SpringContextUtil.getBean("dictService", DictService.class);
list = dictService.findDictItem(dictCode,null);
for (DictItem dictItem : list) {
map.put(dictItem.getCode(), dictItem.getName());
}
} catch (Exception e) {
log.error("", e);
return "{}";
}
return JsonUtils.writeValueAsString(map);
}
/**
* 根据字典code,返回一个json数组。例如:[{"code":"1","name":"男"},{"code":"2","name":"女"}]
* @param dictCode
* @return
*/
public static String getJsonArray(String dictCode) {
List<DictItem> list = null;
try {
DictService dictService = SpringContextUtil.getBean("dictService", DictService.class);
list = dictService.findDictItem(dictCode,null);
} catch (Exception e) {
log.error("", e);
return "[]";
}
if (list == null) {
return "[]";
}
return JsonUtils.writeValueAsString(list);
}
}
| [
"lihuifang@iunionx.com"
] | lihuifang@iunionx.com |
5916e720413b793985bfa1928e08449cc061089e | 23b27cd93a5c551daf10371d4a8baff3b50f386b | /proj2c/bearmaps/TrieSet61B.java | 3ded58904290ba0f9174ac09ec90c386f2d59ca1 | [] | no_license | dennyrich/BerkeleyCS61b | 9dd6d566903ba9a0e875808302a4861b26a4d02c | d3a71d417059dfb9af26b274b7e785a8b0972902 | refs/heads/master | 2020-09-26T11:27:35.004192 | 2019-04-18T03:54:21 | 2019-04-18T03:54:21 | 226,245,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 636 | java | package bearmaps;
import java.util.List;
public interface TrieSet61B {
/** Clears all items out of Trie */
void clear();
/** Returns true if the Trie contains KEY, false otherwise */
boolean contains(String key);
/** Inserts string KEY into Trie */
void add(String key);
/** Returns a list of all words that start with PREFIX */
List<String> keysWithPrefix(String prefix);
/** Returns the longest prefix of KEY that exists in the Trie
* Not required for Lab 9. If you don't implement this, throw an
* UnsupportedOperationException.
*/
String longestPrefixOf(String key);
}
| [
"dsrich@berkeley.edu"
] | dsrich@berkeley.edu |
99903e165643de4e0b54ced1df91d667adcfb8b4 | be310fe3411d906d6f3cffcf88d68ece122c1318 | /vehicles-api/src/main/java/com/udacity/vehicles/config/SwaggerConfig.java | 26d9176085831ee7dc76fc395d572c580fcb1fb7 | [
"MIT"
] | permissive | DannyDenver/Vehicle-Microservices-Application | e4cd1ea19163290445afc68976afed8beb380e91 | fc7b0d1a5ac81555da49d99c0bfa344f3e714e50 | refs/heads/master | 2022-11-22T17:18:39.660510 | 2020-07-22T22:47:27 | 2020-07-22T22:47:27 | 281,205,149 | 0 | 0 | MIT | 2020-07-22T22:48:10 | 2020-07-20T19:15:08 | Java | UTF-8 | Java | false | false | 1,059 | java | package com.udacity.vehicles.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfo(
"Vehicles REST API",
"This API serves to track vehicle inventory.",
"1.0", null, null, null, null);
}
}
| [
"djt09d@fulbrightmail.org"
] | djt09d@fulbrightmail.org |
c8a7e582f86f4ae1077e12a6f945c3bc8b5e7c45 | 22a4f822c8d06a13e0b03c599c4f2b264a6bcd65 | /src/main/java/by/bntu/fitr/povt/coffeebaby/model/sorting/SortWeightAscending.java | 6d5b55f56197f54ba0d8e856d84a8b42f90b45c4 | [] | no_license | KenKingson/LAB15Log4j | 556d889be01de3450d3b22e01e81d439e5c1647f | 911a12e9cd43e13b42e7082bf5259634e8911a15 | refs/heads/master | 2020-03-19T10:24:53.409751 | 2018-06-06T15:59:48 | 2018-06-06T15:59:48 | 136,367,949 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 402 | java | package by.bntu.fitr.povt.coffeebaby.model.sorting;
import by.bntu.fitr.povt.coffeebaby.model.essence.Stone;
import java.util.Comparator;
public class SortWeightAscending implements Comparator<Stone> {
public int compare(Stone stone1, Stone stone2) {
Double weight1 = stone1.getWeigth();
Double weight2 = stone2.getWeigth();
return weight1.compareTo(weight2);
}
}
| [
"alexeyvolskiy@gmail.com"
] | alexeyvolskiy@gmail.com |
b06141a03fdfebdbf7b502c9057f9d9b8b83a4df | fd3536816c0fdc31f45fc48f8f1b11d74771fa16 | /src/main/java/com/example/algamoney/api/event/RecursoCriadoEvent.java | 67c41b7eb558a96b6a7548bb1c802a8e39daa725 | [] | no_license | palmeirasrodrigo/algamoney | c6a09c7c7c718297f1e0356e998424248b238df7 | f24cc37c264dba90fd195924be9b55e4dc6f7461 | refs/heads/master | 2020-08-28T05:26:43.245626 | 2019-10-24T14:29:43 | 2019-10-24T14:29:43 | 217,606,588 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 597 | java | package com.example.algamoney.api.event;
import javax.servlet.http.HttpServletResponse;
import org.springframework.context.ApplicationEvent;
public class RecursoCriadoEvent extends ApplicationEvent{
private static final long serialVersionUID = 1L;
private HttpServletResponse response;
private Long codigo;
public RecursoCriadoEvent(Object source, HttpServletResponse response, Long codigo) {
super(source);
this.response = response;
this.codigo = codigo;
}
public HttpServletResponse getResponse() {
return response;
}
public Long getCodigo() {
return codigo;
}
}
| [
"palmeirasrodrigo@hotmail.com"
] | palmeirasrodrigo@hotmail.com |
99ed9a4c87fffddb198419a04e4756d38013b86b | a45dd5eafb8c5adaccc620a60a6cab2ff9f213d7 | /src/utility/CodeTagsMiner.java | 3a8c7d6eb7d3aa5dca14ac36ba9709fb21f48532 | [] | no_license | masud-technope/SurfClipseServerGH | 0324ab1bc627e170915645f1827b15a673ff45f5 | 8bb361b87996b027c37bb738bbdedd97815cf897 | refs/heads/master | 2021-01-17T15:11:13.949291 | 2016-08-02T05:53:57 | 2016-08-02T05:53:57 | 13,754,473 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,384 | java | package utility;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CodeTagsMiner {
/**
* @param args
*/
String source_code;
String resultContent;
public CodeTagsMiner(String resultContent)
{
//assigning the source code to mine
this.resultContent=resultContent;
}
protected void test_the_extraction()
{
DownloadResultEntryContent dre=
new DownloadResultEntryContent(new ArrayList());
String fileContent=dre.test_download();
this.resultContent=fileContent;
//System.out.println(this.resultContent);
}
public String mine_code_examples()
{
//code for mining <code> tag
String code_pattern="<code>(.+?)</code>";
String pre_pattern="<pre>(.+?)</pre>";
String div_pattern="<div>(.+?)</div>";
String pre_code_pattern="<pre><code>(.+?)</code></pre>";
final Pattern pattern = Pattern.compile(div_pattern);
final Matcher matcher = pattern.matcher(this.resultContent);
System.out.println("Match found:"+matcher.groupCount());
for(int i=0;i<matcher.groupCount();i++)
{
System.out.println(matcher.group(i));
this.source_code+=matcher.group(i);
}
return this.source_code;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
CodeTagsMiner miner=new CodeTagsMiner("");
miner.test_the_extraction();
miner.mine_code_examples();
}
}
| [
"masudcseku@gmail.com"
] | masudcseku@gmail.com |
7cf8d9cb1f718401cababda5ef8e3f832565c5b8 | e6d8414ac8c9fc9de6b67bab57f941dd0f3bbe6a | /Lib/src/androidTest/java/kr/co/hs/firebase/fcm/ApplicationTest.java | 3ab3b27c8e381ce2cc88243851f2ebdcf2c26b0a | [] | no_license | hsbaewa/HsFirebaseCloudMessaging | 51eee395582b8edd267d737dbc85a5f0d50b1de6 | 07d5ae6f57d649d5e7d65497a90b9b15454aceb6 | refs/heads/master | 2021-01-12T04:21:05.940898 | 2016-12-30T02:15:23 | 2016-12-30T02:15:23 | 77,593,312 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 352 | java | package kr.co.hs.firebase.fcm;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
} | [
"hsbaewa@gmail.com"
] | hsbaewa@gmail.com |
374b7eca85909c079c766d98550276874ca9f963 | cb3fde6a04860e63a5fa9973e6c7354e2c5c5951 | /STRING/src/CW/methods_of_string_buffer.java | 2110cc6bb500348644635165c6823262dc100c7e | [] | no_license | pratiksha311/Core-Java | acfc095912c4325e7bdc51d1062eecd174dbf72d | 63587a7f3d7facacb3d39cf080c5046352384211 | refs/heads/main | 2023-01-23T16:55:10.266521 | 2020-12-13T16:55:42 | 2020-12-13T16:55:42 | 319,282,370 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 838 | java | package CW;
import java.util.Scanner;
public class methods_of_string_buffer {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("enter any string");
StringBuffer s1=new StringBuffer(sc.next());
System.out.println("capacity before tramToSize="+s1.capacity());
s1.trimToSize();
System.out.println("capacity after tramToSize="+s1.capacity());
System.out.println("enter string for concat");
StringBuffer s2=new StringBuffer(sc.next());
System.out.println("after append string="+s1.append(s2));
System.out.println("after delete="+s2.delete(2, 4));
System.out.println("after insert="+s2.insert(3,"india"));
System.out.println("after replace="+s2.replace(2, 5, "_world"));
System.out.println("after rever="+s2.reverse());
}
}
| [
"noreply@github.com"
] | pratiksha311.noreply@github.com |
bff8886460520256017ff3cb3cc262247c2d2f36 | d92cd5b28f86fb761787c6ff15ddbe5e4b4aaf20 | /src/main/java/com/newa5pro/job/Job.java | 3959d952ad3571d3b0c3cd837d0baf9351e08250 | [] | no_license | Sreejithw/ICT-2 | b7923f0ed64d733637849da17a8cccb7e869b906 | 872e2815bffc3f22bdc6b46b3c71d5484c1bdac3 | refs/heads/master | 2021-01-17T04:56:33.162570 | 2015-11-24T15:19:03 | 2015-11-24T15:19:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 717 | 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.newa5pro.job;
/**
*
* @author Fu
*/
public class Job {
public int Id ;
public int comId ;
public String info;
public String location;
public String request;
public String benefit;
public String position;
public int cmin;
public int cmax;
public int age;
public String sex;
public String type;
public int exp;
public String country;
public String term;
public Job() {
}
public boolean isValid(){
return Id!=-1;
}
}
| [
"huangyi_95.1.27@hotmail.com"
] | huangyi_95.1.27@hotmail.com |
1c9e4ecbb5d51a228fbbcef00799d590df395a18 | 383e578ec8ac3043ddece8223494f27f4a4c76dd | /legend.biz/src/main/java/com/tqmall/legend/biz/order/impl/OrderServiceImpl.java | 11f4015f54d969c4530668c64a6192cf80b0a006 | [] | no_license | xie-summer/legend | 0018ee61f9e864204382cd202fe595b63d58343a | 7e7bb14d209e03445a098b84cf63566702e07f15 | refs/heads/master | 2021-06-19T13:44:58.640870 | 2017-05-18T08:34:13 | 2017-05-18T08:34:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 134,743 | java | package com.tqmall.legend.biz.order.impl;
import com.google.common.base.Optional;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import com.tqmall.common.Constants;
import com.tqmall.common.UserInfo;
import com.tqmall.common.exception.BizException;
import com.tqmall.common.exception.BusinessCheckedException;
import com.tqmall.common.util.DateUtil;
import com.tqmall.cube.shop.RpcBusinessDailyService;
import com.tqmall.legend.biz.base.BaseServiceImpl;
import com.tqmall.legend.biz.customer.CustomerCarService;
import com.tqmall.legend.biz.customer.CustomerService;
import com.tqmall.legend.biz.customer.ICustomerContactService;
import com.tqmall.legend.biz.goods.GoodsService;
import com.tqmall.legend.biz.insurance.InsuranceCompanyService;
import com.tqmall.legend.biz.manager.thread.OrderInfoExtSaveThread;
import com.tqmall.legend.biz.manager.thread.OrderInfoExtUpdateThread;
import com.tqmall.legend.biz.manager.thread.ThreadManager;
import com.tqmall.legend.biz.order.*;
import com.tqmall.legend.biz.order.log.OrderOperationLog;
import com.tqmall.legend.cache.SnFactory;
import com.tqmall.legend.biz.order.vo.OrderServicesVo;
import com.tqmall.legend.biz.privilege.ShopManagerService;
import com.tqmall.legend.biz.shop.ShopServiceInfoService;
import com.tqmall.legend.common.JsonUtils;
import com.tqmall.legend.common.Result;
import com.tqmall.legend.dao.order.OrderInfoDao;
import com.tqmall.legend.entity.customer.Customer;
import com.tqmall.legend.entity.customer.CustomerCar;
import com.tqmall.legend.entity.goods.Goods;
import com.tqmall.legend.entity.insurance.InsuranceCompany;
import com.tqmall.legend.entity.order.*;
import com.tqmall.legend.entity.precheck.PrecheckDetails;
import com.tqmall.legend.entity.privilege.ShopManager;
import com.tqmall.legend.entity.shop.ShopServiceInfo;
import com.tqmall.legend.facade.precheck.PrechecksFacade;
import com.tqmall.magic.object.result.proxy.ProxyDTO;
import com.tqmall.magic.service.proxy.RpcProxyService;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* orderInfo service
*/
@Service
public class OrderServiceImpl extends BaseServiceImpl implements IOrderService {
public static final Logger LOGGER = LoggerFactory.getLogger(OrderServiceImpl.class);
public static ObjectMapper mapper = new ObjectMapper();
@Autowired
CustomerCarService customerCarService;
@Autowired
GoodsService goodsService;
@Autowired
ShopServiceInfoService shopServiceInfoService;
@Autowired
OrderGoodsService orderGoodsService;
@Autowired
OrderServicesService orderServicesService;
@Autowired
CustomerService customerService;
@Autowired
IOrderSnapshotService orderSnapshotService;
@Autowired
ICustomerContactService customerContactService;
@Autowired
IVirtualOrderService virtualOrderService;
@Autowired
IVirtualOrdergoodService virtualOrdergoodService;
@Autowired
IVirtualOrderserviceService virtualOrderserviceService;
@Autowired
private OrderInfoDao orderInfoDao;
@Autowired
private SnFactory snFactory;
@Autowired
private ShopManagerService shopManagerService;
@Autowired
private ThreadManager threadManager;
@Autowired
private OrderInfoExtSaveThread orderInfoExtSaveThread;
@Autowired
private OrderInfoExtUpdateThread orderInfoExtUpdateThread;
@Autowired
private InsuranceCompanyService insuranceCompanyService;
@Autowired
private RpcProxyService rpcProxyService;
@Autowired
private PrechecksFacade prechecksFacade;
@Autowired
private OrderPrecheckDetailsService orderPrecheckDetailsService;
@Autowired
private RpcBusinessDailyService rpcBusinessDailyService;
/**
* calculate virtual order amount
*
* @param orderGoodsMapList
* @param orderServicesMapList
* @return
*/
private OrderInfo doVirtualCalcPrice(List<Map<String, Object>> orderGoodsMapList,
List<Map<String, Object>> orderServicesMapList) {
BigDecimal serviceAmount = BigDecimal.ZERO;
BigDecimal goodsAmount = BigDecimal.ZERO;
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal discount = BigDecimal.ZERO;
BigDecimal goodsDiscount = BigDecimal.ZERO;
BigDecimal serviceDiscount = BigDecimal.ZERO;
BigDecimal feeDiscount = BigDecimal.ZERO;
BigDecimal feeAmount = BigDecimal.ZERO;
BigDecimal manageFee = BigDecimal.ZERO;
if (!CollectionUtils.isEmpty(orderGoodsMapList)) {
for (int i = 0; i < orderGoodsMapList.size(); i++) {
String orderGoodsStr = JsonUtils.mapToJsonStr(orderGoodsMapList.get(i));
mapper = new ObjectMapper()
.setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY);
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,
false);
OrderGoods orderGoods = new OrderGoods();
try {
orderGoods = mapper.readValue(orderGoodsStr, OrderGoods.class);
} catch (Exception e) {
LOGGER.error("json字符串转orderGoods对象失败,ExceptionInfo:{}",e);
}
// 判断有效物料
goodsAmount = goodsAmount.add(orderGoods.getGoodsPrice().multiply(
orderGoods.getGoodsNumber()));
totalAmount = totalAmount.add(orderGoods.getGoodsPrice().multiply(
orderGoods.getGoodsNumber()));
discount = discount.add(orderGoods.getDiscount());
goodsDiscount = goodsDiscount.add(orderGoods.getDiscount());
}
}
manageFee = goodsAmount.subtract(goodsDiscount);
if (!CollectionUtils.isEmpty(orderServicesMapList)) {
for (int i = 0; i < orderServicesMapList.size(); i++) {
String orderServicesStr = JsonUtils.mapToJsonStr(orderServicesMapList.get(i));
mapper = new ObjectMapper()
.setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY);
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,
false);
OrderServices orderServices = new OrderServices();
try {
orderServices =
mapper.readValue(orderServicesStr, OrderServices.class);
} catch (Exception e) {
LOGGER.error("json字符串转orderService对象失败,ExceptionInfo:{}",e);
}
// 判断有效服务
if (orderServices.getType() == 1) {
serviceDiscount = serviceDiscount.add(orderServices.getDiscount());
serviceAmount = serviceAmount.add(orderServices.getServiceAmount());
}
if (orderServices.getType() == 2) {
if (orderServices.getFlags() != null && orderServices.getFlags().equals(Constants.GLF)) {
feeDiscount = feeDiscount.add(orderServices.getDiscount());
manageFee = manageFee.multiply(orderServices.getManageRate());
feeAmount = feeAmount.add(manageFee);
} else {
feeDiscount = feeDiscount.add(orderServices.getDiscount());
feeAmount = feeAmount.add(orderServices.getServiceAmount());
}
}
}
}
totalAmount = goodsAmount.add(serviceAmount).add(feeAmount);
discount = goodsDiscount.add(serviceDiscount).add(feeDiscount);
OrderInfo orderInfo = new OrderInfo();
orderInfo.setGoodsAmount(goodsAmount);
orderInfo.setServiceAmount(serviceAmount);
orderInfo.setTotalAmount(totalAmount);
orderInfo.setDiscount(discount);
orderInfo.setGoodsDiscount(goodsDiscount);
orderInfo.setServiceDiscount(serviceDiscount);
orderInfo.setFeeAmount(feeAmount);
orderInfo.setFeeDiscount(feeDiscount);
orderInfo.setOrderAmount(totalAmount.subtract(discount));
orderInfo.setManageFee(manageFee);
return orderInfo;
}
/**
* 保存工单使用地方:
* app:快修快保
* pc:快修快保、综合维修、销售单
*
* @param orderFormEntityBo 工单表单实体
* @param userInfo 当前登录用户
* @return
* @throws BusinessCheckedException
*/
@Override
public Result save(OrderFormEntityBo orderFormEntityBo, UserInfo userInfo)
throws BusinessCheckedException {
// order's basic info
OrderInfo orderInfo = orderFormEntityBo.getOrderInfo();
// check customerCar is exsit
Optional<CustomerCar> customerCarOptional =
customerCarService.getCustomerCar(orderInfo.getCustomerCarId());
if (!customerCarOptional.isPresent()) {
// TODO 整理 可查的错误信息{错误码:错误信息}
throw new BusinessCheckedException("1", "车牌信息不存在!");
}
String carLicense = orderInfo.getCarLicense();
if (!StringUtils.isBlank(carLicense)) {
carLicense = carLicense.toUpperCase();
orderInfo.setCarLicense(carLicense);
}
//设置车牌图片
orderInfo.setImgUrl(orderFormEntityBo.getImgUrl());
// copy customerCar's property to order(TODO 冗余字段)
CustomerCar customerCar = customerCarOptional.get();
//回写下次保养时间
CustomerCar tempCar = orderFormEntityBo.getCustomerCar();
if (tempCar != null) {
String keepupTimeStr = tempCar.getKeepupTimeStr();
if (!StringUtils.isBlank(keepupTimeStr)) {
Date keepupTime = DateUtil.convertStringToDateYMD(keepupTimeStr);
customerCar.setKeepupTime(keepupTime);
}
}
//回写下次保养里程
String upkeepMileage = orderInfo.getUpkeepMileage();
if (!StringUtils.isBlank(upkeepMileage)) {
customerCar.setUpkeepMileage(upkeepMileage);
}
// 开单时间(yyyy-MM-dd HH:mm)
String createTimeStr = orderInfo.getCreateTimeStr();
Date createTime = null;
if (StringUtils.isEmpty(createTimeStr)) {
createTime = new Date();
} else {
createTime = DateUtil.convertStringToDate(createTimeStr, "yyyy-MM-dd HH:mm");
}
orderInfo.setCreateTime(createTime);
orderInfo.setCustomerId(customerCar.getCustomerId());
orderInfo.setCarBrand(customerCar.getCarBrand());
orderInfo.setCarBrandId(customerCar.getCarBrandId());
orderInfo.setCarSeries(customerCar.getCarSeries());
orderInfo.setCarSeriesId(customerCar.getCarSeriesId());
/**
* add by zsy
* 设置冗余字段start
* TODO 页面上未展示,导致数据没set进工单冗余字段,以后页面加的话可能需要去除这些设置,
* customerAddress页面没展示,字段在customer里,所以这里不设置了,后续有需要需要查一次customer
*/
orderInfo.setCarPowerId(customerCar.getCarPowerId());
orderInfo.setCarPower(customerCar.getCarPower());
orderInfo.setCarYearId(customerCar.getCarYearId());
orderInfo.setCarYear(customerCar.getCarYear());
orderInfo.setEngineNo(customerCar.getEngineNo());
orderInfo.setCarColor(customerCar.getColor());
/**
* 设置冗余字段end
*/
orderInfo.setCarCompany(customerCar.getCarCompany());
orderInfo.setImportInfo(customerCar.getImportInfo());
orderInfo.setCarAlias(customerCar.getByName());
//add by twg 添加车型
orderInfo.setCarModelsId(customerCar.getCarModelId());
orderInfo.setCarModels(customerCar.getCarModel());
// 关联联系人信息
Optional<Customer> customerOptional = customerService.getCustomer(customerCar.getCustomerId());
if (customerOptional.isPresent()) {
Customer customer = customerOptional.get();
orderInfo.setCustomerName(customer.getCustomerName());
orderInfo.setCustomerMobile(customer.getMobile());
orderInfo.setCustomerAddress(customer.getCustomerAddr());
}
// ordered goods
List<OrderGoods> orderGoodsList = new ArrayList<OrderGoods>();
// valid ordered goods
List<OrderGoods> validGoodsList = new ArrayList<OrderGoods>();
// ordered services
List<OrderServices> orderServiceList = new ArrayList<OrderServices>();
// valid ordered services
List<OrderServices> validServiceList = new ArrayList<OrderServices>();
// transfer json to list
Gson gson = new Gson();
String orderGoodsJson = orderFormEntityBo.getOrderGoodJson();
String orderServiceJson = orderFormEntityBo.getOrderServiceJson();
try {
orderGoodsList = gson.fromJson(orderGoodsJson,
new TypeToken<List<OrderGoods>>() {
}.getType());
} catch (JsonSyntaxException e) {
LOGGER.error("选购物料JSON:{}", orderGoodsJson);
throw new BizException("选购物料JSON转对象异常");
}
try {
orderServiceList = gson.fromJson(orderServiceJson,
new TypeToken<List<OrderServices>>() {
}.getType());
} catch (JsonSyntaxException e) {
LOGGER.error("选购服务JSON:{}", orderServiceJson);
throw new BizException("选购服务JSON转对象异常");
}
// ordered goods‘s total number
Long orderedGoodsTotalNumber = 0l;
// filter valid goods and calculate goods's amount
if (!CollectionUtils.isEmpty(orderGoodsList)) {
// valid goods's ids
Set<Long> goodsIdSet = new HashSet<Long>();
for (OrderGoods goods : orderGoodsList) {
Long goodsId = goods.getGoodsId();
if (goodsId != null) {
goodsIdSet.add(goodsId);
// calculator goods’s amount
BigDecimal goodsPrice = goods.getGoodsPrice();
// goodsPrice default 0
goodsPrice = (goodsPrice == null) ? BigDecimal.ZERO : goodsPrice;
BigDecimal goodsNumber = goods.getGoodsNumber();
// goodsNumber default 1
goodsNumber = (goodsNumber == null ||
goodsNumber.compareTo(BigDecimal.ZERO) == 0) ? BigDecimal.ONE : goodsNumber;
goods.setGoodsNumber(goodsNumber);
BigDecimal goodsAmountTemp = goodsPrice.multiply(goodsNumber);
goods.setGoodsAmount(goodsAmountTemp);
BigDecimal discount = goods.getDiscount();
// discount default 0
discount = (discount == null) ? BigDecimal.ZERO : discount;
BigDecimal soldAmountTemp = goodsAmountTemp.subtract(discount);
goods.setSoldAmount(soldAmountTemp);
goods.setSoldPrice(soldAmountTemp.divide(goodsNumber, 8, BigDecimal.ROUND_HALF_UP));
validGoodsList.add(goods);
}
}
// check goods is exsit
int goodsIdSize = goodsIdSet.size();
if (goodsIdSize > 0) {
List<Goods> goodsLatestData =
goodsService.selectByIds(goodsIdSet.toArray(new Long[goodsIdSize]));
int goodsLatestDataSize = goodsLatestData.size();
// Map<goods.id,goods>
Map<Long, Goods> goodsLatestDataMap = new HashMap<Long, Goods>(goodsLatestDataSize);
for (Goods good : goodsLatestData) {
goodsLatestDataMap.put(good.getId(), good);
}
if (goodsIdSize != goodsLatestDataSize) {
StringBuffer goodsErrorMsgSB = new StringBuffer("选择的配件不存在,配件编号如下:");
Iterator<Long> goodsIdSetIT = goodsIdSet.iterator();
while (goodsIdSetIT.hasNext()) {
Long goodsId = goodsIdSetIT.next();
if (!goodsLatestDataMap.containsKey(goodsId)) {
goodsErrorMsgSB.append("<br/>");
goodsErrorMsgSB.append(goodsId);
}
}
throw new BusinessCheckedException("2", goodsErrorMsgSB.toString());
}
}
orderedGoodsTotalNumber = Long.valueOf(validGoodsList.size() + "");
}
// goods's total number
orderInfo.setGoodsCount(orderedGoodsTotalNumber);
// ordered service total number
Long orderedServiceNumber = 0L;
if (!CollectionUtils.isEmpty(orderServiceList)) {
Set<Long> serviceIdSet = new HashSet<Long>();
Set<Long> workerIdSet = new HashSet<Long>();
// filter valid service and calculate servie's amount
for (OrderServices service : orderServiceList) {
Long serviceId = service.getServiceId();
if (serviceId != null) {
serviceIdSet.add(serviceId);
String workerIds = service.getWorkerIds();
if (StringUtils.isNotBlank(workerIds) && !"0".equals(workerIds)) {
// 通过逗号切分
String[] workerIdArr = workerIds.split(",");
if (ArrayUtils.isNotEmpty(workerIdArr)) {
if (workerIdArr.length > Constants.MAX_WORKER_NUMBER) {
workerIds = StringUtils.join(workerIdArr, ",", 0, Constants.MAX_WORKER_NUMBER);
service.setWorkerIds(workerIds);
workerIdArr = ArrayUtils.subarray(workerIdArr, 0, Constants.MAX_WORKER_NUMBER);
}
for (String workerId : workerIdArr) {
workerId = workerId.trim();
if (!"0".equals(workerId) || !"".equals(workerId)) {
long id = Long.parseLong(workerId);
workerIdSet.add(id);
}
}
}
}
BigDecimal servicePrice = service.getServicePrice();
// servicePrice default 0
servicePrice = (servicePrice == null) ? BigDecimal.ZERO : servicePrice;
// serviceHour default 0
BigDecimal serviceHour = service.getServiceHour();
serviceHour = (serviceHour == null) ? BigDecimal.ZERO : serviceHour;
// discount default 0
BigDecimal discount = service.getDiscount();
discount = (discount == null) ? BigDecimal.ZERO : discount;
BigDecimal serviceAmountTemp = servicePrice.multiply(serviceHour);
service.setServiceAmount(serviceAmountTemp);
BigDecimal soldAmountTemp = serviceAmountTemp.subtract(discount);
service.setSoldAmount(soldAmountTemp);
if (serviceHour.compareTo(BigDecimal.ZERO) <= 0) {
service.setSoldPrice(BigDecimal.ZERO);
} else {
service.setSoldPrice(soldAmountTemp.divide(serviceHour, 8, BigDecimal.ROUND_HALF_UP));
}
validServiceList.add(service);
}
}
// check service is exsit
int serviceIdSetSize = serviceIdSet.size();
if (serviceIdSetSize > 0) {
List<ShopServiceInfo> serviceLatestData =
shopServiceInfoService.selectByIds(serviceIdSet.toArray(new Long[serviceIdSetSize]));
int serviceLatestDataSize = serviceLatestData.size();
// Map<service.id,service>
Map<Long, ShopServiceInfo> orderServiceListDBMap = new HashMap<Long, ShopServiceInfo>(serviceLatestDataSize);
for (ShopServiceInfo serviceInfo : serviceLatestData) {
orderServiceListDBMap.put(serviceInfo.getId(), serviceInfo);
}
if (serviceIdSetSize != serviceLatestDataSize) {
StringBuffer serviceErrorMsgSB = new StringBuffer("选择的服务不存在,服务编号如下:");
Iterator<Long> serviceIdSetIT = serviceIdSet.iterator();
while (serviceIdSetIT.hasNext()) {
Long serviceId = serviceIdSetIT.next();
if (!orderServiceListDBMap.containsKey(serviceId)) {
serviceErrorMsgSB.append("<br/>");
serviceErrorMsgSB.append(serviceId);
}
}
throw new BusinessCheckedException("3", serviceErrorMsgSB.toString());
}
}
// check worker is exsit
int workerIdSetSize = workerIdSet.size();
if (workerIdSetSize > 0) {
List<ShopManager> shopManagerLatestData =
shopManagerService.selectByIds(workerIdSet.toArray(new Long[workerIdSetSize]));
int managerLatestDataSize = shopManagerLatestData.size();
// Map<shopManager.id,shopManager>
Map<Long, ShopManager> shopManagerListDBMap = new HashMap<Long, ShopManager>(managerLatestDataSize);
for (ShopManager shopManager : shopManagerLatestData) {
shopManagerListDBMap.put(shopManager.getId(), shopManager);
}
if (workerIdSetSize != managerLatestDataSize) {
StringBuffer workerErrorMsgSB = new StringBuffer("指派的维修工不存在,维修工名称如下:");
Iterator<Long> workerIdSetIT = workerIdSet.iterator();
while (workerIdSetIT.hasNext()) {
Long workerId = workerIdSetIT.next();
if (!shopManagerListDBMap.containsKey(workerId)) {
workerErrorMsgSB.append("<br/>");
ShopManager shopManager = shopManagerListDBMap.get(workerId);
if(shopManager == null){
throw new BusinessCheckedException("5", "您选择了已删除的维修工,请重新选择维修工");
}
workerErrorMsgSB.append(shopManager.getName());
}
}
throw new BusinessCheckedException("4", workerErrorMsgSB.toString());
}
}
orderedServiceNumber = Long.valueOf(validServiceList.size() + "");
}
orderInfo.setServiceCount(orderedServiceNumber);
// calculate order expense
calculateOrderExpense(orderInfo, validGoodsList, validServiceList);
// 检验工单金额是否超过限度
checkOrderAmountIsValid(orderInfo);
// TODO 设置公共信息(创建者、创建时间、更新者、更新时间)
orderInfo.setCreator(userInfo.getUserId());
orderInfo.setModifier(userInfo.getUserId());
orderInfo.setOperatorName(userInfo.getName());
orderInfo.setShopId(userInfo.getShopId());
// set order's status
orderInfo.setOrderStatus(OrderStatusEnum.CJDD.getKey());
// set pay's status
orderInfo.setPayStatus(PayStatusEnum.UNPAY.getCode());
// set expectedTime
orderInfo.setExpectedTime(DateUtil.convertStringToDate(
orderInfo.getExpectedTimeYMD(), DateUtil.DATE_FORMAT_YMDHM));
// set buyTime
String buyTimeYMD = orderInfo.getBuyTimeYMD();
if(StringUtils.isNotBlank(buyTimeYMD)){
orderInfo.setBuyTime(DateUtil.convertStringToDate(orderInfo.getBuyTimeYMD(),
DateUtil.DATE_FORMAT_YMD));
}else{
orderInfo.setBuyTime(customerCar.getBuyTime());
}
//set orderStatus
String orderStatus = orderInfo.getOrderStatus();
//set finishTime
if (orderStatus != null && orderStatus.equals(OrderStatusEnum.DDWC.getKey())) {
orderInfo.setFinishTime(new Date());
}
//set postscript
String postscript = orderInfo.getPostscript();
orderInfo.setPostscript(postscript == null ? "" : postscript);
//set vin,若vin为null,则从customerCar取
String vin = orderInfo.getVin();
orderInfo.setVin(vin == null ? customerCar.getVin() : vin);
//set insuranceCompanyName
Long insuranceCompanyId = orderInfo.getInsuranceCompanyId();
Long otherInsuranceCompanyId = orderInfo.getOtherInsuranceCompanyId();
if ((insuranceCompanyId != null && insuranceCompanyId > 0) || (otherInsuranceCompanyId != null && otherInsuranceCompanyId > 0)) {
List<InsuranceCompany> insuranceCompanyList = insuranceCompanyService.select(null);
for (InsuranceCompany insuranceCompany : insuranceCompanyList) {
if (insuranceCompany.getId().equals(insuranceCompanyId)) {
orderInfo.setInsuranceCompanyName(insuranceCompany.getName());
}
if (insuranceCompany.getId().equals(otherInsuranceCompanyId)) {
orderInfo.setOtherInsuranceCompanyName(insuranceCompany.getName());
}
}
}
//设置预检信息
List<OrderPrecheckDetails> orderPrecheckDetailsList = setOrderPrecheckDetails(orderFormEntityBo, userInfo.getShopId(), orderFormEntityBo.getPrecheckId());
// insert DB
insertOrder(orderInfo, validGoodsList, validServiceList, orderPrecheckDetailsList, userInfo);
//添加工单详情日志start
Optional<OrderInfo> orderInfoOptional = getOrder(orderInfo.getId(), orderInfo.getShopId());
if(orderInfoOptional.isPresent()){
OrderInfo tempOrder = orderInfoOptional.get();
StringBuffer orderLog = new StringBuffer();
orderLog.append("工单创建成功: 工单号为:");
orderLog.append(tempOrder.getId());
orderLog.append(" 操作人:");
orderLog.append(userInfo.getUserId());
String operationLog = OrderOperationLog.getOperationLog(tempOrder, orderLog);
LOGGER.info(operationLog);
}
//添加工单详情日志end
// 捕获无关紧要信息保存异常,确保工单主数据保存成功。
try {
Long proxyId = orderFormEntityBo.getProxyId();
orderInfoExtSaveThread.init(customerCar, orderInfo, userInfo, orderGoodsJson,
orderServiceJson, proxyId);
threadManager.execute(orderInfoExtSaveThread);
} catch (Exception e) {
LOGGER.error(e.toString());
}
return Result.wrapSuccessfulResult(orderInfo.getId());
}
/**
* 引流活动工单保存方法
*
* @param orderInfo 工单基本信息
* @param orderServicesList 工单服务列表
* @param userInfo
* @return
*/
@Override
public OrderInfo save(OrderInfo orderInfo, List<OrderServices> orderServicesList, UserInfo userInfo) {
// currrent car's license
String carLicense = orderInfo.getCarLicense();
// current record's operator and shop
Long optUserId = userInfo.getUserId();
Long shopId = userInfo.getShopId();
// generate Order'Sn
String newOrderSn = snFactory.generateOrderSn(shopId);
orderInfo.setOrderSn(newOrderSn);
// TODO Aspect record log
LOGGER.info("工单操作流水:{} 工单编号生成,编号为:{} 操作人:{}", carLicense, newOrderSn, optUserId);
try {
orderInfoDao.insert(orderInfo);
} catch (Exception e) {
LOGGER.error("DB插入工单数据异常,工单实体:{}", orderInfo.toString());
throw new RuntimeException("DB数据库保存工单数据异常");
}
// new orderId
Long newOrderId = orderInfo.getId();
LOGGER.info("工单操作流水:{} 保存工单基本信息 操作人:{}", carLicense, optUserId);
// batch insert new serviceList
if (!CollectionUtils.isEmpty(orderServicesList)) {
for (OrderServices orderServices : orderServicesList) {
// refer new order
orderServices.setOrderId(newOrderId);
orderServices.setOrderSn(newOrderSn);
// set operate message
orderServices.setCreator(optUserId);
orderServices.setModifier(optUserId);
orderServices.setShopId(shopId);
}
// batch save
try {
orderServicesService.batchSave(orderServicesList);
} catch (Exception e) {
LOGGER.error("插入服务数据异常,服务实体:{}", new Gson().toJson(orderServicesList));
throw new RuntimeException("数据库保存服务数据异常");
}
LOGGER.info("工单操作流水:{} 保存工单服务信息 操作人:{}", carLicense, optUserId);
}
Optional<OrderInfo> orderInfoOptional = this.getOrder(newOrderId);
if (!orderInfoOptional.isPresent()) {
LOGGER.error("DB未成功保存工单数据");
throw new RuntimeException("数据库保存服务数据异常");
}
return orderInfoOptional.get();
}
/**
* 保存工单基本信息、选购商品、选购服务
*
* @param orderInfo
* @param orderGoodsList
* @param orderServicesList
* @param userInfo
*/
// TODO 声明式事务,不起作用
@Transactional
public void insertOrder(OrderInfo orderInfo,
List<OrderGoods> orderGoodsList,
List<OrderServices> orderServicesList,
List<OrderPrecheckDetails> orderPrecheckDetailsList,
UserInfo userInfo) {
// currrent car's license
String carLicense = orderInfo.getCarLicense();
// current record's operator and shop
Long optUserId = userInfo.getUserId();
Long shopId = userInfo.getShopId();
// generate Order'Sn
String newOrderSn = snFactory.generateOrderSn(shopId);
orderInfo.setOrderSn(newOrderSn);
// TODO Aspect record log
LOGGER.info("工单操作流水:{} 工单编号生成,编号为:{} 操作人:{}", carLicense, newOrderSn, optUserId);
// insert orderInfo
orderInfoDao.insert(orderInfo);
// new orderId
Long newOrderId = orderInfo.getId();
LOGGER.info("工单操作流水:{} 保存工单基本信息 操作人:{}", carLicense, optUserId);
// batch insert new goodList
if (!CollectionUtils.isEmpty(orderGoodsList)) {
// 同步物料的成本价(InventoryPrice)
syncGoodsInventoryPrice(orderGoodsList);
for (OrderGoods orderGoods : orderGoodsList) {
// refer new order
orderGoods.setOrderId(newOrderId);
orderGoods.setOrderSn(newOrderSn);
// set operate message
orderGoods.setCreator(optUserId);
orderGoods.setModifier(optUserId);
orderGoods.setShopId(shopId);
}
orderGoodsService.batchInsert(orderGoodsList);
LOGGER.info("工单操作流水:{} 保存工单物料信息 操作人:{}", carLicense, optUserId);
}
// batch insert new serviceList
if (!CollectionUtils.isEmpty(orderServicesList)) {
for (OrderServices orderServices : orderServicesList) {
// refer new order
orderServices.setOrderId(newOrderId);
orderServices.setOrderSn(newOrderSn);
// set operate message
orderServices.setCreator(optUserId);
orderServices.setModifier(optUserId);
orderServices.setShopId(shopId);
}
orderServicesService.batchSave(orderServicesList);
LOGGER.info("工单操作流水:{} 保存工单服务信息 操作人:{}", carLicense, optUserId);
}
// 添加工单预检信息
if (!CollectionUtils.isEmpty(orderPrecheckDetailsList)) {
for (OrderPrecheckDetails orderPrecheckDetails : orderPrecheckDetailsList) {
orderPrecheckDetails.setOrderId(newOrderId);
orderPrecheckDetails.setShopId(shopId);
orderPrecheckDetails.setCreator(optUserId);
}
LOGGER.info("工单操作流水:{} 操作人:{},添加预检单信息{}", carLicense, optUserId, orderPrecheckDetailsList);
orderPrecheckDetailsService.batchInsert(orderPrecheckDetailsList);
}
}
/**
* 同步物料成本价、单位
*
* @param orderGoodsList
*/
private void syncGoodsInventoryPrice(List<OrderGoods> orderGoodsList) {
Set<Long> newGoodsIdSet = new HashSet<Long>();
for (OrderGoods orderGoods : orderGoodsList) {
// gather goods Id
newGoodsIdSet.add(orderGoods.getGoodsId());
}
// sync good InventoryPrice (APP下单时,未传入成本价)
Long[] newGoodsIdArray = new Long[newGoodsIdSet.size()];
List<Goods> goodsList = goodsService.selectByIds(newGoodsIdSet.toArray(newGoodsIdArray));
// 物料(ID):成本价格(inventoryPrice)
Map<Long, Goods> goodsMap = new HashMap<Long, Goods>(goodsList.size());
for (Goods goods : goodsList) {
goodsMap.put(goods.getId(), goods);
}
// refer good成本价/单位
for (OrderGoods orderGoods : orderGoodsList) {
Long goodsId = orderGoods.getGoodsId();
if(goodsMap.containsKey(goodsId)){
Goods goods = goodsMap.get(orderGoods.getGoodsId());
BigDecimal inventoryPrice = goods.getInventoryPrice();
// default 0
inventoryPrice = (inventoryPrice == null) ? BigDecimal.ZERO : inventoryPrice;
orderGoods.setInventoryPrice(inventoryPrice);
orderGoods.setMeasureUnit(goods.getMeasureUnit());
}
}
}
/**
* 工单更新
* @param orderFormEntityBo
* @param userInfo
* @param isUseNewPrecheck 是否需要更新工单预检信息,如果是,则更新order_precheck_details表(钣喷中心只有综合维修单才有预检信息)
* @return
* @throws BusinessCheckedException
*/
@Override
public Result update(OrderFormEntityBo orderFormEntityBo, UserInfo userInfo, boolean isUseNewPrecheck)
throws BusinessCheckedException {
// order's basic info
OrderInfo orderInfo = orderFormEntityBo.getOrderInfo();
Long orderId = orderInfo.getId();
Long shopId = userInfo.getShopId();
// check order exsit
OrderInfo orderLatestData = this.selectByIdAndShopId(orderInfoDao, orderId, shopId);
if (orderLatestData == null) {
throw new BusinessCheckedException("21", "工单不存在!");
}
orderInfo.setOrderSn(orderLatestData.getOrderSn());
// 上一次开单日期
orderInfo.setLastCreateTime(orderLatestData.getCreateTime());
// check 同时操作
String modifiedYMDHMS = orderInfo.getGmtModifiedYMDHMS();
if (StringUtils.isNotEmpty(modifiedYMDHMS)) {
Date oldGmtModified = DateUtil.convertStringToDate(modifiedYMDHMS);
Date newGmtModified = orderLatestData.getGmtModified();
long diff = newGmtModified.getTime() - oldGmtModified.getTime();
long diffSeconds = diff / 1000 % 60;
// <=3秒内:不是同时操作
if (newGmtModified != null && (Math.abs(diffSeconds) > 3)) {
throw new BusinessCheckedException("10000", "已经有人修改过这条工单记录,请刷新后重试!");
}
}
// check customerCar is exsit
Optional<CustomerCar> customerCarOptional =
customerCarService.getCustomerCar(orderInfo.getCustomerCarId());
if (!customerCarOptional.isPresent()) {
throw new BusinessCheckedException("1", "车牌信息不存在!");
}
// copy customerCar's property to order
CustomerCar customerCar = customerCarOptional.get();
//回写下次保养时间
CustomerCar tempCar = orderFormEntityBo.getCustomerCar();
if (tempCar != null) {
String keepupTimeStr = tempCar.getKeepupTimeStr();
if (!StringUtils.isBlank(keepupTimeStr)) {
Date keepupTime = DateUtil.convertStringToDateYMD(keepupTimeStr);
customerCar.setKeepupTime(keepupTime);
}
}
//回写下次保养里程
String upkeepMileage = orderInfo.getUpkeepMileage();
if (!StringUtils.isBlank(upkeepMileage)) {
customerCar.setUpkeepMileage(upkeepMileage);
}
// 开单时间(yyyy-MM-dd HH:mm)
Date createTime = DateUtil.convertStringToDate(orderInfo.getCreateTimeStr(), "yyyy-MM-dd HH:mm");
orderInfo.setCreateTime(createTime);
orderInfo.setCustomerId(customerCar.getCustomerId());
orderInfo.setCarBrand(customerCar.getCarBrand());
orderInfo.setCarBrandId(customerCar.getCarBrandId());
orderInfo.setCarSeries(customerCar.getCarSeries());
orderInfo.setCarSeriesId(customerCar.getCarSeriesId());
orderInfo.setCarCompany(customerCar.getCarCompany());
orderInfo.setImportInfo(customerCar.getImportInfo());
orderInfo.setCarAlias(customerCar.getByName());
// ordered goods
List<OrderGoods> orderedGoodsList = new ArrayList<OrderGoods>();
// valid ordered goods
List<OrderGoods> validGoodsList = new ArrayList<OrderGoods>();
// ordered services
List<OrderServices> orderedServiceList = new ArrayList<OrderServices>();
// valid ordered services
List<OrderServices> validServiceList = new ArrayList<OrderServices>();
// transfer json to list
Gson gson = new Gson();
String orderGoodsJson = orderFormEntityBo.getOrderGoodJson();
String orderServiceJson = orderFormEntityBo.getOrderServiceJson();
try {
orderedGoodsList = gson.fromJson(orderGoodsJson,
new TypeToken<List<OrderGoods>>() {
}.getType());
} catch (JsonSyntaxException e) {
LOGGER.error("选购物料JSON:{}", orderGoodsJson);
throw new RuntimeException("选购物料JSON转对象异常");
}
try {
orderedServiceList = gson.fromJson(orderServiceJson,
new TypeToken<List<OrderServices>>() {
}.getType());
} catch (JsonSyntaxException e) {
LOGGER.error("选购服务JSON:{}", orderServiceJson);
throw new RuntimeException("选购服务JSON转对象异常");
}
// ordered goods total number
Long orderedGoodsTotalNumber = 0l;
// filter valid goods and calculate goods's amount
if (!CollectionUtils.isEmpty(orderedGoodsList)) {
Set<Long> goodsIdSet = new HashSet<Long>();
for (OrderGoods goods : orderedGoodsList) {
Long goodsId = goods.getGoodsId();
if (goodsId != null) {
goodsIdSet.add(goodsId);
// calculator goods’s amount
BigDecimal goodsPrice = goods.getGoodsPrice();
// goodsPrice default 0
goodsPrice = (goodsPrice == null) ? BigDecimal.ZERO : goodsPrice;
BigDecimal goodsNumber = goods.getGoodsNumber();
// goodsNumber default 1
goodsNumber = (goodsNumber == null ||
goodsNumber.compareTo(BigDecimal.ZERO) == 0) ? BigDecimal.ONE : goodsNumber;
goods.setGoodsNumber(goodsNumber);
BigDecimal goodsAmountTemp = goodsPrice.multiply(goodsNumber);
goods.setGoodsAmount(goodsAmountTemp);
BigDecimal discount = goods.getDiscount();
// discount default 0
discount = (discount == null) ? BigDecimal.ZERO : discount;
BigDecimal soldAmountTemp = goodsAmountTemp.subtract(discount);
goods.setSoldAmount(soldAmountTemp);
goods.setSoldPrice(soldAmountTemp.divide(goodsNumber, 8, BigDecimal.ROUND_HALF_UP));
validGoodsList.add(goods);
}
}
// check goods is exsit
int goodsIdSize = goodsIdSet.size();
if (goodsIdSize > 0) {
List<Goods> goodsLatestData =
goodsService.selectByIds(goodsIdSet.toArray(new Long[goodsIdSize]));
int goodsLatestDataSize = goodsLatestData.size();
// Map<goods.id,goods>
Map<Long, Goods> goodsLatestDataMap = new HashMap<Long, Goods>(goodsLatestDataSize);
for (Goods good : goodsLatestData) {
goodsLatestDataMap.put(good.getId(), good);
}
if (goodsIdSize != goodsLatestDataSize) {
StringBuffer goodsErrorMsgSB = new StringBuffer("选择的配件不存在,配件编号如下:");
Iterator<Long> goodsIdSetIT = goodsIdSet.iterator();
while (goodsIdSetIT.hasNext()) {
Long goodsId = goodsIdSetIT.next();
if (!goodsLatestDataMap.containsKey(goodsId)) {
goodsErrorMsgSB.append("<br/>");
goodsErrorMsgSB.append(goodsId);
}
}
throw new BusinessCheckedException("2", goodsErrorMsgSB.toString());
}
}
orderedGoodsTotalNumber = Long.valueOf(validGoodsList.size() + "");
}
// goods's total number
orderInfo.setGoodsCount(orderedGoodsTotalNumber);
// ordered service total number
Long orderedServiceNumber = 0L;
if (!CollectionUtils.isEmpty(orderedServiceList)) {
Set<Long> serviceIdSet = new HashSet<Long>();
Set<Long> workerIdSet = new HashSet<Long>();
// filter valid service and calculate servie's amount
for (OrderServices service : orderedServiceList) {
Long serviceId = service.getServiceId();
if (serviceId != null) {
serviceIdSet.add(serviceId);
String workerIds = service.getWorkerIds();
//TODO 兼容APP 开单
Long workId = service.getWorkerId();
if(StringUtils.isBlank(workerIds) && workId != null && workId > 0){
workerIds = String.valueOf(workId);
service.setWorkerIds(workerIds);
}
if (StringUtils.isNotBlank(workerIds) && !"0".equals(workerIds)) {
// 通过逗号切分
String[] workerIdArr = workerIds.split(",");
if (ArrayUtils.isNotEmpty(workerIdArr)) {
if (workerIdArr.length > Constants.MAX_WORKER_NUMBER) {
workerIds = StringUtils.join(workerIdArr, ",", 0, Constants.MAX_WORKER_NUMBER);
service.setWorkerIds(workerIds);
workerIdArr = ArrayUtils.subarray(workerIdArr, 0, Constants.MAX_WORKER_NUMBER);
}
for (String workerId : workerIdArr) {
workerId = workerId.trim();
if (!"0".equals(workerId) || !"".equals(workerId)) {
long id = Long.parseLong(workerId);
workerIdSet.add(id);
}
}
}
}
BigDecimal servicePrice = service.getServicePrice();
// servicePrice default 0
servicePrice = (servicePrice == null) ? BigDecimal.ZERO : servicePrice;
// serviceHour default 0
BigDecimal serviceHour = service.getServiceHour();
serviceHour = (serviceHour == null) ? BigDecimal.ZERO : serviceHour;
// discount default 0
BigDecimal discount = service.getDiscount();
discount = (discount == null) ? BigDecimal.ZERO : discount;
BigDecimal serviceAmountTemp = servicePrice.multiply(serviceHour);
service.setServiceAmount(serviceAmountTemp);
BigDecimal soldAmountTemp = serviceAmountTemp.subtract(discount);
service.setSoldAmount(soldAmountTemp);
if (serviceHour.compareTo(BigDecimal.ZERO) <= 0) {
service.setSoldPrice(BigDecimal.ZERO);
} else {
service.setSoldPrice(soldAmountTemp.divide(serviceHour, 8, BigDecimal.ROUND_HALF_UP));
}
validServiceList.add(service);
}
}
// check service is exsit
int serviceIdSetSize = serviceIdSet.size();
if (serviceIdSetSize > 0) {
List<ShopServiceInfo> serviceLatestData =
shopServiceInfoService.selectByIds(serviceIdSet.toArray(new Long[serviceIdSetSize]));
int serviceLatestDataSize = serviceLatestData.size();
// Map<service.id,service>
Map<Long, ShopServiceInfo> orderServiceListDBMap = new HashMap<Long, ShopServiceInfo>(serviceLatestDataSize);
for (ShopServiceInfo serviceInfo : serviceLatestData) {
orderServiceListDBMap.put(serviceInfo.getId(), serviceInfo);
}
if (serviceIdSetSize != serviceLatestDataSize) {
StringBuffer serviceErrorMsgSB = new StringBuffer("选购的服务不存在,服务编号如下:");
Iterator<Long> serviceIdSetIT = serviceIdSet.iterator();
while (serviceIdSetIT.hasNext()) {
Long serviceId = serviceIdSetIT.next();
if (!orderServiceListDBMap.containsKey(serviceId)) {
serviceErrorMsgSB.append("<br/>");
serviceErrorMsgSB.append(serviceId);
}
}
throw new BusinessCheckedException("3", serviceErrorMsgSB.toString());
}
}
// check worker is exsit
int workerIdSetSize = workerIdSet.size();
if (workerIdSetSize > 0) {
List<ShopManager> shopManagerLatestData =
shopManagerService.selectByIds(workerIdSet.toArray(new Long[workerIdSetSize]));
int managerLatestDataSize = shopManagerLatestData.size();
// Map<shopManager.id,shopManager>
Map<Long, ShopManager> shopManagerListDBMap = new HashMap<Long, ShopManager>(managerLatestDataSize);
for (ShopManager shopManager : shopManagerLatestData) {
shopManagerListDBMap.put(shopManager.getId(), shopManager);
}
if (workerIdSetSize != managerLatestDataSize) {
StringBuffer workerErrorMsgSB = new StringBuffer("指派的维修工不存在,维修工名称如下:");
Iterator<Long> workerIdSetIT = workerIdSet.iterator();
while (workerIdSetIT.hasNext()) {
Long workerId = workerIdSetIT.next();
if (!shopManagerListDBMap.containsKey(workerId)) {
workerErrorMsgSB.append("<br/>");
ShopManager shopManager = shopManagerListDBMap.get(workerId);
if(shopManager == null){
throw new BusinessCheckedException("5", "您选择了已删除的维修工,请重新选择维修工");
}
workerErrorMsgSB.append(shopManager.getName());
}
}
throw new BusinessCheckedException("4", workerErrorMsgSB.toString());
}
}
orderedServiceNumber = Long.valueOf(validServiceList.size() + "");
}
orderInfo.setServiceCount(orderedServiceNumber);
// calculate order's expense
calculateOrderExpense(orderInfo, validGoodsList, validServiceList);
// 检验工单金额是否超过限度
checkOrderAmountIsValid(orderInfo);
// TODO 设置公共信息(创建时间、更新者、更新时间)
orderInfo.setModifier(userInfo.getUserId());
orderInfo.setOperatorName(userInfo.getName());
orderInfo.setShopId(userInfo.getShopId());
// set expectedTime
orderInfo.setExpectedTime(DateUtil.convertStringToDate(
orderInfo.getExpectedTimeYMD(), DateUtil.DATE_FORMAT_YMDHM));
// set buyTime
orderInfo.setBuyTime(DateUtil.convertStringToDate(orderInfo.getBuyTimeYMD(),
DateUtil.DATE_FORMAT_YMD));
String orderStatus = orderInfo.getOrderStatus();
if (orderStatus != null && orderStatus.equals("DDWC")) {
orderInfo.setFinishTime(new Date());
}
//set postscript
String postscript = orderInfo.getPostscript();
orderInfo.setPostscript(postscript == null ? "" : postscript);
//set vin
String vin = orderInfo.getVin();
orderInfo.setVin(vin == null ? "" : vin);
//set insuranceCompanyName
Long insuranceCompanyId = orderInfo.getInsuranceCompanyId();
Long otherInsuranceCompanyId = orderInfo.getOtherInsuranceCompanyId();
if ((insuranceCompanyId != null && insuranceCompanyId > 0) || (otherInsuranceCompanyId != null && otherInsuranceCompanyId > 0)) {
List<InsuranceCompany> insuranceCompanyList = insuranceCompanyService.select(null);
for (InsuranceCompany insuranceCompany : insuranceCompanyList) {
if (insuranceCompany.getId().equals(insuranceCompanyId)) {
orderInfo.setInsuranceCompanyName(insuranceCompany.getName());
}
if (insuranceCompany.getId().equals(otherInsuranceCompanyId)) {
orderInfo.setOtherInsuranceCompanyName(insuranceCompany.getName());
}
}
} else if (insuranceCompanyId != null && insuranceCompanyId == 0) {
orderInfo.setInsuranceCompanyName("");
} else if (otherInsuranceCompanyId != null && otherInsuranceCompanyId == 0) {
orderInfo.setOtherInsuranceCompanyName("");
}
//设置预检信息
List<OrderPrecheckDetails> orderPrecheckDetailsList = setOrderPrecheckDetails(orderFormEntityBo, userInfo.getShopId(), orderFormEntityBo.getPrecheckId());
// update orderInfo and goodList and serviceList
updateOrder(orderInfo, validGoodsList, validServiceList, orderPrecheckDetailsList, userInfo, isUseNewPrecheck);
// 捕获无关紧要信息更新异常,确保工单主数据更新成功。
try {
orderInfoExtUpdateThread.init(customerCar, orderInfo, orderLatestData, userInfo);
threadManager.execute(orderInfoExtUpdateThread);
} catch (Exception e) {
LOGGER.error(e.toString());
}
return Result.wrapSuccessfulResult(orderId);
}
/**
* 校验工单金额是否超过限度
*
* @param orderInfo
* @throws BusinessCheckedException
*/
private void checkOrderAmountIsValid(OrderInfo orderInfo) throws BusinessCheckedException {
// 数据字段 12位\2精度最大数=999999999999.99
BigDecimal ceilingAmount = new BigDecimal("999999999999.99");
BigDecimal goodsTotalAmount = orderInfo.getGoodsAmount();
if (goodsTotalAmount != null && goodsTotalAmount.compareTo(ceilingAmount) == 1) {
LOGGER.error("创建工单失败,工单金额超过最大额度,工单物料总金额:{}", goodsTotalAmount);
throw new BusinessCheckedException("", "无效金额");
}
BigDecimal serviceTotalAmount = orderInfo.getServiceAmount();
if (serviceTotalAmount != null && serviceTotalAmount.compareTo(ceilingAmount) == 1) {
LOGGER.error("创建工单失败,工单金额超过最大额度,工单服务总金额:{}", serviceTotalAmount);
throw new BusinessCheckedException("", "无效金额");
}
BigDecimal totalAmount = orderInfo.getTotalAmount();
if (totalAmount != null && totalAmount.compareTo(ceilingAmount) == 1) {
LOGGER.error("创建工单失败,工单金额超过最大额度,工单总金额:{}", totalAmount);
throw new BusinessCheckedException("", "无效金额");
}
}
/**
* update orderInfo、goodList、serviceList
*
* @param orderInfo 工单基本信息
* @param allGoodList 选购的物料
* @param allServiceList 选购的服务
* @param userInfo 当前操作人
* @return
*/
// TODO transactional invalid
@Transactional
public void updateOrder(OrderInfo orderInfo,
List<OrderGoods> allGoodList,
List<OrderServices> allServiceList,
List<OrderPrecheckDetails> orderPrecheckDetailsList,
UserInfo userInfo,
boolean isUseNewPrecheck) {
// current car's license
String carLicense = orderInfo.getCarLicense();
// current operator and shop
Long optUserId = userInfo.getUserId();
Long shopId = userInfo.getShopId();
// current orderId and orderSn
Long orderId = orderInfo.getId();
String orderSn = orderInfo.getOrderSn();
// update orderInfo
orderInfoDao.updateById(orderInfo);
LOGGER.info("工单操作流水:{} 更新工单信息 操作人:{}", carLicense, optUserId);
// 编辑前:已选购的物料
List<OrderGoods> preOrderedGoodList = orderGoodsService.queryOrderGoodList(orderId, shopId);
// 编辑前:已选购的物料ID集合
Set<Long> preOldGoodIdSet = new HashSet<Long>();
if (!CollectionUtils.isEmpty(preOrderedGoodList)) {
for (OrderGoods good : preOrderedGoodList) {
preOldGoodIdSet.add(good.getId());
}
}
// 编辑后:已选购的物料
Set<Long> afterOrderedGoodIdSet = new HashSet<Long>();
// 编辑后:本次新增的商品集合
List<OrderGoods> newGoodList = new ArrayList<OrderGoods>();
// 删除之前已选购的物料集合
Set<Long> delPreOrderedGoodIdSet = new HashSet<Long>();
// 同步物料成本价
syncGoodsInventoryPrice(allGoodList);
for (OrderGoods orderGood : allGoodList) {
Long goodId = orderGood.getId();
if (goodId == null) {
orderGood.setOrderId(orderId);
orderGood.setOrderSn(orderSn);
orderGood.setCreator(optUserId);
orderGood.setModifier(optUserId);
orderGood.setShopId(shopId);
newGoodList.add(orderGood);
} else {
if (preOldGoodIdSet != null && !preOldGoodIdSet.contains(goodId)) {
LOGGER.error("传递的工单配件ID不正确,配件ID:{}", goodId);
throw new RuntimeException("传递的工单配件ID不正确");
}
orderGoodsService.update(orderGood);
afterOrderedGoodIdSet.add(goodId);
}
}
// batch save
if (!newGoodList.isEmpty()) {
orderGoodsService.batchInsert(newGoodList);
}
// 筛选 删除之前已选购的物料
if (!CollectionUtils.isEmpty(preOrderedGoodList)) {
for (OrderGoods oldOrderGoods : preOrderedGoodList) {
Long preOrderedGoodId = oldOrderGoods.getId();
if (!afterOrderedGoodIdSet.contains(preOrderedGoodId)) {
// orderGoodsService.update(oldOrderGoods);
delPreOrderedGoodIdSet.add(preOrderedGoodId);
}
}
}
// batch delete
if (!delPreOrderedGoodIdSet.isEmpty()) {
orderGoodsService.batchDel(delPreOrderedGoodIdSet.toArray());
}
LOGGER.info("工单操作流水:{} 更新工单物料信息 操作人:{}", carLicense, optUserId);
// update service
// 编辑前:已选购的服务
List<OrderServices> preOrderedServiceList =
orderServicesService.queryOrderServiceList(orderId, shopId);
// 编辑前:已选购的服务ID集合
Set<Long> preServiceIdSet = new HashSet<Long>();
// 删除之前已选购的物料集合
Set<Long> delPreOrderedServiceIdSet = new HashSet<Long>();
if (!CollectionUtils.isEmpty(preOrderedServiceList)) {
for (OrderServices service : preOrderedServiceList) {
preServiceIdSet.add(service.getId());
}
}
// 编辑后:已选购的服务
Set<Long> afterOrderedServiceIdSet = new HashSet<Long>();
// 编辑后:新增服务
List<OrderServices> newOrderServiceList = new ArrayList<OrderServices>();
for (OrderServices service : allServiceList) {
Long serviceId = service.getId();
if (serviceId == null) {
// 关联工单
service.setOrderId(orderId);
service.setOrderSn(orderSn);
service.setCreator(optUserId);
service.setModifier(optUserId);
service.setShopId(shopId);
newOrderServiceList.add(service);
} else {
// 伪造服务ID:更新操作
if (preServiceIdSet != null && !preServiceIdSet.contains(serviceId)) {
LOGGER.error("传递的工单服务ID不正确,服务ID:{}", serviceId);
throw new RuntimeException("传递的工单服务ID不正确");
}
service.setModifier(optUserId);
if (StringUtils.isEmpty(service.getWorkerIds())) {
service.setWorkerIds("");
}
orderServicesService.update(service);
afterOrderedServiceIdSet.add(service.getId());
}
}
// batch save new orderService
if (!newOrderServiceList.isEmpty()) {
orderServicesService.batchSave(newOrderServiceList);
}
// 之前选择的:不存在情况,删除掉
if (!CollectionUtils.isEmpty(preOrderedServiceList)) {
for (OrderServices oldOrderServices : preOrderedServiceList) {
Long serviceId = oldOrderServices.getId();
if (!afterOrderedServiceIdSet.contains(serviceId)) {
delPreOrderedServiceIdSet.add(serviceId);
}
}
}
if (!delPreOrderedServiceIdSet.isEmpty()) {
orderServicesService.batchDel(delPreOrderedServiceIdSet.toArray());
}
if(isUseNewPrecheck){
//更新预检信息
Map<String, Object> searchOrderPrecheckDetailsMap = new HashMap<>();
searchOrderPrecheckDetailsMap.put("shopId", shopId);
searchOrderPrecheckDetailsMap.put("orderId", orderId);
List<OrderPrecheckDetails> existList = orderPrecheckDetailsService.select(searchOrderPrecheckDetailsMap);
Map<Long,OrderPrecheckDetails> existMap = new HashMap<>();
for (OrderPrecheckDetails orderPrecheckDetails : existList) {
Long precheckItemId = orderPrecheckDetails.getPrecheckItemId();
//需要更新的数据
existMap.put(precheckItemId, orderPrecheckDetails);
}
List<OrderPrecheckDetails> insertList = new ArrayList<>();
//设置需要添加的数据
Map<Long,Long> newOrderPrecheckDetailsMap = new HashMap<>();
if(!CollectionUtils.isEmpty(orderPrecheckDetailsList)){
for (OrderPrecheckDetails orderPrecheckDetails : orderPrecheckDetailsList) {
Long precheckItemId = orderPrecheckDetails.getPrecheckItemId();
Long precheckValueId = orderPrecheckDetails.getPrecheckValueId();
if(!existMap.containsKey(precheckItemId)){
insertList.add(orderPrecheckDetails);
}else{
OrderPrecheckDetails existDetails = existMap.get(precheckItemId);
Long existPrecheckValueId = existDetails.getPrecheckValueId();
if(!existPrecheckValueId.equals(precheckValueId)){
//更新操作
existDetails.setPrecheckValueId(precheckValueId);
existDetails.setPrecheckValue(orderPrecheckDetails.getPrecheckValue());
existDetails.setModifier(userInfo.getUserId());
LOGGER.info("工单操作流水:{} 操作人:{},更新工单,更新原预检单某个项目信息{}", carLicense, optUserId, existDetails);
orderPrecheckDetailsService.updateById(existDetails);
}
}
newOrderPrecheckDetailsMap.put(precheckItemId,precheckItemId);
}
}
//设置需要删除的数据
if (!CollectionUtils.isEmpty(existList)) {
List<Long> deleteIds = new ArrayList<>();
for (OrderPrecheckDetails orderPrecheckDetails : existList) {
Long id = orderPrecheckDetails.getId();
Long precheckItemId = orderPrecheckDetails.getPrecheckItemId();
if(!newOrderPrecheckDetailsMap.containsKey(precheckItemId)){
deleteIds.add(id);
}
}
if(!CollectionUtils.isEmpty(deleteIds)){
LOGGER.info("工单操作流水:{} 操作人:{},删除原有的工单预检信息,工单id{}", carLicense, optUserId, orderId);
orderPrecheckDetailsService.deleteByIds(deleteIds.toArray());
}
}
if (!CollectionUtils.isEmpty(insertList)) {
for (OrderPrecheckDetails orderPrecheckDetails : insertList) {
orderPrecheckDetails.setShopId(shopId);
orderPrecheckDetails.setOrderId(orderId);
orderPrecheckDetails.setCreator(optUserId);
}
LOGGER.info("工单操作流水:{} 操作人:{},更新工单,添加预检单信息{}", carLicense, optUserId, insertList);
orderPrecheckDetailsService.batchInsert(insertList);
}
}
LOGGER.info("工单操作流水:{} 更新工单服务信息 操作人:{}", carLicense, optUserId);
}
/**
* 核算订单各项金额
*
* @param orderInfo 工单基本信息
* @param orderServiceList 选购服务
*/
@Override
public void calculateOrderExpense(OrderInfo orderInfo,
List<OrderServices> orderServiceList) {
// 服务项目总金额
BigDecimal serviceTotalAmount = BigDecimal.ZERO;
// 商品总金额
BigDecimal goodsTotalAmount = BigDecimal.ZERO;
// 订单总金额
BigDecimal totalAmount = BigDecimal.ZERO;
// 订单总折扣
BigDecimal totalDiscount = BigDecimal.ZERO;
// 商品总折扣
BigDecimal goodsTotalDiscount = BigDecimal.ZERO;
// 服务总折扣
BigDecimal serviceTotalDiscount = BigDecimal.ZERO;
// 费用总折扣
BigDecimal feeTotalDiscount = BigDecimal.ZERO;
// 费用总金额
BigDecimal feeTotalAmount = BigDecimal.ZERO;
// 管理费
BigDecimal manageFee = BigDecimal.ZERO;
// 商品总费用
manageFee = goodsTotalAmount.subtract(goodsTotalDiscount);
if (!CollectionUtils.isEmpty(orderServiceList)) {
for (OrderServices orderServices : orderServiceList) {
Integer serviceType = orderServices.getType();
// 1:基本服务
if (serviceType == OrderServiceTypeEnum.BASIC.getCode()) {
BigDecimal discount = orderServices.getDiscount();
discount = (discount == null) ? BigDecimal.ZERO : discount;
serviceTotalDiscount = serviceTotalDiscount.add(discount);
BigDecimal serviceAmount = orderServices.getServiceAmount();
serviceAmount = (serviceAmount == null) ? BigDecimal.ZERO : serviceAmount;
serviceTotalAmount = serviceTotalAmount.add(serviceAmount);
}
// 2:附属服务
if (serviceType == OrderServiceTypeEnum.ANCILLARY.getCode()) {
String flags = orderServices.getFlags();
BigDecimal discount = orderServices.getDiscount();
discount = (discount == null) ? BigDecimal.ZERO : discount;
if (flags != null && flags.equals(Constants.GLF)) {
feeTotalDiscount = feeTotalDiscount.add(discount);
BigDecimal manageRate = orderServices.getManageRate();
manageRate = (manageRate == null) ? BigDecimal.ZERO : manageRate;
manageFee = manageFee.multiply(manageRate);
feeTotalAmount = feeTotalAmount.add(manageFee);
} else {
feeTotalDiscount = feeTotalDiscount.add(discount);
BigDecimal serviceAmount = orderServices.getServiceAmount();
serviceAmount = (serviceAmount == null) ? BigDecimal.ZERO : serviceAmount;
feeTotalAmount = feeTotalAmount.add(serviceAmount);
}
}
}
}
totalAmount = goodsTotalAmount.add(serviceTotalAmount).add(feeTotalAmount);
totalDiscount = goodsTotalDiscount.add(serviceTotalDiscount).add(feeTotalDiscount);
orderInfo.setGoodsAmount(goodsTotalAmount);
orderInfo.setServiceAmount(serviceTotalAmount);
orderInfo.setTotalAmount(totalAmount);
orderInfo.setDiscount(totalDiscount);
orderInfo.setGoodsDiscount(goodsTotalDiscount);
orderInfo.setServiceDiscount(serviceTotalDiscount);
orderInfo.setFeeAmount(feeTotalAmount);
orderInfo.setFeeDiscount(feeTotalDiscount);
orderInfo.setManageFee(manageFee);
BigDecimal taxAmount = orderInfo.getTaxAmount();
taxAmount = (taxAmount == null) ? BigDecimal.ZERO : taxAmount;
totalAmount = totalAmount.add(taxAmount).subtract(totalDiscount);
// TODO 已被取消 *折扣=1 + 费用-优惠
// 核算工单优惠(兼容普通工单)
// 折扣
BigDecimal preDiscountRate = BigDecimal.ONE;
orderInfo.setPreDiscountRate(preDiscountRate);
// 费用
BigDecimal preTaxAmount = BigDecimal.ZERO;
orderInfo.setPreTaxAmount(preTaxAmount);
// 优惠
BigDecimal prePreferentiaAmount = BigDecimal.ZERO;
orderInfo.setPrePreferentiaAmount(prePreferentiaAmount);
// 代金券
BigDecimal preCouponAmount = BigDecimal.ZERO;
orderInfo.setPreCouponAmount(preCouponAmount);
// 实际应收金额 =工单总金额 * 折扣 + 费用 - 优惠 - 代金券
BigDecimal preTotalAmount = totalAmount.multiply(preDiscountRate)
.add(preTaxAmount)
.subtract(prePreferentiaAmount)
.subtract(preCouponAmount);
orderInfo.setPreTotalAmount(preTotalAmount);
orderInfo.setOrderAmount(totalAmount);
}
/**
* 核算订单各项金额
*
* @param orderInfo 工单基本信息
* @param orderGoodsList 选购物料
* @param orderServiceList 选购服务
*/
@Override
public void calculateOrderExpense(OrderInfo orderInfo,
List<OrderGoods> orderGoodsList,
List<OrderServices> orderServiceList) {
// 服务项目总金额
BigDecimal serviceTotalAmount = BigDecimal.ZERO;
// 商品总金额
BigDecimal goodsTotalAmount = BigDecimal.ZERO;
// 订单总金额
BigDecimal totalAmount = BigDecimal.ZERO;
// 订单总折扣
BigDecimal totalDiscount = BigDecimal.ZERO;
// 商品总折扣
BigDecimal goodsTotalDiscount = BigDecimal.ZERO;
// 服务总折扣
BigDecimal serviceTotalDiscount = BigDecimal.ZERO;
// 费用总折扣
BigDecimal feeTotalDiscount = BigDecimal.ZERO;
// 费用总金额
BigDecimal feeTotalAmount = BigDecimal.ZERO;
// 管理费
BigDecimal manageFee = BigDecimal.ZERO;
if (!CollectionUtils.isEmpty(orderGoodsList)) {
for (OrderGoods orderGoods : orderGoodsList) {
BigDecimal goodsAmount = orderGoods.getGoodsAmount();
goodsAmount = (goodsAmount == null) ? BigDecimal.ZERO : goodsAmount;
goodsTotalAmount = goodsTotalAmount.add(goodsAmount);
totalAmount = totalAmount.add(goodsAmount);
BigDecimal discount = orderGoods.getDiscount();
discount = (discount == null) ? BigDecimal.ZERO : discount;
totalDiscount = totalDiscount.add(discount);
goodsTotalDiscount = goodsTotalDiscount.add(discount);
}
}
// 商品总费用
manageFee = goodsTotalAmount.subtract(goodsTotalDiscount);
if (!CollectionUtils.isEmpty(orderServiceList)) {
for (OrderServices orderServices : orderServiceList) {
Integer serviceType = orderServices.getType();
// 1:基本服务
if (serviceType == OrderServiceTypeEnum.BASIC.getCode()) {
BigDecimal discount = orderServices.getDiscount();
discount = (discount == null) ? BigDecimal.ZERO : discount;
serviceTotalDiscount = serviceTotalDiscount.add(discount);
BigDecimal serviceAmount = orderServices.getServiceAmount();
serviceAmount = (serviceAmount == null) ? BigDecimal.ZERO : serviceAmount;
serviceTotalAmount = serviceTotalAmount.add(serviceAmount);
}
// 2:附属服务
if (serviceType == OrderServiceTypeEnum.ANCILLARY.getCode()) {
String flags = orderServices.getFlags();
BigDecimal discount = orderServices.getDiscount();
discount = (discount == null) ? BigDecimal.ZERO : discount;
if (flags != null && flags.equals(Constants.GLF)) {
feeTotalDiscount = feeTotalDiscount.add(discount);
BigDecimal manageRate = orderServices.getManageRate();
manageRate = (manageRate == null) ? BigDecimal.ZERO : manageRate;
manageFee = manageFee.multiply(manageRate);
feeTotalAmount = feeTotalAmount.add(manageFee);
} else {
feeTotalDiscount = feeTotalDiscount.add(discount);
BigDecimal serviceAmount = orderServices.getServiceAmount();
serviceAmount = (serviceAmount == null) ? BigDecimal.ZERO : serviceAmount;
feeTotalAmount = feeTotalAmount.add(serviceAmount);
}
}
}
}
totalAmount = goodsTotalAmount.add(serviceTotalAmount).add(feeTotalAmount);
totalDiscount = goodsTotalDiscount.add(serviceTotalDiscount).add(feeTotalDiscount);
orderInfo.setGoodsAmount(goodsTotalAmount);
orderInfo.setServiceAmount(serviceTotalAmount);
orderInfo.setTotalAmount(totalAmount);
orderInfo.setDiscount(totalDiscount);
orderInfo.setGoodsDiscount(goodsTotalDiscount);
orderInfo.setServiceDiscount(serviceTotalDiscount);
orderInfo.setFeeAmount(feeTotalAmount);
orderInfo.setFeeDiscount(feeTotalDiscount);
orderInfo.setManageFee(manageFee);
BigDecimal taxAmount = orderInfo.getTaxAmount();
taxAmount = (taxAmount == null) ? BigDecimal.ZERO : taxAmount;
totalAmount = totalAmount.add(taxAmount).subtract(totalDiscount);
// TODO 已被取消 *折扣=1 + 费用-优惠
// 核算工单优惠(兼容普通工单)
// 折扣
BigDecimal preDiscountRate = BigDecimal.ONE;
orderInfo.setPreDiscountRate(preDiscountRate);
// 费用
BigDecimal preTaxAmount = BigDecimal.ZERO;
orderInfo.setPreTaxAmount(preTaxAmount);
// 优惠
BigDecimal prePreferentiaAmount = BigDecimal.ZERO;
orderInfo.setPrePreferentiaAmount(prePreferentiaAmount);
// 代金券
BigDecimal preCouponAmount = BigDecimal.ZERO;
orderInfo.setPreCouponAmount(preCouponAmount);
// 实际应收金额 =工单总金额 * 折扣 + 费用 - 优惠 - 代金券
BigDecimal preTotalAmount = totalAmount.multiply(preDiscountRate)
.add(preTaxAmount)
.subtract(prePreferentiaAmount)
.subtract(preCouponAmount);
orderInfo.setPreTotalAmount(preTotalAmount);
orderInfo.setOrderAmount(totalAmount);
}
public Result virtualCalcPrice(List<Map<String, Object>> orderGoodsMapList,
List<Map<String, Object>> orderServicesMapList) {
return Result.wrapSuccessfulResult(doVirtualCalcPrice(orderGoodsMapList, orderServicesMapList));
}
@Override
public Result updateOrderOfWareHouse(OrderFormEntityBo orderFormEntityBo, UserInfo userInfo) throws BusinessCheckedException {
// order's basic info
OrderInfo orderInfo = orderFormEntityBo.getOrderInfo();
Long orderId = orderInfo.getId();
Long shopId = userInfo.getShopId();
// check order exsit
OrderInfo orderLatestData = this.selectByIdAndShopId(orderInfoDao,
orderId, shopId);
if (orderLatestData == null) {
throw new BusinessCheckedException("21", "工单不存在!");
}
if(orderLatestData.getOrderStatus().equals(OrderStatusEnum.DDYFK.getKey()) ||
orderLatestData.getOrderStatus().equals(OrderStatusEnum.DDWC.getKey())){
throw new BusinessCheckedException("21", "工单状态不正确,请刷新页面再试");
}
// 设置orderStatus
orderLatestData.setOrderStatus(orderInfo.getOrderStatus());
// check 2015-09-15 3秒内,不是同时操作
String modifiedYMDHMS = orderInfo.getGmtModifiedYMDHMS();
if (StringUtils.isNotEmpty(modifiedYMDHMS)) {
Date oldGmtModified = DateUtil.convertStringToDate(modifiedYMDHMS);
Date newGmtModified = orderLatestData.getGmtModified();
long diff = newGmtModified.getTime() - oldGmtModified.getTime();
long diffSeconds = diff / 1000 % 60;
// <=3秒内:不是同时操作
if (newGmtModified != null && (Math.abs(diffSeconds) > 3)) {
throw new BusinessCheckedException("10000", "已经有人修改过这条工单记录,请刷新后重试!");
}
}
// check customerCar is exsit
Optional<CustomerCar> customerCarOptional =
customerCarService.getCustomerCar(orderInfo.getCustomerCarId());
if (!customerCarOptional.isPresent()) {
throw new BusinessCheckedException("1", "车牌信息不存在!");
}
// ordered goods
List<OrderGoods> orderedGoodsList = new ArrayList<OrderGoods>();
// valid ordered goods
List<OrderGoods> actualGoodsList = new ArrayList<OrderGoods>();
List<OrderGoods> actualGoodsListTemp = new ArrayList<OrderGoods>();
// transfer json to list
Gson gson = new Gson();
String orderGoodsJson = orderFormEntityBo.getOrderGoodJson();
try {
orderedGoodsList = gson.fromJson(orderGoodsJson,
new TypeToken<List<OrderGoods>>() {
}.getType());
} catch (JsonSyntaxException e) {
LOGGER.error("选购物料JSON:{}", orderGoodsJson);
throw new RuntimeException("选购物料JSON转对象异常");
}
// ordered goods total number
Long orderedGoodsTotalNumber = 0l;
// filter valid goods and calculate goods's amount
if (!CollectionUtils.isEmpty(orderedGoodsList)) {
Set<Long> goodsIdSet = new HashSet<Long>();
for (OrderGoods goods : orderedGoodsList) {
Long goodsId = goods.getGoodsId();
if (goodsId != null) {
goodsIdSet.add(goodsId);
// calculator goods’s amount
BigDecimal goodsPrice = goods.getGoodsPrice();
// goodsPrice default 0
goodsPrice = (goodsPrice == null) ? BigDecimal.ZERO : goodsPrice;
BigDecimal goodsNumber = goods.getGoodsNumber();
// goodsNumber default 1
goodsNumber = (goodsNumber == null ||
goodsNumber.compareTo(BigDecimal.ZERO) == 0) ? BigDecimal.ONE : goodsNumber;
goods.setGoodsNumber(goodsNumber);
BigDecimal goodsAmountTemp = goodsPrice.multiply(goodsNumber);
goods.setGoodsAmount(goodsAmountTemp);
BigDecimal discount = goods.getDiscount();
// discount default 0
discount = (discount == null) ? BigDecimal.ZERO : discount;
BigDecimal soldAmountTemp = goodsAmountTemp.subtract(discount);
goods.setSoldAmount(soldAmountTemp);
goods.setSoldPrice(soldAmountTemp.divide(goodsNumber, 8, BigDecimal.ROUND_HALF_UP));
actualGoodsList.add(goods);
actualGoodsListTemp.add(goods);
}
}
// check goods is exsit
int goodsIdSize = goodsIdSet.size();
if (goodsIdSize > 0) {
List<Goods> goodsLatestData =
goodsService.selectByIds(goodsIdSet.toArray(new Long[goodsIdSize]));
int goodsLatestDataSize = goodsLatestData.size();
// Map<goods.id,goods>
Map<Long, Goods> goodsLatestDataMap = new HashMap<Long, Goods>(goodsLatestDataSize);
for (Goods good : goodsLatestData) {
goodsLatestDataMap.put(good.getId(), good);
}
if (goodsIdSize != goodsLatestDataSize) {
StringBuffer goodsErrorMsgSB = new StringBuffer("选择的配件不存在,配件编号如下:");
Iterator<Long> goodsIdSetIT = goodsIdSet.iterator();
while (goodsIdSetIT.hasNext()) {
Long goodsId = goodsIdSetIT.next();
if (!goodsLatestDataMap.containsKey(goodsId)) {
goodsErrorMsgSB.append("<br/>");
goodsErrorMsgSB.append(goodsId);
}
}
throw new BusinessCheckedException("2", goodsErrorMsgSB.toString());
}
}
orderedGoodsTotalNumber = Long.valueOf(actualGoodsList.size() + "");
}
// 虚开物料
List<OrderGoods> vituralOrderGoodsList = orderGoodsService.queryOrderGoodList(orderId, shopId, OrderGoodTypeEnum.VIRTUAL);
// 加上虚开物料数量
orderedGoodsTotalNumber = orderedGoodsTotalNumber + vituralOrderGoodsList.size();
// goods's total number
orderLatestData.setGoodsCount(orderedGoodsTotalNumber);
// oldServiceList
List<OrderServices> validServiceList =
orderServicesService.queryOrderServiceList(orderId, shopId);
// 追加虚开物料
actualGoodsListTemp.addAll(vituralOrderGoodsList);
calculateOrderExpense(orderLatestData, actualGoodsListTemp, validServiceList);
orderLatestData.setModifier(userInfo.getUserId());
orderLatestData.setOperatorName(userInfo.getName());
orderLatestData.setPostscript(orderInfo.getPostscript());
updateOrder(orderLatestData, actualGoodsList, userInfo);
return Result.wrapSuccessfulResult(orderId);
}
/**
* update 工单基本信息、选购实开物料
*
* @param orderInfo 工单实体
* @param actualGoodsList 实开物料
* @param userInfo 当前操作人
* @return
*/
// TODO 事务不起作用
@Transactional
public void updateOrder(OrderInfo orderInfo,
List<OrderGoods> actualGoodsList,
UserInfo userInfo) {
// userId
Long userId = userInfo.getUserId();
// 更新orderInfo
orderInfoDao.updateById(orderInfo);
// orderId
Long orderId = orderInfo.getId();
// shopId
Long shopId = userInfo.getShopId();
// 编辑前:选购的实开物料
List<OrderGoods> oldActualGoodsList =
orderGoodsService.queryOrderGoodList(orderId, shopId, OrderGoodTypeEnum.ACTUAL);
Set<Long> orderGoodsIds = new HashSet<Long>();
Set<Long> oldGoodsIds = new HashSet<Long>();
if (!CollectionUtils.isEmpty(oldActualGoodsList)) {
for (OrderGoods good : oldActualGoodsList) {
oldGoodsIds.add(good.getId());
}
}
if (!CollectionUtils.isEmpty(actualGoodsList)) {
// new orderGoods
List<OrderGoods> newOrderGoodseList = new ArrayList<OrderGoods>();
for (OrderGoods orderGood : actualGoodsList) {
Long goodId = orderGood.getId();
if (goodId == null) {
// 关联工单
orderGood.setOrderId(orderInfo.getId());
orderGood.setOrderSn(orderInfo.getOrderSn());
orderGood.setCreator(userInfo.getUserId());
orderGood.setModifier(userInfo.getUserId());
orderGood.setShopId(userInfo.getShopId());
newOrderGoodseList.add(orderGood);
} else {
// 伪造物料ID:更新操作
if (oldGoodsIds != null && !oldGoodsIds.contains(goodId)) {
LOGGER.error("传递的工单配件ID不正确,配件ID:{}", goodId);
throw new RuntimeException("传递的工单配件ID不正确");
}
orderGood.setModifier(userId);
orderGoodsService.update(orderGood);
orderGoodsIds.add(goodId);
}
}
// batch save new OrderGoods
if (!newOrderGoodseList.isEmpty()) {
orderGoodsService.batchInsert(newOrderGoodseList);
}
}
// 之前选择的:不存在情况,删除掉
if (!CollectionUtils.isEmpty(oldActualGoodsList)) {
for (OrderGoods oldOrderGoods : oldActualGoodsList) {
if (orderGoodsIds != null && !orderGoodsIds.contains(oldOrderGoods.getId())) {
oldOrderGoods.setModifier(userId);
oldOrderGoods.setIsDeleted("Y");
orderGoodsService.update(oldOrderGoods);
}
}
}
}
@Override
public Result virtualSave(OrderFormEntityBo orderFormEntityBo, UserInfo userInfo)
throws BusinessCheckedException {
// order's basic info
OrderInfo orderInfo = orderFormEntityBo.getOrderInfo();
// ordered goods
List<OrderGoods> orderedGoodsList = new ArrayList<OrderGoods>();
// valid ordered goods
List<OrderGoods> validGoodsList = new ArrayList<OrderGoods>();
// ordered services
List<OrderServices> orderedServiceList = new ArrayList<OrderServices>();
// valid ordered services
List<OrderServices> validServiceList = new ArrayList<OrderServices>();
// transfer json to list
Gson gson = new Gson();
String orderGoodsJson = orderFormEntityBo.getOrderGoodJson();
String orderServiceJson = orderFormEntityBo.getOrderServiceJson();
try {
orderedGoodsList = gson.fromJson(orderGoodsJson,
new TypeToken<List<OrderGoods>>() {
}.getType());
} catch (JsonSyntaxException e) {
LOGGER.error("选购物料JSON:{}", orderGoodsJson);
throw new RuntimeException("选购物料JSON转对象异常");
}
try {
orderedServiceList = gson.fromJson(orderServiceJson,
new TypeToken<List<OrderServices>>() {
}.getType());
} catch (JsonSyntaxException e) {
LOGGER.error("选购服务JSON:{}", orderServiceJson);
throw new RuntimeException("选购服务JSON转对象异常");
}
// ordered goods‘s total number
Long orderedGoodsTotalNumber = 0l;
// filter valid goods and calculate goods's amount
if (!CollectionUtils.isEmpty(orderedGoodsList)) {
// valid goods's ids
for (OrderGoods goods : orderedGoodsList) {
String goodsFormat = goods.getGoodsFormat();
String goodsName = goods.getGoodsName();
if (!StringUtils.isEmpty(goodsFormat) ||
!StringUtils.isEmpty(goodsName)) {
// calculator goods’s amount
BigDecimal goodsPrice = goods.getGoodsPrice();
// goodsPrice default 0
goodsPrice = (goodsPrice == null) ? BigDecimal.ZERO : goodsPrice;
BigDecimal goodsNumber = goods.getGoodsNumber();
// goodsNumber default 1
goodsNumber = (goodsNumber == null ||
goodsNumber.compareTo(BigDecimal.ZERO) == 0) ? BigDecimal.ONE : goodsNumber;
goods.setGoodsNumber(goodsNumber);
BigDecimal goodsAmountTemp = goodsPrice.multiply(goodsNumber);
goods.setGoodsAmount(goodsAmountTemp);
BigDecimal discount = goods.getDiscount();
// discount default 0
discount = (discount == null) ? BigDecimal.ZERO : discount;
BigDecimal soldAmountTemp = goodsAmountTemp.subtract(discount);
goods.setSoldAmount(soldAmountTemp);
goods.setSoldPrice(soldAmountTemp.divide(goodsNumber, 8, BigDecimal.ROUND_HALF_UP));
validGoodsList.add(goods);
}
}
orderedGoodsTotalNumber = Long.valueOf(validGoodsList.size() + "");
}
// goods's total number
orderInfo.setGoodsCount(orderedGoodsTotalNumber);
// ordered service total number
Long orderedServiceNumber = 0L;
if (!CollectionUtils.isEmpty(orderedServiceList)) {
// filter valid service and calculate servie's amount
for (OrderServices service : orderedServiceList) {
String serviceName = service.getServiceName();
if (!StringUtils.isEmpty(serviceName)) {
BigDecimal servicePrice = service.getServicePrice();
// servicePrice default 0
servicePrice = (servicePrice == null) ? BigDecimal.ZERO : servicePrice;
// serviceHour default 0
BigDecimal serviceHour = service.getServiceHour();
serviceHour = (serviceHour == null) ? BigDecimal.ZERO : serviceHour;
// discount default 0
BigDecimal discount = service.getDiscount();
discount = (discount == null) ? BigDecimal.ZERO : discount;
BigDecimal serviceAmountTemp = servicePrice.multiply(serviceHour);
service.setServiceAmount(serviceAmountTemp);
BigDecimal soldAmountTemp = serviceAmountTemp.subtract(discount);
service.setSoldAmount(soldAmountTemp);
if (serviceHour.compareTo(BigDecimal.ZERO) <= 0) {
service.setSoldPrice(BigDecimal.ZERO);
} else {
service.setSoldPrice(soldAmountTemp.divide(serviceHour, 8, BigDecimal.ROUND_HALF_UP));
}
validServiceList.add(service);
}
}
orderedServiceNumber = Long.valueOf(validServiceList.size() + "");
}
orderInfo.setServiceCount(orderedServiceNumber);
// calculate order's Amount
calculateOrderExpense(orderInfo, validGoodsList, validServiceList);
// TODO 设置公共信息(创建者、创建时间、更新者、更新时间)
orderInfo.setCreator(userInfo.getUserId());
orderInfo.setModifier(userInfo.getUserId());
orderInfo.setOperatorName(userInfo.getName());
orderInfo.setShopId(userInfo.getShopId());
//set postscript
String postscript = orderInfo.getPostscript();
orderInfo.setPostscript(postscript == null ? "" : postscript);
//set vin
String vin = orderInfo.getVin();
orderInfo.setVin(vin == null ? "" : vin);
// insert DB
insertVirtualOrder(orderInfo, validGoodsList, validServiceList, userInfo);
return Result.wrapSuccessfulResult(orderInfo.getParentId());
}
/**
* 保存虚拟工单基本信息、选购商品、选购服务
*
* @param orderInfo
* @param orderGoodsList
* @param orderServicesList
* @param userInfo
*/
// TODO 声明式事务,不起作用
@Transactional
public Long insertVirtualOrder(OrderInfo orderInfo,
List<OrderGoods> orderGoodsList,
List<OrderServices> orderServicesList,
UserInfo userInfo) {
String orderSn = orderInfo.getOrderSn();
orderInfo.setOrderSn(orderSn);
//插入orderInfo
VirtualOrder virtualOrder = copyOrderPropertyToVirtualOrder(orderInfo);
virtualOrder.setParentId(orderInfo.getParentId());
String identityCard = orderInfo.getIdentityCard();
virtualOrder.setIdentityCard(identityCard == null ? "" : identityCard);
// TODO 设置公共信息(创建者、创建时间、更新者、更新时间)
virtualOrder.setCreator(userInfo.getUserId());
virtualOrder.setModifier(userInfo.getUserId());
virtualOrder.setOperatorName(userInfo.getName());
virtualOrder.setShopId(userInfo.getShopId());
virtualOrderService.save(virtualOrder);
//插入orderGoods
// TODO 调整为批量保存
if (!CollectionUtils.isEmpty(orderGoodsList)) {
for (OrderGoods orderGoods : orderGoodsList) {
VirtualOrdergood virtualOrdergood = copyGoodPropertyToVirtualGood(userInfo, virtualOrder, orderGoods);
virtualOrdergoodService.save(virtualOrdergood);
}
}
//插入orderService基本信息
// TODO 调整为批量保存
if (!CollectionUtils.isEmpty(orderServicesList)) {
for (OrderServices orderServices : orderServicesList) {
VirtualOrderservice virtualOrderservice = copyServicePropertyToVirtualService(userInfo, virtualOrder, orderServices);
virtualOrderserviceService.save(virtualOrderservice);
}
}
return virtualOrder.getId();
}
/**
* copy Service's Property To VirtualService's property
*
* @param userInfo
* @param virtualOrder
* @param orderServices
* @return
*/
private VirtualOrderservice copyServicePropertyToVirtualService(UserInfo userInfo, VirtualOrder virtualOrder, OrderServices orderServices) {
VirtualOrderservice virtualOrderservice = new VirtualOrderservice();
virtualOrderservice.setOrderId(virtualOrder.getId());
String orderSn = virtualOrder.getOrderSn();
virtualOrderservice.setOrderSn(orderSn == null ? "" : orderSn);
virtualOrderservice.setCreator(userInfo.getUserId());
virtualOrderservice.setModifier(userInfo.getUserId());
virtualOrderservice.setShopId(userInfo.getShopId());
virtualOrderservice.setServiceId(orderServices.getServiceId());
virtualOrderservice.setServiceSn(orderServices.getServiceSn());
virtualOrderservice.setFlags(orderServices.getFlags());
virtualOrderservice.setType(orderServices.getType());
virtualOrderservice.setServiceCatId(orderServices.getServiceCatId());
String serviceName = orderServices.getServiceName();
virtualOrderservice.setServiceName(serviceName == null ? "" : serviceName);
String serviceCatName = orderServices.getServiceCatName();
virtualOrderservice.setServiceCatName(serviceCatName == null ? "" : serviceCatName);
BigDecimal servicePrice = orderServices.getServicePrice();
virtualOrderservice.setServicePrice(servicePrice == null ? BigDecimal.ZERO : servicePrice);
BigDecimal serviceHour = orderServices.getServiceHour();
virtualOrderservice.setServiceHour(serviceHour == null ? BigDecimal.ONE : serviceHour);
virtualOrderservice.setServiceAmount(orderServices.getServiceAmount());
BigDecimal discount = orderServices.getDiscount();
virtualOrderservice.setDiscount(discount == null ? BigDecimal.ZERO : discount);
virtualOrderservice.setWorkerId(orderServices.getWorkerId());
String serviceNote = orderServices.getServiceNote();
virtualOrderservice.setServiceNote(serviceNote == null ? "" : serviceNote);
virtualOrderservice.setFlags(orderServices.getFlags());
return virtualOrderservice;
}
/**
* copy Good's Property To VirtualGood's property
*
* @param userInfo
* @param virtualOrder
* @param orderGoods
* @return
*/
private VirtualOrdergood copyGoodPropertyToVirtualGood(UserInfo userInfo, VirtualOrder virtualOrder, OrderGoods orderGoods) {
VirtualOrdergood virtualOrdergood = new VirtualOrdergood();
virtualOrdergood.setOrderId(virtualOrder.getId());
String orderSn = virtualOrder.getOrderSn();
virtualOrdergood.setOrderSn(orderSn == null ? "" : orderSn);
virtualOrdergood.setCreator(userInfo.getUserId());
virtualOrdergood.setModifier(userInfo.getUserId());
virtualOrdergood.setShopId(userInfo.getShopId());
virtualOrdergood.setGoodsId(orderGoods.getGoodsId());
String goodsSn = orderGoods.getGoodsSn();
virtualOrdergood.setGoodsSn(goodsSn == null ? "" : goodsSn);
virtualOrdergood.setInventoryPrice(orderGoods.getInventoryPrice());
virtualOrdergood.setGoodsType(orderGoods.getGoodsType());
String goodsFormat = orderGoods.getGoodsFormat();
virtualOrdergood.setGoodsFormat(goodsFormat == null ? "" : goodsFormat);
String goodsName = orderGoods.getGoodsName();
virtualOrdergood.setGoodsName(goodsName == null ? "" : goodsName);
BigDecimal goodsPrice = orderGoods.getGoodsPrice();
virtualOrdergood.setGoodsPrice(goodsPrice == null ? BigDecimal.ZERO : goodsPrice);
BigDecimal goodsNumber = orderGoods.getGoodsNumber();
virtualOrdergood.setGoodsNumber(goodsNumber == null ? BigDecimal.ONE : goodsNumber);
virtualOrdergood.setGoodsAmount(orderGoods.getGoodsAmount());
BigDecimal discount = orderGoods.getDiscount();
virtualOrdergood.setDiscount(discount == null ? BigDecimal.ZERO : discount);
String goodsNote = orderGoods.getGoodsNote();
virtualOrdergood.setGoodsNote(goodsNote == null ? "" : goodsNote);
virtualOrdergood.setMeasureUnit(orderGoods.getMeasureUnit());
virtualOrdergood.setSaleId(orderGoods.getSaleId());
return virtualOrdergood;
}
/**
* copy Order's Property To VirtualOrder's property
*
* @param orderInfo
* @return
*/
private VirtualOrder copyOrderPropertyToVirtualOrder(OrderInfo orderInfo) {
VirtualOrder virtualOrder = new VirtualOrder();
String orderSn = orderInfo.getOrderSn();
virtualOrder.setOrderSn(orderSn == null ? "" : orderSn);
virtualOrder.setOrderStatus(orderInfo.getOrderStatus());
virtualOrder.setPayStatus(orderInfo.getPayStatus());
String carLicense = orderInfo.getCarLicense();
virtualOrder.setCarLicense(carLicense == null ? "" : carLicense);
String carModels = orderInfo.getCarModels();
virtualOrder.setCarModels(carModels == null ? "" : carModels);
//add by twg
virtualOrder.setCarBrand(orderInfo.getCarBrand());
virtualOrder.setCarBrandId(orderInfo.getCarBrandId());
virtualOrder.setCarSeriesId(orderInfo.getCarSeriesId());
virtualOrder.setCarSeries(orderInfo.getCarSeries());
virtualOrder.setCarModelsId(orderInfo.getCarModelsId());
virtualOrder.setImportInfo(orderInfo.getImportInfo());
//end
String carAlias = orderInfo.getCarAlias();
virtualOrder.setCarAlias(carAlias == null ? "" : carAlias);
virtualOrder.setOrderType(orderInfo.getOrderType());
virtualOrder.setExpectedTime(orderInfo.getExpectedTime());
String mileage = orderInfo.getMileage();
virtualOrder.setMileage(mileage == null ? "" : mileage);
virtualOrder.setReceiver(orderInfo.getReceiver());
virtualOrder.setReceiverName(orderInfo.getReceiverName());
String contactName = orderInfo.getContactName();
virtualOrder.setContactName(contactName == null ? "" : contactName);
String contactMobile = orderInfo.getContactMobile();
virtualOrder.setContactMobile(contactMobile == null ? "" : contactMobile);
String customerName = orderInfo.getCustomerName();
virtualOrder.setCustomerName(customerName == null ? "" : customerName);
String customerMobile = orderInfo.getCustomerMobile();
virtualOrder.setCustomerMobile(customerMobile == null ? "" : customerMobile);
virtualOrder.setInsuranceCompanyId(orderInfo.getInsuranceCompanyId());
virtualOrder.setInsuranceCompanyName(orderInfo.getInsuranceCompanyName());
virtualOrder.setOtherInsuranceCompanyId(orderInfo.getOtherInsuranceCompanyId());
virtualOrder.setOtherInsuranceCompanyName(orderInfo.getOtherInsuranceCompanyName());
String carColor = orderInfo.getCarColor();
virtualOrder.setCarColor(carColor == null ? "" : carColor);
virtualOrder.setBuyTime(orderInfo.getBuyTime());
virtualOrder.setCustomerId(orderInfo.getCustomerId());
virtualOrder.setCustomerCarId(orderInfo.getCustomerCarId());
String vin = orderInfo.getVin();
virtualOrder.setVin(vin == null ? "" : vin);
String engineNo = orderInfo.getEngineNo();
virtualOrder.setEngineNo(engineNo == null ? "" : engineNo);
String customerAddress = orderInfo.getCustomerAddress();
virtualOrder.setCustomerAddress(customerAddress == null ? "" : customerAddress);
String oilMeter = orderInfo.getOilMeter();
virtualOrder.setOilMeter(oilMeter == null ? "" : oilMeter);
virtualOrder.setServiceAmount(orderInfo.getServiceAmount());
virtualOrder.setServiceDiscount(orderInfo.getServiceDiscount());
virtualOrder.setGoodsAmount(orderInfo.getGoodsAmount());
virtualOrder.setGoodsDiscount(orderInfo.getGoodsDiscount());
virtualOrder.setFeeAmount(orderInfo.getFeeAmount());
virtualOrder.setFeeDiscount(orderInfo.getFeeDiscount());
virtualOrder.setOrderAmount(orderInfo.getOrderAmount());
virtualOrder.setPostscript(orderInfo.getPostscript());
//设置开子单时间
virtualOrder.setCreateTime(orderInfo.getCreateTime());
//设置子单结算日期
virtualOrder.setPayTime(orderInfo.getPayTime());
//设置子单打印时间
virtualOrder.setPrintTime(orderInfo.getPrintTime());
// 客户单位
virtualOrder.setCompany(orderInfo.getCompany());
//设置完工日期
virtualOrder.setExpectedTime(orderInfo.getExpectedTime());
return virtualOrder;
}
@Override
public Result virtualUpdate(OrderFormEntityBo orderFormEntityBo, UserInfo userInfo)
throws BusinessCheckedException {
// order's basic info
OrderInfo orderInfo = orderFormEntityBo.getOrderInfo();
Long orderId = orderInfo.getId();
// ordered goods
List<OrderGoods> orderedGoodsList = new ArrayList<OrderGoods>();
// valid ordered goods
List<OrderGoods> validGoodsList = new ArrayList<OrderGoods>();
// ordered services
List<OrderServices> orderedServiceList = new ArrayList<OrderServices>();
// valid ordered services
List<OrderServices> validServiceList = new ArrayList<OrderServices>();
// transfer json to list
Gson gson = new Gson();
String orderGoodsJson = orderFormEntityBo.getOrderGoodJson();
String orderServiceJson = orderFormEntityBo.getOrderServiceJson();
try {
orderedGoodsList = gson.fromJson(orderGoodsJson,
new TypeToken<List<OrderGoods>>() {
}.getType());
} catch (JsonSyntaxException e) {
LOGGER.error("选购物料JSON:{}", orderGoodsJson);
throw new RuntimeException("选购物料JSON转对象异常");
}
try {
orderedServiceList = gson.fromJson(orderServiceJson,
new TypeToken<List<OrderServices>>() {
}.getType());
} catch (JsonSyntaxException e) {
LOGGER.error("选购服务JSON:{}", orderServiceJson);
throw new RuntimeException("选购服务JSON转对象异常");
}
// ordered goods total number
Long orderedGoodsTotalNumber = 0l;
// filter valid goods and calculate goods's amount
if (!CollectionUtils.isEmpty(orderedGoodsList)) {
for (OrderGoods goods : orderedGoodsList) {
Long goodsId = goods.getId();
String goodsFormat = goods.getGoodsFormat();
String goodsName = goods.getGoodsName();
if ((goodsId != null && goodsId != 0)
|| (!StringUtils.isEmpty(goodsFormat) ||
!StringUtils.isEmpty(goodsName))) {
// calculator goods’s amount
BigDecimal goodsPrice = goods.getGoodsPrice();
// goodsPrice default 0
goodsPrice = (goodsPrice == null) ? BigDecimal.ZERO : goodsPrice;
BigDecimal goodsNumber = goods.getGoodsNumber();
// goodsNumber default 1
goodsNumber = (goodsNumber == null ||
goodsNumber.compareTo(BigDecimal.ZERO) == 0) ? BigDecimal.ONE : goodsNumber;
goods.setGoodsNumber(goodsNumber);
BigDecimal goodsAmountTemp = goodsPrice.multiply(goodsNumber);
goods.setGoodsAmount(goodsAmountTemp);
BigDecimal discount = goods.getDiscount();
// discount default 0
discount = (discount == null) ? BigDecimal.ZERO : discount;
BigDecimal soldAmountTemp = goodsAmountTemp.subtract(discount);
goods.setSoldAmount(soldAmountTemp);
goods.setSoldPrice(soldAmountTemp.divide(goodsNumber, 8, BigDecimal.ROUND_HALF_UP));
validGoodsList.add(goods);
}
}
orderedGoodsTotalNumber = Long.valueOf(validGoodsList.size() + "");
}
// goods's total number
orderInfo.setGoodsCount(orderedGoodsTotalNumber);
// ordered service total number
Long orderedServiceNumber = 0L;
if (!CollectionUtils.isEmpty(orderedServiceList)) {
// filter valid service and calculate servie's amount
for (OrderServices service : orderedServiceList) {
Long serviceId = service.getId();
String serviceName = service.getServiceName();
if ((serviceId != null && serviceId != 0) ||
!StringUtils.isEmpty(serviceName)) {
BigDecimal servicePrice = service.getServicePrice();
// servicePrice default 0
servicePrice = (servicePrice == null) ? BigDecimal.ZERO : servicePrice;
// serviceHour default 0
BigDecimal serviceHour = service.getServiceHour();
serviceHour = (serviceHour == null) ? BigDecimal.ZERO : serviceHour;
// discount default 0
BigDecimal discount = service.getDiscount();
discount = (discount == null) ? BigDecimal.ZERO : discount;
BigDecimal serviceAmountTemp = servicePrice.multiply(serviceHour);
service.setServiceAmount(serviceAmountTemp);
BigDecimal soldAmountTemp = serviceAmountTemp.subtract(discount);
service.setSoldAmount(soldAmountTemp);
if (serviceHour.compareTo(BigDecimal.ZERO) <= 0) {
service.setSoldPrice(BigDecimal.ZERO);
} else {
service.setSoldPrice(soldAmountTemp.divide(serviceHour, 8, BigDecimal.ROUND_HALF_UP));
}
validServiceList.add(service);
}
}
orderedServiceNumber = Long.valueOf(validServiceList.size() + "");
}
orderInfo.setServiceCount(orderedServiceNumber);
// calculate order's Amount
calculateOrderExpense(orderInfo, validGoodsList, validServiceList);
// TODO 设置公共信息(创建者、创建时间、更新者、更新时间)
orderInfo.setModifier(userInfo.getUserId());
orderInfo.setOperatorName(userInfo.getName());
orderInfo.setShopId(userInfo.getShopId());
updateVirtualOrder(orderInfo, validGoodsList, validServiceList, userInfo);
return Result.wrapSuccessfulResult(orderInfo.getParentId());
}
@Override
@Transactional
public void virtualDelete(Long orderId, UserInfo userInfo) throws BusinessCheckedException {
Long shopId = userInfo.getShopId();
// 主对象为null,直接退出逻辑,前端给公共错误提示
Optional<VirtualOrder> virtualOrderOptional = virtualOrderService.getOrderById(orderId);
if (virtualOrderOptional.isPresent()) {
VirtualOrder virtualOrder = virtualOrderOptional.get();
Long virtualOrderId = virtualOrder.getId();
try {
virtualOrderService.delete(virtualOrderId);
} catch (Exception e) {
LOGGER.error("删除虚拟子单失败,工单ID:{}", virtualOrderId);
throw new RuntimeException("删除虚拟子单异常");
}
// 物料
List<VirtualOrdergood> virtualOrdergoodList = virtualOrdergoodService.queryOrderGoods(orderId, shopId);
Set<Long> goodIdSet = new HashSet<Long>(virtualOrdergoodList.size());
for (VirtualOrdergood good : virtualOrdergoodList) {
goodIdSet.add(good.getId());
}
if (goodIdSet.size() > 0) {
try {
virtualOrdergoodService.deleteByIds(goodIdSet);
} catch (Exception e) {
LOGGER.error("批量删除虚拟子单的物料失败,物料IDS:{}", goodIdSet.toString());
throw new RuntimeException("批量删除虚拟子单的物料异常");
}
}
// 服务
List<VirtualOrderservice> virtualOrderserviceList = virtualOrderserviceService.queryOrderServices(orderId, shopId);
Set<Long> serviceIdSet = new HashSet<Long>(virtualOrderserviceList.size());
for (VirtualOrderservice service : virtualOrderserviceList) {
serviceIdSet.add(service.getId());
}
if (serviceIdSet.size() > 0) {
try {
virtualOrderserviceService.deleteByIds(serviceIdSet);
} catch (Exception e) {
LOGGER.error("批量删除虚拟子单的服务失败,服务IDS:{}", serviceIdSet.toString());
throw new RuntimeException("批量删除虚拟子单的服务异常");
}
}
} else {
throw new BusinessCheckedException("12", "虚拟子单不存在!");
}
}
@Override
public OrderExpenseEntity calculateOrderExpense(List<OrderGoods> orderGoodsList,
List<OrderServices> orderServicesList) {
// 服务总金额
BigDecimal serviceTotalAmount = BigDecimal.ZERO;
// 物料总金额
BigDecimal goodsTotalAmount = BigDecimal.ZERO;
// 工单总金额
BigDecimal totalAmount = BigDecimal.ZERO;
// 工单总折扣
BigDecimal totalDiscount = BigDecimal.ZERO;
// 物料总折扣
BigDecimal goodsTotalDiscount = BigDecimal.ZERO;
// 服务总折扣
BigDecimal serviceTotalDiscount = BigDecimal.ZERO;
// 费用总折扣
BigDecimal feeTotalDiscount = BigDecimal.ZERO;
// 费用总金额
BigDecimal feeTotalAmount = BigDecimal.ZERO;
// 管理费用
BigDecimal manageFee = BigDecimal.ZERO;
for (OrderGoods orderGoods : orderGoodsList) {
// 判断有效物料
Long goodsId = orderGoods.getGoodsId();
if (goodsId != null) {
BigDecimal goodsPrice = orderGoods.getGoodsPrice();
goodsPrice = (goodsPrice == null) ? BigDecimal.ZERO : goodsPrice;
BigDecimal goodsNumber = orderGoods.getGoodsNumber();
goodsNumber = (goodsNumber == null) ? BigDecimal.ZERO : goodsNumber;
BigDecimal goodsAmount = goodsPrice.multiply(goodsNumber);
goodsTotalAmount = goodsTotalAmount.add(goodsAmount);
totalAmount = totalAmount.add(goodsAmount);
BigDecimal goodDiscount = orderGoods.getDiscount();
goodDiscount = (goodDiscount == null) ? BigDecimal.ZERO : goodDiscount;
// 累加总折扣
totalDiscount = totalDiscount.add(goodDiscount);
// 累加总折扣
goodsTotalDiscount = goodsTotalDiscount.add(goodDiscount);
}
}
manageFee = goodsTotalAmount.subtract(goodsTotalDiscount);
for (OrderServices orderServices : orderServicesList) {
Long serviceId = orderServices.getServiceId();
if (serviceId != null) {
Integer serviceType = orderServices.getType();
BigDecimal serviceDiscount = orderServices.getDiscount();
serviceDiscount = (serviceDiscount == null) ? BigDecimal.ZERO : serviceDiscount;
BigDecimal serviceAmount = orderServices.getServiceAmount();
serviceAmount = (serviceAmount == null) ? BigDecimal.ZERO : serviceAmount;
if (serviceType != null && serviceType.intValue() == 1) {
// 累加服务折扣
serviceTotalDiscount = serviceTotalDiscount.add(serviceDiscount);
// 累加服务金额
serviceTotalAmount = serviceTotalAmount.add(serviceAmount);
}
if (serviceType != null && serviceType.intValue() == 2) {
String flags = orderServices.getFlags();
if (flags != null && flags.equals(Constants.GLF)) {
feeTotalDiscount = feeTotalDiscount.add(serviceDiscount);
BigDecimal manageRate = orderServices.getManageRate();
manageRate = (manageRate == null) ? BigDecimal.ONE : manageRate;
// 管理费 * 比率
manageFee = manageFee.multiply(manageRate);
// 累加费用总金额
feeTotalAmount = feeTotalAmount.add(manageFee);
} else {
// 累加费用总金额
feeTotalDiscount = feeTotalDiscount.add(serviceDiscount);
feeTotalAmount = feeTotalAmount.add(serviceAmount);
}
}
}
}
// 工单总金额 =物料总金额 + 服务总金额 + 费用总金额
totalAmount = goodsTotalAmount.add(serviceTotalAmount).add(feeTotalAmount);
// 工单总折扣 =物料总折扣 + 服务总折扣 + 费用总折扣
totalDiscount = goodsTotalDiscount.add(serviceTotalDiscount).add(feeTotalDiscount);
// 工单费用相应实体
OrderExpenseEntity expenseEntity = new OrderExpenseEntity();
expenseEntity.setGoodsAmount(goodsTotalAmount);
expenseEntity.setServiceAmount(serviceTotalAmount);
expenseEntity.setTotalAmount(totalAmount);
expenseEntity.setDiscount(totalDiscount);
expenseEntity.setGoodsDiscount(goodsTotalDiscount);
expenseEntity.setServiceDiscount(serviceTotalDiscount);
expenseEntity.setFeeAmount(feeTotalAmount);
expenseEntity.setFeeDiscount(feeTotalDiscount);
expenseEntity.setOrderAmount(totalAmount.subtract(totalDiscount));
expenseEntity.setManageFee(manageFee);
return expenseEntity;
}
/**
* update 虚拟工单基本信息、选购商品、选购服务
*
* @param orderInfo
* @param orderGoodsList
* @param orderServicesList
* @param userInfo
* @return
*/
@Transactional
public void updateVirtualOrder(OrderInfo orderInfo,
List<OrderGoods> orderGoodsList,
List<OrderServices> orderServicesList,
UserInfo userInfo) {
// 当前操作人
Long userId = userInfo.getUserId();
// 工单ID
Long orderId = orderInfo.getId();
Long shopId = orderInfo.getShopId();
// 更新orderInfo
VirtualOrder virtualOrder = copyOrderPropertyToVirtualOrder(orderInfo);
virtualOrder.setId(orderId);
virtualOrder.setParentId(orderInfo.getParentId());
String identityCard = orderInfo.getIdentityCard();
virtualOrder.setIdentityCard(identityCard == null ? "" : identityCard);
// 操作人信息
virtualOrder.setModifier(userInfo.getUserId());
virtualOrder.setOperatorName(userInfo.getName());
virtualOrder.setShopId(userInfo.getShopId());
virtualOrderService.update(virtualOrder);
// 编辑前:选购的商品
List<VirtualOrdergood> oldGoodsList =
virtualOrdergoodService.queryOrderGoods(orderId, shopId);
Set<Long> orderGoodsIds = new HashSet<Long>();
Set<Long> oldGoodsIds = new HashSet<Long>();
if (!CollectionUtils.isEmpty(oldGoodsList)) {
for (VirtualOrdergood good : oldGoodsList) {
oldGoodsIds.add(good.getId());
}
}
if (!CollectionUtils.isEmpty(orderGoodsList)) {
for (OrderGoods orderGood : orderGoodsList) {
Long goodId = orderGood.getId();
VirtualOrdergood virtualOrdergood = copyGoodPropertyToVirtualGood(userInfo, virtualOrder, orderGood);
if (goodId == null) {
virtualOrdergoodService.save(virtualOrdergood);
} else {
virtualOrdergood.setId(goodId);
virtualOrdergoodService.update(virtualOrdergood);
orderGoodsIds.add(goodId);
}
}
}
// 之前选择的:不存在情况,删除掉
if (!CollectionUtils.isEmpty(oldGoodsList)) {
for (VirtualOrdergood oldOrderGoods : oldGoodsList) {
if (orderGoodsIds != null && !orderGoodsIds.contains(oldOrderGoods.getId())) {
oldOrderGoods.setModifier(userId);
oldOrderGoods.setIsDeleted("Y");
virtualOrdergoodService.update(oldOrderGoods);
}
}
}
// (Long orderId,Long shopId);
List<VirtualOrderservice> oldOrderServicesList =
virtualOrderserviceService.queryOrderServices(orderId, shopId);
Set<Long> orderServicesIds = new HashSet<>();
Set<Long> oldServicesIds = new HashSet<>();
if (!CollectionUtils.isEmpty(oldOrderServicesList)) {
for (VirtualOrderservice oldOrderServices : oldOrderServicesList) {
oldServicesIds.add(oldOrderServices.getId());
}
}
if (!CollectionUtils.isEmpty(orderServicesList)) {
for (OrderServices newOrderServices : orderServicesList) {
Long newOrderServiceId = newOrderServices.getId();
VirtualOrderservice virtualOrderservice = copyServicePropertyToVirtualService(userInfo, virtualOrder, newOrderServices);
if (newOrderServiceId == null) {
virtualOrderserviceService.save(virtualOrderservice);
} else {
virtualOrderservice.setId(newOrderServiceId);
virtualOrderserviceService.update(virtualOrderservice);
orderServicesIds.add(newOrderServiceId);
}
}
}
// 之前选择的:不存在情况,删除掉
if (!CollectionUtils.isEmpty(oldOrderServicesList)) {
for (VirtualOrderservice oldOrderServices : oldOrderServicesList) {
if (orderServicesIds != null && !orderServicesIds.contains(oldOrderServices.getId())) {
oldOrderServices.setModifier(userInfo.getUserId());
oldOrderServices.setIsDeleted("Y");
virtualOrderserviceService.update(oldOrderServices);
}
}
}
}
@Override
public int statisticsOrderNumber(long shopId, OrderCategoryEnum orderCategoryEnum) {
Map<String, Object> map = new HashMap<String, Object>(2);
map.put("shopId", shopId);
map.put("orderTag", orderCategoryEnum.getCode());
return orderInfoDao.selectCount(map);
}
@Override
public Optional<OrderInfo> getOrder(Long orderId) {
OrderInfo orderInfo = null;
try {
orderInfo = orderInfoDao.selectById(orderId);
} catch (Exception e) {
LOGGER.error("根据工单ID,查询数据库的工单实体异常,异常{}", e.toString());
return Optional.absent();
}
return Optional.fromNullable(orderInfo);
}
@Override
public Optional<OrderInfo> getOrder(Long orderId, Long shopId) {
Map<String,Object> searchMap = new HashMap<>();
searchMap.put("id",orderId);
searchMap.put("shopId",shopId);
OrderInfo orderInfo = orderInfoDao.selectByIdAndShopId(searchMap);
return Optional.fromNullable(orderInfo);
}
@Override
@Transactional
public int updateOrderStatus(long orderId, OrderStatusEnum statusEnum) {
int updateSign = 0;
// 查找工单
Optional<OrderInfo> orderInfoOptional = this.getOrder(orderId);
if (!orderInfoOptional.isPresent()) {
LOGGER.error("更新数据库工单状态失败。工单不存在,工单ID:{}", orderId);
return updateSign;
}
// 更新工单实体
OrderInfo orderInfo = orderInfoOptional.get();
String orderStatus = statusEnum.getKey();
orderInfo.setOrderStatus(orderStatus);
int success = orderInfoDao.updateById(orderInfo);
//TODO 工单状态变更需要插入track表,此方法可能还要修改,到时候回写方法直接写在track内,现在暂时先这么写
if(success == 1) {
//回写委托单
writeBackProxy(orderInfo);
}
return success;
}
@Override
@Transactional
public int updateOrder(OrderInfo orderInfo) {
Long orderId = orderInfo.getId();
Optional<OrderInfo> orderInfoOptional = this.getOrder(orderId);
if (!orderInfoOptional.isPresent()) {
LOGGER.error("更新工单实体失败,原因:工单实体不存在,工单ID:{}", orderId);
throw new BizException("更新工单实体失败,原因:工单实体不存在");
}
return orderInfoDao.updateById(orderInfo);
}
/**
* TODO refactor code
* <p/>
* 获取门店最近一次洗车单信息
*
* @param shopId
* @return
*/
public OrderServicesVo getLastCarwash(Long shopId) {
//获取门店最近一次洗车单
Map<String, Object> orderMap = new HashMap<>(5);
orderMap.put("shopId", shopId);
orderMap.put("orderTag", OrderCategoryEnum.CARWASH.getCode());
List<String> sorts = new ArrayList<>();
sorts.add(" id desc ");
orderMap.put("sorts", sorts);
orderMap.put("offset", 0);
orderMap.put("limit", 1);
List<OrderInfo> orderInfoList = orderInfoDao.select(orderMap);
if (CollectionUtils.isEmpty(orderInfoList)) {
return null;
}
OrderInfo orderInfo = orderInfoList.get(0);
Map<String, Object> orderServiceMap = new HashMap<>();
orderServiceMap.put("orderId", orderInfo.getId());
orderServiceMap.put("shopId", shopId);
List<OrderServices> orderServicesList = orderServicesService.select(orderServiceMap);
if (CollectionUtils.isEmpty(orderServicesList)) {
return null;
}
OrderServices orderServices = orderServicesList.get(0);
OrderServicesVo orderServicesVo = null;
if (orderServices != null) {
orderServicesVo = OrderServicesVo.getVo(orderServices);
Set<Long> workerIdSet = new HashSet();
String workerIds = orderServices.getWorkerIds();
if (StringUtils.isNotBlank(workerIds) && !"0".equals(workerIds)) {
// 通过逗号切分
String[] workerIdArr = workerIds.split(",");
if (ArrayUtils.isNotEmpty(workerIdArr)) {
for (String workerId : workerIdArr) {
workerId = workerId.trim();
if (!"0".equals(workerId) || !"".equals(workerId)) {
long id = Long.parseLong(workerId);
workerIdSet.add(id);
}
}
}
}
if (!CollectionUtils.isEmpty(workerIdSet)) {
Long[] workerIdArray = new Long[workerIdSet.size()];
workerIdArray = workerIdSet.toArray(workerIdArray);
//查询多个维修工
List<ShopManager> shopManagerList = shopManagerService.selectByIds(workerIdArray);
StringBuilder workerNames = new StringBuilder();
for (ShopManager shopManager : shopManagerList) {
workerNames.append(shopManager.getName()).append(",");
}
if (workerNames.length() > 0) {
orderServicesVo.setWorkerNames(workerNames.substring(0, workerNames.length() - 1));
}
}
}
return orderServicesVo;
}
@Override
public WashCarStats getWashCarTodayStats(Long shopId) {
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String dayStr = fmt.format(date);
String startTime = dayStr + " 00:00:00";
String endTime = dayStr + " 23:59:59";
WashCarStats washCarStats = new WashCarStats();
//统计今日洗车订单数
Map<String, Object> searchMap = new HashMap();
searchMap.put("shopId", shopId);
searchMap.put("orderTag", OrderCategoryEnum.CARWASH.getCode());
searchMap.put("startTime", startTime);
searchMap.put("endTime", endTime);
int statsCount = orderInfoDao.selectCount(searchMap);
BigDecimal statsAmount = BigDecimal.ZERO;
//统计今日收款数
try {
com.tqmall.core.common.entity.Result<Map<Long, BigDecimal>> carWashPaymentAmountResult = rpcBusinessDailyService.getCarWashPaymentAmount(shopId, dayStr);
if (carWashPaymentAmountResult.isSuccess()) {
Map<Long, BigDecimal> carWashPaymentAmountMap = carWashPaymentAmountResult.getData();
for (Map.Entry<Long, BigDecimal> entry : carWashPaymentAmountMap.entrySet()) {
if (entry.getKey().compareTo(0l) == 1) {
BigDecimal amount = entry.getValue();
//目前payment 0为会员卡收款
statsAmount = statsAmount.add(amount);
}
}
}
} catch (Exception e) {
LOGGER.error("调用cube获取今日洗车收款金额异常", e);
}
washCarStats.setStatsAmount(statsAmount + "");
washCarStats.setStatsCount(statsCount);
return washCarStats;
}
@Override
public List<OrderInfo> selectByIdsAndShopId(List<Long> orderIds, Long shopId) {
return orderInfoDao.selectByIdsAndShopId(orderIds, shopId);
}
@Override
@Transactional
public int delete(Long orderId) {
int updateSign = 0;
// 查找工单
Optional<OrderInfo> orderInfoOptional = this.getOrder(orderId);
if (!orderInfoOptional.isPresent()) {
LOGGER.error("逻辑删除工单失败。工单不存在,工单ID:{}", orderId);
return updateSign;
}
// 更新工单实体
OrderInfo orderInfo = orderInfoOptional.get();
orderInfo.setIsDeleted("Y");
return orderInfoDao.updateById(orderInfo);
}
@Override
public List<OrderInfo> getHistoryOrderByCustomerCarId(Long customerCarId, Long shopId) {
List<OrderInfo> orderInfoList = null;
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("customerCarId", customerCarId);
paramMap.put("shopId", shopId);
try {
orderInfoList = orderInfoDao.select(paramMap);
} catch (Exception e) {
LOGGER.error("[DB]query legend_order_info failure param:{} exception:{}", "customerCarId:" + customerCarId + ",shopId:" + shopId, e);
orderInfoList = new ArrayList<OrderInfo>();
}
if (CollectionUtils.isEmpty(orderInfoList)) {
orderInfoList = new ArrayList<OrderInfo>();
}
return orderInfoList;
}
@Override
public int selectCount(Map<String, Object> params) {
return orderInfoDao.selectCount(params);
}
public void writeBackProxy(OrderInfo orderInfo){
if(orderInfo.getProxyType() != null && orderInfo.getProxyType().equals(2)){
/**
* 同步委托单状态
* order_status proxy_status
* FPDD 分配订单 ==> FPDD:已派工
* DDWC 订单完成 ==> DDWC:已完工
*/
Long orderId = orderInfo.getId();
Long shopId = orderInfo.getShopId();
String orderStatus = orderInfo.getOrderStatus();
if(orderStatus.equals(OrderStatusEnum.FPDD.getKey()) || orderStatus.equals(OrderStatusEnum.DDWC.getKey())){
LOGGER.info("【委托单转工单,工单状态变更同步委托单】:查询委托单信息,门店id:{},受托的工单id:{}", shopId, orderId);
com.tqmall.core.common.entity.Result<ProxyDTO> proxyDTOResult = rpcProxyService.getProxyInfoByShopIdAndProxyOrderId(shopId, orderId);
if (proxyDTOResult.isSuccess()) {
ProxyDTO proxyDTO = proxyDTOResult.getData();
proxyDTO.setOrderStatus(orderStatus);
proxyDTO.setProxyStatus(orderStatus);
com.tqmall.core.common.entity.Result updateResult = rpcProxyService.updateProxyOrder(proxyDTO);
LOGGER.info("【委托单转工单,工单状态变更同步委托单】:更新委托单,委托单id:{},orderStatus:{},proxyStatus:{}", proxyDTO.getId(), orderStatus, orderStatus);
if(!updateResult.isSuccess()){
throw new RuntimeException("同步委托单失败");
}
}
}
}
}
/**
* 设置工单预检信息
* @param orderFormEntityBo
* @return
*/
private List<OrderPrecheckDetails> setOrderPrecheckDetails(OrderFormEntityBo orderFormEntityBo,Long shopId,Long precheckId){
if(orderFormEntityBo == null){
return null;
}
String orderPrecheckDetailsStr = orderFormEntityBo.getOrderPrecheckDetailsJson();
if(StringUtils.isNotBlank(orderPrecheckDetailsStr)){
try {
Map<String, String> tmpItemsAppearance = new Gson().fromJson(orderPrecheckDetailsStr,
new TypeToken<Map<String, String>>() {
}.getType());
List<PrecheckDetails> precheckDetailsList = prechecksFacade.getItemList(tmpItemsAppearance,null,null,shopId);
if(!CollectionUtils.isEmpty(precheckDetailsList)){
List<OrderPrecheckDetails> orderPrecheckDetailsList = new ArrayList<>();
for(PrecheckDetails precheckDetails : precheckDetailsList){
OrderPrecheckDetails orderPrecheckDetails = new OrderPrecheckDetails();
BeanUtils.copyProperties(precheckDetails, orderPrecheckDetails);
orderPrecheckDetails.setPrecheckId(precheckId);
orderPrecheckDetails.setShopId(shopId);
orderPrecheckDetailsList.add(orderPrecheckDetails);
}
return orderPrecheckDetailsList;
}
} catch (JsonSyntaxException e) {
LOGGER.error("工单预检信息Json转换出错:{}", orderPrecheckDetailsStr);
throw new RuntimeException("工单预检信息有误");
}
}
return null;
}
}
| [
"zhangting.huang@tqmall.com"
] | zhangting.huang@tqmall.com |
4615bda3d0fbf8a4dca533573df15cdc0af1cbb3 | 0003a85b39a2899dadcf307628cc9c9376585a89 | /src/main/java/org/example/config/db/connection/MySqlConnection.java | 4690b920b6bb93440e5cd92a8fba1eecec12b1e4 | [] | no_license | qWaZaR21/CatsHouse | 200f5c40cea407627f137fb7d04e32f610df43e4 | e78d31c234d80f83a984dd713a0b1d98f67bdeb7 | refs/heads/main | 2023-03-14T14:58:50.205710 | 2021-03-14T11:28:21 | 2021-03-14T11:28:21 | 347,364,691 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 583 | java | package org.example.config.db.connection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public final class MySqlConnection {
public static final String URL = "jdbc:mysql://localhost:3306/db_example";
public static final String USERNAME = "paku";
public static final String PASSWORD = "123qwe!@#QWE";
public MySqlConnection() {
}
public Connection getConnection() throws SQLException {
return DriverManager.getConnection(URL, USERNAME, PASSWORD);
}
}
| [
"kulesh.p.v.b.2.m@gmail.com"
] | kulesh.p.v.b.2.m@gmail.com |
3c61c6e10dffb8cb622740aae471d614520d5596 | 790d89ef02e19d25670427ccaf24b60596eb098b | /app/src/main/java/com/fujiyama/pulp/mvvmpattern/data/manager/IDataManager.java | feab8fb79010661d732d74ef169f096c6692488b | [] | no_license | pupupulp/android-mvvm-template | 16e905e39af3f7acac1913cd8effb0260a845ccd | 66c328b1c587ce67d373c8f3f170a87f0764ead3 | refs/heads/master | 2020-04-12T13:14:46.367164 | 2018-12-20T02:44:19 | 2018-12-20T02:44:19 | 162,517,203 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 350 | java | package com.fujiyama.pulp.mvvmpattern.data.manager;
import com.fujiyama.pulp.mvvmpattern.data.local.prefs.IPreferencesHelper;
import com.fujiyama.pulp.mvvmpattern.data.local.db.IDatabaseHelper;
import com.fujiyama.pulp.mvvmpattern.data.remote.IApiHelper;
public interface IDataManager extends IDatabaseHelper, IPreferencesHelper, IApiHelper {
}
| [
"mece.martinece@gmail.com"
] | mece.martinece@gmail.com |
ccbfacbbb616204fb1ab29a5386ed1d2b9f81720 | 8a0b26c9c90bdc77160ee14cb6edbc20e86f60fe | /src/main/java/com/hundredwordsgof/facade/Parser.java | 85c929cb0d42f23edfcdb666b89a992fb3f4d792 | [
"CC-BY-SA-4.0",
"MIT",
"GFDL-1.1-or-later",
"CC-BY-SA-3.0",
"CC-BY-SA-2.0",
"LicenseRef-scancode-public-domain",
"CC0-1.0",
"CC-BY-2.0"
] | permissive | dstar55/100-words-design-patterns-java | 1713da5a28feeedd2db421f79df7864abc529d6f | 6eca18a78802b258d27d30be66c03bbaef05ce8a | refs/heads/master | 2022-04-30T23:43:37.561876 | 2021-12-23T11:03:45 | 2021-12-23T11:03:45 | 39,254,966 | 179 | 86 | MIT | 2021-12-26T22:02:14 | 2015-07-17T13:17:27 | Java | UTF-8 | Java | false | false | 1,774 | java | package com.hundredwordsgof.facade;
import java.util.List;
import java.util.Stack;
/**
*
* Parser parses simple expression which adds two numbers, for example: 1 + 2
* Note: due to scope error handling is not implemented.
*
*/
public class Parser {
private Stack<String> expressionStack = new Stack<String>();
private Stack<String> operandStack = new Stack<String>();
public Node parse(List<String> tokens) {
for (String token : tokens) {
if (isTokenExpression(token)) {
expressionStack.push(token);
} else if (isTokenOperand(token)) {
operandStack.push(token);
}
}
ExpressionNode expressionNode = new ExpressionNode();
// create Abstract Syntax Tree
while (!expressionStack.empty()) {
String expression = (String) expressionStack.pop();
expressionNode.setOperator(expression.charAt(0));
String rightOperand = (String) operandStack.pop();
OperandNode rightOperandNode = new OperandNode();
rightOperandNode.setValue(Integer.parseInt(rightOperand));
String leftOperand = (String) operandStack.pop();
OperandNode leftOperandNode = new OperandNode();
leftOperandNode.setValue(Integer.parseInt(leftOperand));
expressionNode.setRight(rightOperandNode);
expressionNode.setLeft(leftOperandNode);
}
return expressionNode;
}
private boolean isTokenExpression(String token) {
if (token.equals("+")) {
return true;
}
return false;
}
// operand is supposed to be number
private boolean isTokenOperand(String token) {
for (char c : token.toCharArray()) {
if (!Character.isDigit(c))
return false;
}
return true;
}
}
| [
"dstar55@yahoo.com"
] | dstar55@yahoo.com |
9f120ab52a3a2b01ac6e608d7a45ae70b2fdbe16 | 1aac142fe90f0bbf74ca3acf0194dd7c18ff0b99 | /Sistema-Factura-Java-Escritorio--master/src/formularios/FrmProductos.java | 10e93bb0b78ef61736bb859c15cfb33c1b40920e | [] | no_license | janesds/GitHub | 1ae0c4cdeef9cf83c0bac5af4a7e235e9fde88af | e8d36cb44afd1e0b011fdaea019e7f85e28d318a | refs/heads/master | 2020-03-29T23:49:24.299194 | 2018-09-28T03:50:58 | 2018-09-28T03:50:58 | 150,490,875 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 28,394 | java | package formularios;
import clases.Datos;
import clases.Producto;
import clases.Utilidades;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class FrmProductos extends javax.swing.JInternalFrame {
private Datos misDatos;
private int proAct = 0;
private boolean nuevo = false;
private DefaultTableModel miTabla;
public FrmProductos() {
initComponents();
}
public void setDatos(Datos misDatos) {
this.misDatos = misDatos;
}
private void mostrarResgistro() {
txtIdProducto.setText(misDatos.getProductos()[proAct].getIdProducto());
txtDescripcion.setText(misDatos.getProductos()[proAct].getDescripcion());
txtPrecio.setText("" + misDatos.getProductos()[proAct].getPrecio());
cboIGV.setSelectedIndex((misDatos.getProductos()[proAct].getIGV()));
txtNota.setText(misDatos.getProductos()[proAct].getNota());
}
private void llenarTabla() {
String titulos[] = { "ID Producto", "Descripcion", "Precio", "IGV", "Nota" };
String registro[] = new String[5];
miTabla = new DefaultTableModel(null, titulos);
for (int i = 0; i < misDatos.numeroProductos(); i++) {
registro[0] = misDatos.getProductos()[i].getIdProducto();
registro[1] = misDatos.getProductos()[i].getDescripcion();
registro[2] = "" + misDatos.getProductos()[i].getPrecio();
registro[3] = igv(misDatos.getProductos()[i].getIGV());
registro[4] = misDatos.getProductos()[i].getNota();
miTabla.addRow(registro);
}
tblProducto.setModel(miTabla);
}
private String igv(int idIGV) {
switch(idIGV) {
case 0 : return "0 %";
case 1 : return "18 %";
case 2 : return "19 %";
default: return "No definido";
}
}
public void habilitarBotones(boolean cond){
btnPrimero.setEnabled(cond);
btnAnterior.setEnabled(cond);
btnSiguiente.setEnabled(cond);
btnUltimo.setEnabled(cond);
btnNuevo.setEnabled(cond);
btnPrimero.setEnabled(cond);
btnBorrar.setEnabled(cond);
btnBuscar.setEnabled(cond);
btnEditar.setEnabled(cond);
btnCancelar.setEnabled(!cond);
btnGuardar.setEnabled(!cond);
}
public void habilitarCampos(boolean cond){
txtIdProducto.setEnabled(cond);
txtDescripcion.setEnabled(cond);
txtPrecio.setEnabled(cond);
cboIGV.setEnabled(cond);
txtNota.setEnabled(cond);
}
public void limpiarCampos(){
cboIGV.setSelectedIndex(0);
txtIdProducto.setText("");
txtDescripcion.setText("");
txtPrecio.setText("");
txtNota.setText("");
}
public void validarCampos(){
//validaciones
if ("".equals(txtIdProducto.getText())) {
JOptionPane.showMessageDialog(rootPane, "Debe digitar un ID");
txtIdProducto.requestFocusInWindow();
return;
}
if ("".equals(txtDescripcion.getText())) {
JOptionPane.showMessageDialog(rootPane, "Debe digitar una Descripcion");
txtDescripcion.requestFocusInWindow();
return;
}
if ("".equals(txtPrecio.getText())) {
JOptionPane.showMessageDialog(rootPane, "Debe digitar un Precio");
txtPrecio.requestFocusInWindow();
return;
}
if (!Utilidades.isDouble(txtPrecio.getText())) {
JOptionPane.showMessageDialog(rootPane, "Debe digitar un valor numerico");
txtPrecio.requestFocusInWindow();
return;
}
int precio = Integer.parseInt(txtPrecio.getText());
if (precio <= 0) {
JOptionPane.showMessageDialog(rootPane, "Debe digitar un valor mayor a 0");
txtPrecio.requestFocusInWindow();
return;
}
if (cboIGV.getSelectedIndex() == 0) {
JOptionPane.showMessageDialog(rootPane, "Debe seleccionar un IGV");
cboIGV.requestFocusInWindow();
return;
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
txtIdProducto = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
txtDescripcion = new javax.swing.JTextField();
txtPrecio = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
jPanel1 = new javax.swing.JPanel();
btnPrimero = new javax.swing.JButton();
btnAnterior = new javax.swing.JButton();
btnSiguiente = new javax.swing.JButton();
btnUltimo = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
btnNuevo = new javax.swing.JButton();
btnGuardar = new javax.swing.JButton();
btnCancelar = new javax.swing.JButton();
btnEditar = new javax.swing.JButton();
btnBuscar = new javax.swing.JButton();
btnBorrar = new javax.swing.JButton();
jLabel7 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
tblProducto = new javax.swing.JTable();
cboIGV = new javax.swing.JComboBox();
jLabel5 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
txtNota = new javax.swing.JTextArea();
setClosable(true);
setTitle("Productos");
addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
formInternalFrameOpened(evt);
}
});
jLabel1.setText("ID Producto *");
txtIdProducto.setEnabled(false);
jLabel2.setText("Descripción *");
txtDescripcion.setEnabled(false);
txtPrecio.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
txtPrecio.setEnabled(false);
jLabel3.setText("Nota");
jLabel4.setText("IGV *");
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
btnPrimero.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/primero.png"))); // NOI18N
btnPrimero.setToolTipText("Va al primer registro");
btnPrimero.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPrimeroActionPerformed(evt);
}
});
btnAnterior.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/anterior.png"))); // NOI18N
btnAnterior.setToolTipText("Va al anterior registro");
btnAnterior.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAnteriorActionPerformed(evt);
}
});
btnSiguiente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/siguiente.png"))); // NOI18N
btnSiguiente.setToolTipText("Va al siguiente registro");
btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSiguienteActionPerformed(evt);
}
});
btnUltimo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/ultimo.png"))); // NOI18N
btnUltimo.setToolTipText("Va al ultimo registro");
btnUltimo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnUltimoActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnPrimero)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnAnterior)
.addGap(9, 9, 9)
.addComponent(btnSiguiente)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnUltimo)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnPrimero)
.addComponent(btnAnterior)
.addComponent(btnUltimo)
.addComponent(btnSiguiente))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
btnNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/nuevo24x24.png"))); // NOI18N
btnNuevo.setToolTipText("Nuevo registro");
btnNuevo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNuevoActionPerformed(evt);
}
});
btnGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/guardar24x24.png"))); // NOI18N
btnGuardar.setToolTipText("Guardar registro");
btnGuardar.setEnabled(false);
btnGuardar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnGuardarActionPerformed(evt);
}
});
btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/cancelar24x24.png"))); // NOI18N
btnCancelar.setToolTipText("Guardar registro");
btnCancelar.setEnabled(false);
btnCancelar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelarActionPerformed(evt);
}
});
btnEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/editar24x24.png"))); // NOI18N
btnEditar.setToolTipText("Editar registro");
btnEditar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnEditarActionPerformed(evt);
}
});
btnBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/buscar24x24.png"))); // NOI18N
btnBuscar.setToolTipText("Buscar registro");
btnBuscar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBuscarActionPerformed(evt);
}
});
btnBorrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/borrar24x24.png"))); // NOI18N
btnBorrar.setToolTipText("Borrar registro");
btnBorrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBorrarActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnNuevo)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnGuardar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancelar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnEditar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnBuscar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnBorrar)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnNuevo)
.addComponent(btnBuscar)
.addComponent(btnEditar)
.addComponent(btnBorrar)
.addComponent(btnGuardar)
.addComponent(btnCancelar))
.addContainerGap())
);
jLabel7.setForeground(java.awt.Color.blue);
jLabel7.setText("* Campos Obligatorios");
tblProducto.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane1.setViewportView(tblProducto);
cboIGV.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0 %", "18 %", "19 %" }));
cboIGV.setEnabled(false);
jLabel5.setText("Precio *");
txtNota.setColumns(20);
txtNota.setRows(5);
txtNota.setEnabled(false);
jScrollPane2.setViewportView(txtNota);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabel7)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 129, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jSeparator1)
.addComponent(jScrollPane1)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(jLabel1))
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING))
.addGroup(layout.createSequentialGroup()
.addGap(46, 46, 46)
.addComponent(jLabel3)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtDescripcion)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtIdProducto, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(txtPrecio, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cboIGV, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(jScrollPane2))))
.addContainerGap())))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(txtIdProducto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtPrecio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(cboIGV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addGap(16, 16, 16)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoActionPerformed
this.habilitarBotones(false);
this.habilitarCampos(true);
this.limpiarCampos();
//activamos el flag de registro nuevo
nuevo = true;
txtIdProducto.requestFocusInWindow();
}//GEN-LAST:event_btnNuevoActionPerformed
private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
this.validarCampos();
int precio = Integer.parseInt(txtPrecio.getText());
//si es nuevo, validamos que el usuario no exista
int pos = misDatos.posicionProducto(txtIdProducto.getText());
if (nuevo) {
if (pos != -1) {
JOptionPane.showMessageDialog(rootPane, "Producto ya existe");
txtIdProducto.requestFocusInWindow();
return;
}
} else {
if (pos == -1) {
JOptionPane.showMessageDialog(rootPane, "Producto no existe");
txtDescripcion.requestFocusInWindow();
return;
}
}
//creamos el objeto usuario y lo agregamos a datos
Producto miProducto = new Producto(txtIdProducto.getText(), txtDescripcion.getText(), precio, cboIGV.getSelectedIndex(), txtNota.getText());
String msg;
if (nuevo) {
msg = misDatos.agregarProducto(miProducto);
} else {
msg = misDatos.modificarProducto(miProducto, pos);
}
JOptionPane.showMessageDialog(rootPane, msg);
this.habilitarBotones(true);
this.habilitarCampos(false);
this.limpiarCampos();
//actualizamos los cambios en la tabla
llenarTabla();
}//GEN-LAST:event_btnGuardarActionPerformed
private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
this.habilitarBotones(true);
this.habilitarCampos(false);
this.limpiarCampos();
}//GEN-LAST:event_btnCancelarActionPerformed
private void btnEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarActionPerformed
this.habilitarBotones(false);
this.habilitarCampos(true);
txtIdProducto.setEnabled(false);
//desactivamos el flag de registro nuevo
nuevo = false;
txtDescripcion.requestFocusInWindow();
}//GEN-LAST:event_btnEditarActionPerformed
private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
mostrarResgistro();
llenarTabla();
}//GEN-LAST:event_formInternalFrameOpened
private void btnPrimeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrimeroActionPerformed
proAct = 0;
mostrarResgistro();
}//GEN-LAST:event_btnPrimeroActionPerformed
private void btnUltimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUltimoActionPerformed
proAct = misDatos.numeroProductos()- 1;
mostrarResgistro();
}//GEN-LAST:event_btnUltimoActionPerformed
private void btnSiguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSiguienteActionPerformed
proAct++;
if (proAct == misDatos.numeroProductos()) {
proAct = 0;
}
mostrarResgistro();
}//GEN-LAST:event_btnSiguienteActionPerformed
private void btnAnteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAnteriorActionPerformed
proAct--;
if (proAct == -1) {
proAct = misDatos.numeroProductos()- 1;
}
mostrarResgistro();
}//GEN-LAST:event_btnAnteriorActionPerformed
private void btnBorrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBorrarActionPerformed
int rta = JOptionPane.showConfirmDialog(rootPane, "¿Esta seguro de borrar el registro?");
if (rta != 0) {
return;
}
String msg;
msg = misDatos.borrarProducto(proAct);
JOptionPane.showMessageDialog(rootPane, msg);
proAct = 0;
mostrarResgistro();
//actualizamos los cambios en la tabla
llenarTabla();
}//GEN-LAST:event_btnBorrarActionPerformed
private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
String producto = JOptionPane.showInputDialog("Ingrese código de Producto");
if (producto.equals("")) {
return;
}
int pos = misDatos.posicionProducto(producto);
if (pos == -1) {
JOptionPane.showMessageDialog(rootPane, "Producto no existe");
return;
}
proAct = pos;
mostrarResgistro();
}//GEN-LAST:event_btnBuscarActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnAnterior;
private javax.swing.JButton btnBorrar;
private javax.swing.JButton btnBuscar;
private javax.swing.JButton btnCancelar;
private javax.swing.JButton btnEditar;
private javax.swing.JButton btnGuardar;
private javax.swing.JButton btnNuevo;
private javax.swing.JButton btnPrimero;
private javax.swing.JButton btnSiguiente;
private javax.swing.JButton btnUltimo;
private javax.swing.JComboBox cboIGV;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTable tblProducto;
private javax.swing.JTextField txtDescripcion;
private javax.swing.JTextField txtIdProducto;
private javax.swing.JTextArea txtNota;
private javax.swing.JTextField txtPrecio;
// End of variables declaration//GEN-END:variables
}
| [
"43115382+janesds@users.noreply.github.com"
] | 43115382+janesds@users.noreply.github.com |
4f2ba4b538167989d751693fa96f84f92bb4c4d8 | a49b8e33e776fd76e783010a238629f4ddc43028 | /src/main/java/io/quarkus/code/testing/AcceptanceTestApp.java | 11afd310c9e644e051279bb5cef711ac9a1b448a | [] | no_license | ia3andy/code.quarkus-acceptance-test | 12ffd0945e7b02f99479c375b22d013de8fd2903 | d477d89bf4dac226ec410b35ed98f6791328e630 | refs/heads/main | 2023-08-07T03:07:29.018024 | 2021-10-01T07:43:47 | 2021-10-01T07:43:47 | 412,080,123 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,179 | java | package io.quarkus.code.testing;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserContext;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.ElementHandle;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.QuarkusMain;
import java.util.List;
@QuarkusMain
public class AcceptanceTestApp implements QuarkusApplication {
@Override public int run(String... args) throws Exception {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions()
.setArgs(List.of("--headless","--disable-gpu", "--no-sandbox")));
BrowserContext context = browser.newContext();
// Open new page
Page page = context.newPage();
page.navigate("https://stage.code.quarkus.io");
final ElementHandle generateButton = page.waitForSelector(".generate-button");
System.out.println(generateButton.textContent());
}
return 0;
}
}
| [
"ia3andy@gmail.com"
] | ia3andy@gmail.com |
0686442ef1183e354b3dc79527d4fb296aedf693 | 5976fada6f069cb52615c0c02b2c989a7657b3cb | /designpattern/src/main/java/decorator/Finery.java | 8a3e1bc28414ad94281d7b906ca38294f620210c | [] | no_license | cdncn/Code | ca216a7b9256ade05f16f408dfd2e20e555a6172 | cf0b72da47156b81e47c4b984b2d7c044c215ba0 | refs/heads/master | 2022-11-13T11:16:08.109727 | 2019-07-03T17:01:09 | 2019-07-03T17:01:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 322 | java | package decorator;
/**
* 装饰类
* Created by hetao on 2019/4/24.
*/
public class Finery implements Person{
protected Person person;
public void decorate(Person person) {
this.person = person;
}
public void show() {
if(person != null) {
person.show();
}
}
}
| [
"fengyunhetao@gmail.com"
] | fengyunhetao@gmail.com |
f80c6071682f3a1463f8d4e90879eceff70b7777 | f782c6bdaff293228880715ba1ac34ef2c6022eb | /framework/src/test/java/org/zwen/media/TestAVTimeUnit.java | a931b976563f9888789cd9d1b48a5e8777624d84 | [] | no_license | zwensoft/seven-media-server | f1ba00cb68b301043e71bf80bf9482182d706cce | 9db3e7b05330fd315493313cc00c5f9a45f4255b | refs/heads/master | 2020-04-09T18:47:47.692895 | 2015-07-06T13:10:30 | 2015-07-06T13:10:30 | 38,166,407 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 299 | java | package org.zwen.media;
import junit.framework.TestCase;
public class TestAVTimeUnit extends TestCase {
public void testConvert() {
AVTimeUnit mills = AVTimeUnit.MILLISECONDS;
AVTimeUnit _90k = AVTimeUnit.MILLISECONDS_90;
assertEquals(_90k.convert(12, mills), 90 * 12);
}
}
| [
"chenxiuheng@gmail.com"
] | chenxiuheng@gmail.com |
b7a7a16e68a9feee73600aac7cc9597ec65ff139 | 742fad47a68e83ee001d02e26c3f79b618181c18 | /src/test/java/br/com/biblioteca/loan/loan/UpdateLoanServiceTest.java | 371280493c8abcf63480da79229481d0e06cb8fb | [] | no_license | waldirmarques/loan-microservice | de64cc14a5c8ccfbb3d2fd9e8e23b39a982f1137 | 881b4e5be3942b79c397a1fd457a6d54aa0aa0cc | refs/heads/master | 2023-01-15T04:43:24.374531 | 2020-11-24T00:31:49 | 2020-11-24T00:31:49 | 315,475,189 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,067 | java | package br.com.biblioteca.loan.loan;
import br.com.biblioteca.loan.loan.Loan;
import br.com.biblioteca.loan.loan.LoanRepository;
import br.com.biblioteca.loan.loan.services.UpdateLoanServiceImpl;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Optional;
import static br.com.biblioteca.loan.loan.builders.LoanBuilder.createLoan;
import static br.com.biblioteca.loan.loan.builders.LoanUpdate.createLoanUpdate;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@Tag("service")
@DisplayName("Valida funcionalidade do serviço responsável por atualizar Loan")
public class UpdateLoanServiceTest {
@Mock
private LoanRepository loanRepository;
private UpdateLoanServiceImpl updateLoan;
@BeforeEach
public void setUp() {
this.updateLoan = new UpdateLoanServiceImpl(loanRepository);
}
@Test
@DisplayName("Deve atualizar um Loan")
void shouldUpdateLaon() {
when(loanRepository.findById(1L)).thenReturn(Optional.of(createLoan().id(1L).build()));
updateLoan.update(createLoanUpdate().loanTime("teste update").build(), 1L);
//preparação
ArgumentCaptor<Loan> captorLoan = ArgumentCaptor.forClass(Loan.class);
verify(loanRepository).save(captorLoan.capture());
Loan result = captorLoan.getValue();
//verificação
assertAll("Loan",
() -> assertThat(result.getUserApp(), is("001")),
() -> assertThat(result.getBook(), is("001")),
() -> assertThat(result.getLoanTime(), is("teste update"))
);
}
}
| [
"waldir.marques@dcx.ufpb.br"
] | waldir.marques@dcx.ufpb.br |
424653393982a4cf15f376300986fbca36878080 | dbd7cdb1b43a620820d00bfd1d4b2937f6aeec18 | /Assessment/6-August/abcd.java | 1af10ddc12871b75c5e6729489623bd8ec03be19 | [] | no_license | SohrabAzam/iiht_project | 819cfed6f89a571d95737470e13c62ec720d6b52 | 254f26147d701f363993abcccba06e02af3f5855 | refs/heads/master | 2020-06-27T03:41:13.236474 | 2019-09-18T09:25:09 | 2019-09-18T09:25:09 | 199,834,867 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 855 | java | import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
public class abcd {
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<LinkedList<Student>> li=new ArrayList<LinkedList<Student>>();
LinkedList<Student> lii=new LinkedList<Student>();
lii.add(new Student("Rohan",34));
lii.add(new Student("Rahul",25));
LinkedList<Student> lii2=new LinkedList<Student>();
lii2.add(new Student("Akash",14));
lii2.add(new Student("Arya",54));
li.add(lii);
li.add(lii2);
System.out.println(li);
Iterator<LinkedList<Student>> ii=li.iterator();
while(ii.hasNext())
{
LinkedList<Student> linkedlist=ii.next();
Iterator<Student> ii2=linkedlist.iterator();
while(ii2.hasNext())
{
System.out.println(ii2.next());
}
}
}
}
| [
"noreply@github.com"
] | SohrabAzam.noreply@github.com |
4e8a7d7f5bfbc3647601bc25e91316a82b296431 | a8cf3ca3323a5bb3893eceef7abcb2a6c932c037 | /sample/src/main/java/digital/bakehouse/resdecorator/sample/SampleApp.java | 1715e1350e27365d118e02b4e2a14672bbb40c0f | [
"Apache-2.0"
] | permissive | bakehousedigital/resdecorator | fce72aa93c7619142173872671bd3fab4e363943 | f9913a63627cabe102ea03de2d9b98ae23c40c0b | refs/heads/master | 2021-06-03T12:39:58.956693 | 2020-09-28T10:58:04 | 2020-09-28T10:58:04 | 109,184,212 | 0 | 2 | Apache-2.0 | 2020-09-28T10:00:07 | 2017-11-01T21:09:40 | Java | UTF-8 | Java | false | false | 1,076 | java | package digital.bakehouse.resdecorator.sample;
import android.app.Application;
import digital.bakehouse.resdecorator.ResourceContextWrapper;
import io.github.inflationx.calligraphy3.CalligraphyConfig;
import io.github.inflationx.calligraphy3.CalligraphyInterceptor;
import io.github.inflationx.viewpump.ViewPump;
public class SampleApp extends Application {
@Override
public void onCreate() {
super.onCreate();
//Default usage
ResourceContextWrapper.initialize();
//Using with calligraphy
// initializeWithCalligraphy();
}
private void initializeWithCalligraphy() {
ResourceContextWrapper.initialize(
ViewPump.builder()
.addInterceptor(new CalligraphyInterceptor(
new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/ArialMT.ttf")
.setFontAttrId(R.attr.fontPath)
.build())
));
}
}
| [
"roman.reaboi@gmail.com"
] | roman.reaboi@gmail.com |
33c52f6663605ab44e077761e8fab02dfdb61971 | 28f03abf2cbff0e13bfe157220a6c644da221aba | /bizcore/WEB-INF/retailscm_core_src/com/doublechaintech/retailscm/supplyorderdelivery/SupplyOrderDelivery.java | ad62b119c4463f0f1ca88d3f91fc559c38243705 | [] | no_license | ouyangshaolei/retailscm-biz-suite | f4a04a14b211caebeb9d93e26001d458e84c067e | 871075f0122da52a2cc409c731766a4e2c307a0e | refs/heads/master | 2020-04-27T11:45:46.414211 | 2019-03-07T03:28:27 | 2019-03-07T03:28:27 | 174,307,024 | 1 | 0 | null | 2019-03-07T08:51:23 | 2019-03-07T08:51:22 | null | UTF-8 | Java | false | false | 13,585 | java |
package com.doublechaintech.retailscm.supplyorderdelivery;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.math.BigDecimal;
import com.terapico.caf.DateTime;
import com.doublechaintech.retailscm.BaseEntity;
import com.doublechaintech.retailscm.SmartList;
import com.doublechaintech.retailscm.KeyValuePair;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.doublechaintech.retailscm.consumerorder.ConsumerOrder;
import com.doublechaintech.retailscm.supplyorder.SupplyOrder;
@JsonSerialize(using = SupplyOrderDeliverySerializer.class)
public class SupplyOrderDelivery extends BaseEntity implements java.io.Serializable{
public static final String ID_PROPERTY = "id" ;
public static final String WHO_PROPERTY = "who" ;
public static final String DELIVERY_TIME_PROPERTY = "deliveryTime" ;
public static final String VERSION_PROPERTY = "version" ;
public static final String CONSUMER_ORDER_LIST = "consumerOrderList" ;
public static final String SUPPLY_ORDER_LIST = "supplyOrderList" ;
public static final String INTERNAL_TYPE="SupplyOrderDelivery";
public String getInternalType(){
return INTERNAL_TYPE;
}
public String getDisplayName(){
String displayName = getWho();
if(displayName!=null){
return displayName;
}
return super.getDisplayName();
}
private static final long serialVersionUID = 1L;
protected String mId ;
protected String mWho ;
protected Date mDeliveryTime ;
protected int mVersion ;
protected SmartList<ConsumerOrder> mConsumerOrderList ;
protected SmartList<SupplyOrder> mSupplyOrderList ;
public SupplyOrderDelivery(){
//lazy load for all the properties
}
//disconnect from all, 中文就是一了百了,跟所有一切尘世断绝往来藏身于茫茫数据海洋
public void clearFromAll(){
this.changed = true;
}
public SupplyOrderDelivery(String who, Date deliveryTime)
{
setWho(who);
setDeliveryTime(deliveryTime);
this.mConsumerOrderList = new SmartList<ConsumerOrder>();
this.mSupplyOrderList = new SmartList<SupplyOrder>();
}
//Support for changing the property
public void changeProperty(String property, String newValueExpr) {
if(WHO_PROPERTY.equals(property)){
changeWhoProperty(newValueExpr);
}
if(DELIVERY_TIME_PROPERTY.equals(property)){
changeDeliveryTimeProperty(newValueExpr);
}
}
protected void changeWhoProperty(String newValueExpr){
String oldValue = getWho();
String newValue = parseString(newValueExpr);
if(equalsString(oldValue , newValue)){
return;//they can be both null, or exact the same object, this is much faster than equals function
}
//they are surely different each other
updateWho(newValue);
this.onChangeProperty(WHO_PROPERTY, oldValue, newValue);
return;
}
protected void changeDeliveryTimeProperty(String newValueExpr){
Date oldValue = getDeliveryTime();
Date newValue = parseDate(newValueExpr);
if(equalsDate(oldValue , newValue)){
return;//they can be both null, or exact the same object, this is much faster than equals function
}
//they are surely different each other
updateDeliveryTime(newValue);
this.onChangeProperty(DELIVERY_TIME_PROPERTY, oldValue, newValue);
return;
}
public void setId(String id){
this.mId = trimString(id);;
}
public String getId(){
return this.mId;
}
public SupplyOrderDelivery updateId(String id){
this.mId = trimString(id);;
this.changed = true;
return this;
}
public void setWho(String who){
this.mWho = trimString(who);;
}
public String getWho(){
return this.mWho;
}
public SupplyOrderDelivery updateWho(String who){
this.mWho = trimString(who);;
this.changed = true;
return this;
}
public void setDeliveryTime(Date deliveryTime){
this.mDeliveryTime = deliveryTime;;
}
public Date getDeliveryTime(){
return this.mDeliveryTime;
}
public SupplyOrderDelivery updateDeliveryTime(Date deliveryTime){
this.mDeliveryTime = deliveryTime;;
this.changed = true;
return this;
}
public void setVersion(int version){
this.mVersion = version;;
}
public int getVersion(){
return this.mVersion;
}
public SupplyOrderDelivery updateVersion(int version){
this.mVersion = version;;
this.changed = true;
return this;
}
public SmartList<ConsumerOrder> getConsumerOrderList(){
if(this.mConsumerOrderList == null){
this.mConsumerOrderList = new SmartList<ConsumerOrder>();
this.mConsumerOrderList.setListInternalName (CONSUMER_ORDER_LIST );
//有名字,便于做权限控制
}
return this.mConsumerOrderList;
}
public void setConsumerOrderList(SmartList<ConsumerOrder> consumerOrderList){
for( ConsumerOrder consumerOrder:consumerOrderList){
consumerOrder.setDelivery(this);
}
this.mConsumerOrderList = consumerOrderList;
this.mConsumerOrderList.setListInternalName (CONSUMER_ORDER_LIST );
}
public void addConsumerOrder(ConsumerOrder consumerOrder){
consumerOrder.setDelivery(this);
getConsumerOrderList().add(consumerOrder);
}
public void addConsumerOrderList(SmartList<ConsumerOrder> consumerOrderList){
for( ConsumerOrder consumerOrder:consumerOrderList){
consumerOrder.setDelivery(this);
}
getConsumerOrderList().addAll(consumerOrderList);
}
public ConsumerOrder removeConsumerOrder(ConsumerOrder consumerOrderIndex){
int index = getConsumerOrderList().indexOf(consumerOrderIndex);
if(index < 0){
String message = "ConsumerOrder("+consumerOrderIndex.getId()+") with version='"+consumerOrderIndex.getVersion()+"' NOT found!";
throw new IllegalStateException(message);
}
ConsumerOrder consumerOrder = getConsumerOrderList().get(index);
// consumerOrder.clearDelivery(); //disconnect with Delivery
consumerOrder.clearFromAll(); //disconnect with Delivery
boolean result = getConsumerOrderList().planToRemove(consumerOrder);
if(!result){
String message = "ConsumerOrder("+consumerOrderIndex.getId()+") with version='"+consumerOrderIndex.getVersion()+"' NOT found!";
throw new IllegalStateException(message);
}
return consumerOrder;
}
//断舍离
public void breakWithConsumerOrder(ConsumerOrder consumerOrder){
if(consumerOrder == null){
return;
}
consumerOrder.setDelivery(null);
//getConsumerOrderList().remove();
}
public boolean hasConsumerOrder(ConsumerOrder consumerOrder){
return getConsumerOrderList().contains(consumerOrder);
}
public void copyConsumerOrderFrom(ConsumerOrder consumerOrder) {
ConsumerOrder consumerOrderInList = findTheConsumerOrder(consumerOrder);
ConsumerOrder newConsumerOrder = new ConsumerOrder();
consumerOrderInList.copyTo(newConsumerOrder);
newConsumerOrder.setVersion(0);//will trigger copy
getConsumerOrderList().add(newConsumerOrder);
addItemToFlexiableObject(COPIED_CHILD, newConsumerOrder);
}
public ConsumerOrder findTheConsumerOrder(ConsumerOrder consumerOrder){
int index = getConsumerOrderList().indexOf(consumerOrder);
//The input parameter must have the same id and version number.
if(index < 0){
String message = "ConsumerOrder("+consumerOrder.getId()+") with version='"+consumerOrder.getVersion()+"' NOT found!";
throw new IllegalStateException(message);
}
return getConsumerOrderList().get(index);
//Performance issue when using LinkedList, but it is almost an ArrayList for sure!
}
public void cleanUpConsumerOrderList(){
getConsumerOrderList().clear();
}
public SmartList<SupplyOrder> getSupplyOrderList(){
if(this.mSupplyOrderList == null){
this.mSupplyOrderList = new SmartList<SupplyOrder>();
this.mSupplyOrderList.setListInternalName (SUPPLY_ORDER_LIST );
//有名字,便于做权限控制
}
return this.mSupplyOrderList;
}
public void setSupplyOrderList(SmartList<SupplyOrder> supplyOrderList){
for( SupplyOrder supplyOrder:supplyOrderList){
supplyOrder.setDelivery(this);
}
this.mSupplyOrderList = supplyOrderList;
this.mSupplyOrderList.setListInternalName (SUPPLY_ORDER_LIST );
}
public void addSupplyOrder(SupplyOrder supplyOrder){
supplyOrder.setDelivery(this);
getSupplyOrderList().add(supplyOrder);
}
public void addSupplyOrderList(SmartList<SupplyOrder> supplyOrderList){
for( SupplyOrder supplyOrder:supplyOrderList){
supplyOrder.setDelivery(this);
}
getSupplyOrderList().addAll(supplyOrderList);
}
public SupplyOrder removeSupplyOrder(SupplyOrder supplyOrderIndex){
int index = getSupplyOrderList().indexOf(supplyOrderIndex);
if(index < 0){
String message = "SupplyOrder("+supplyOrderIndex.getId()+") with version='"+supplyOrderIndex.getVersion()+"' NOT found!";
throw new IllegalStateException(message);
}
SupplyOrder supplyOrder = getSupplyOrderList().get(index);
// supplyOrder.clearDelivery(); //disconnect with Delivery
supplyOrder.clearFromAll(); //disconnect with Delivery
boolean result = getSupplyOrderList().planToRemove(supplyOrder);
if(!result){
String message = "SupplyOrder("+supplyOrderIndex.getId()+") with version='"+supplyOrderIndex.getVersion()+"' NOT found!";
throw new IllegalStateException(message);
}
return supplyOrder;
}
//断舍离
public void breakWithSupplyOrder(SupplyOrder supplyOrder){
if(supplyOrder == null){
return;
}
supplyOrder.setDelivery(null);
//getSupplyOrderList().remove();
}
public boolean hasSupplyOrder(SupplyOrder supplyOrder){
return getSupplyOrderList().contains(supplyOrder);
}
public void copySupplyOrderFrom(SupplyOrder supplyOrder) {
SupplyOrder supplyOrderInList = findTheSupplyOrder(supplyOrder);
SupplyOrder newSupplyOrder = new SupplyOrder();
supplyOrderInList.copyTo(newSupplyOrder);
newSupplyOrder.setVersion(0);//will trigger copy
getSupplyOrderList().add(newSupplyOrder);
addItemToFlexiableObject(COPIED_CHILD, newSupplyOrder);
}
public SupplyOrder findTheSupplyOrder(SupplyOrder supplyOrder){
int index = getSupplyOrderList().indexOf(supplyOrder);
//The input parameter must have the same id and version number.
if(index < 0){
String message = "SupplyOrder("+supplyOrder.getId()+") with version='"+supplyOrder.getVersion()+"' NOT found!";
throw new IllegalStateException(message);
}
return getSupplyOrderList().get(index);
//Performance issue when using LinkedList, but it is almost an ArrayList for sure!
}
public void cleanUpSupplyOrderList(){
getSupplyOrderList().clear();
}
public void collectRefercences(BaseEntity owner, List<BaseEntity> entityList, String internalType){
}
public List<BaseEntity> collectRefercencesFromLists(String internalType){
List<BaseEntity> entityList = new ArrayList<BaseEntity>();
collectFromList(this, entityList, getConsumerOrderList(), internalType);
collectFromList(this, entityList, getSupplyOrderList(), internalType);
return entityList;
}
public List<SmartList<?>> getAllRelatedLists() {
List<SmartList<?>> listOfList = new ArrayList<SmartList<?>>();
listOfList.add( getConsumerOrderList());
listOfList.add( getSupplyOrderList());
return listOfList;
}
public List<KeyValuePair> keyValuePairOf(){
List<KeyValuePair> result = super.keyValuePairOf();
appendKeyValuePair(result, ID_PROPERTY, getId());
appendKeyValuePair(result, WHO_PROPERTY, getWho());
appendKeyValuePair(result, DELIVERY_TIME_PROPERTY, getDeliveryTime());
appendKeyValuePair(result, VERSION_PROPERTY, getVersion());
appendKeyValuePair(result, CONSUMER_ORDER_LIST, getConsumerOrderList());
if(!getConsumerOrderList().isEmpty()){
appendKeyValuePair(result, "consumerOrderCount", getConsumerOrderList().getTotalCount());
appendKeyValuePair(result, "consumerOrderCurrentPageNumber", getConsumerOrderList().getCurrentPageNumber());
}
appendKeyValuePair(result, SUPPLY_ORDER_LIST, getSupplyOrderList());
if(!getSupplyOrderList().isEmpty()){
appendKeyValuePair(result, "supplyOrderCount", getSupplyOrderList().getTotalCount());
appendKeyValuePair(result, "supplyOrderCurrentPageNumber", getSupplyOrderList().getCurrentPageNumber());
}
return result;
}
public BaseEntity copyTo(BaseEntity baseDest){
if(baseDest instanceof SupplyOrderDelivery){
SupplyOrderDelivery dest =(SupplyOrderDelivery)baseDest;
dest.setId(getId());
dest.setWho(getWho());
dest.setDeliveryTime(getDeliveryTime());
dest.setVersion(getVersion());
dest.setConsumerOrderList(getConsumerOrderList());
dest.setSupplyOrderList(getSupplyOrderList());
}
super.copyTo(baseDest);
return baseDest;
}
public String toString(){
StringBuilder stringBuilder=new StringBuilder(128);
stringBuilder.append("SupplyOrderDelivery{");
stringBuilder.append("\tid='"+getId()+"';");
stringBuilder.append("\twho='"+getWho()+"';");
stringBuilder.append("\tdeliveryTime='"+getDeliveryTime()+"';");
stringBuilder.append("\tversion='"+getVersion()+"';");
stringBuilder.append("}");
return stringBuilder.toString();
}
//provide number calculation function
}
| [
"philip_chang@163.com"
] | philip_chang@163.com |
01dcc6fc43c6aa6c6b1fb589622de67445159057 | c9edd21bdf3e643fe182c5b0f480d7deb218737c | /dy-agent-log4j/dy-agent-log4j-core/src/main/java/com/hust/foolwc/dy/agent/log4j/core/pattern/LineLocationPatternConverter.java | 7327fa51fda64fb14f7a78aede61d38b35313a4d | [] | no_license | foolwc/dy-agent | f302d2966cf3ab9fe8ce6872963828a66ca8a34e | d7eca9df2fd8c4c4595a7cdc770d6330e7ab241c | refs/heads/master | 2022-11-22T00:13:52.434723 | 2022-02-18T09:39:15 | 2022-02-18T09:39:15 | 201,186,332 | 10 | 4 | null | 2022-11-16T02:45:38 | 2019-08-08T05:44:02 | Java | UTF-8 | Java | false | false | 2,101 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.hust.foolwc.dy.agent.log4j.core.pattern;
import com.hust.foolwc.dy.agent.log4j.core.LogEvent;
import com.hust.foolwc.dy.agent.log4j.core.config.plugins.Plugin;
/**
* Returns the event's line location information in a StringBuilder.
*/
@Plugin(name = "LineLocationPatternConverter", category = PatternConverter.CATEGORY)
@ConverterKeys({ "L", "line" })
public final class LineLocationPatternConverter extends LogEventPatternConverter {
/**
* Singleton.
*/
private static final LineLocationPatternConverter INSTANCE =
new LineLocationPatternConverter();
/**
* Private constructor.
*/
private LineLocationPatternConverter() {
super("Line", "line");
}
/**
* Obtains an instance of pattern converter.
*
* @param options options, may be null.
* @return instance of pattern converter.
*/
public static LineLocationPatternConverter newInstance(
final String[] options) {
return INSTANCE;
}
/**
* {@inheritDoc}
*/
@Override
public void format(final LogEvent event, final StringBuilder output) {
final StackTraceElement element = event.getSource();
if (element != null) {
output.append(element.getLineNumber());
}
}
}
| [
"liwencheng@douyu.tv"
] | liwencheng@douyu.tv |
271a940f51042c7f1db7c767cf8976bac68ceb6f | c363218b1bbd15471ef2d04593ffd4fc91d032fa | /leetcode/isValid.java | 57fe1d4fa186d41dad33681c19be7adc10ccc6a8 | [] | no_license | tianjia0604/study | 59022360d17f8ddb4ef135a77cf03e55b0bd314d | afa6539368432efe0d995d7635239522f774612a | refs/heads/master | 2021-05-17T08:37:01.016162 | 2020-09-23T13:41:10 | 2020-09-23T13:41:10 | 251,189,978 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,358 | java | package leetcode6;
import java.util.Stack;
/**
* 20. 有效的括号
* 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。
*
* 有效字符串需满足:
*
* 左括号必须用相同类型的右括号闭合。
* 左括号必须以正确的顺序闭合。
* 注意空字符串可被认为是有效字符串。
*
* 示例 1:
*
* 输入: "()"
* 输出: true
* 示例 2:
*
* 输入: "()[]{}"
* 输出: true
* 示例 3:
*
* 输入: "(]"
* 输出: false
* 示例 4:
*
* 输入: "([)]"
* 输出: false
* 示例 5:
*
* 输入: "{[]}"
* 输出: true*/
public class isValid {
public boolean isValid(String s) {
Stack<Character> stack = new Stack();
for(int i = 0;i < s.length();i++) {
char c = s.charAt(i);
if(c == '(' || c == '[' ||c == '{') {
stack.push(c);
}else {
if(stack.isEmpty()) {
return false;
}
if(c == ')' && stack.pop() != '(') {
return false;
}else if(c == ']' && stack.pop() != '[') {
return false;
}else if(c == '}' && stack.pop() != '{') {
return false;
}
}
}
return stack.isEmpty();
}
}
| [
"1365751272@qq.com"
] | 1365751272@qq.com |
52c170664d351cf698bcb34abcd66da5e53b62cf | 0ef0c78fbd8e0e19c0cf327fa15cf1ac2c606178 | /PrakharTKG/Test.java | bf43d34b497b08e52fb9b4f8b5b8647c024abd0e | [] | no_license | shweyoe/PrakharTKGRepo | 9c6570a079b8cafddd356eb689f9e5485936a13a | 1ecc0d7b66850a11248cd43f77719fa76d4d9c9f | refs/heads/master | 2020-12-11T06:12:35.169089 | 2016-01-07T13:00:52 | 2016-01-07T13:00:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 323 | java | private class A{
A(){
System.out.println("A");
}
}
class B extends A{
B(){
System.out.println("B");
}
}
class C extends B{
static {
System.out.println("Static");
}
{
System.out.println("Instance");
}
C(){
System.out.println("C");
}
}
class Test{
public static void main(String...args){
C c=new C();}
} | [
"prakhar.jain@YITRNG17DT.Yash.com"
] | prakhar.jain@YITRNG17DT.Yash.com |
94899f48f72228546319bbc05e7f482f736e999f | 30872b5d29f13ea2753b4b5bcc4bff825331e3be | /app/src/main/java/xp/luocaca/xpdemo/shell/ShellUtils.java | ef90050a1ba8b7e1ad6d079fa85da5a954b047d0 | [] | no_license | liangzai448/XPdemo | d54b2b0d5c80e8e9415dae885c2757e9ce751ef6 | cbe45b9576542bce9e0c1670853f3ef2a6f4157b | refs/heads/master | 2023-02-28T17:55:26.920781 | 2021-02-06T07:50:10 | 2021-02-06T07:50:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,330 | java | package xp.luocaca.xpdemo.shell;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
/**
* ————————————————
* 版权声明:本文为CSDN博主「小码哥_WS」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
* 原文链接:https://blog.csdn.net/King1425/article/details/53043490
*/
public class ShellUtils {
public static final String COMMAND_SU = "su";
public static final String COMMAND_SH = "sh";
public static final String COMMAND_EXIT = "exit\n";
public static final String COMMAND_LINE_END = "\n";
private ShellUtils() {
throw new AssertionError();
}
/**
* check whether has root permission
*
* @return
*/
public static boolean checkRootPermission() {
return execCommand("echo root", true, false).result == 0;
}
/**
* execute shell command, default return result msg
*
* @param command command
* @param isRoot whether need to run with root
* @return
* @see ShellUtils#execCommand(String[], boolean, boolean)
*/
public static CommandResult execCommand(String command, boolean isRoot) {
return execCommand(new String[]{command}, isRoot, true);
}
/**
* execute shell commands, default return result msg
*
* @param commands command list
* @param isRoot whether need to run with root
* @return
* @see ShellUtils#execCommand(String[], boolean, boolean)
*/
public static CommandResult execCommand(List<String> commands, boolean isRoot) {
return execCommand(commands == null ? null : commands.toArray(new String[]{}), isRoot, true);
}
/**
* execute shell commands, default return result msg
*
* @param commands command array
* @param isRoot whether need to run with root
* @return
* @see ShellUtils#execCommand(String[], boolean, boolean)
*/
public static CommandResult execCommand(String[] commands, boolean isRoot) {
return execCommand(commands, isRoot, true);
}
/**
* execute shell command
*
* @param command command
* @param isRoot whether need to run with root
* @param isNeedResultMsg whether need result msg
* @return
* @see ShellUtils#execCommand(String[], boolean, boolean)
*/
public static CommandResult execCommand(String command, boolean isRoot, boolean isNeedResultMsg) {
return execCommand(new String[]{command}, isRoot, isNeedResultMsg);
}
/**
* execute shell commands
*
* @param commands command list
* @param isRoot whether need to run with root
* @param isNeedResultMsg whether need result msg
* @return
* @see ShellUtils#execCommand(String[], boolean, boolean)
*/
public static CommandResult execCommand(List<String> commands, boolean isRoot, boolean isNeedResultMsg) {
return execCommand(commands == null ? null : commands.toArray(new String[]{}), isRoot, isNeedResultMsg);
}
/**
* execute shell commands
*
* @param commands command array
* @param isRoot whether need to run with root
* @param isNeedResultMsg whether need result msg
* @return <ul>
* <li>if isNeedResultMsg is false, {@link CommandResult#successMsg} is null and
* {@link CommandResult#errorMsg} is null.</li>
* <li>if {@link CommandResult#result} is -1, there maybe some excepiton.</li>
* </ul>
*/
public static CommandResult execCommand(String[] commands, boolean isRoot, boolean isNeedResultMsg) {
int result = -1;
if (commands == null || commands.length == 0) {
return new CommandResult(result, null, null);
}
Process process = null;
BufferedReader successResult = null;
BufferedReader errorResult = null;
StringBuilder successMsg = null;
StringBuilder errorMsg = null;
DataOutputStream os = null;
try {
process = Runtime.getRuntime().exec(isRoot ? COMMAND_SU : COMMAND_SH);
os = new DataOutputStream(process.getOutputStream());
for (String command : commands) {
if (command == null) {
continue;
}
// donnot use os.writeBytes(commmand), avoid chinese charset error
os.write(command.getBytes());
os.writeBytes(COMMAND_LINE_END);
os.flush();
}
os.writeBytes(COMMAND_EXIT);
os.flush();
result = process.waitFor();
// get command result
if (isNeedResultMsg) {
successMsg = new StringBuilder();
errorMsg = new StringBuilder();
successResult = new BufferedReader(new InputStreamReader(process.getInputStream()));
errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String s;
while ((s = successResult.readLine()) != null) {
successMsg.append(s);
}
while ((s = errorResult.readLine()) != null) {
errorMsg.append(s);
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (os != null) {
os.close();
}
if (successResult != null) {
successResult.close();
}
if (errorResult != null) {
errorResult.close();
}
} catch (IOException e) {
e.printStackTrace();
}
if (process != null) {
process.destroy();
}
}
return new CommandResult(result, successMsg == null ? null : successMsg.toString(), errorMsg == null ? null
: errorMsg.toString());
}
/**
* result of command
* <ul>
* <li>{@link CommandResult#result} means result of command, 0 means normal, else means error, same to excute in
* linux shell</li>
* <li>{@link CommandResult#successMsg} means success message of command result</li>
* <li>{@link CommandResult#errorMsg} means error message of command result</li>
* </ul>
*
* @author <a href="http://www.trinea.cn" target="_blank">Trinea</a> 2013-5-16
*/
public static class CommandResult {
/**
* result of command
**/
public int result;
/**
* success message of command result
**/
public String successMsg;
/**
* error message of command result
**/
public String errorMsg;
public CommandResult(int result) {
this.result = result;
}
public CommandResult(int result, String successMsg, String errorMsg) {
this.result = result;
this.successMsg = successMsg;
this.errorMsg = errorMsg;
}
}
}
| [
"luocaca@gmail.com"
] | luocaca@gmail.com |
c4e577cd22426e57913e81ae9fe5e6944cb80db7 | 25114a901da9b526d94daa416463950beb6c4271 | /user/src/main/java/com/user/management/ProfileRepo.java | 0358a6401fde8141f437fd3163fd093829d8c183 | [] | no_license | sridhar-jarch/simpleservice | 27d80bfa082983a91080f663e76592bbcd0724e1 | a943f6ec954ab60282c444e68099b2f5b43966e9 | refs/heads/master | 2022-04-07T10:48:05.347690 | 2020-02-13T17:54:17 | 2020-02-13T17:54:17 | 233,868,205 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 357 | java | package com.user.management;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
public interface ProfileRepo extends JpaRepository<Profile, Integer> {
@Query("SELECT t FROM Profile t WHERE t.userid = ?1")
List<Profile> findByUserid(String userId);
} | [
"Sridhar.jarch@gmail.com"
] | Sridhar.jarch@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.