blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 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 684M ⌀ | 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 132 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 28 values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 352 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
014b9efd3f3d3fa89f971149c6f3dd8129e151db | a5c0483ae6b394b96dcce41165cc76e9dca7109f | /siif20130305/src/ar/com/siif/struts/actions/forms/FiscalizacionForm.java | 743eb75d5e369056a7a0d97d4ee7e5f79bcf0112 | [] | no_license | ticoerrecart/siif | 8a11e22b1128a0e471b1104a2f4438ceff701c0e | aa4098058c2d16ab05f677a8e2e6b5124d89a816 | refs/heads/master | 2020-05-18T19:53:55.725951 | 2015-11-10T12:48:47 | 2015-11-10T12:48:47 | 35,677,847 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,219 | java | package ar.com.siif.struts.actions.forms;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.collections.FactoryUtils;
import org.apache.commons.collections.list.LazyList;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import ar.com.siif.dto.FiscalizacionDTO;
import ar.com.siif.dto.MuestraDTO;
import ar.com.siif.struts.utils.Validator;
import ar.com.siif.utils.Constantes;
public class FiscalizacionForm extends ActionForm {
//-------------//
private FiscalizacionDTO fiscalizacionDTO;
private List<MuestraDTO> muestrasDTO;
//-------------//
public FiscalizacionForm() {
//fiscalizacion = new Fiscalizacion();
/*muestras = (List<Muestra>) LazyList.decorate(new ArrayList(),
FactoryUtils.instantiateFactory(Muestra.class));*/
fiscalizacionDTO = new FiscalizacionDTO();
muestrasDTO = (List<MuestraDTO>) LazyList.decorate(new ArrayList(),
FactoryUtils.instantiateFactory(MuestraDTO.class));
}
@Override
public void reset(ActionMapping mapping, HttpServletRequest request) {
/*Fiscalizacion f = (Fiscalizacion)request.getSession().getAttribute("fiscalizacion");
muestras = (List<Muestra>) LazyList.decorate(new ArrayList(),
FactoryUtils.instantiateFactory(Muestra.class));*/
FiscalizacionDTO fDTO = (FiscalizacionDTO) request.getSession().getAttribute(
"fiscalizacionDTO");
if (fDTO != null) {
//fiscalizacion = f;
fiscalizacionDTO = fDTO;
} else {
//fiscalizacion = new Fiscalizacion();
fiscalizacionDTO = new FiscalizacionDTO();
}
muestrasDTO = (List<MuestraDTO>) LazyList.decorate(new ArrayList(),
FactoryUtils.instantiateFactory(MuestraDTO.class));
}
public boolean validar(StringBuffer error) {
boolean ok2 = true;
boolean ok3 = true;
boolean ok4 = true;
boolean ok5 = true;
boolean ok6 = true;
boolean ok7 = true;
boolean ok8 = true;
boolean ok9 = true;
boolean ok10 = true;
boolean ok11 = true;
boolean ok12 = true;
boolean ok13 = true;
boolean ok14 = true;
boolean ok15 = true;
boolean ok16 = true;
ok2 = Validator.validarComboRequerido("-1",
Long.toString(fiscalizacionDTO.getProductorForestal().getId()),
"Productor Forestal", error);
ok5 = Validator.requerido(fiscalizacionDTO.getFecha(), "Fecha", error)
&& Validator.validarFechaValida(fiscalizacionDTO.getFecha(), "Fecha", error);
ok3 = Validator.requerido(fiscalizacionDTO.getPeriodoForestal(), "Periodo Forestal", error);
ok11 = Validator.validarComboRequerido("-1",
Long.toString(fiscalizacionDTO.getTipoProducto().getId()), "Tipo de Producto",
error);
ok9 = Validator.validarDoubleMayorQue(0,
Double.toString(fiscalizacionDTO.getCantidadMts()), "Cantidad Mts3", error);
if (fiscalizacionDTO.getTipoProducto().getId().longValue() != Constantes.LENIA_ID) {
ok8 = Validator.validarEnteroMayorQue(0,
Integer.toString(fiscalizacionDTO.getCantidadUnidades()), "Cantidad Unidades",
error);
ok10 = Validator.validarEnteroMayorQue(0,
Integer.toString(fiscalizacionDTO.getTamanioMuestra()), "Tamaño de la Muestra",
error);
ok16 = Validator.validarMuestras(this.getMuestrasDTO(), fiscalizacionDTO
.getTipoProducto().getId(), error);
}
ok11 = Validator.validarComboRequerido("-1",
Long.toString(fiscalizacionDTO.getOficinaAlta().getId()), "Oficina", error);
ok15 = Validator.validarComboRequerido("-1",
Long.toString(fiscalizacionDTO.getRodal().getId()), "Rodal", error);
//VALIDACIONES FISCALIZACION
return ok2 && ok3 && ok4 && ok5 && ok6 && ok7 && ok8 && ok9 && ok10 && ok11 && ok12 && ok13
&& ok14 && ok15 && ok16;
}
public FiscalizacionDTO getFiscalizacionDTO() {
return fiscalizacionDTO;
}
public void setFiscalizacionDTO(FiscalizacionDTO fiscalizacionDTO) {
this.fiscalizacionDTO = fiscalizacionDTO;
}
public List<MuestraDTO> getMuestrasDTO() {
return muestrasDTO;
}
public void setMuestrasDTO(List<MuestraDTO> muestrasDTO) {
this.muestrasDTO = muestrasDTO;
}
}
| [
"ticoerrecart@gmail.com@0f544f79-e0f4-099d-537f-5924260e9aa1"
] | ticoerrecart@gmail.com@0f544f79-e0f4-099d-537f-5924260e9aa1 |
896bcf6421b5616268913e24a0228d41d3765787 | 11aaed5a9469ebeaaefc179fda02ba1e300e7988 | /consumer/src/test/java/cn/boc/consumer/DemoApplicationTests.java | 4a470631367117b106d867012dbce54780039647 | [] | no_license | freesOcean/spring-cloud | a9a6caf14cc2594fe5938f48de71fdc04d18c61c | 66a6831572c43d63e908d8e60f0bac40c13d3167 | refs/heads/master | 2021-02-10T04:16:03.327118 | 2020-03-02T11:21:38 | 2020-03-02T11:21:38 | 244,351,122 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 205 | java | package cn.boc.consumer;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class DemoApplicationTests {
@Test
void contextLoads() {
}
}
| [
"zhangxub@163.com"
] | zhangxub@163.com |
49f9c12368806a42ca8f11994988ab91b74dfc5d | 7ef86525fbd9e71f4e5b5302d1ad89afb94f507e | /src/se/bryggmester/Program.java | 828dd632bbcee57a24b34a3726e1d0e8bd9f0985 | [] | no_license | smasseman/bryggmester | f1e81c529ad97027e0ab6a31a464a7d8691fd8e2 | 7d5cfbe7dd7e258d9ba9c95fb4cb07cffdcb9f9b | refs/heads/master | 2016-09-02T18:59:44.025264 | 2013-09-16T07:21:14 | 2013-09-16T07:21:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,239 | java | package se.bryggmester;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import se.bryggmester.instruction.Instruction;
/**
* @author jorgen.smas@entercash.com
*/
public class Program {
private static class KeyAndValue {
String key;
String value;
private KeyAndValue(String key, String value) {
super();
this.key = key;
this.value = value;
}
}
public static final Comparator<? super Program> NAME_COMPARATOR = new Comparator<Program>() {
@Override
public int compare(Program o1, Program o2) {
return o1.name.compareTo(o2.name);
}
};
private List<Instruction> instructions = new ArrayList<>();
private String name;
private Long id;
public List<Instruction> getInstructions() {
return instructions;
}
public void setInstructions(List<Instruction> instructions) {
this.instructions = instructions;
}
public static Program parse(File f) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(f));
Program p = new Program();
parseProperties(p, reader);
parseInstructions(p, reader);
reader.close();
return p;
}
private static void parseProperties(Program p, BufferedReader reader)
throws IOException {
String line;
String name = null;
Long id = null;
while ((line = reader.readLine()) != null) {
line = trim(line);
if (line == null) {
// Ignore
} else if ("-".equals(line)) {
if (name == null)
throw new IllegalArgumentException(
"Missing name in program properties.");
p.setName(name);
if (id == null)
throw new IllegalArgumentException(
"Missing id in program properties.");
p.setId(id);
return;
} else {
KeyAndValue kv = createKeyAndValue(line);
if (kv.key.equals("name")) {
name = kv.value;
} else if (kv.key.equals("id")) {
try {
id = new Long(kv.value);
} catch (Exception e) {
throw new IllegalArgumentException("Invalid id ("
+ kv.value + ") in program properties. "
+ e.getMessage());
}
}
}
}
}
private static KeyAndValue createKeyAndValue(String line) {
int index = line.indexOf('=');
if (index < 0)
throw new IllegalArgumentException("Line " + line
+ " does not contain a = char.");
return new KeyAndValue(line.substring(0, index),
line.substring(index + 1));
}
private static void parseInstructions(Program p, BufferedReader reader)
throws IOException {
String line;
while ((line = reader.readLine()) != null) {
line = trim(line);
if (line != null) {
p.getInstructions().add(Instruction.parse(line));
}
}
}
private static String trim(String line) {
line = line.trim();
if (line.length() == 0) {
// Ignore empy lines.
return null;
} else if (line.startsWith("#")) {
// Ignore comments
return null;
} else {
return line;
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Program other = (Program) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
@Override
public String toString() {
return "[id=" + id + ", name=" + name + "]";
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String export() {
StringBuilder s = new StringBuilder();
writeKeyAndValue(s, "id", id.toString());
writeKeyAndValue(s, "name", name);
s.append("-\n");
for (Instruction i : instructions) {
s.append(i.getType().name() + " " + i.getType().export(i)).append(
"\n");
}
return s.toString();
}
private void writeKeyAndValue(StringBuilder s, String name, String value) {
s.append(name).append("=").append(value).append("\n");
}
}
| [
"jorgen.smas@entercash.com"
] | jorgen.smas@entercash.com |
9b9d567cf3fe243bb61a07e87c766def6cc520bb | 043703eaf27a0d5e6f02bf7a9ac03c0ce4b38d04 | /subject_systems/Struts2/src/struts-2.3.30/src/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderResultsTest.java | cd3cde02c7d45a89c4470bc061e2dd0d544a1b6d | [] | no_license | MarceloLaser/arcade_console_test_resources | e4fb5ac4a7b2d873aa9d843403569d9260d380e0 | 31447aabd735514650e6b2d1a3fbaf86e78242fc | refs/heads/master | 2020-09-22T08:00:42.216653 | 2019-12-01T21:51:05 | 2019-12-01T21:51:05 | 225,093,382 | 1 | 2 | null | null | null | null | UTF-8 | Java | false | false | 129 | java | version https://git-lfs.github.com/spec/v1
oid sha256:f850d76232efde234c57b1561bb45543b218cfb1e5008460a45ab7e277ab6e72
size 5375
| [
"marcelo.laser@gmail.com"
] | marcelo.laser@gmail.com |
5d97823fe57b7850fef447057b6a91a76c0859f8 | e5204cafc0c26d7b46584342725d3867ac6f9684 | /src/main/java/com/changyue/shiro/sys/shiro/ShiroRealm.java | b032f1dec08863d7ef6be1c0b0c166715a31e831 | [] | no_license | yuanchangyue/ShiroDemo | d52503ac07467d35eb9a6747f5d5f2fe07aa0d6e | f279d1452518c7e5a3df24b05e6a74c8ade74563 | refs/heads/master | 2022-10-23T06:52:54.034416 | 2019-12-02T15:33:20 | 2019-12-02T15:33:20 | 222,095,942 | 0 | 0 | null | 2022-10-12T20:33:52 | 2019-11-16T12:27:55 | Java | UTF-8 | Java | false | false | 3,157 | java | package com.changyue.shiro.sys.shiro;
import com.changyue.shiro.sys.model.User;
import com.changyue.shiro.utils.MD5Utils;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import java.util.HashSet;
import java.util.Set;
/**
* @program: shirodemo
* @description: 自定义realm
* @author: 袁阊越
* @create: 2019-11-16 22:04
*/
public class ShiroRealm extends AuthorizingRealm {
/**
* 授权
* 将认证的通过的用户信息和权限信息设置给认证的主体
*/
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
//用户的身份信息
String username = principals.getPrimaryPrincipal().toString();
//通过username从数据库获取当前用户的角色
Set<String> rolesNames = new HashSet<>();
rolesNames.add("系统管理员");
rolesNames.add("系统运维");
//从数据库获取当前用户的权限
Set<String> permissionName = new HashSet<>();
permissionName.add("sys:user:create");
permissionName.add("sys:user:update");
permissionName.add("sys:user:list");
permissionName.add("sys:user:delete");
permissionName.add("sys:user:info");
//简单授权的信息,对象的中包含用户的角色和权限信息
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
info.addRoles(rolesNames);
info.addStringPermissions(permissionName);
System.out.println("授权...");
return info;
}
/**
* 认证
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;
//1. 获取用户的用户名
String username = token.getUsername();
//2. 获取用户的密码
String password = new String(token.getPassword());
//3. 根据用户名去数据库中查询用户是否存在
//3. 模拟获得用户在数据库的信息
User user = new User("zhangsan", "6d58d495d0517b4e7205346a72e211bc", 0, "f4af64b5c211be990ec6f26feef0f1ff");
//3. 明文加密
password = MD5Utils.md5PrivateSalt(password, user.getPrivateSalt());
if (!user.getUsername().equals(username)) {
throw new UnknownAccountException("用户不存在");
}
if (!user.getPassword().equals(password)) {
throw new CredentialsException("密码错误");
}
if (user.getStatus() == 1) {
throw new DisabledAccountException("账号被禁用");
}
if (user.getStatus() == 2) {
throw new LockedAccountException("账号被锁定");
}
System.out.println("登录认证...");
return new SimpleAuthenticationInfo(token.getPrincipal(), token.getCredentials(), getName());
}
}
| [
"34939635+yuanchangyue@users.noreply.github.com"
] | 34939635+yuanchangyue@users.noreply.github.com |
4bcdc0cdbe50df2806ac0b00f82666d4e7bde165 | 0ac11d1079c4e9d4e8fe4aefd8dfd8c9050851af | /src/PhoneTicket/PhoneTicket.Android/test/activities/DetailMovieTest.java | 0e9c553b0433ac7c4be0e5fa750af6693c9abf01 | [] | no_license | dschenkelman/a-malazan-wolvering | 7018ef15f9760e2e46b322c5aeb43663855cb8e7 | 6a0d61ca30acdf230d62c938cae2230d6aea3a98 | refs/heads/master | 2020-06-08T15:14:29.052607 | 2013-11-26T13:08:57 | 2013-11-26T13:08:57 | 32,240,297 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,331 | java | package activities;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import junit.framework.Assert;
import module.TestModule;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowActivity;
import org.robolectric.shadows.ShadowIntent;
import org.robolectric.shadows.ShadowPreferenceManager;
import phoneticket.android.R;
import phoneticket.android.activities.LoginActivity;
import phoneticket.android.activities.MasterActivity;
import phoneticket.android.activities.fragments.DetailCinemaFragment;
import phoneticket.android.activities.fragments.DetailMovieFragment;
import phoneticket.android.activities.fragments.RoomFragment;
import phoneticket.android.services.get.IRetrieveCinemaInfoService;
import phoneticket.android.services.get.IRetrieveMovieFunctionsService;
import phoneticket.android.services.get.IRetrieveMovieInfoService;
import phoneticket.android.services.get.IRetrieveMovieListService;
import phoneticket.android.services.get.IRetrieveRoomInfoService;
import phoneticket.android.services.get.mock.MockRetrieveMovieFunctionsService;
import phoneticket.android.services.get.mock.MockRetrieveMovieInfoService;
import phoneticket.android.utils.UserManager;
import android.content.ComponentName;
import android.content.Intent;
import android.content.SharedPreferences;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
@RunWith(RobolectricTestRunner.class)
public class DetailMovieTest {
@Mock
private IRetrieveMovieInfoService retrieveMovieInfoService;
@Mock
private IRetrieveMovieFunctionsService movieFunctionsService;
@Mock
private IRetrieveMovieListService iRetrieveMovieListService;
@Mock
private IRetrieveCinemaInfoService iRetrieveCinemaInfoService;
@Mock
private IRetrieveRoomInfoService roomInfoService;
private DetailMovieFragment fragment;
private MasterActivity activity;
private int movieId;
private Button watchTrailerButton;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
TestModule module = new TestModule();
module.addBinding(IRetrieveMovieInfoService.class,
retrieveMovieInfoService);
module.addBinding(IRetrieveMovieFunctionsService.class,
movieFunctionsService);
module.addBinding(IRetrieveMovieListService.class,
iRetrieveMovieListService);
module.addBinding(IRetrieveCinemaInfoService.class,
iRetrieveCinemaInfoService);
module.addBinding(IRetrieveRoomInfoService.class, roomInfoService);
TestModule.setUp(this, module);
activity = Robolectric.buildActivity(MasterActivity.class).create()
.resume().get();
movieId = 0;
activity.onMovielistItemSelected(movieId, "Titulo");
fragment = (DetailMovieFragment) activity.getSupportFragmentManager()
.findFragmentById(R.id.fragment_container);
watchTrailerButton = (Button) fragment.getView().findViewById(
R.id.watchTrailerButton);
SharedPreferences sharedPreferences = ShadowPreferenceManager
.getDefaultSharedPreferences(Robolectric.application
.getApplicationContext());
UserManager.initialize(sharedPreferences);
}
@Test
public void detailMovieActivityCallRetrieveMovieFunctionsServiceOnCreate() {
Mockito.verify(movieFunctionsService, Mockito.times(1))
.retrieveMovieFunctions(fragment, movieId);
}
@Test
public void detailMovieActivityCallRetrieveMovieInfoServiceOnCreate() {
Mockito.verify(retrieveMovieInfoService, Mockito.times(1))
.retrieveMovieInfo(fragment, movieId);
}
@Test
public void actionViewIntentOnWatchTrailer() {
new MockRetrieveMovieInfoService().retrieveMovieInfo(fragment, 0);
watchTrailerButton.performClick();
ShadowActivity shadowActivity = Robolectric.shadowOf(activity);
Intent intent = shadowActivity.getNextStartedActivity();
assertNotNull(intent);
ShadowIntent shadowIntent = Robolectric.shadowOf(intent);
assertThat(shadowIntent.getAction(), equalTo(Intent.ACTION_VIEW));
}
@Test
public void detailMovieChangeToDetailCinemaFragmentOnItemClick() {
new MockRetrieveMovieFunctionsService().retrieveMovieFunctions(
fragment, movieId);
ImageButton button = (ImageButton) fragment.getView().findViewById(
R.id.goToCinema);
button.performClick();
Assert.assertEquals(
DetailCinemaFragment.class.getCanonicalName(),
activity.getSupportFragmentManager()
.findFragmentById(R.id.fragment_container).getClass()
.getCanonicalName());
}
@Test
public void detailMovieChangeCallLoginActivityWhenNotLogIn() {
new MockRetrieveMovieInfoService().retrieveMovieInfo(fragment, 0);
new MockRetrieveMovieFunctionsService().retrieveMovieFunctions(
fragment, movieId);
LinearLayout button = (LinearLayout) fragment.getView().findViewById(
R.id.timeLinearLayout);
TextView v = (TextView) button.getChildAt(0);
v.performClick();
ShadowActivity shadowActivity = Robolectric.shadowOf(activity);
Intent intent = shadowActivity.getNextStartedActivity();
ComponentName c = intent.getComponent();
String call = c.getClassName();
assertNotNull(intent);
Assert.assertEquals(LoginActivity.class.getName(), call);
}
@Test
public void detailMovieChangeChangeFragmentOnLoginIn() {
new MockRetrieveMovieInfoService().retrieveMovieInfo(fragment, 0);
new MockRetrieveMovieFunctionsService().retrieveMovieFunctions(
fragment, movieId);
LinearLayout button = (LinearLayout) fragment.getView().findViewById(
R.id.timeLinearLayout);
UserManager.getInstance().setCredentials("pepe", "pepe");
UserManager.getInstance().loginUserWithId(0, true);
TextView v = (TextView) button.getChildAt(0);
v.performClick();
Assert.assertEquals(
RoomFragment.class.getCanonicalName(),
activity.getSupportFragmentManager()
.findFragmentById(R.id.fragment_container).getClass()
.getCanonicalName());
}
}
| [
"gdfesta@2a5ade1e-0ce3-53c1-387a-2b2623bf7fdd"
] | gdfesta@2a5ade1e-0ce3-53c1-387a-2b2623bf7fdd |
64e136e33757366b51847990611de145429581e1 | ba035357514fb46132c781ee3379ccd5628fbc74 | /src/TestBST.java | 73c551df28df12c05154a7ab75c5db3ba97ff647 | [] | no_license | AysenurKan/BinarySearchTreeCodes | e904d86ac460e3789898ec3ecd2675684b313e65 | e9de2d7b7629a77f0178dafbaf067c95c6538f2f | refs/heads/master | 2020-12-31T04:06:55.245399 | 2016-05-10T19:29:32 | 2016-05-10T19:29:32 | 58,528,966 | 0 | 0 | null | 2016-05-11T08:51:34 | 2016-05-11T08:51:33 | null | UTF-8 | Java | false | false | 1,807 | java | import java.util.Scanner;
public class TestBST {
public static void main(String[] args) {
BST tree = new BST();
int option=0;
int number;
Scanner s=new Scanner(System.in);
do{
System.out.print("\n\nMenu:\n1. Insert Number\n2. Search a number\n3. Delete a number\n4. Display tree as an ordered list" +
"\n5. Display Tree (breadthFirstTravelsal)\n6. Display count of nodes\n7. Display height of tree\n8. Display count of leaf nodes\n"+
"9. Exit");
System.out.print("\n\nOption>> ");
option=s.nextInt();
switch(option){
case 1:
System.out.println("Enter numbers (0 is exit) >> ");
number=s.nextInt();
while(number!=0){
tree.insert(number);
number=s.nextInt();
}
System.out.println(tree.getCount()+" numbers are added");
break;
case 2:
System.out.print("Enter a number to be seach: ");
number=s.nextInt();
if(tree.search(number))
System.out.println("exist");
else
System.out.println("not exist");
break;
case 3:
System.out.println("Enter a number to be deleted: ");
number=s.nextInt();
tree.delete(number);
System.out.println(number+" is deleted");
break;
case 4:
System.out.print("Ordered list: ");
tree.inorder();
break;
case 5:
// tree.breadthFirstTravelsal();
break;
case 6:
System.out.print("# of nodes:"+tree.getCount());
break;
case 7:
System.out.println("Height: "+tree.getHeight());
break;
case 8:
System.out.println("# of leaf nodes: "+tree.getNumberofLeaves());
break;
case 9:
System.out.println("Goodbye my lover :-*");
break;
default:
System.out.println("Try again!!!");
}
}while(option!=9);
}
}
| [
"gulnurkaya38@gmail.com"
] | gulnurkaya38@gmail.com |
ddea65bc0fd2fe08a04349614fc5f56e3a1c5178 | 6d51a2f5b54c005c022bcf5897d3490dd6c3a576 | /src/main/java/gwt/material/design/demo/client/application/roadmap/RoadMapView.java | 0cc3ade60b75392685b7d0fd2ef8385f9293bbce | [
"Apache-2.0"
] | permissive | GwtMaterialDesign/gwt-material-demo | 9f95a90cb939f0897d7bcebed8dd27e581c0ddcf | ef9ede80abac6e5fed4cbe0ede772eb44f674c71 | refs/heads/master | 2021-01-24T10:40:22.310022 | 2019-02-03T00:15:26 | 2019-02-03T00:15:26 | 33,317,132 | 38 | 75 | Apache-2.0 | 2020-05-26T19:13:43 | 2015-04-02T15:41:09 | Java | UTF-8 | Java | false | false | 1,139 | java | package gwt.material.design.demo.client.application.roadmap;
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2016 GwtMaterialDesign
* %%
* 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.
* #L%
*/
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.ui.Widget;
import com.gwtplatform.mvp.client.ViewImpl;
import javax.inject.Inject;
public class RoadMapView extends ViewImpl implements RoadMapPresenter.MyView {
interface Binder extends UiBinder<Widget, RoadMapView> {
}
@Inject
RoadMapView(Binder uiBinder) {
initWidget(uiBinder.createAndBindUi(this));
}
}
| [
"kevzlou7979@gmail.com"
] | kevzlou7979@gmail.com |
be46c0a7c51c5ae07b35ef36242037a2c375a605 | 0c167564979866d6dbbb89d8d128575b98c5310f | /hadoop_hive/src/com/shengli/tools/Hive2Mysql.java | 7c6d27353a3e9e1c65eef7c8bd15ac907e812d8e | [] | no_license | shengli2015/javaArithmetic | 58267528f6f270cfbd7870228c71a32fa60d5e84 | 125cfac65354e60af18a03e2beee03f287be93bc | refs/heads/master | 2021-01-17T19:18:25.425478 | 2016-07-04T12:10:59 | 2016-07-04T12:10:59 | 62,559,117 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,226 | java | package com.shengli.tools;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;
public class Hive2Mysql {
Properties prop = new Properties();
public Hive2Mysql(String propertyName) throws Exception {
init(propertyName);
}
public void init(String propertyName) throws Exception {
InputStream stream = new FileInputStream(propertyName);
prop.load(stream);
}
public static void main(String [] args) {
try {
if(args.length < 1) {
System.out.println("please set propertyName");
System.exit(1);
}
String propertyName = args[0];
Hive2Mysql h2 = new Hive2Mysql(propertyName);
System.out.println(h2.prop.get("Hive_sql"));
System.out.println(h2.prop.get("Mysql_table"));
String Hive_sql = h2.prop.get("Hive_sql").toString();
String Mysql_table = h2.prop.get("Mysql_table").toString();
String mysql_columns = h2.prop.get("mysql_columns").toString();
String mysql_delete = h2.prop.get("mysql_delete").toString();
Connection mysqlCon = MyConnection.getMysqlInstance();
Connection hiveCon = MyConnection.getHiveInstance();
String mysql_sql = "insert into " + Mysql_table + " (" + mysql_columns + ") values (";
Statement stHive = hiveCon.createStatement();
Statement stMysql = mysqlCon.createStatement();
ResultSet rsHive = stHive.executeQuery(Hive_sql);
int len = Hive_sql.split("from")[0].split("select")[1].trim().split(",").length;
String value = "";
stMysql.execute(mysql_delete);
while(rsHive.next()) {
for(int i=1;i<=len;i++) {
value += "'" + rsHive.getString(i) + "',";
}
value = value.substring(0, value.length()-1);
mysql_sql = mysql_sql + value + ")";
stMysql.execute(mysql_sql);
System.out.println(value);
value = "";
mysql_sql = "insert into " + Mysql_table + " (" + mysql_columns + ") values (";
}
rsHive.close();
stHive.close();
stMysql.close();
mysqlCon.close();
hiveCon.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
| [
"18811793100@163.com"
] | 18811793100@163.com |
04ef5a81975dfdbc82b6ea0c54acab5bf9ef0f19 | c5e469d9fcd1bdaa897257c01834afbc3f4a9090 | /src/main/java/complexpattern/interpreter/OperatorExpression.java | ddbd96af4c8335a911857a0f2efd1d9e03190ad7 | [] | no_license | thanhnew2001/AllDesignPatterns | 393dffebbb3d7d9ba3ae35947ad28dfef9755fa5 | cee3e28c9e6707aba18eb78df3a82f12994b717c | refs/heads/master | 2021-07-14T15:48:53.107244 | 2017-10-19T09:45:50 | 2017-10-19T09:45:50 | 107,353,120 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 985 | java | package complexpattern.interpreter;
/**
* Created by CoT on 10/17/17.
*/
public class OperatorExpression implements Expression {
private OperatorExpression leftOperand;
private OperatorExpression rightOperand;
private char operator;
public OperatorExpression(OperatorExpression leftOperand, OperatorExpression rightOperand, char operator) {
this.leftOperand = leftOperand;
this.rightOperand = rightOperand;
this.operator = operator;
}
public int intepret() {
switch (operator){
case '+':
return leftOperand.intepret() + rightOperand.intepret();
case '-':
return leftOperand.intepret() - rightOperand.intepret();
case '*':
return leftOperand.intepret() * rightOperand.intepret();
case '/':
return leftOperand.intepret() / rightOperand.intepret();
default:
return 0;
}
}
}
| [
"thanh.hispvietnam@gmail.com"
] | thanh.hispvietnam@gmail.com |
1d63ee770ebcb703fff666b5e004737c9d323237 | bf3e8c43a4dec5478142e86109428ba315f34141 | /demo3/src/main/java/com/Handler5.java | 3c3c75b7500751574aa92da878b068da52ecd624 | [] | no_license | sheldonfa/disruptor | 22a1223331643a8b122681a9aec0498c6e17fa52 | 1feb5997053f99e5c819f60bbe276d9eecc3221a | refs/heads/master | 2021-01-20T15:03:10.528434 | 2017-05-09T09:11:36 | 2017-05-09T09:11:36 | 90,707,781 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 550 | java | package com;
import java.util.UUID;
import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;
public class Handler5 implements EventHandler<Trade>,WorkHandler<Trade> {
@Override
public void onEvent(Trade event, long sequence, boolean endOfBatch) throws Exception {
this.onEvent(event);
}
@Override
public void onEvent(Trade event) throws Exception {
System.out.println("handler5: get price : " + event.getPrice());
event.setPrice(event.getPrice() + 3.0);
}
} | [
"727171280@qq.com"
] | 727171280@qq.com |
f84b6a6e1cab0e67a69c3e4437178a9c345a74b9 | 22d50fc24864b6a08bf96ad259fd143982505007 | /app/src/main/java/com/snail/iweibo/util/Configuration.java | 3bebd8393d9b8e9dc7ae2cfe8bf372aebc2f08ed | [] | no_license | wangwei1121/iweibo | 75992091743ba8ed7c7aae2cc33cc657316847c8 | ee3c51b739ca1b9c0a8fd8ddf3b8ea3caa9ce673 | refs/heads/master | 2021-01-21T04:59:24.909007 | 2016-05-16T15:39:09 | 2016-05-16T15:39:09 | 50,438,301 | 1 | 2 | null | 2016-01-29T01:38:51 | 2016-01-26T15:33:22 | Java | UTF-8 | Java | false | false | 257 | java | package com.snail.iweibo.util;
/**
* Configuration App环境配置
* Created by alexwan on 16/1/30.
*/
public class Configuration {
public static final boolean DEBUG = true;
public static final String WEIBO_BASE_URL = "https://api.weibo.com/";
}
| [
"alexwan1989@sina.com"
] | alexwan1989@sina.com |
e92841b5ef67a27aab557b2ea10b7b6c7d5c5344 | 4b756398e4a884714feeab8a6926df8880475e31 | /CalculatriceAOO/src/calculatriceaoo/App.java | fff8a2691164ea237e633d6ef6b59ba113bb12c6 | [] | no_license | ThomatoKetchup/NetBeansProjects | 035f4b07863b2c3310147f2e9a5c0de7d1ead189 | b51e801add69090f8f13f6fce1f59c6d38d32cc0 | refs/heads/master | 2021-04-06T08:49:02.059510 | 2018-03-11T15:22:42 | 2018-03-11T15:22:42 | 124,767,382 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,301 | 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 calculatriceaoo;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class App extends Application {
private Calculatrice c;
public App() {
c = new Calculatrice();
try {
c.addOperation("+", new Addition());
c.addOperation("-", new Soustraction());
c.addOperation("/", new Division()); //Il faut necessairement que Division implément opération, sinon il ne peut pas $etre de type operation
c.addOperation("*", new Multiplication());
} catch (ExceptionOperationExistante e) {
}
}
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("UI.fxml")); //"la vue est dans le UI Fxml, on la charge avec get resource
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
| [
"duc-toan.nguyen@etu.univ-paris1.fr"
] | duc-toan.nguyen@etu.univ-paris1.fr |
2bfec0fc21f20e499284031db6b3b4d4dd9c51ac | 7b808da40d2ca0e7b410072e21b8bd8f4667daef | /q/c/submissions/Pheonix/problem2.java | 4a347c3efdaf332272a85c4943976139a49a4f8e | [] | no_license | nishant1408/Code-Judge | 29bf3a1a2b8684d784c613866f27ad9a3d665911 | c4da0ad83b5ddf79388369f80739735087f4d884 | refs/heads/master | 2020-04-13T04:57:42.993969 | 2018-12-25T10:32:23 | 2018-12-25T10:32:23 | 162,976,535 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 287 | java | import java.util.Scanner;
public class problem2{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
int l,i,j,c=0;
String rev="";
l=s.length();
j=s.indexOf(" ");
System.out.println(s.charAt(0)+"."+" "+s.substring(j+1,l));
}
}
| [
"n1481997@gmail.com"
] | n1481997@gmail.com |
6c466df36e53fafadab3ec4af9d3521ce25a3c15 | 538bba9b8c621993a5d45636ecc2b3860a5e9b2d | /src/main/java/com/zhk/controller/ResourceController.java | 3c142da34cfeb6909775ff634e0da393f5ad2a62 | [] | no_license | EHENJOOM/online-course-server | 13235edc450a751253f38735f2c027a5f4f48fc5 | b8df3d4f2aa37d842ebb161d02715f40b4ff400b | refs/heads/master | 2022-12-12T06:12:44.875194 | 2020-08-27T06:52:04 | 2020-08-27T06:52:04 | 284,223,317 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,174 | java | package com.zhk.controller;
import com.zhk.entity.vo.CommonResultVo;
import com.zhk.service.ResourceService;
import com.zhk.util.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @author 赵洪苛
* @date 2020/8/22 16:25
* @description 资源控制层
*/
@Slf4j
@RestController
public class ResourceController {
@Resource
private ResourceService resourceService;
@GetMapping("/resource/{courseId}")
public CommonResultVo getResource(@PathVariable("courseId") Integer courseId) {
LinkedHashMap resource = resourceService.getResource(courseId);
log.info("根据courseId和teacherId查询资源列表:{}", resource);
return ResultUtil.success(resource);
}
@PostMapping("/resource")
public CommonResultVo addResource(@RequestBody Map map) {
log.info("添加资源:{}", map.get("resourceVo"));
resourceService.saveResource((Map) map.get("resourceVo"), Integer.valueOf((String) map.get("courseId")));
return ResultUtil.success("成功!");
}
}
| [
"884101977@qq.com"
] | 884101977@qq.com |
a0cf13b1d6559b607baf703422022c7d222e9ffd | 4379ab0e4c4590c1b7044f713e633354bbe6de44 | /spring-ssm/src/main/java/com/shy/ssm/bean/User.java | e1da596dfd4be7a0abfbba95b191caafc3317ecd | [
"Apache-2.0"
] | permissive | shihaoyan/spring5.0.x | 7f85a56114b09b02ed627eb4cbebd8dc207c6011 | cb545787e97364295ae5f6bae40f3c9b3e653d0f | refs/heads/master | 2022-04-24T14:35:51.766345 | 2020-04-20T11:31:51 | 2020-04-20T11:31:51 | 257,198,593 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 707 | java | package com.shy.ssm.bean;
/**
* @author 石皓岩
* @create 2020-03-01 19:43
* 描述:
*/
public class User {
private Integer id;
private String username;
private String password;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public User(Integer id, String username, String password) {
this.id = id;
this.username = username;
this.password = password;
}
public User() {
}
}
| [
"923463567@qq.com"
] | 923463567@qq.com |
490d5c785d73039cbc1b8df18e98b84e65fe7baa | 43890d58dd7790f9a3cda48964cf0af554a58d19 | /src/br/com/softblue/loucademia/domain/aluno/EstadoRepository.java | f6a61886a7f663ecb592a2e09ea253815687cbac | [] | no_license | wsnino/Locademia | 113a020f1fd5fdaea9577806fd16e06d071c3172 | b50d5b4eb9ef458cd06dd25220ac94485b8bf062 | refs/heads/master | 2023-03-21T23:53:58.132259 | 2021-03-21T16:32:10 | 2021-03-21T16:32:10 | 347,661,085 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 424 | java | package br.com.softblue.loucademia.domain.aluno;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Stateless
public class EstadoRepository {
@PersistenceContext
private EntityManager em;
public List<Estado> listEstados() {
return em.createQuery("SELECT e FROM Estado e ORDER BY e.nome", Estado.class).getResultList();
}
}
| [
"wsnino.contato@gmail.com"
] | wsnino.contato@gmail.com |
6112cf918c3f07637e49adfe9a8f6e13a81d7e0a | 1d928c3f90d4a0a9a3919a804597aa0a4aab19a3 | /java/dbeaver/2015/4/IGridLabelProvider.java | e0a04ae1907467b76409c21bb79cf43edd30cdad | [] | no_license | rosoareslv/SED99 | d8b2ff5811e7f0ffc59be066a5a0349a92cbb845 | a062c118f12b93172e31e8ca115ce3f871b64461 | refs/heads/main | 2023-02-22T21:59:02.703005 | 2021-01-28T19:40:51 | 2021-01-28T19:40:51 | 306,497,459 | 1 | 1 | null | 2020-11-24T20:56:18 | 2020-10-23T01:18:07 | null | UTF-8 | Java | false | false | 1,434 | java | /*
* Copyright (C) 2010-2015 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.ext.ui.ITooltipProvider;
public interface IGridLabelProvider extends IColorProvider, IFontProvider, ITooltipProvider {
@NotNull
public String getText(Object element);
@Nullable
public Image getImage(Object element);
}
| [
"rodrigosoaresilva@gmail.com"
] | rodrigosoaresilva@gmail.com |
a94399ad5b6153d42c76ec5b03eb4a417d83fa23 | 7fcf73e834eaa6f53fd2db1da5ffeacbd0b4105e | /src/parser/rules/InitializerRule.java | cd0b3594279591516822af5c63af10b74550610e | [] | no_license | Nachodlv/lexer-parser-interpreter | 713e7eb124c164c84ef2ba6dd5032457608ff893 | 31818e2a181a77031b161ec33de1c14236bb2a33 | refs/heads/master | 2020-05-29T10:12:22.623062 | 2019-07-20T20:20:38 | 2019-07-20T20:20:38 | 189,088,749 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 758 | java | package parser.rules;
import parser.NodeType;
import parser.nodes.NonTerminalNode;
import parser.nodes.TreeNode;
import java.util.ArrayList;
import java.util.Stack;
public class InitializerRule implements Rule {
@Override
public Stack<TreeNode> apply(Stack<TreeNode> stack) {
TreeNode additive = stack.pop();
TreeNode equals = stack.pop();
ArrayList<TreeNode> child = new ArrayList<>();
child.add(equals);
child.add(additive);
NonTerminalNode node = new NonTerminalNode(
child,
NodeType.INITIALIZER,
additive.getRow(),
additive.getColumn(),
additive.getValue());
stack.push(node);
return stack;
}
}
| [
"ignacio.delavega@ing.austral.edu.ar"
] | ignacio.delavega@ing.austral.edu.ar |
f4c582981c648a2dd10c452227c3acce08bfa319 | c3b50309325790c2048938dc89b6a85b347a58f3 | /src/com/smlib/activity/ShellSplashActivity.java | 0785e8ac925164de9679854c3d02e64f378f228a | [] | no_license | audacelin/SMLib | 76e0e5e2d95896c1efb9cad9d6b06c6e0ac7d93a | 9827e0c36a21288825cc9c68c5901462c25085cf | refs/heads/master | 2021-01-01T19:04:44.726138 | 2017-07-27T06:32:14 | 2017-07-27T06:32:14 | 98,501,687 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 3,216 | java | package com.smlib.activity;
import com.smlib.R;
import com.smlib.bussiness.ShellContextParamsModule;
import com.smlib.bussiness.ShellSPConfigModule;
import com.smlib.bussiness.ShellSPConfigModule.CustSP;
import com.smlib.utils.AndroidUtils;
import com.smlib.utils.StringUtils;
import com.smlib.utils.SystemBarTintManager;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
public class ShellSplashActivity extends TraceActivity{
private TextView tv_indicator,tv_appVersion,tv_appName;
private final long SPLASH_WAITING=1000;
private ShellContextParamsModule shellContextParamsModule=ShellContextParamsModule.getInstance();
private ShellSPConfigModule spConfigModule=ShellSPConfigModule.getInstance();
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
Log.e("ShellSplashActivity", "test");
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// setTranslucentStatus(true);
// SystemBarTintManager tintManager = new SystemBarTintManager(this);
// tintManager.setStatusBarTintEnabled(true);
// tintManager.setStatusBarTintResource(R.color.barcolor);//通知栏所需颜色
// }
setContentView(R.layout.shell_splash_activity);
init();
}
private void setTranslucentStatus(boolean on) {
Window win = getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
if (on) {
winParams.flags |= bits;
} else {
winParams.flags &= ~bits;
}
win.setAttributes(winParams);
}
public void init(){
initUI();
//检查是否存在登录的用户
tryLogin();
}
public void initUI(){
tv_indicator=(TextView)this.findViewById(R.id.idStartIndicator);
tv_appVersion=(TextView)this.findViewById(R.id.app_version_tv);
tv_appName=(TextView)this.findViewById(R.id.app_name_tv);
tv_appName.setText(AndroidUtils.s(R.string.app_name));
tv_appVersion.setText("V"+AndroidUtils.System.getVersionName());
}
private void tryLogin(){
if(canAutoLogin()){
//满足自动登录条件
Login();
return;
}
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try{
Thread.sleep(SPLASH_WAITING);
}catch(InterruptedException ex){
ex.printStackTrace();
}
goToLogin();
}
}).start();;
}
private boolean canAutoLogin(){
if(!spConfigModule.isAutoLogin(shellContextParamsModule.getCurCustNo()))
return false;
CustSP custSP=spConfigModule.getLastestCustSP();
if(custSP==null)
return false;
if(StringUtils.isBlank(custSP.custNo))
return false;
return true;
}
//跳转登录界面
protected void goToLogin(){
}
//自动登录
protected void Login(){
//
}
}
| [
"920401496@qq.com"
] | 920401496@qq.com |
30d30245c89617137dc64e782d60f4d1816e1f3e | 0bf55802ab1869ad0798d7d5851e1fa31be2ae54 | /src/Strategy/Use_a_cabeca_Livro/DUCK/comportamentos/FlyWithWings.java | b57d0a7324467152e96f724b8da4f74348d72b02 | [] | no_license | loressl/Padroes_de_Projeto | 8159105c3a6132f2f541a6874b96b96b792c3a24 | 72644a731436699c309f82cacf74f35f15da5276 | refs/heads/master | 2020-05-18T14:56:01.731636 | 2019-10-17T05:10:53 | 2019-10-17T05:10:53 | 184,483,652 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 251 | java | package Strategy.Use_a_cabeca_Livro.DUCK.comportamentos;
import Strategy.Use_a_cabeca_Livro.DUCK.Interface.FlyBehavior;
public class FlyWithWings implements FlyBehavior{
@Override
public void fly() {
System.out.println("I'm flying!!");
}
}
| [
"loryssl@hotmail.com"
] | loryssl@hotmail.com |
7246a17f70b9c53ab10a753e21fc71492c6e24da | d7cb8f49de3dc52438bae4c926824c2ca24f0e84 | /src/examples/RequestRelatedItems.java | 9794a14aead1f63594ff4fc88b5df863c62fd5d5 | [] | no_license | showaid/SerenaAPI | a8e15296fee428d1c485dcf302c277907023944b | a5a0f00fd56bd913d148bf06e957d51cc3c2cc25 | refs/heads/master | 2021-01-10T03:17:07.381505 | 2015-09-30T05:07:56 | 2015-09-30T05:07:56 | 43,412,233 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,638 | java | /* ===========================================================================
* Copyright (c) 2007 Serena Software. All rights reserved.
*
* Use of the Sample Code provided by Serena is governed by the following
* terms and conditions. By using the Sample Code, you agree to be bound by
* the terms contained herein. If you do not agree to the terms herein, do
* not install, copy, or use the Sample Code.
*
* 1. GRANT OF LICENSE. Subject to the terms and conditions herein, you
* shall have the nonexclusive, nontransferable right to use the Sample Code
* for the sole purpose of developing applications for use solely with the
* Serena software product(s) that you have licensed separately from Serena.
* Such applications shall be for your internal use only. You further agree
* that you will not: (a) sell, market, or distribute any copies of the
* Sample Code or any derivatives or components thereof; (b) use the Sample
* Code or any derivatives thereof for any commercial purpose; or (c) assign
* or transfer rights to the Sample Code or any derivatives thereof.
*
* 2. DISCLAIMER OF WARRANTIES. TO THE MAXIMUM EXTENT PERMITTED BY
* APPLICABLE LAW, SERENA PROVIDES THE SAMPLE CODE AS IS AND WITH ALL
* FAULTS, AND HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EITHER
* EXPRESSED, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY
* IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A
* PARTICULAR PURPOSE, OF LACK OF VIRUSES, OF RESULTS, AND OF LACK OF
* NEGLIGENCE OR LACK OF WORKMANLIKE EFFORT, CONDITION OF TITLE, QUIET
* ENJOYMENT, OR NON-INFRINGEMENT. THE ENTIRE RISK AS TO THE QUALITY OF
* OR ARISING OUT OF USE OR PERFORMANCE OF THE SAMPLE CODE, IF ANY,
* REMAINS WITH YOU.
*
* 3. EXCLUSION OF DAMAGES. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE
* LAW, YOU AGREE THAT IN CONSIDERATION FOR RECEIVING THE SAMPLE CODE AT NO
* CHARGE TO YOU, SERENA SHALL NOT BE LIABLE FOR ANY DAMAGES WHATSOEVER,
* INCLUDING BUT NOT LIMITED TO DIRECT, SPECIAL, INCIDENTAL, INDIRECT, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, DAMAGES FOR LOSS OF
* PROFITS OR CONFIDENTIAL OR OTHER INFORMATION, FOR BUSINESS INTERRUPTION,
* FOR PERSONAL INJURY, FOR LOSS OF PRIVACY, FOR NEGLIGENCE, AND FOR ANY
* OTHER LOSS WHATSOEVER) ARISING OUT OF OR IN ANY WAY RELATED TO THE USE
* OF OR INABILITY TO USE THE SAMPLE CODE, EVEN IN THE EVENT OF THE FAULT,
* TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY, OR BREACH OF CONTRACT,
* EVEN IF SERENA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THE
* FOREGOING LIMITATIONS, EXCLUSIONS AND DISCLAIMERS SHALL APPLY TO THE
* MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW. NOTWITHSTANDING THE ABOVE,
* IN NO EVENT SHALL SERENA'S LIABILITY UNDER THIS AGREEMENT OR WITH RESPECT
* TO YOUR USE OF THE SAMPLE CODE AND DERIVATIVES THEREOF EXCEED US$10.00.
*
* 4. INDEMNIFICATION. You hereby agree to defend, indemnify and hold
* harmless Serena from and against any and all liability, loss or claim
* arising from this agreement or from (i) your license of, use of or
* reliance upon the Sample Code or any related documentation or materials,
* or (ii) your development, use or reliance upon any application or
* derivative work created from the Sample Code.
*
* 5. TERMINATION OF THE LICENSE. This agreement and the underlying
* license granted hereby shall terminate if and when your license to the
* applicable Serena software product terminates or if you breach any terms
* and conditions of this agreement.
*
* 6. CONFIDENTIALITY. The Sample Code and all information relating to the
* Sample Code (collectively "Confidential Information") are the
* confidential information of Serena. You agree to maintain the
* Confidential Information in strict confidence for Serena. You agree not
* to disclose or duplicate, nor allow to be disclosed or duplicated, any
* Confidential Information, in whole or in part, except as permitted in
* this Agreement. You shall take all reasonable steps necessary to ensure
* that the Confidential Information is not made available or disclosed by
* you or by your employees to any other person, firm, or corporation. You
* agree that all authorized persons having access to the Confidential
* Information shall observe and perform under this nondisclosure covenant.
* You agree to immediately notify Serena of any unauthorized access to or
* possession of the Confidential Information.
*
* 7. AFFILIATES. Serena as used herein shall refer to Serena Software,
* Inc. and its affiliates. An entity shall be considered to be an
* affiliate of Serena if it is an entity that controls, is controlled by,
* or is under common control with Serena.
*
* 8. GENERAL. Title and full ownership rights to the Sample Code,
* including any derivative works shall remain with Serena. If a court of
* competent jurisdiction holds any provision of this agreement illegal or
* otherwise unenforceable, that provision shall be severed and the
* remainder of the agreement shall remain in full force and effect.
* ===========================================================================
*/
package examples;
import java.util.ArrayList;
import java.util.List;
import com.clt.serena.resources.PropertyReader;
import com.serena.dmclient.api.BulkOperator;
import com.serena.dmclient.api.DimensionsConnection;
import com.serena.dmclient.api.DimensionsConnectionDetails;
import com.serena.dmclient.api.DimensionsConnectionManager;
import com.serena.dmclient.api.DimensionsRelatedObject;
import com.serena.dmclient.api.ItemRevision;
import com.serena.dmclient.api.Project;
import com.serena.dmclient.api.Request;
import com.serena.dmclient.api.SystemAttributes;
/**
* Example showing how to find all of the item revisions (regardless of which
* project those revisions are contained within) related to a Request object.
* Note that, because we are not specifying a project, it is not possible to
* retrieve filenames for the item revisions, only their specifications.
*/
public final class RequestRelatedItems {
public static void main(final String[] args) {
// if (args.length != 5) {
// usage();
// }
// connect using the command-line arguments.
DimensionsConnectionDetails details = new DimensionsConnectionDetails();
PropertyReader prop = PropertyReader.getInstance();
details.setUsername(prop.getUsername());
details.setPassword(prop.getPassword());
details.setDbName(prop.getDbName());
details.setDbConn(prop.getDbConn());
details.setServer(prop.getServer());
DimensionsConnection connection = DimensionsConnectionManager
.getConnection(details);
try {
listRequestRelatedItems(connection);
} finally {
// disconnect.
connection.close();
}
}
static void listRequestRelatedItems(final DimensionsConnection connection) {
// find the request QLARIUS_CR_1 - note that normally you would have
// obtained a Request instance through some other means than this.
Request requestObj = connection.getObjectFactory().findRequest(
"TERMINAL_P3_0_0_344");
// all items live in the "global" project, however because filenames
// of items can differ from project to project, the filename from the
// global project may not be the same as it is in the project you are
// interested in.
Project globalProjectObj = connection.getObjectFactory()
.getGlobalProject();
// getChildItems from the global project will return all items that
// may be in any project. However, the resulting ItemRevision instances
// are scoped to the global project, not the current project.
// the flushRelatedObjects calls may or may not be necessary depending
// how up-to-date your version of the API JAR files is (it is safer
// to do it).
requestObj.flushRelatedObjects(ItemRevision.class, true);
List relObjs = requestObj.getChildItems(null, globalProjectObj);
requestObj.flushRelatedObjects(ItemRevision.class, true);
// note that some items may appear more than once (for the
// Affected revisions and the In Response To revision).
List revObjs = new ArrayList(relObjs.size());
for (int i = 0; i < relObjs.size(); ++i) {
DimensionsRelatedObject relObj = (DimensionsRelatedObject) relObjs
.get(i);
ItemRevision revObj = (ItemRevision) relObj.getObject();
revObjs.add(revObj);
}
// Because the ItemRevision objects are in the scope of the global
// project, if we query filename then we'll get the filename in the
// global project.
int[] attrs = {
SystemAttributes.OBJECT_ID,
SystemAttributes.OBJECT_SPEC,
SystemAttributes.REVISION,
SystemAttributes.FULL_PATH_NAME
};
BulkOperator bulk = connection.getObjectFactory().getBulkOperator(
revObjs);
bulk.queryAttribute(attrs);
// now display them.
for (int i = 0; i < revObjs.size(); ++i) {
ItemRevision revObj = (ItemRevision) revObjs.get(i);
String itemSpec = (String) revObj
.getAttribute(SystemAttributes.FULL_PATH_NAME);
String revision = (String) revObj
.getAttribute(SystemAttributes.REVISION);
System.out.println((i + 1) + ". " + itemSpec + " " + revision);
}
}
private static void usage() {
System.err.println("java " + RequestRelatedItems.class.getName()
+ " \\");
System.err.println(" {userID} {password} {dbName} {dbConn} {server}");
System.exit(1);
}
}
| [
"showaid@cyberlogitec.com"
] | showaid@cyberlogitec.com |
6e9c73c4035f5d3c7edbbdcedee4b1cabdc15604 | 8a3061ef1d175ac0a8bce621186c3258e9dd6eca | /src/main/java/algorithm/chapter_2_listproblem/Problem_03_RemoveNodeByRatio.java | 96657ee7b4b32364dc627273a821558c03acdaeb | [] | no_license | hugo980521/Algorithm | cc0c2a5bc730922713192104ca23dcb9407f42f7 | 767903fa25c106b0b9c32862a30638e820f869e1 | refs/heads/master | 2022-12-27T22:44:58.263668 | 2019-09-03T10:04:59 | 2019-09-03T10:04:59 | 203,977,881 | 0 | 0 | null | 2022-12-16T00:47:32 | 2019-08-23T10:30:59 | Java | UTF-8 | Java | false | false | 1,660 | java | package algorithm.chapter_2_listproblem;
public class Problem_03_RemoveNodeByRatio {
public static class Node {
public int value;
public Node next;
public Node(int data) {
this.value = data;
}
}
public static Node removeMidNode(Node head) {
if (head == null || head.next == null) {
return head;
}
if (head.next.next == null) {
return head.next;
}
Node pre = head;
Node cur = head.next.next;
while (cur.next != null && cur.next.next != null) {
pre = pre.next;
cur = cur.next.next;
}
pre.next = pre.next.next;
return head;
}
public static Node removeByRatio(Node head, int a, int b) {
if (a < 1 || a > b) {
return head;
}
int n = 0;
Node cur = head;
while (cur != null) {
n++;
cur = cur.next;
}
n = (int) Math.ceil(((double) (a * n)) / (double) b);
if (n == 1) {
head = head.next;
}
if (n > 1) {
cur = head;
while (--n != 1) {
cur = cur.next;
}
cur.next = cur.next.next;
}
return head;
}
public static void printLinkedList(Node head) {
System.out.print("Linked List: ");
while (head != null) {
System.out.print(head.value + " ");
head = head.next;
}
System.out.println();
}
public static void main(String[] args) {
Node head = new Node(1);
head.next = new Node(2);
head.next.next = new Node(3);
head.next.next.next = new Node(4);
head.next.next.next.next = new Node(5);
head.next.next.next.next.next = new Node(6);
printLinkedList(head);
head = removeMidNode(head);
printLinkedList(head);
head = removeByRatio(head, 2, 5);
printLinkedList(head);
head = removeByRatio(head, 1, 3);
printLinkedList(head);
}
}
| [
"chuanmeng.li@tendcloud.com"
] | chuanmeng.li@tendcloud.com |
dd2d473adb8cbfb8eda071284a9a6fa593ac410c | 5407585b7749d94f5a882eee6f7129afc6f79720 | /dm-code/dm-service/src/main/java/org/finra/dm/service/impl/EmrServiceImpl.java | 241ef8956f0318d5a1c3fcfb15932701deb4b8e6 | [
"Apache-2.0"
] | permissive | walw/herd | 67144b0192178050118f5572c5aa271e1525e14f | e236f8f4787e62d5ebf5e1a55eda696d75c5d3cf | refs/heads/master | 2021-01-14T14:16:23.163693 | 2015-10-08T14:23:54 | 2015-10-08T14:23:54 | 43,558,552 | 0 | 1 | null | 2015-10-02T14:50:59 | 2015-10-02T14:50:59 | null | UTF-8 | Java | false | false | 55,247 | java | /*
* Copyright 2015 herd contributors
*
* 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 org.finra.dm.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.xml.datatype.XMLGregorianCalendar;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.elasticmapreduce.model.Cluster;
import com.amazonaws.services.elasticmapreduce.model.ClusterSummary;
import com.amazonaws.services.elasticmapreduce.model.Step;
import com.amazonaws.services.elasticmapreduce.model.StepSummary;
import org.apache.http.HttpStatus;
import org.apache.oozie.client.WorkflowAction;
import org.apache.oozie.client.WorkflowJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.finra.dm.core.DmDateUtils;
import org.finra.dm.core.helper.ConfigurationHelper;
import org.finra.dm.dao.DmDao;
import org.finra.dm.dao.EmrDao;
import org.finra.dm.dao.OozieDao;
import org.finra.dm.dao.config.DaoSpringModuleConfig;
import org.finra.dm.dao.helper.DmStringHelper;
import org.finra.dm.dao.helper.EmrHelper;
import org.finra.dm.dao.helper.EmrPricingHelper;
import org.finra.dm.dao.helper.XmlHelper;
import org.finra.dm.dao.impl.OozieDaoImpl;
import org.finra.dm.model.ObjectNotFoundException;
import org.finra.dm.model.dto.AwsParamsDto;
import org.finra.dm.model.dto.ConfigurationValue;
import org.finra.dm.model.dto.EmrClusterAlternateKeyDto;
import org.finra.dm.model.jpa.EmrClusterCreationLogEntity;
import org.finra.dm.model.jpa.EmrClusterDefinitionEntity;
import org.finra.dm.model.jpa.NamespaceEntity;
import org.finra.dm.model.api.xml.EmrCluster;
import org.finra.dm.model.api.xml.EmrClusterCreateRequest;
import org.finra.dm.model.api.xml.EmrClusterDefinition;
import org.finra.dm.model.api.xml.EmrMasterSecurityGroup;
import org.finra.dm.model.api.xml.EmrMasterSecurityGroupAddRequest;
import org.finra.dm.model.api.xml.EmrStep;
import org.finra.dm.model.api.xml.OozieWorkflowAction;
import org.finra.dm.model.api.xml.OozieWorkflowJob;
import org.finra.dm.model.api.xml.RunOozieWorkflowRequest;
import org.finra.dm.service.EmrService;
import org.finra.dm.service.helper.DmDaoHelper;
import org.finra.dm.service.helper.DmHelper;
import org.finra.dm.service.helper.EmrStepHelper;
import org.finra.dm.service.helper.EmrStepHelperFactory;
/**
* The EMR service implementation.
*/
@Service
@Transactional(value = DaoSpringModuleConfig.DM_TRANSACTION_MANAGER_BEAN_NAME)
public class EmrServiceImpl implements EmrService
{
@Autowired
private DmDaoHelper dmDaoHelper;
@Autowired
private EmrHelper emrHelper;
@Autowired
private EmrPricingHelper emrPricingHelper;
@Autowired
private EmrDao emrDao;
@Autowired
private DmHelper dmHelper;
@Autowired
protected XmlHelper xmlHelper;
@Autowired
private ConfigurationHelper configurationHelper;
@Autowired
private EmrStepHelperFactory emrStepHelperFactory;
@Autowired
private DmDao dmDao;
@Autowired
private OozieDao oozieDao;
@Autowired
private DmStringHelper dmStringHelper;
/**
* Gets details of an existing EMR Cluster. Creates its own transaction.
*
* @param emrClusterAlternateKeyDto, the EMR cluster alternate key
* @param emrClusterId, the cluster id of the cluster to get details
* @param emrStepId, the step id of the step to get details
* @param verbose, parameter for whether to return detailed information
* @param retrieveOozieJobs parameter for whether to retrieve oozie job information
*
* @return the EMR Cluster object with details.
* @throws Exception
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EmrCluster getCluster(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, String emrClusterId, String emrStepId, boolean verbose,
boolean retrieveOozieJobs) throws Exception
{
return getClusterImpl(emrClusterAlternateKeyDto, emrClusterId, emrStepId, verbose, retrieveOozieJobs);
}
/**
* Gets details of an existing EMR Cluster.
*
* @param emrClusterAlternateKeyDto the EMR cluster alternate key
* @param emrClusterId the cluster id of the cluster to get details
* @param emrStepId the step id of the step to get details
* @param verbose parameter for whether to return detailed information
* @param retrieveOozieJobs parameter for whether to retrieve oozie job information
*
* @return the EMR Cluster object with details.
* @throws Exception if an error occurred while getting the cluster.
*/
protected EmrCluster getClusterImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, String emrClusterId, String emrStepId, boolean verbose,
boolean retrieveOozieJobs) throws Exception
{
// Perform the request validation.
emrHelper.validateEmrClusterKey(emrClusterAlternateKeyDto);
// Get the namespace and ensure it exists.
NamespaceEntity namespaceEntity = dmDaoHelper.getNamespaceEntity(emrClusterAlternateKeyDto.getNamespace());
// Get the EMR cluster definition and ensure it exists.
EmrClusterDefinitionEntity emrClusterDefinitionEntity =
dmDaoHelper.getEmrClusterDefinitionEntity(emrClusterAlternateKeyDto.getNamespace(), emrClusterAlternateKeyDto.getEmrClusterDefinitionName());
EmrCluster emrCluster =
createEmrClusterFromRequest(null, namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName(),
null, null, null, null);
String clusterName =
emrHelper.buildEmrClusterName(namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName());
try
{
// Get Cluster status if clusterId is specified
if (StringUtils.hasText(emrClusterId))
{
Cluster cluster = emrDao.getEmrClusterById(emrClusterId.trim(), emrHelper.getAwsParamsDto());
// Validate that, Cluster exists
Assert.notNull(cluster, "An EMR cluster must exists with the cluster ID \"" + emrClusterId + "\".");
// Validate that, Cluster name match as specified
Assert.isTrue(clusterName.equalsIgnoreCase(cluster.getName()),
"Cluster name of specified cluster id \"" + emrClusterId + "\" must match the name specified.");
emrCluster.setId(cluster.getId());
emrCluster.setStatus(cluster.getStatus().getState());
}
else
{
ClusterSummary clusterSummary = emrDao.getActiveEmrClusterByName(clusterName, emrHelper.getAwsParamsDto());
// Validate that, Cluster exists with the name
Assert.notNull(clusterSummary, "An EMR cluster must exists with the name \"" + clusterName + "\".");
emrCluster.setId(clusterSummary.getId());
emrCluster.setStatus(clusterSummary.getStatus().getState());
}
// Get active step details
if (emrHelper.isActiveEmrState(emrCluster.getStatus()))
{
StepSummary stepSummary = emrDao.getClusterActiveStep(emrCluster.getId(), emrHelper.getAwsParamsDto());
if (stepSummary != null)
{
EmrStep activeStep;
// If verbose get active step details
if (verbose)
{
activeStep = buildEmrStepFromAwsStep(emrDao.getClusterStep(emrCluster.getId(), stepSummary.getId(), emrHelper.getAwsParamsDto()), true);
}
else
{
activeStep = buildEmrStepFromAwsStepSummary(stepSummary);
}
emrCluster.setActiveStep(activeStep);
}
}
// Get requested step details
if (StringUtils.hasText(emrStepId))
{
Step step = emrDao.getClusterStep(emrCluster.getId(), emrStepId.trim(), emrHelper.getAwsParamsDto());
emrCluster.setStep(buildEmrStepFromAwsStep(step, verbose));
}
// Get oozie job details if requested.
if (retrieveOozieJobs && (emrCluster.getStatus().equalsIgnoreCase("RUNNING") || emrCluster.getStatus().equalsIgnoreCase("WAITING")))
{
emrCluster.setOozieWorkflowJobs(retrieveOozieJobs(emrCluster.getId()));
}
}
catch (AmazonServiceException ex)
{
handleAmazonException(ex, "An Amazon exception occurred while getting EMR cluster details with name \"" + clusterName + "\".");
}
return emrCluster;
}
/**
* Retrieves the List of running oozie workflow jobs on the cluster.
*
* @param clusterId the cluster Id
*
* @return the List of running oozie workflow jobs on the cluster.
* @throws Exception
*/
private List<OozieWorkflowJob> retrieveOozieJobs(String clusterId) throws Exception
{
// Retrieve cluster's master instance IP
String masterIpAddress = getEmrClusterMasterIpAddress(clusterId);
// Number of jobs to be included in the response.
int jobsToInclude = dmStringHelper.getConfigurationValueAsInteger(ConfigurationValue.EMR_OOZIE_JOBS_TO_INCLUDE_IN_CLUSTER_STATUS);
// List of wrapper jobs that have been found.
List<WorkflowJob> jobsFound = oozieDao.getRunningEmrOozieJobsByName(masterIpAddress, OozieDaoImpl.DM_OOZIE_WRAPPER_WORKFLOW_NAME, 1, jobsToInclude);
// Construct the response
List<OozieWorkflowJob> oozieWorkflowJobs = new ArrayList<>();
for (WorkflowJob workflowJob : jobsFound)
{
// Get the client Workflow id.
WorkflowAction clientWorkflowAction = emrHelper.getClientWorkflowAction(workflowJob);
OozieWorkflowJob resultOozieWorkflowJob = new OozieWorkflowJob();
resultOozieWorkflowJob.setId(workflowJob.getId());
// If client workflow is null means that DM wrapper workflow has not started the client workflow yet.
// Hence return status that it is still in DM preparation.
if (clientWorkflowAction == null)
{
resultOozieWorkflowJob.setStatus(OozieDaoImpl.OOZIE_WORKFLOW_JOB_STATUS_DM_PREP);
}
else
{
resultOozieWorkflowJob.setStartTime(toXmlGregorianCalendar(clientWorkflowAction.getStartTime()));
resultOozieWorkflowJob.setStatus(workflowJob.getStatus().toString());
}
oozieWorkflowJobs.add(resultOozieWorkflowJob);
}
return oozieWorkflowJobs;
}
/**
* Builds EmrStep object from the EMR step. Fills in details if verbose=true.
*/
private EmrStep buildEmrStepFromAwsStep(Step step, boolean verbose)
{
EmrStep emrStep = new EmrStep();
emrStep.setId(step.getId());
emrStep.setStepName(step.getName());
emrStep.setStatus(step.getStatus().getState());
if (verbose)
{
emrStep.setJarLocation(step.getConfig().getJar());
emrStep.setMainClass(step.getConfig().getMainClass());
emrStep.setScriptArguments(step.getConfig().getArgs());
emrStep.setContinueOnError(step.getActionOnFailure());
}
return emrStep;
}
/**
* Builds EmrStep object from the EMR StepSummary. Fills in details if verbose=true.
*/
private EmrStep buildEmrStepFromAwsStepSummary(StepSummary stepSummary)
{
EmrStep emrStep = new EmrStep();
emrStep.setId(stepSummary.getId());
emrStep.setStepName(stepSummary.getName());
emrStep.setStatus(stepSummary.getStatus().getState());
return emrStep;
}
/**
* Creates a new EMR Cluster. Creates its own transaction.
*
* @param request the EMR cluster create request
*
* @return the created EMR cluster object
* @throws Exception if there were any errors while creating the cluster.
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EmrCluster createCluster(EmrClusterCreateRequest request) throws Exception
{
return createClusterImpl(request);
}
/**
* <p> Creates a new EMR cluster based on the given request if the cluster with the given name does not already exist. If the cluster already exist, returns
* the information about the existing cluster. </p> <p> The request must contain: </p> <ul> <li>A namespace and definition name which refer to an existing
* EMR cluster definition.</li> <li>A valid cluster name to create.</li> </ul> <p> The request may optionally contain: </p> <ul> <li>A "dry run" flag, which
* when set to {@code true}, no calls to AWS will occur, but validations and override will. Defaults to {@code false}.</li> <li>An override parameter, which
* when set, overrides the given parameters in the cluster definition before creating the cluster. Defaults to no override. </li> </ul> <p> A successful
* response will contain: </p> <ul> <li>The ID of the cluster that was created, or if the cluster already exists, the ID of the cluster that exists. This
* field will be {@code null} when dry run flag is {@code true}.</li> <li>The status of the cluster that was created or already exists. The status will
* normally be "Starting" on successful creations. This field will be {@code null} when dry run flag is {@code true}</li> <li>The namespace, definition
* name, and cluster name of the cluster.</li> <li>The dry run flag, if given in the request.</li> <li>An indicator whether the cluster was created or not.
* If the cluster already exists, the cluster will not be created and this flag will be set to {@code false}.</li> <li>The definition which was used to
* create the cluster. If any overrides were given, this definition's values will be the values after the override. This field will be {@code null} if the
* cluster was not created.</li> </ul> <p> Notes: </p> <ul> <li>At any point of the execution, if there are validation errors, the method will immediately
* throw an exception.</li> <li>Even if the validations pass, AWS may still reject the request, which will cause this method to throw an exception.</li>
* <li>Dry runs do not make any calls to AWS, therefore AWS may still reject the creation request even when a dry run succeeds.</li> </ul>
*
* @param request - {@link EmrClusterCreateRequest} The EMR cluster create request
*
* @return {@link EmrCluster} the created EMR cluster object
* @throws Exception when the original EMR cluster definition XML is malformed
*/
protected EmrCluster createClusterImpl(EmrClusterCreateRequest request) throws Exception
{
AwsParamsDto awsParamsDto = emrHelper.getAwsParamsDto();
// Extract EMR cluster alternate key from the create request.
EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = getEmrClusterAlternateKey(request);
// Perform the request validation.
emrHelper.validateEmrClusterKey(emrClusterAlternateKeyDto);
// Get the namespace and ensure it exists.
NamespaceEntity namespaceEntity = dmDaoHelper.getNamespaceEntity(emrClusterAlternateKeyDto.getNamespace());
// Get the EMR cluster definition and ensure it exists.
EmrClusterDefinitionEntity emrClusterDefinitionEntity =
dmDaoHelper.getEmrClusterDefinitionEntity(emrClusterAlternateKeyDto.getNamespace(), emrClusterAlternateKeyDto.getEmrClusterDefinitionName());
// Replace all S3 managed location variables in xml
String toReplace = getS3ManagedReplaceString();
String replacedConfigXml = emrClusterDefinitionEntity.getConfiguration().replaceAll(toReplace, emrHelper.getS3StagingLocation());
// Unmarshal definition xml into JAXB object.
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, replacedConfigXml);
// Perform override if override is set
overrideEmrClusterDefinition(emrClusterDefinition, request.getEmrClusterDefinitionOverride());
// Perform the EMR cluster definition configuration validation.
dmHelper.validateEmrClusterDefinitionConfiguration(emrClusterDefinition);
// Find best price and update definition
emrPricingHelper.updateEmrClusterDefinitionWithBestPrice(emrClusterDefinition);
String clusterId = null; // The cluster ID record.
String emrClusterStatus = null;
Boolean emrClusterCreated = null; // Was cluster created?
// If the dryRun flag is null or false. This is the default option if no flag is given.
if (!Boolean.TRUE.equals(request.isDryRun()))
{
/*
* Create the cluster only if the cluster does not already exist.
* If the cluster is created, record the newly created cluster ID.
* If the cluster already exists, record the existing cluster ID.
* If there is any error while attempting to check for existing cluster or create a new one, handle the exception to throw appropriate exception.
*/
String clusterName =
emrHelper.buildEmrClusterName(namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName());
try
{
ClusterSummary clusterSummary = emrDao.getActiveEmrClusterByName(clusterName, awsParamsDto);
// If cluster does not already exist.
if (clusterSummary == null)
{
clusterId = emrDao.createEmrCluster(clusterName, emrClusterDefinition, awsParamsDto);
emrClusterCreated = true;
EmrClusterCreationLogEntity emrClusterCreationLogEntity = new EmrClusterCreationLogEntity();
emrClusterCreationLogEntity.setNamespace(emrClusterDefinitionEntity.getNamespace());
emrClusterCreationLogEntity.setEmrClusterDefinitionName(emrClusterDefinitionEntity.getName());
emrClusterCreationLogEntity.setEmrClusterName(emrClusterAlternateKeyDto.getEmrClusterName());
emrClusterCreationLogEntity.setEmrClusterId(clusterId);
emrClusterCreationLogEntity.setEmrClusterDefinition(xmlHelper.objectToXml(emrClusterDefinition));
dmDao.saveAndRefresh(emrClusterCreationLogEntity);
}
// If the cluster already exist.
else
{
clusterId = clusterSummary.getId();
emrClusterCreated = false;
emrClusterDefinition = null; // Do not include definition in response
}
emrClusterStatus = emrDao.getEmrClusterStatusById(clusterId, awsParamsDto);
}
catch (AmazonServiceException ex)
{
handleAmazonException(ex, "An Amazon exception occurred while creating EMR cluster with name \"" + clusterName + "\".");
}
}
// If the dryRun flag is true and not null
else
{
emrClusterCreated = false;
}
return createEmrClusterFromRequest(clusterId, namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(),
emrClusterAlternateKeyDto.getEmrClusterName(), emrClusterStatus, emrClusterCreated, request.isDryRun(), emrClusterDefinition);
}
/**
* <p> Overrides the properties of {@code emrClusterDefinition} with the properties of {@code emrClusterDefinitionOverride}. </p> <p> If any property in
* {@code emrClusterDefinitionOverride} is {@code null}, the property will remain unmodified. </p> <p> If any property in {@code
* emrClusterDefinitionOverride} is not {@code null}, the property will be set. </p> <p> Any list or object type properties will be shallowly overridden.
* That is, if a list is given in the override, the entire list will be set. Note that this is a shallow copy operation, so any modification to the override
* list or object will affect the definition. </p> <p> This method does nothing if {@code emrClusterDefinitionOverride} is {@code null}. </p>
*
* @param emrClusterDefinition - definition to override
* @param emrClusterDefinitionOverride - the override value or {@code null}
*/
@SuppressWarnings("PMD.CyclomaticComplexity") // Method is not complex. It's just very repetitive.
private void overrideEmrClusterDefinition(EmrClusterDefinition emrClusterDefinition, EmrClusterDefinition emrClusterDefinitionOverride)
{
if (emrClusterDefinitionOverride != null)
{
if (emrClusterDefinitionOverride.getReleaseLabel() != null)
{
emrClusterDefinition.setReleaseLabel(emrClusterDefinitionOverride.getReleaseLabel());
}
if (emrClusterDefinitionOverride.getApplications() != null)
{
emrClusterDefinition.setApplications(emrClusterDefinitionOverride.getApplications());
}
if (emrClusterDefinitionOverride.getConfigurations() != null)
{
emrClusterDefinition.setConfigurations(emrClusterDefinitionOverride.getConfigurations());
}
if (emrClusterDefinitionOverride.getSshKeyPairName() != null)
{
emrClusterDefinition.setSshKeyPairName(emrClusterDefinitionOverride.getSshKeyPairName());
}
if (emrClusterDefinitionOverride.getSubnetId() != null)
{
emrClusterDefinition.setSubnetId(emrClusterDefinitionOverride.getSubnetId());
}
if (emrClusterDefinitionOverride.getLogBucket() != null)
{
emrClusterDefinition.setLogBucket(emrClusterDefinitionOverride.getLogBucket());
}
if (emrClusterDefinitionOverride.isKeepAlive() != null)
{
emrClusterDefinition.setKeepAlive(emrClusterDefinitionOverride.isKeepAlive());
}
if (emrClusterDefinitionOverride.isVisibleToAll() != null)
{
emrClusterDefinition.setVisibleToAll(emrClusterDefinitionOverride.isVisibleToAll());
}
if (emrClusterDefinitionOverride.isTerminationProtection() != null)
{
emrClusterDefinition.setTerminationProtection(emrClusterDefinitionOverride.isTerminationProtection());
}
if (emrClusterDefinitionOverride.isEncryptionEnabled() != null)
{
emrClusterDefinition.setEncryptionEnabled(emrClusterDefinitionOverride.isEncryptionEnabled());
}
if (emrClusterDefinitionOverride.getAmiVersion() != null)
{
emrClusterDefinition.setAmiVersion(emrClusterDefinitionOverride.getAmiVersion());
}
if (emrClusterDefinitionOverride.getHadoopVersion() != null)
{
emrClusterDefinition.setHadoopVersion(emrClusterDefinitionOverride.getHadoopVersion());
}
if (emrClusterDefinitionOverride.getHiveVersion() != null)
{
emrClusterDefinition.setHiveVersion(emrClusterDefinitionOverride.getHiveVersion());
}
if (emrClusterDefinitionOverride.getPigVersion() != null)
{
emrClusterDefinition.setPigVersion(emrClusterDefinitionOverride.getPigVersion());
}
if (emrClusterDefinitionOverride.getEc2NodeIamProfileName() != null)
{
emrClusterDefinition.setEc2NodeIamProfileName(emrClusterDefinitionOverride.getEc2NodeIamProfileName());
}
if (emrClusterDefinitionOverride.isInstallOozie() != null)
{
emrClusterDefinition.setInstallOozie(emrClusterDefinitionOverride.isInstallOozie());
}
if (emrClusterDefinitionOverride.getCustomBootstrapActionMaster() != null)
{
emrClusterDefinition.setCustomBootstrapActionMaster(emrClusterDefinitionOverride.getCustomBootstrapActionMaster());
}
if (emrClusterDefinitionOverride.getCustomBootstrapActionAll() != null)
{
emrClusterDefinition.setCustomBootstrapActionAll(emrClusterDefinitionOverride.getCustomBootstrapActionAll());
}
if (emrClusterDefinitionOverride.getAdditionalInfo() != null)
{
emrClusterDefinition.setAdditionalInfo(emrClusterDefinitionOverride.getAdditionalInfo());
}
if (emrClusterDefinitionOverride.getInstanceDefinitions() != null)
{
emrClusterDefinition.setInstanceDefinitions(emrClusterDefinitionOverride.getInstanceDefinitions());
}
if (emrClusterDefinitionOverride.getNodeTags() != null)
{
emrClusterDefinition.setNodeTags(emrClusterDefinitionOverride.getNodeTags());
}
if (emrClusterDefinitionOverride.getDaemonConfigurations() != null)
{
emrClusterDefinition.setDaemonConfigurations(emrClusterDefinitionOverride.getDaemonConfigurations());
}
if (emrClusterDefinitionOverride.getHadoopConfigurations() != null)
{
emrClusterDefinition.setHadoopConfigurations(emrClusterDefinitionOverride.getHadoopConfigurations());
}
if (emrClusterDefinitionOverride.getServiceIamRole() != null)
{
emrClusterDefinition.setServiceIamRole(emrClusterDefinitionOverride.getServiceIamRole());
}
if (emrClusterDefinitionOverride.getSupportedProduct() != null)
{
emrClusterDefinition.setSupportedProduct(emrClusterDefinitionOverride.getSupportedProduct());
}
if (emrClusterDefinitionOverride.getHadoopJarSteps() != null)
{
emrClusterDefinition.setHadoopJarSteps(emrClusterDefinitionOverride.getHadoopJarSteps());
}
}
}
/**
* Terminates the EMR Cluster. Creates its own transaction.
*
* @param emrClusterAlternateKeyDto, the EMR cluster alternate key
* @param overrideTerminationProtection, parameter for whether to override termination protection
*
* @return the terminated EMR cluster object
* @throws Exception if there were any errors while terminating the cluster.
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EmrCluster terminateCluster(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, boolean overrideTerminationProtection) throws Exception
{
return terminateClusterImpl(emrClusterAlternateKeyDto, overrideTerminationProtection);
}
/**
* Terminates the EMR Cluster.
*
* @param emrClusterAlternateKeyDto the EMR cluster alternate key
* @param overrideTerminationProtection parameter for whether to override termination protection
*
* @return the terminated EMR cluster object
* @throws Exception if there were any errors while terminating the cluster.
*/
protected EmrCluster terminateClusterImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, boolean overrideTerminationProtection) throws Exception
{
AwsParamsDto awsParamsDto = emrHelper.getAwsParamsDto();
// Perform the request validation.
emrHelper.validateEmrClusterKey(emrClusterAlternateKeyDto);
// Get the namespace and ensure it exists.
NamespaceEntity namespaceEntity = dmDaoHelper.getNamespaceEntity(emrClusterAlternateKeyDto.getNamespace());
// Get the EMR cluster definition and ensure it exists.
EmrClusterDefinitionEntity emrClusterDefinitionEntity =
dmDaoHelper.getEmrClusterDefinitionEntity(emrClusterAlternateKeyDto.getNamespace(), emrClusterAlternateKeyDto.getEmrClusterDefinitionName());
String clusterId = null;
String clusterName =
emrHelper.buildEmrClusterName(namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName());
try
{
clusterId = emrDao.terminateEmrCluster(clusterName, overrideTerminationProtection, awsParamsDto);
}
catch (AmazonServiceException ex)
{
handleAmazonException(ex, "An Amazon exception occurred while terminating EMR cluster with name \"" + clusterName + "\".");
}
return createEmrClusterFromRequest(clusterId, namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(),
emrClusterAlternateKeyDto.getEmrClusterName(), emrDao.getEmrClusterStatusById(clusterId, awsParamsDto), null, null, null);
}
/**
* Creates a EMR cluster alternate key from the relative values in the EMR Cluster Create Request.
*
* @param emrClusterCreateRequest the EMR cluster create request
*
* @return the EMR cluster alternate key
*/
private EmrClusterAlternateKeyDto getEmrClusterAlternateKey(EmrClusterCreateRequest emrClusterCreateRequest)
{
return EmrClusterAlternateKeyDto.builder().namespace(emrClusterCreateRequest.getNamespace())
.emrClusterDefinitionName(emrClusterCreateRequest.getEmrClusterDefinitionName()).emrClusterName(emrClusterCreateRequest.getEmrClusterName())
.build();
}
/**
* Creates a new EMR cluster object from request.
*
* @param clusterId the cluster Id.
* @param namespaceCd the namespace Code
* @param clusterDefinitionName the cluster definition
* @param clusterName the cluster name
* @param clusterStatus the cluster status
* @param emrClusterCreated whether EMR cluster was created.
* @param dryRun The dry run flag.
* @param emrClusterDefinition the EMR cluster definition.
*
* @return the created EMR cluster object
*/
private EmrCluster createEmrClusterFromRequest(String clusterId, String namespaceCd, String clusterDefinitionName, String clusterName, String clusterStatus,
Boolean emrClusterCreated, Boolean dryRun, EmrClusterDefinition emrClusterDefinition)
{
// Create the EMR cluster.
EmrCluster emrCluster = new EmrCluster();
emrCluster.setId(clusterId);
emrCluster.setNamespace(namespaceCd);
emrCluster.setEmrClusterDefinitionName(clusterDefinitionName);
emrCluster.setEmrClusterName(clusterName);
emrCluster.setStatus(clusterStatus);
emrCluster.setDryRun(dryRun);
emrCluster.setEmrClusterCreated(emrClusterCreated);
emrCluster.setEmrClusterDefinition(emrClusterDefinition);
return emrCluster;
}
/**
* Adds step to an existing EMR Cluster. Creates its own transaction.
* <p/>
* There are five serializable objects supported currently. They are 1: ShellStep - For shell scripts 2: OozieStep - For Oozie workflow xml files 3:
* HiveStep - For hive scripts 4: HadoopJarStep - For Custom Map Reduce Jar files and 5: PigStep - For Pig scripts.
*
* @param request the EMR steps add request
*
* @return the EMR steps add object with added steps
* @throws Exception if there were any errors while adding a step to the cluster.
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Object addStepToCluster(Object request) throws Exception
{
return addStepToClusterImpl(request);
}
/**
* Adds step to an existing EMR Cluster.
*
* @param request the EMR steps add request
*
* @return the EMR step add object with added steps
* @throws Exception if there were any errors while adding a step to the cluster.
*/
protected Object addStepToClusterImpl(Object request) throws Exception
{
EmrStepHelper stepHelper = emrStepHelperFactory.getStepHelper(request.getClass().getName());
// Perform the request validation.
validateAddStepToClusterRequest(request, stepHelper);
// Perform the step specific validation
stepHelper.validateAddStepRequest(request);
// Get the namespace and ensure it exists.
NamespaceEntity namespaceEntity = dmDaoHelper.getNamespaceEntity(stepHelper.getRequestNamespace(request));
// Get the EMR cluster definition and ensure it exists.
EmrClusterDefinitionEntity emrClusterDefinitionEntity =
dmDaoHelper.getEmrClusterDefinitionEntity(stepHelper.getRequestNamespace(request), stepHelper.getRequestEmrClusterDefinitionName(request));
// Update the namespace and cluster definition name in request from database.
stepHelper.setRequestNamespace(request, namespaceEntity.getCode());
stepHelper.setRequestEmrClusterDefinitionName(request, emrClusterDefinitionEntity.getName());
String clusterName =
emrHelper.buildEmrClusterName(namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), stepHelper.getRequestEmrClusterName(request));
Object emrStep = stepHelper.buildResponseFromRequest(request);
try
{
String stepId = emrDao.addEmrStep(clusterName, stepHelper.getEmrStepConfig(emrStep), emrHelper.getAwsParamsDto());
stepHelper.setStepId(emrStep, stepId);
}
catch (AmazonServiceException ex)
{
handleAmazonException(ex,
"An Amazon exception occurred while adding EMR step \"" + stepHelper.getRequestStepName(request) + "\" to cluster with name \"" + clusterName +
"\".");
}
return emrStep;
}
/**
* Validates the add steps to EMR cluster create request. This method also trims request parameters.
*
* @param request the request.
*
* @throws IllegalArgumentException if any validation errors were found.
*/
private void validateAddStepToClusterRequest(Object request, EmrStepHelper stepHelper) throws IllegalArgumentException
{
String namespace = stepHelper.getRequestNamespace(request);
String clusterDefinitionName = stepHelper.getRequestEmrClusterDefinitionName(request);
String clusterName = stepHelper.getRequestEmrClusterName(request);
// Validate required elements
Assert.hasText(namespace, "A namespace must be specified.");
Assert.hasText(clusterDefinitionName, "An EMR cluster definition name must be specified.");
Assert.hasText(clusterName, "An EMR cluster name must be specified.");
// Remove leading and trailing spaces.
stepHelper.setRequestNamespace(request, namespace.trim());
stepHelper.setRequestEmrClusterDefinitionName(request, clusterDefinitionName.trim());
stepHelper.setRequestEmrClusterName(request, clusterName.trim());
}
private String getS3ManagedReplaceString()
{
return configurationHelper.getProperty(ConfigurationValue.S3_STAGING_RESOURCE_LOCATION);
}
/**
* Adds security groups to the master node of an existing EMR Cluster. Creates its own transaction.
*
* @param request, the EMR master security group add request
*
* @return the added EMR master security groups
* @throws Exception if there were any errors adding the security groups to the cluster master.
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EmrMasterSecurityGroup addSecurityGroupsToClusterMaster(EmrMasterSecurityGroupAddRequest request) throws Exception
{
return addSecurityGroupsToClusterMasterImpl(request);
}
/**
* Adds security groups to the master node of an existing EMR Cluster.
*
* @param request the EMR master security group add request
*
* @return the added EMR master security groups
* @throws Exception if there were any errors adding the security groups to the cluster master.
*/
protected EmrMasterSecurityGroup addSecurityGroupsToClusterMasterImpl(EmrMasterSecurityGroupAddRequest request) throws Exception
{
// Perform the request validation.
validateAddSecurityGroupsToClusterMasterRequest(request);
// Get the namespace and ensure it exists.
NamespaceEntity namespaceEntity = dmDaoHelper.getNamespaceEntity(request.getNamespace());
// Get the EMR cluster definition and ensure it exists.
EmrClusterDefinitionEntity emrClusterDefinitionEntity =
dmDaoHelper.getEmrClusterDefinitionEntity(request.getNamespace(), request.getEmrClusterDefinitionName());
List<String> groupIds = null;
String clusterName = emrHelper.buildEmrClusterName(namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), request.getEmrClusterName());
try
{
groupIds = emrDao.addEmrMasterSecurityGroups(clusterName, request.getSecurityGroupIds(), emrHelper.getAwsParamsDto());
}
catch (AmazonServiceException ex)
{
handleAmazonException(ex,
"An Amazon exception occurred while adding EMR security groups: " + dmHelper.buildStringWithDefaultDelimiter(request.getSecurityGroupIds()) +
" to cluster: " + clusterName);
}
return createEmrClusterMasterGroupFromRequest(namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), request.getEmrClusterName(), groupIds);
}
/**
* Validates the add groups to EMR cluster master create request. This method also trims request parameters.
*
* @param request the request.
*
* @throws IllegalArgumentException if any validation errors were found.
*/
private void validateAddSecurityGroupsToClusterMasterRequest(EmrMasterSecurityGroupAddRequest request) throws IllegalArgumentException
{
// Validate required elements
Assert.hasText(request.getNamespace(), "A namespace must be specified.");
Assert.hasText(request.getEmrClusterDefinitionName(), "An EMR cluster definition name must be specified.");
Assert.hasText(request.getEmrClusterName(), "An EMR cluster name must be specified.");
Assert.notEmpty(request.getSecurityGroupIds(), "At least one security group must be specified.");
for (String securityGroup : request.getSecurityGroupIds())
{
Assert.hasText(securityGroup, "A security group value must be specified.");
}
// Remove leading and trailing spaces.
request.setNamespace(request.getNamespace().trim());
request.setEmrClusterDefinitionName(request.getEmrClusterDefinitionName().trim());
request.setEmrClusterName(request.getEmrClusterName().trim());
String[] trimmedGroups = new String[request.getSecurityGroupIds().size()];
trimmedGroups = StringUtils.trimArrayElements(request.getSecurityGroupIds().toArray(trimmedGroups));
request.setSecurityGroupIds(Arrays.asList(trimmedGroups));
}
/**
* Creates a new EMR master group object from request.
*
* @param namespaceCd, the namespace Code
* @param clusterDefinitionName, the cluster definition name
* @param clusterName, the cluster name
* @param groupIds, the List of groupId
*
* @return the created EMR master group object
*/
private EmrMasterSecurityGroup createEmrClusterMasterGroupFromRequest(String namespaceCd, String clusterDefinitionName, String clusterName,
List<String> groupIds)
{
// Create the EMR cluster.
EmrMasterSecurityGroup emrMasterSecurityGroup = new EmrMasterSecurityGroup();
emrMasterSecurityGroup.setNamespace(namespaceCd);
emrMasterSecurityGroup.setEmrClusterDefinitionName(clusterDefinitionName);
emrMasterSecurityGroup.setEmrClusterName(clusterName);
emrMasterSecurityGroup.setSecurityGroupIds(groupIds);
return emrMasterSecurityGroup;
}
/**
* Runs oozie job on an existing EMR Cluster. Creates its own transaction.
*
* @param request the Run oozie workflow request
*
* @return the oozie workflow job that was submitted.
* @throws Exception if there were any errors while submitting the job.
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public OozieWorkflowJob runOozieWorkflow(RunOozieWorkflowRequest request) throws Exception
{
return runOozieWorkflowImpl(request);
}
/**
* Runs oozie job on an existing EMR Cluster.
*
* @param request the Run oozie workflow request
*
* @return the oozie workflow job that was submitted.
* @throws Exception if there were any errors while submitting the job.
*/
protected OozieWorkflowJob runOozieWorkflowImpl(RunOozieWorkflowRequest request) throws Exception
{
// Perform the request validation.
validateRunOozieWorkflowRequest(request);
String namespace = request.getNamespace();
String emrClusterDefinitionName = request.getEmrClusterDefinitionName();
String emrClusterName = request.getEmrClusterName();
ClusterSummary clusterSummary = getRunningOrWaitingEmrCluster(namespace, emrClusterDefinitionName, emrClusterName);
String emrClusterPrivateIpAddress = getEmrClusterMasterIpAddress(clusterSummary.getId());
String jobId = oozieDao.runOozieWorkflow(emrClusterPrivateIpAddress, request.getWorkflowLocation(), request.getParameters());
OozieWorkflowJob oozieWorkflowJob = new OozieWorkflowJob();
oozieWorkflowJob.setId(jobId);
oozieWorkflowJob.setNamespace(namespace);
oozieWorkflowJob.setEmrClusterDefinitionName(emrClusterDefinitionName);
oozieWorkflowJob.setEmrClusterName(emrClusterName);
return oozieWorkflowJob;
}
/**
* Get the EMR master private IP address.
*
* @param emrClusterId the cluster id
*
* @return the master node private IP address
* @throws Exception Exception
*/
private String getEmrClusterMasterIpAddress(String emrClusterId) throws Exception
{
AwsParamsDto awsParamsDto = emrHelper.getAwsParamsDto();
return emrDao.getEmrMasterInstance(emrClusterId, awsParamsDto).getPrivateIpAddress();
}
/**
* Get the cluster in RUNNING or WAITING status.
*
* @param namespace namespace
* @param emrClusterDefinitionName emrClusterDefinitionName
* @param emrClusterName emrClusterName
*
* @return ClusterSummary
*/
private ClusterSummary getRunningOrWaitingEmrCluster(String namespace, String emrClusterDefinitionName, String emrClusterName)
{
// Get the namespace and ensure it exists.
NamespaceEntity namespaceEntity = dmDaoHelper.getNamespaceEntity(namespace);
// Get the EMR cluster definition and ensure it exists.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = dmDaoHelper.getEmrClusterDefinitionEntity(namespace, emrClusterDefinitionName);
String clusterName = emrHelper.buildEmrClusterName(namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), emrClusterName);
// Look up cluster
ClusterSummary clusterSummary = emrDao.getActiveEmrClusterByName(clusterName, emrHelper.getAwsParamsDto());
// We can only run oozie job when the cluster is up (RUNNING or WAITING). Can not submit job otherwise like bootstraping.
// Make sure that cluster exists and is in RUNNING or WAITING state.
if (clusterSummary == null ||
!(clusterSummary.getStatus().getState().equalsIgnoreCase("RUNNING") || clusterSummary.getStatus().getState().equalsIgnoreCase("WAITING")))
{
throw new ObjectNotFoundException(String.format("Either the cluster \"%s\" does not exist or not in RUNNING or WAITING state.", clusterName));
}
return clusterSummary;
}
/**
* Get the oozie workflow. Starts a new transaction.
*
* @param namespace the namespace
* @param emrClusterDefinitionName the EMR cluster definition name
* @param emrClusterName the EMR cluster name
* @param oozieWorkflowJobId the ooxie workflow Id.
* @param verbose the flag to indicate whether to return verbose information
*
* @return OozieWorkflowJob OozieWorkflowJob
* @throws Exception Exception
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public OozieWorkflowJob getEmrOozieWorkflowJob(String namespace, String emrClusterDefinitionName, String emrClusterName, String oozieWorkflowJobId,
Boolean verbose) throws Exception
{
return getEmrOozieWorkflowJobImpl(namespace, emrClusterDefinitionName, emrClusterName, oozieWorkflowJobId, verbose);
}
/**
* Get the oozie workflow.
*
* @param namespace the namespace
* @param emrClusterDefinitionName the EMR cluster definition name
* @param emrClusterName the EMR cluster name
* @param oozieWorkflowJobId the ooxie workflow Id.
* @param verbose the flag to indicate whether to return verbose information
*
* @return OozieWorkflowJob OozieWorkflowJob
* @throws Exception Exception
*/
protected OozieWorkflowJob getEmrOozieWorkflowJobImpl(String namespace, String emrClusterDefinitionName, String emrClusterName, String oozieWorkflowJobId,
Boolean verbose) throws Exception
{
// Validate parameters
Assert.isTrue(StringUtils.hasText(namespace), "Namespace is required");
Assert.isTrue(StringUtils.hasText(emrClusterDefinitionName), "EMR cluster definition name is required");
Assert.isTrue(StringUtils.hasText(emrClusterName), "EMR cluster name is required");
Assert.isTrue(StringUtils.hasText(oozieWorkflowJobId), "Oozie workflow job ID is required");
// Trim string parameters
String namespaceTrimmed = namespace.trim();
String emrClusterDefinitionNameTrimmed = emrClusterDefinitionName.trim();
String emrClusterNameTrimmed = emrClusterName.trim();
String oozieWorkflowJobIdTrimmed = oozieWorkflowJobId.trim();
// Retrieve cluster's master instance IP
ClusterSummary emrClusterSummary = getRunningOrWaitingEmrCluster(namespaceTrimmed, emrClusterDefinitionNameTrimmed, emrClusterNameTrimmed);
String masterIpAddress = getEmrClusterMasterIpAddress(emrClusterSummary.getId());
// Retrieve the wrapper oozie workflow. This workflow is the workflow that DM wraps the client's workflow to help copy client workflow definition from
// S3 to HDFS.
WorkflowJob wrapperWorkflowJob = oozieDao.getEmrOozieWorkflow(masterIpAddress, oozieWorkflowJobIdTrimmed);
// Check to make sure that the workflow job is a DM wrapper workflow.
Assert.isTrue(wrapperWorkflowJob.getAppName().equals(OozieDaoImpl.DM_OOZIE_WRAPPER_WORKFLOW_NAME),
"The oozie workflow with job ID '" + oozieWorkflowJobIdTrimmed + "' is not created by DM. Please ensure that the workflow was created through DM.");
// Retrieve the client workflow's job action by navigating through the actions of the wrapper workflow. The client's workflow job ID is represented as
// the action's external ID.
WorkflowAction clientWorkflowAction = emrHelper.getClientWorkflowAction(wrapperWorkflowJob);
WorkflowJob clientWorkflowJob = null;
String clientWorkflowStatus = null;
boolean hasClientWorkflowInfo = false;
WorkflowAction errorWrapperWorkflowAction = null;
/*
* If the client workflow action is not found, there are three possibilities:
* 1. DM_PREP: The client workflow has not yet been run.
* 2. DM_FAILED : DM wrapper workflow failed to run successfully.
* 3. If client workflow action is found but does not have the external ID, means that it failed to kick off the client workflow. Possible causes:
* 3.1 workflow.xml is not present in the location provided.
* 3.2 workflow.xml is not a valid workflow.
*/
if (clientWorkflowAction == null || clientWorkflowAction.getExternalId() == null)
{
// If wrapper workflow is FAILED/KILLED, means wrapper failed without running client workflow
// else DM_PREP
if (wrapperWorkflowJob.getStatus().equals(WorkflowJob.Status.KILLED) || wrapperWorkflowJob.getStatus().equals(WorkflowJob.Status.FAILED))
{
clientWorkflowStatus = OozieDaoImpl.OOZIE_WORKFLOW_JOB_STATUS_DM_FAILED;
// Get error information.
errorWrapperWorkflowAction = emrHelper.getFirstWorkflowActionInError(wrapperWorkflowJob);
}
else
{
clientWorkflowStatus = OozieDaoImpl.OOZIE_WORKFLOW_JOB_STATUS_DM_PREP;
}
}
else
{
// Retrieve the client workflow
clientWorkflowJob = oozieDao.getEmrOozieWorkflow(masterIpAddress, clientWorkflowAction.getExternalId());
hasClientWorkflowInfo = true;
}
// Construct result
OozieWorkflowJob resultOozieWorkflowJob = new OozieWorkflowJob();
resultOozieWorkflowJob.setId(oozieWorkflowJobId);
resultOozieWorkflowJob.setNamespace(namespace);
resultOozieWorkflowJob.setEmrClusterDefinitionName(emrClusterDefinitionName);
resultOozieWorkflowJob.setEmrClusterName(emrClusterName);
// If client workflow is information is not available that DM wrapper workflow has not started the client workflow yet or failed to start.
// Hence return status that it is still in DM preparation.
if (!hasClientWorkflowInfo)
{
resultOozieWorkflowJob.setStatus(clientWorkflowStatus);
if (errorWrapperWorkflowAction != null)
{
resultOozieWorkflowJob.setErrorCode(errorWrapperWorkflowAction.getErrorCode());
resultOozieWorkflowJob.setErrorMessage(errorWrapperWorkflowAction.getErrorMessage());
}
}
else
{
resultOozieWorkflowJob.setStartTime(toXmlGregorianCalendar(clientWorkflowJob.getStartTime()));
resultOozieWorkflowJob.setEndTime(toXmlGregorianCalendar(clientWorkflowJob.getEndTime()));
resultOozieWorkflowJob.setStatus(clientWorkflowJob.getStatus().toString());
// Construct actions in the result if verbose flag is explicitly true, default to false
if (Boolean.TRUE.equals(verbose))
{
List<OozieWorkflowAction> oozieWorkflowActions = new ArrayList<>();
for (WorkflowAction workflowAction : clientWorkflowJob.getActions())
{
OozieWorkflowAction resultOozieWorkflowAction = new OozieWorkflowAction();
resultOozieWorkflowAction.setId(workflowAction.getId());
resultOozieWorkflowAction.setName(workflowAction.getName());
resultOozieWorkflowAction.setStartTime(toXmlGregorianCalendar(workflowAction.getStartTime()));
resultOozieWorkflowAction.setEndTime(toXmlGregorianCalendar(workflowAction.getEndTime()));
resultOozieWorkflowAction.setStatus(workflowAction.getStatus().toString());
resultOozieWorkflowAction.setErrorCode(workflowAction.getErrorCode());
resultOozieWorkflowAction.setErrorMessage(workflowAction.getErrorMessage());
oozieWorkflowActions.add(resultOozieWorkflowAction);
}
resultOozieWorkflowJob.setWorkflowActions(oozieWorkflowActions);
}
}
return resultOozieWorkflowJob;
}
/**
* Builds the {@link XMLGregorianCalendar} for the given {@link Date}
*
* @param date date
*
* @return XMLGregorianCalendar
*/
private XMLGregorianCalendar toXmlGregorianCalendar(Date date)
{
XMLGregorianCalendar result = null;
if (date != null)
{
result = DmDateUtils.getXMLGregorianCalendarValue(date);
}
return result;
}
/**
* Validates the run oozie workflow request.
*
* @param request the request.
*
* @throws IllegalArgumentException if any validation errors were found.
*/
private void validateRunOozieWorkflowRequest(RunOozieWorkflowRequest request)
{
// Validate required elements
Assert.hasText(request.getNamespace(), "A namespace must be specified.");
Assert.hasText(request.getEmrClusterDefinitionName(), "An EMR cluster definition name must be specified.");
Assert.hasText(request.getEmrClusterName(), "An EMR cluster name must be specified.");
Assert.hasText(request.getWorkflowLocation(), "An oozie workflow location must be specified.");
// Validate that parameter names are there and not duplicate
dmHelper.validateParameters(request.getParameters());
// Remove leading and trailing spaces.
request.setNamespace(request.getNamespace().trim());
request.setEmrClusterDefinitionName(request.getEmrClusterDefinitionName().trim());
request.setEmrClusterName(request.getEmrClusterName().trim());
}
/**
* Handles the AmazonServiceException, throws corresponding exception based on status code in amazon exception.
*/
private void handleAmazonException(AmazonServiceException ex, String message) throws IllegalArgumentException, ObjectNotFoundException
{
if (ex.getStatusCode() == HttpStatus.SC_BAD_REQUEST)
{
throw new IllegalArgumentException(message + " Reason: " + ex.getMessage(), ex);
}
else if (ex.getStatusCode() == HttpStatus.SC_NOT_FOUND)
{
throw new ObjectNotFoundException(message + " Reason: " + ex.getMessage(), ex);
}
throw ex;
}
} | [
"mchao47@gmail.com"
] | mchao47@gmail.com |
4af426e4cbf76dd848917082cea2b80a2b0409d3 | e3ed7864bee05a2304f74aa0ea3503da9593fa7e | /slot-dist-adam2/src/clive/peer/membership/ShuffleResponse.java | 7e8cbf275fbe16f9e2c213e407a9b83637feeadd | [] | no_license | payberah/distro | 1142d13f66bc95d17f08b1adcc0dfe3838f7ed34 | c1ea273f45add843890974951dd71b1861a2a39d | refs/heads/master | 2021-01-10T05:26:27.688806 | 2015-05-27T13:56:18 | 2015-05-27T13:56:18 | 36,368,246 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,650 | java | package clive.peer.membership;
import java.util.UUID;
import clive.peer.common.MSMessage;
import clive.peer.common.MSPeerAddress;
public class ShuffleResponse extends MSMessage {
private static final long serialVersionUID = -5022051054665787770L;
private final UUID requestId;
private final DescriptorBuffer randomBuffer;
private double[] hitRatio;
private LockState lockstate;
private double v;
//-------------------------------------------------------------------
public ShuffleResponse(MSPeerAddress source, MSPeerAddress destination, UUID requestId, DescriptorBuffer randomBuffer, double[] hitRatio, LockState lockstate, double v) {
super(source, destination);
this.requestId = requestId;
this.randomBuffer = randomBuffer;
this.hitRatio = hitRatio;
this.lockstate = lockstate;
this.v = v;
}
//-------------------------------------------------------------------
public UUID getRequestId() {
return requestId;
}
//-------------------------------------------------------------------
public DescriptorBuffer getRandomBuffer() {
return randomBuffer;
}
//-------------------------------------------------------------------
public double[] getHitRatio() {
return hitRatio;
}
//-------------------------------------------------------------------
public double getV() {
return v;
}
//-------------------------------------------------------------------
public LockState getLockState() {
return lockstate;
}
//-------------------------------------------------------------------
public int getSize() {
return 0;
//return hitRatio.length;
}
}
| [
"amir@sics.se"
] | amir@sics.se |
9557c82d62e46bb7f29326a85c07998da85abe4b | c5d2de197f99d0c087fc59d8bac5d0c7989f2d09 | /src/com/cos/util/MyUtils.java | fc988801e2bab86182aea04a2f2edd0bf5ee699b | [] | no_license | SEOK8561/jhblog | 975a6f8f86b20250c772e832ed82045bba81e454 | a0e78a5c8b7226a13d646114366285753393dbfe | refs/heads/master | 2020-05-18T16:53:40.579856 | 2019-05-02T07:12:09 | 2019-05-02T07:12:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,098 | java | package com.cos.util;
import java.io.IOException;
import java.io.PrintWriter;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import javax.servlet.http.HttpServletResponse;
public class MyUtils {
public static LocalDate StringToLocalDate(String target) {
LocalDate result =
LocalDate.parse(
target,
DateTimeFormatter.
ofPattern("yyyy-MM-dd HH:mm:ss"));
return result;
}
public static void script(String msg, HttpServletResponse response) {
try {
PrintWriter script = response.getWriter();
script.println("<script>");
script.println("alert('"+msg+"')");
script.println("history.back()");
script.println("</script>");
} catch (IOException e) {
e.printStackTrace();
}
}
public static void script(String msg, String url, HttpServletResponse response) {
try {
PrintWriter script = response.getWriter();
script.println("<script>");
script.println("alert('"+msg+"')");
script.println("location.href='"+url+"'");
script.println("</script>");
} catch (IOException e) {
e.printStackTrace();
}
}
}
| [
"ssarmango@gmail.com"
] | ssarmango@gmail.com |
c5071510bc99faf8970673d649419bb517a19066 | 2c0edfcd9e6ddf16a88762a018589cbebe6fa8e8 | /CleanSheets/src/main/java/csheets/ext/macro_beanshell/ui/MacroBeanShellAction.java | d73049bbe02a88511f1fd3d3c3b41aa74f2a008c | [] | no_license | ABCurado/University-Projects | 7fb32b588f2c7fbe384ca947d25928b8d702d667 | 6c9475f5ef5604955bc21bb4f8b1d113a344d7ab | refs/heads/master | 2021-01-12T05:25:21.614584 | 2017-01-03T15:29:00 | 2017-01-03T15:29:00 | 77,926,226 | 1 | 3 | null | null | null | null | UTF-8 | Java | false | false | 971 | java | package csheets.ext.macro_beanshell.ui;
import csheets.CleanSheets;
import csheets.ui.ctrl.BaseAction;
import csheets.ui.ctrl.UIController;
import java.awt.event.ActionEvent;
import static javax.swing.Action.SMALL_ICON;
import javax.swing.ImageIcon;
/**
*
* @author Rui Bento
*/
public class MacroBeanShellAction extends BaseAction {
/**
* The user interface controller
*/
private UIController uiController;
/**
* Creates a new action.
*
* @param uiController the user interface controller
*/
public MacroBeanShellAction(UIController uiController) {
this.uiController = uiController;
}
@Override
protected String getName() {
return "Create Macro/BeanShell";
}
protected void defineProperties() {
putValue(SMALL_ICON, new ImageIcon(CleanSheets.class.
getResource("ext/macro_beanshell/script_small.png")));
}
@Override
public void actionPerformed(ActionEvent e) {
new MacroBeanShellPanel(uiController).setVisible(true);
}
}
| [
"1140280@isep.ipp.pt"
] | 1140280@isep.ipp.pt |
91162d2e2df70a6608d911d6c82fa4cce48dd69b | 986bb9554b584c584410a022c896704b5ad22ea2 | /app/src/main/java/com/example/katrinpolitexercise/database/data/greenDAOclasses/LoginDataDao.java | af18292139702b4a0552eb26993096aef83236d1 | [] | no_license | katrinpolit/KatrinPolitExercise | 8ae6f3265f3e36f7506048dbb88fd4ab780986b7 | be319ca783f9f2e5bbc2d0ab21d362d95e34f6f6 | refs/heads/master | 2021-04-30T05:18:40.072527 | 2018-02-14T21:26:39 | 2018-02-14T21:26:39 | 121,412,007 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,864 | java | package com.example.katrinpolitexercise.database.data.greenDAOclasses;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "UserTable".
*/
public class LoginDataDao extends AbstractDao<LoginData, String> {
public static final String TABLENAME = "UserTable";
/**
* Properties of entity LoginData.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Email = new Property(0, String.class, "Email", true, "EMAIL");
public final static Property Pass = new Property(1, String.class, "pass", false, "PASS");
}
private DaoSession daoSession;
public LoginDataDao(DaoConfig config) {
super(config);
}
public LoginDataDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
this.daoSession = daoSession;
}
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"UserTable\" (" + //
"\"EMAIL\" TEXT PRIMARY KEY NOT NULL ," + // 0: Email
"\"PASS\" TEXT NOT NULL );"); // 1: pass
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"UserTable\"";
db.execSQL(sql);
}
@Override
protected final void bindValues(DatabaseStatement stmt, LoginData entity) {
stmt.clearBindings();
String Email = entity.getEmail();
if (Email != null) {
stmt.bindString(1, Email);
}
stmt.bindString(2, entity.getPass());
}
@Override
protected final void bindValues(SQLiteStatement stmt, LoginData entity) {
stmt.clearBindings();
String Email = entity.getEmail();
if (Email != null) {
stmt.bindString(1, Email);
}
stmt.bindString(2, entity.getPass());
}
@Override
protected final void attachEntity(LoginData entity) {
super.attachEntity(entity);
entity.__setDaoSession(daoSession);
}
@Override
public String readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0);
}
@Override
public LoginData readEntity(Cursor cursor, int offset) {
LoginData entity = new LoginData( //
cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // Email
cursor.getString(offset + 1) // pass
);
return entity;
}
@Override
public void readEntity(Cursor cursor, LoginData entity, int offset) {
entity.setEmail(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
entity.setPass(cursor.getString(offset + 1));
}
@Override
protected final String updateKeyAfterInsert(LoginData entity, long rowId) {
return entity.getEmail();
}
@Override
public String getKey(LoginData entity) {
if(entity != null) {
return entity.getEmail();
} else {
return null;
}
}
@Override
public boolean hasKey(LoginData entity) {
return entity.getEmail() != null;
}
@Override
protected final boolean isEntityUpdateable() {
return true;
}
}
| [
"katrin.polit@gmail.com"
] | katrin.polit@gmail.com |
fa8b800ebb9506dd2886fad7926963d7b7d2a504 | 99d41187e30161c81eeece70f8fb43ff1071d0ab | /src/test/java/logic/ItemLogicTest.java | c7db0bf854b759e2e639721609c0dc2886747925 | [] | no_license | li000611/Kijiji_Project | 9bfe514856417814ffba34981224281b2ded17aa | 5c8ac0edab1644cc8dc2bc379b2593d1c463c268 | refs/heads/master | 2022-11-03T10:59:10.421397 | 2020-05-18T01:41:56 | 2020-05-18T01:41:56 | 243,583,012 | 0 | 0 | null | 2022-09-01T23:23:10 | 2020-02-27T18:03:30 | Java | UTF-8 | Java | false | false | 10,513 | 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 logic;
import common.TomcatStartUp;
import entity.Item;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
*
* @author Min Li
*/
public class ItemLogicTest {
private ItemLogic logic;
private Map<String, String[]> sampleMap;
@BeforeAll
final static void setUpBeforeClass() throws Exception {
TomcatStartUp.createTomcat();
}
@AfterAll
final static void tearDownAfterClass() throws Exception {
TomcatStartUp.stopAndDestroyTomcat();
}
@BeforeEach
final void setUp() throws Exception {
logic = new ItemLogic();
/*HashMap implements interface Map. Map is generic, it has two parameters, first is the Key (in our case String) and second is Value (in our case String[])*/
sampleMap = new HashMap<>();
/*Map stores date based on the idea of dictionaries. Each value is associated with a key. Key can be used to get a value very quickly*/
sampleMap.put(ItemLogic.PRICE, new String[]{"5"});
/*Map::put is used to store a key and a value inside of a map and Map::get is used to retrieve a value using a key.*/
sampleMap.put(ItemLogic.TITLE, new String[]{"junit"});
/*In this case we are using static values stored in ItemLogic which represent general names for Item Columns in DB to store values in Map*/
sampleMap.put(ItemLogic.DATE, new String[]{"02/02/2020"});
sampleMap.put(ItemLogic.URL, new String[]{"www.junit5.com"});
sampleMap.put(ItemLogic.LOCATION, new String[]{"Ottawa"});
sampleMap.put(ItemLogic.DESCRIPTION, new String[]{"large, square"});
sampleMap.put(ItemLogic.CATEGORY_ID, new String[]{"3"});
sampleMap.put(ItemLogic.IMAGE_ID, new String[]{"3"});
sampleMap.put(ItemLogic.ID, new String[]{"4"});
/*This item has Price: " 5", Title: "junit", Date: "2020,02,02", Location:"Ottawa", Description:"large, square", Category:"furniture"*/
}
@AfterEach
final void tearDown() throws Exception {
}
@Test
final void testGetAll() {
//get all the items from the DB
List<Item> list = logic.getAll();
//store the size of list/ this way we know how many items exits in DB
int originalSize = list.size();
//create a new Item and save it so we can delete later
Item testItem = logic.createEntity(sampleMap);
testItem.setCategory(new CategoryLogic().getWithId(1));
testItem.setImage(new ImageLogic().getWithId(1));
//add the newly created item to DB
logic.add(testItem);
//get all the items again
list = logic.getAll();
//the new size of items must be 1 larger than original size
assertEquals(originalSize + 1, list.size());
//delete the new item, so DB is reverted back to it original form
logic.delete(testItem);
//get all items again
list = logic.getAll();
//the new size of items must be same as original size
assertEquals(originalSize, list.size());
}
@Test
final void testGetWithId() {
//get all items
List<Item> list = logic.getAll();
//use the first item in the list as test item
Item testItem = list.get(0);
//using the id of test item get another item from logic
Item returnedItem = logic.getWithId(testItem.getId());
//the two items (testItem and returnedItem) must be the same
//assert all field to guarantee they are the same
assertEquals(testItem.getId(), returnedItem.getId());
assertEquals(testItem.getUrl(), returnedItem.getUrl());
assertEquals(testItem.getPrice(), returnedItem.getPrice());
assertEquals(testItem.getTitle(), returnedItem.getTitle());
assertEquals(testItem.getLocation(), returnedItem.getLocation());
assertEquals(testItem.getDescription(), returnedItem.getDescription());
}
@Test
final void testGetWithPrice() {
List<Item> list = logic.getAll();
Item testItem = list.get(0);
List<Item> returnedItems = logic.getWithPrice(testItem.getPrice());
for (Item item : returnedItems) {
assertEquals(testItem.getId(), item.getId());
assertEquals(testItem.getUrl(), item.getUrl());
assertEquals(testItem.getPrice(), item.getPrice());
assertEquals(testItem.getTitle(), item.getTitle());
assertEquals(testItem.getLocation(), item.getLocation());
assertEquals(testItem.getDescription(), item.getDescription());
}
}
@Test
final void testGetWithTitle() {
List<Item> list = logic.getAll();
Item testItem = list.get(0);
List<Item> returnedItems = logic.getWithTitle(testItem.getTitle());
for (Item item : returnedItems) {
assertEquals(testItem.getId(), item.getId());
assertEquals(testItem.getUrl(), item.getUrl());
assertEquals(testItem.getPrice(), item.getPrice());
assertEquals(testItem.getTitle(), item.getTitle());
assertEquals(testItem.getLocation(), item.getLocation());
assertEquals(testItem.getDescription(), item.getDescription());
}
}
@Test
final void testGetWithLocation() {
List<Item> list = logic.getAll();
Item testItem = list.get(0);
List<Item> returnedItems = logic.getWithLocation(testItem.getLocation());
for (Item item : returnedItems) {
assertEquals(testItem.getId(), item.getId());
assertEquals(testItem.getUrl(), item.getUrl());
assertEquals(testItem.getPrice(), item.getPrice());
assertEquals(testItem.getTitle(), item.getTitle());
assertEquals(testItem.getLocation(), item.getLocation());
assertEquals(testItem.getDescription(), item.getDescription());
}
}
@Test
final void testGetWithDescription() {
List<Item> list = logic.getAll();
Item testItem = list.get(0);
List<Item> returnedItems = logic.getWithDescription(testItem.getDescription());
for (Item item : returnedItems) {
assertEquals(testItem.getId(), item.getId());
assertEquals(testItem.getUrl(), item.getUrl());
assertEquals(testItem.getPrice(), item.getPrice());
assertEquals(testItem.getTitle(), item.getTitle());
assertEquals(testItem.getLocation(), item.getLocation());
assertEquals(testItem.getDescription(), item.getDescription());
}
}
@Test
final void testGetWithUrl() {
List<Item> list = logic.getAll();
Item testItem = list.get(0);
Item returnedItem = logic.getWithUrl(testItem.getUrl());
assertEquals(testItem.getId(), returnedItem.getId());
assertEquals(testItem.getUrl(), returnedItem.getUrl());
assertEquals(testItem.getPrice(), returnedItem.getPrice());
assertEquals(testItem.getTitle(), returnedItem.getTitle());
assertEquals(testItem.getLocation(), returnedItem.getLocation());
assertEquals(testItem.getDescription(), returnedItem.getDescription());
}
@Test
final void testGetWithCategory() {
List<Item> list = logic.getAll();
Item testItem = list.get(0);
List<Item> returnedItems = logic.getWithCategory(testItem.getCategory().getId());
for(Item items: returnedItems){
assertEquals(testItem.getCategory(), items.getCategory());
}
}
@Test
final void testCreateEntity() {
Item testItem = logic.createEntity(sampleMap);
testItem.setCategory(new CategoryLogic().getWithId(1));
testItem.setImage(new ImageLogic().getWithId(1));
logic.add(testItem);
Item item = logic.getWithId(testItem.getId());
assertEquals(testItem.getId(), item.getId());
assertEquals(testItem.getUrl(), item.getUrl());
assertEquals(testItem.getPrice().compareTo( item.getPrice()),0);
assertEquals(testItem.getTitle(), item.getTitle());
assertEquals(testItem.getLocation(), item.getLocation());
assertEquals(testItem.getDescription(), item.getDescription());
assertEquals(testItem.getCategory(), item.getCategory());
assertEquals(testItem.getImage(), item.getImage());
logic.delete(testItem);
}
@Test
final void testSearch() {
List<Item> list = logic.getAll();
Item testItem = list.get(0);
String search = testItem.getTitle();
List<Item> returned = logic.search(search);
returned.forEach((item) -> {
Assertions.assertTrue(item.getUrl().contains(search) ||
item.getTitle().contains(search) || item.getLocation().contains(search) || item.getDescription().contains(search));
});
}
@Test
final void testGetColumnNames() {
List<String> list = logic.getColumnNames();
List<?> hardCodedList = Arrays.asList("ID", "URL", "DATE", "TITLE", "PRICE", "LOCATION", "IMAGE_ID", "CATEGORY_ID", "DESCRIPTION");
assertIterableEquals(list, hardCodedList);
}
@Test
final void testGetColumnCodes() {
List<String> list = logic.getColumnCodes();
List<?> hardCodedList = Arrays.asList(ItemLogic.ID, ItemLogic.URL, ItemLogic.DATE, ItemLogic.TITLE, ItemLogic.PRICE, ItemLogic.LOCATION, ItemLogic.IMAGE_ID,
ItemLogic.CATEGORY_ID, ItemLogic.DESCRIPTION);
assertIterableEquals(list, hardCodedList);
}
@Test
final void testExtraDataAsList() {
List<Item> items = logic.getAll();
Item testIt = items.get(0);
Item returnedIt = logic.getWithId(testIt.getId());
List<?> testItData = logic.extractDataAsList(testIt);
List<?> returnedItData = logic.extractDataAsList(returnedIt);
assertIterableEquals(testItData, returnedItData);
}
}
| [
"li000611@algonquinlive.com"
] | li000611@algonquinlive.com |
e9b188f19fcac02f99650184be91cc8de6e056c0 | ada50c9a1da83bb480124c2f23504f7c3f8d59ca | /src/main/java/com/example/SmartHouseLite/RequestController.java | 957ab28fc464ed357f148813550095ddc554f26c | [] | no_license | ffSaschaGff/SmartHouseLite | 5a210712fbae4b006e36f926b15ff9126e84130b | 1b81a536b22dc6c4257761642517cdbbedeb5e6a | refs/heads/master | 2020-03-27T20:57:59.348150 | 2018-09-30T06:10:44 | 2018-09-30T06:10:44 | 147,106,407 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,711 | java | package com.example.SmartHouseLite;
import com.example.SmartHouseLite.domain.Alarm;
import com.example.SmartHouseLite.domain.RemoteArduino;
import com.example.SmartHouseLite.domain.RemoteSonoff;
import com.example.SmartHouseLite.domain.TempSensorValue;
import com.example.SmartHouseLite.repossitory.AlarmRepository;
import com.example.SmartHouseLite.repossitory.RemoteArduinoRepository;
import com.example.SmartHouseLite.repossitory.RemoteSonoffRepository;
import com.example.SmartHouseLite.repossitory.TempSensorValueRepository;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.util.JSONPObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Optional;
@Controller
public class RequestController {
@Autowired
private RemoteArduinoRepository remoteArduinoRepository;
@Autowired
private RemoteSonoffRepository remoteSonoffRepository;
@Autowired
private AlarmRepository alarmRepository;
@Autowired
private TempSensorValueRepository tempSensorValueRepository;
@GetMapping("index")
public String index(Map<String, Object> model) {
Iterable<Alarm> alarms = alarmRepository.findAll();
model.put("hour", "");
model.put("minute", "");
model.put("alarmIsCheced","");
for (Alarm alarm: alarms) {
model.put("hour", alarm.getHour());
model.put("minute", alarm.getMinute());
model.put("alarmIsCheced", alarm.getEnabled() ? "checked": "");
}
Iterable<TempSensorValue> temps = tempSensorValueRepository.getFirstByDate();
model.put("tempeture", "");
model.put("pressure", "");
model.put("humidity", "");
for (TempSensorValue tempSensorValue: temps) {
model.put("tempeture", tempSensorValue.getTempeture());
model.put("pressure", tempSensorValue.getPressure());
model.put("humidity", tempSensorValue.getHumidity());
}
Iterable<RemoteArduino> arduinos = remoteArduinoRepository.findAll();
model.put("arduinos", arduinos);
Iterable<RemoteSonoff> sonoffs = remoteSonoffRepository.findAll();
model.put("sonoffs", sonoffs);
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
model.put("currentTime",format.format(date));
return "index";
}
@GetMapping("editSwitch")
public String editRemoteGet(Map<String, Object> model) {
model.put("name", "");
model.put("address", "");
model.put("id", "null");
Iterable<RemoteArduino> arduinos = remoteArduinoRepository.findAll();
model.put("arduinos", arduinos);
return "editSwitch";
}
@PostMapping("editSwitch")
public String editRemotePost(@RequestParam(value = "id", defaultValue = "null") String id, Map<String, Object> model) {
if (!id.equals("null")) {
Optional<RemoteArduino> arduinos = remoteArduinoRepository.findById(Integer.parseInt(id));
if (arduinos.isPresent()) {
model.put("name", arduinos.get().getName());
model.put("address", arduinos.get().getAdress());
}
}
if (!model.containsKey("name") || !model.containsKey("address")) {
model.put("name", "");
model.put("address", "");
}
model.put("id", id);
Iterable<RemoteArduino> arduinos = remoteArduinoRepository.findAll();
model.put("arduinos", arduinos);
return "editSwitch";
}
@PostMapping("editSwitchSave")
public ModelAndView editRemoteSave(@RequestParam(value = "id") String id,
@RequestParam(value = "name") String name,
@RequestParam(value = "address") String address, ModelMap model) {
model.addAttribute("attribute", "redirectWithRedirectPrefix");
if (!id.equals("null")) {
RemoteArduino arduino = new RemoteArduino(Integer.parseInt(id), name, address);
remoteArduinoRepository.save(arduino);
}
return new ModelAndView("redirect:/index", model);
}
@GetMapping("addNew")
public String addNewGet(Map<String, Object> model) {
return "addNew";
}
@PostMapping("addNew")
public ModelAndView addNewPost(@RequestParam(value = "name") String name,
@RequestParam(value = "address") String address, ModelMap model) {
model.addAttribute("attribute", "redirectWithRedirectPrefix");
RemoteArduino arduino = new RemoteArduino(name, address);
remoteArduinoRepository.save(arduino);
return new ModelAndView("redirect:/index", model);
}
@PostMapping("deleteSwitch")
public ModelAndView deleteSwitch(@RequestParam(value = "id") String id, ModelMap model) {
model.addAttribute("attribute", "redirectWithRedirectPrefix");
if (!id.equals("null")) {
remoteArduinoRepository.deleteById(Integer.parseInt(id));
}
return new ModelAndView("redirect:/index", model);
}
@PostMapping("turnSwitchArduino")
@ResponseBody
public String turnSwitchArduino(@RequestParam(value = "id") String id, ModelMap model) {
model.addAttribute("attribute", "redirectWithRedirectPrefix");
if (!id.equals("null")) {
Optional<RemoteArduino> arduino = remoteArduinoRepository.findById(Integer.parseInt(id));
arduino.ifPresent(RemoteArduino::turnSwitch);
}
return "{\"status\":\"ok\"}";
}
@PostMapping("turnSwitchSonoff")
@ResponseBody
public String turnSwitchSonoff(@RequestParam(value = "id") String id, ModelMap model) {
model.addAttribute("attribute", "redirectWithRedirectPrefix");
if (!id.equals("null")) {
Optional<RemoteSonoff> sonoff = remoteSonoffRepository.findById(Integer.parseInt(id));
sonoff.ifPresent(RemoteSonoff::turnSwitch);
}
return "{\"status\":\"ok\"}";
}
@PostMapping("setAlarm")
public ModelAndView setAlarm(@RequestParam(value = "hour") String sHour,
@RequestParam(value = "minute") String sMinute,
@RequestParam(value = "isOn", defaultValue = "off") String sIsOn,
ModelMap model) {
synchronized (Application.class) {
Alarm alarm = new Alarm(Integer.parseInt(sMinute), Integer.parseInt(sHour), sIsOn.equals("on"));
alarm.setLastDay("");
alarmRepository.save(alarm);
}
return new ModelAndView("redirect:/index", model);
}
@GetMapping("turnAlarmsOff")
@ResponseBody
public String turnAlarmsOff() {
Iterable<Alarm> alarms = alarmRepository.getAllActive();
for (Alarm alarm: alarms) {
alarm.setActive(false);
alarmRepository.save(alarm);
WebResouces webResouces = new WebResouces();
webResouces.turnAlarmOff();
}
return "{\"status\":\"ok\"}";
}
@GetMapping("getTempetureJSON")
@ResponseBody
public String getTempetureJSON() {
StringBuilder response = new StringBuilder();
ObjectMapper jsonMapper = new ObjectMapper();
ObjectNode rootNode = jsonMapper.createObjectNode();
ArrayNode rootArray = rootNode.putArray("tempetureValues");
Iterable<TempSensorValue> tempDates = tempSensorValueRepository.get500FirstByDate();
double tMax = 0, tMin = 300, hMin = 100, hMax = 0, pMin = 1000, pMax = 0;
for(TempSensorValue tempDate: tempDates) {
ObjectNode tempElement = rootArray.addObject();
tempElement.put("temp", tempDate.getTempeture());
tempElement.put("press", tempDate.getPressure());
tempElement.put("hum", tempDate.getHumidity());
if (tempDate.getTempeture() > tMax) {
tMax = tempDate.getTempeture();
}
if (tempDate.getTempeture() < tMin) {
tMin = tempDate.getTempeture();
}
if (tempDate.getPressure() > pMax) {
pMax = tempDate.getPressure();
}
if (tempDate.getPressure() < pMin) {
pMin = tempDate.getPressure();
}
if (tempDate.getHumidity() > hMax) {
hMax = tempDate.getHumidity();
}
if (tempDate.getHumidity() < hMin) {
hMin = tempDate.getHumidity();
}
}
ObjectNode rangeNode = rootNode.putObject("range");
rangeNode.put("tMax", tMax);
rangeNode.put("tMin", tMin);
rangeNode.put("pMax", pMax);
rangeNode.put("pMin", pMin);
rangeNode.put("hMax", hMax);
rangeNode.put("hMin", hMin);
try {
return jsonMapper.writeValueAsString(rootNode);
} catch (JsonProcessingException e) {
return "{\"error\": \"ok\"}";
}
}
} | [
"ffSaschaGff@yandex.ru"
] | ffSaschaGff@yandex.ru |
e4be4deb073173172c1ad9d353a49e6f53a43a1c | 4df56bcdc06bd5e1dfe788b9b337a50911abfe75 | /chrome/android/javatests/src/org/chromium/chrome/browser/app/metrics/TabbedActivityLaunchCauseMetricsTest.java | dde3c8f5c919bd3512795fa68ee63268620fefd0 | [
"BSD-3-Clause"
] | permissive | Dr3xler/chromium | 54f33430525cec0e6da9efc45a2cbc60b4197b40 | 268e816f13aa8e06dbdb4f6b9a6d465b4d99480c | refs/heads/main | 2023-06-22T19:31:10.411169 | 2021-07-15T12:47:46 | 2021-07-15T12:47:46 | 386,290,191 | 0 | 0 | BSD-3-Clause | 2021-07-15T12:56:21 | 2021-07-15T12:56:21 | null | UTF-8 | Java | false | false | 11,627 | java | // Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.app.metrics;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.pressKey;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import android.app.Activity;
import android.app.SearchManager;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.support.test.runner.lifecycle.Stage;
import android.view.KeyEvent;
import androidx.test.filters.MediumTest;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.mockito.quality.Strictness;
import org.chromium.android.support.PackageManagerWrapper;
import org.chromium.base.ActivityState;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.ContextUtils;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.test.util.ApplicationTestUtils;
import org.chromium.base.test.util.Batch;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Criteria;
import org.chromium.base.test.util.CriteriaHelper;
import org.chromium.base.test.util.FlakyTest;
import org.chromium.base.test.util.JniMocker;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.LauncherShortcutActivity;
import org.chromium.chrome.browser.ServiceTabLauncher;
import org.chromium.chrome.browser.ServiceTabLauncherJni;
import org.chromium.chrome.browser.bookmarkswidget.BookmarkWidgetProxy;
import org.chromium.chrome.browser.document.ChromeLauncherActivity;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.searchwidget.SearchActivity;
import org.chromium.chrome.test.ChromeBrowserTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ChromeApplicationTestUtils;
import org.chromium.network.mojom.ReferrerPolicy;
import org.chromium.ui.mojom.WindowOpenDisposition;
import org.chromium.url.GURL;
import java.util.Collections;
import java.util.List;
/**
* Integration tests for TabbedActivityLaunchCauseMetrics.
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
@Batch(Batch.PER_CLASS)
public final class TabbedActivityLaunchCauseMetricsTest {
private static final long CHROME_LAUNCH_TIMEOUT = 10000L;
@Rule
public final ChromeTabbedActivityTestRule mActivityTestRule =
new ChromeTabbedActivityTestRule();
@ClassRule
public static final ChromeBrowserTestRule sBrowserTestRule = new ChromeBrowserTestRule();
@Rule
public final JniMocker mJniMocker = new JniMocker();
@Rule
public MockitoRule mMockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
@Mock
private ServiceTabLauncher.Natives mServiceTabLauncherJni;
private static int histogramCountForValue(int value) {
if (!LibraryLoader.getInstance().isInitialized()) return 0;
return RecordHistogram.getHistogramValueCountForTesting(
LaunchCauseMetrics.LAUNCH_CAUSE_HISTOGRAM, value);
}
@Test
@MediumTest
public void testMainIntentMetrics() throws Throwable {
final int count = histogramCountForValue(LaunchCauseMetrics.LaunchCause.MAIN_LAUNCHER_ICON);
mActivityTestRule.startMainActivityFromLauncher();
CriteriaHelper.pollInstrumentationThread(() -> {
Criteria.checkThat(
histogramCountForValue(LaunchCauseMetrics.LaunchCause.MAIN_LAUNCHER_ICON),
Matchers.is(count + 1));
});
ChromeApplicationTestUtils.fireHomeScreenIntent(mActivityTestRule.getActivity());
mActivityTestRule.resumeMainActivityFromLauncher();
CriteriaHelper.pollInstrumentationThread(() -> {
Criteria.checkThat(
histogramCountForValue(LaunchCauseMetrics.LaunchCause.MAIN_LAUNCHER_ICON),
Matchers.is(count + 2));
});
}
@Test
@MediumTest
public void testNoMainIntentMetricsFromRecents() throws Throwable {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ApplicationStatus.ActivityStateListener listener =
new ApplicationStatus.ActivityStateListener() {
@Override
public void onActivityStateChange(
Activity activity, @ActivityState int newState) {
if (newState == ActivityState.CREATED) {
// Android strips FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY from sent intents,
// so we have to inject it as early as possible during startup.
activity.setIntent(activity.getIntent().addFlags(
Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY));
}
};
};
ApplicationStatus.registerStateListenerForAllActivities(listener);
final int mainCount =
histogramCountForValue(LaunchCauseMetrics.LaunchCause.MAIN_LAUNCHER_ICON);
final int recentsCount = histogramCountForValue(LaunchCauseMetrics.LaunchCause.RECENTS);
mActivityTestRule.startMainActivityFromIntent(intent, null);
CriteriaHelper.pollInstrumentationThread(() -> {
Criteria.checkThat(histogramCountForValue(LaunchCauseMetrics.LaunchCause.RECENTS),
Matchers.is(recentsCount + 1));
});
Assert.assertEquals(mainCount,
histogramCountForValue(LaunchCauseMetrics.LaunchCause.MAIN_LAUNCHER_ICON));
ApplicationStatus.unregisterActivityStateListener(listener);
}
@Test
@MediumTest
public void testLauncherShortcutMetrics() throws Throwable {
Intent intent = new Intent(LauncherShortcutActivity.ACTION_OPEN_NEW_INCOGNITO_TAB);
intent.setClass(ContextUtils.getApplicationContext(), LauncherShortcutActivity.class);
final int count = 1
+ histogramCountForValue(
LaunchCauseMetrics.LaunchCause.MAIN_LAUNCHER_ICON_SHORTCUT);
mActivityTestRule.startMainActivityFromIntent(intent, null);
CriteriaHelper.pollInstrumentationThread(() -> {
Criteria.checkThat(histogramCountForValue(
LaunchCauseMetrics.LaunchCause.MAIN_LAUNCHER_ICON_SHORTCUT),
Matchers.is(count));
});
}
@Test
@MediumTest
public void testBookmarkWidgetMetrics() throws Throwable {
Intent intent = new Intent();
intent.setClass(ContextUtils.getApplicationContext(), BookmarkWidgetProxy.class);
intent.setData(Uri.parse("about:blank"));
final int count =
1 + histogramCountForValue(LaunchCauseMetrics.LaunchCause.HOME_SCREEN_WIDGET);
mActivityTestRule.setActivity(ApplicationTestUtils.waitForActivityWithClass(
ChromeTabbedActivity.class, Stage.RESUMED,
() -> ContextUtils.getApplicationContext().sendBroadcast(intent)));
CriteriaHelper.pollInstrumentationThread(() -> {
Criteria.checkThat(
histogramCountForValue(LaunchCauseMetrics.LaunchCause.HOME_SCREEN_WIDGET),
Matchers.is(count));
}, CHROME_LAUNCH_TIMEOUT, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
}
private static class TestContext extends ContextWrapper {
public TestContext(Context baseContext) {
super(baseContext);
}
@Override
public PackageManager getPackageManager() {
return new PackageManagerWrapper(super.getPackageManager()) {
@Override
public List<ResolveInfo> queryIntentActivities(Intent intent, int flags) {
if (intent.getAction().equals(Intent.ACTION_WEB_SEARCH)) {
return Collections.emptyList();
}
return TestContext.super.getPackageManager().queryIntentActivities(
intent, flags);
}
};
}
}
@Test
@MediumTest
public void testExternalSearchIntentNoResolvers() throws Throwable {
final int count = 1
+ histogramCountForValue(
LaunchCauseMetrics.LaunchCause.EXTERNAL_SEARCH_ACTION_INTENT);
final Context contextToRestore = ContextUtils.getApplicationContext();
ContextUtils.initApplicationContextForTests(new TestContext(contextToRestore));
Intent intent = new Intent(Intent.ACTION_SEARCH);
intent.setClass(ContextUtils.getApplicationContext(), ChromeLauncherActivity.class);
intent.putExtra(SearchManager.QUERY, "about:blank");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
SearchActivity searchActivity = ApplicationTestUtils.waitForActivityWithClass(
SearchActivity.class, Stage.RESUMED, () -> contextToRestore.startActivity(intent));
onView(withId(R.id.url_bar)).perform(click());
ChromeTabbedActivity cta = ApplicationTestUtils.waitForActivityWithClass(
ChromeTabbedActivity.class, Stage.CREATED, null,
() -> onView(withId(R.id.url_bar)).perform(pressKey(KeyEvent.KEYCODE_ENTER)));
CriteriaHelper.pollInstrumentationThread(() -> {
Criteria.checkThat(
histogramCountForValue(
LaunchCauseMetrics.LaunchCause.EXTERNAL_SEARCH_ACTION_INTENT),
Matchers.is(count));
}, CHROME_LAUNCH_TIMEOUT, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
ApplicationTestUtils.finishActivity(cta);
ApplicationTestUtils.finishActivity(searchActivity);
ContextUtils.initApplicationContextForTests(contextToRestore);
}
@Test
@MediumTest
@FlakyTest(message = "https://crbug.com/1224738")
public void testServiceWorkerTabLaunch() throws Throwable {
final int count = 1 + histogramCountForValue(LaunchCauseMetrics.LaunchCause.NOTIFICATION);
mJniMocker.mock(ServiceTabLauncherJni.TEST_HOOKS, mServiceTabLauncherJni);
mActivityTestRule.setActivity(ApplicationTestUtils.waitForActivityWithClass(
ChromeTabbedActivity.class, Stage.RESUMED, () -> {
ServiceTabLauncher.launchTab(0, false, new GURL("about:blank"),
WindowOpenDisposition.NEW_FOREGROUND_TAB, "", ReferrerPolicy.DEFAULT,
"", null);
}));
CriteriaHelper.pollInstrumentationThread(() -> {
Criteria.checkThat(histogramCountForValue(LaunchCauseMetrics.LaunchCause.NOTIFICATION),
Matchers.is(count));
}, CHROME_LAUNCH_TIMEOUT, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
}
}
| [
"chromium-scoped@luci-project-accounts.iam.gserviceaccount.com"
] | chromium-scoped@luci-project-accounts.iam.gserviceaccount.com |
fbe9ec9a5faf155bbab77560b5ed8c8a9786a86a | db3043ea4728125fd1d7a6a127daf0cc2caad626 | /OCPay_admin/src/main/java/com/stormfives/ocpay/member/dao/OcpayAddressBalanceDualDAO.java | 9af1b8bd32673b140fd9b47b454996fa9e5623d8 | [] | no_license | OdysseyOCN/OCPay | 74f0b2ee9b2c847599118861ffa43b8c869b2e71 | 5f6c03c8eea53ea107ac6917f3d97a3c7fc86209 | refs/heads/master | 2022-07-25T07:49:12.120351 | 2019-03-29T03:14:46 | 2019-03-29T03:14:46 | 135,281,926 | 9 | 5 | null | 2022-07-15T21:06:38 | 2018-05-29T10:48:50 | Java | UTF-8 | Java | false | false | 753 | java | package com.stormfives.ocpay.member.dao;
import com.stormfives.ocpay.member.dao.entity.OcpayAddressBalanceDual;
import com.stormfives.ocpay.member.dao.entity.OcpayAddressBalanceDualExample;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.math.BigDecimal;
import java.util.List;
@Mapper
public interface OcpayAddressBalanceDualDAO {
@Select("select sum(addresses_balance) from ocpay_address_balance_dual")
BigDecimal getTotalAmount();
@Select("select count(1) from ocpay_address_balance_dual")
int getCount();
@Delete("delete from ocpay_address_balance_dual")
void deleteDual();
} | [
"cyp206@qq.com"
] | cyp206@qq.com |
9f9bf0d48e4200ec57c1c20ef8d81687fd4d41ad | fccf4e1b9c15b2271e82e924e53bad2f6771dc82 | /src/thinginjava/concurrency/DaemonThreadFactory.java | ee25a1405de17c35209b0d400a2953fb1838636b | [] | no_license | luyna/learning-java | d7f424728dc5713d8b630a5cdee1e07c3dd55a79 | 6eb5e1eb66794a4ac524784833ef66448319212d | refs/heads/master | 2020-12-31T05:25:33.602149 | 2015-04-29T08:49:31 | 2015-04-29T08:49:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 256 | java | package thinginjava.concurrency;
import java.util.concurrent.ThreadFactory;
public class DaemonThreadFactory implements ThreadFactory {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setDaemon(true);
return t;
}
}
| [
"vonzhou@163.com"
] | vonzhou@163.com |
10ae218e9f935f9498ebc182a5a3f069bc38c56c | c3241185f626bcbc8a8b2affbd44a79392405f35 | /app/src/main/java/org/vliux/android/gesturecut/util/SimpleAnimatorListener.java | c00a9ad5e2a6b04f3efef6998fdaf228de7a7906 | [] | no_license | vliux/GestureCut | 32b5c48a4c0c1d9ec6d1c01e8754ee36f067c82a | b031e6057903c990366acf221ccac569abfd42eb | refs/heads/master | 2020-12-30T10:12:38.622980 | 2015-02-25T07:57:57 | 2015-02-25T07:57:57 | 18,392,886 | 4 | 1 | null | null | null | null | UTF-8 | Java | false | false | 500 | java | package org.vliux.android.gesturecut.util;
import android.animation.Animator;
/**
* Created by vliux on 2/16/15.
*/
public class SimpleAnimatorListener implements Animator.AnimatorListener {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
}
| [
"simpsons.liux@alipay.com"
] | simpsons.liux@alipay.com |
8709a0c57315a5f3b940a34a859fb6ba6e27ba21 | 31f043184e2839ad5c3acbaf46eb1a26408d4296 | /src/main/java/com/github/highcharts4gwt/model/highcharts/option/api/plotoptions/spline/point/ClickEvent.java | 22ff0c3e88165dd939cf56d5947410df94781473 | [] | no_license | highcharts4gwt/highchart-wrapper | 52ffa84f2f441aa85de52adb3503266aec66e0ac | 0a4278ddfa829998deb750de0a5bd635050b4430 | refs/heads/master | 2021-01-17T20:25:22.231745 | 2015-06-30T15:05:01 | 2015-06-30T15:05:01 | 24,794,406 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 213 | java |
package com.github.highcharts4gwt.model.highcharts.option.api.plotoptions.spline.point;
import com.github.highcharts4gwt.model.highcharts.object.api.Point;
public interface ClickEvent {
Point point();
}
| [
"ronan.quillevere@gmail.com"
] | ronan.quillevere@gmail.com |
0fb47715b53d053a1daf8ca2ad58b6631f047ae5 | 25db4f3cf67787a1d5cf7bdeaabdb16cbf715962 | /src/modernJava/chapter10/ex01/StockBuilder.java | fe3be9eb4f11f6528789beaf31fa6858f018b045 | [] | no_license | bruiser99-ko/modernJava | 0a0dcde2290b46d5eac8f742b491b36c13eb2f20 | 67b41f6aa924c575e31fa94a5b466ba59592164c | refs/heads/master | 2021-01-16T01:10:47.666052 | 2020-03-22T08:14:36 | 2020-03-22T08:14:36 | 242,920,997 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 773 | java | package modernJava.chapter10.ex01;
public class StockBuilder {
private final MethodChainingOrderBuilder builder;
private final Trade trade;
final Stock stock = new Stock();
StockBuilder(MethodChainingOrderBuilder builder, Trade trade, String symbol) {
this.builder = builder;
this.trade = trade;
stock.setSymbol(symbol);
}
public StockBuilder() {
this.builder = null;
this.trade = new Trade();
}
public TradeBuilderWithStock on(String market) {
stock.setMarket(market);
trade.setStock(stock);
return new TradeBuilderWithStock(builder, trade);
}
/* 람다식 추가 */
public void symbol(String symbol) {
stock.setSymbol(symbol);
}
public void market(String market) {
stock.setMarket(market);
}
}
| [
"bruiser99@naver.com"
] | bruiser99@naver.com |
82541fb5bbe194a28abc6618bf7497e454489fd5 | 1130eee1b845f59879815cc7d71e804cbdc82aeb | /eclipse-workspace/day_1/src/com/lanou3g/demo/Demo_3.java | 4ec7500032721a118106dedbab684bc03ec47e9b | [] | no_license | Nicetrylp/java | e4ba8713a9ecb6b676fb7b613eec03be5177b200 | 2d68790878de422549cce0ab8561617de791d394 | refs/heads/master | 2021-08-28T05:24:31.009749 | 2017-12-11T08:55:58 | 2017-12-11T08:55:58 | 112,324,746 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 1,683 | java | package com.lanou3g.demo;
import java.util.Scanner;
public class Demo_3 {
public static void main(String[] args) {
/*
System.out.println("请输入这次考试的分数:");
Scanner scanner = new Scanner(System.in);
// 接收分数
int score = scanner.nextInt();
if(score >= 90)
{
System.out.println("优秀");
}else if (score >= 70) {
System.out.println("良好");
}else if (score >= 60) {
System.out.println("及格");
}else {
System.out.println("不及格");
}
//
scanner.close();
*/
/*
* 练习题1.从控制台输入一个字符 如果是‘m’则输出男性 否则什么都不输出
*/
/*
System.out.println("请输入一个字符:");
Scanner scanner = new Scanner(System.in);
String str = scanner.nextLine();
//将字符串转成char类型
// 字符 索引 下标
char ch = str.charAt(0);
if(ch == 'm') {
System.out.println("男");
}
scanner.close();
*/
/*
* 输入一个数 判断 是哪个季节(3 4 5 春季 6 7 8 夏季 9 10 11 秋季 12 1 2 冬季)
*/
// 当有多个case同时执行一个语句时,可以省略break(根据实际情况选择)
/*
System.out.println("请输入一个月份");
Scanner scanner = new Scanner(System.in);
int month = scanner.nextInt();
switch (month) {
case 3:
case 4:
case 5:
System.out.println("春");
break;
case 6:
case 7:
case 8:
System.out.println("夏");
break;
case 9:
case 10:
case 11:
System.out.println("秋");
break;
case 12:
case 1:
case 2:
System.out.println("冬");
break;
default:
System.out.println("error");
break;
}
scanner.close();
*/
}
}
| [
"34057887+Nicetrylp@users.noreply.github.com"
] | 34057887+Nicetrylp@users.noreply.github.com |
e28ce23417133c1547208dcf971ed304ffad83e3 | 5aa33eff5490fc80c5d9da70d9e16c88ba8c2111 | /mianshi-service/src/main/java/cn/xyz/commons/utils/ThreadUtil.java | 6f227e9d311a3b4e15e1aa04ff58137a5b8370f6 | [] | no_license | lyly0906/imapi | 70065f3d08548bdd6d9b69e760761ebd53736923 | 4d8fa2c013a0ae5deac343ae51f66ecfbb9c057f | refs/heads/master | 2020-03-21T15:01:59.525584 | 2018-06-26T05:53:19 | 2018-06-26T05:53:19 | 138,690,369 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 488 | java | package cn.xyz.commons.utils;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import cn.xyz.commons.support.Callback;
public class ThreadUtil{
public static final ExecutorService mThreadPool = Executors.newFixedThreadPool(1000);
public static void executeInThread(Callback callback){
mThreadPool.execute(new Runnable() {
@Override
public void run() {
callback.execute(Thread.currentThread().getName());
}
});
}
}
| [
"58926330@qq.com"
] | 58926330@qq.com |
714e49fe8bfda1345a96c4d86e6282f8e9ae5c3f | 687ad64266358a8d6dba88ebb2e5431790fbe3e7 | /Structural/Bridge/GameProject.java | a7391757126ce639b78df48b17b92187ba787ee1 | [] | no_license | rmzcn/design_patterns | 4ab7cecd45ba1eeaa97d4351e1fe77df44c0623a | 8fe5f2d07718bd3a97d6464ae81d5ae8ba4b9d49 | refs/heads/master | 2023-02-11T00:05:39.459574 | 2021-01-10T20:55:21 | 2021-01-10T20:55:21 | 324,346,410 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 302 | java | package Structural.Bridge;
public class GameProject extends Project {
public GameProject(IProjectPlatform projectPlatform) {
super(projectPlatform);
}
@Override
public void publish() {
super.publish();
System.out.println("Publishing Game Project...");
}
}
| [
"ramazancangolgen@gmail.com"
] | ramazancangolgen@gmail.com |
dedbd158bc865ffe01957638987cce45356f6690 | 386f86b60bb4371359b997b5cb1f0000f37d086b | /src/main/java/pojo/Artikel.java | 8534375e74cb7694df4a4b82754719b7e1298dcd | [] | no_license | HdeJonge/KlantBestellingBasic | ecc21e1165162867ba69decafe7a0b7c256005a6 | b00d3c4bb38788597cb05b7038ad30f78d3ba79e | refs/heads/master | 2021-01-21T14:53:14.747560 | 2017-08-20T13:36:19 | 2017-08-20T13:36:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 852 | java | package pojo;
import java.math.BigDecimal;
public class Artikel {
Integer id;
String naam;
BigDecimal prijs;
Integer voorraad;
public Artikel(){
}
public Artikel(String naam, BigDecimal prijs, int voorraad) {
this.naam = naam;
this.prijs = prijs;
this.voorraad= voorraad;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNaam() {
return naam;
}
public void setNaam(String naam) {
this.naam = naam;
}
public BigDecimal getPrijs() {
return prijs;
}
public void setPrijs(BigDecimal price) {
this.prijs = price;
}
public Integer getVoorraad() {
return voorraad;
}
public void setVoorraad(Integer voorraad) {
this.voorraad = voorraad;
}
public String toString(){
return "naam=" + naam
+ " prijs=" + prijs
+ " voorrad=" + voorraad;
}
}
| [
"herman.de.jonge@gmail.com"
] | herman.de.jonge@gmail.com |
b92df8a434c3f0d4213f8e378b975373afa41e28 | 32f7ffabe1863690b6870a1df9086322e88ee3e7 | /src/com/ict03/class06/Ex01.java | cd64603e4575a1bdc8f5b2c8630c022e9b6a7ae4 | [] | no_license | HJH3077/java_project | 19443bf36824149397f4efc01d05620a18501bdd | 180d4e25ee35979f89f3df5a7bfb4b841d8bd8a9 | refs/heads/master | 2023-04-02T12:51:57.001297 | 2021-04-11T19:50:30 | 2021-04-11T19:50:30 | 354,699,986 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 798 | java | package com.ict03.class06;
// 열거형(enum) : 상수를 하나의 객체로 인식하고, 여러개의 상수 객체들을 한 곳에 모아둔 하나의 묶음(객체)
public class Ex01 {
// 흔히 알려진 상수
static final int JAVA = 100;
static final int DB = 200;
// 열거형
public enum Lesson {
JAVA, JSP, SPRING, ANDROID, HTML
}
public static void main(String[] args) {
// System.out.println("JAVA : " + Ex01.); // ctrl space 하면 E가 enum임
System.out.println("JAVA : " + Ex01.JAVA);
// enum
System.out.println("enum JAVA : " + Lesson.JAVA);
Lesson[] arr = Lesson.values();
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i] + ":" + arr[i].ordinal()); // ordinal() : index값
// 배열의 순서가 나옴
}
}
}
| [
"wnsgur0657@naver.com"
] | wnsgur0657@naver.com |
50a6cc3185137289e235a0802316be28cfed4c3b | 1bdab33b7bba71fc03965156649652f3462b2fc2 | /src/test/java/Second/JavaLearning/JavaLearning/PrimeNumber.java | 0dba887498bf272cc656f4b6ec79deb5fede3012 | [] | no_license | narendrareddytippala/JavaLearning | 80f7a178bf30666975d9a781057ba33318b4a81c | a594859b283699ddcb3e5bc2d0e21d5be8ac6e2a | refs/heads/main | 2023-04-10T05:54:26.718255 | 2021-04-05T16:36:47 | 2021-04-05T16:36:47 | 354,895,039 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 328 | java | package Second.JavaLearning.JavaLearning;
public class PrimeNumber {
public static void main(String[] args) {
int num = 4;
int count=0;
for(int i =1;i<=num;i++){
if(num%i==0){
count++;
}
}
if(count==2){
System.out.println("Its Prime number");
}else{ System.out.println("Its not Prime number");}
}
}
| [
"narendranaresh@gmail.com"
] | narendranaresh@gmail.com |
f602b8064e806a626e98686e5b8db3d15b47879a | d84f50bab4d4efd8f4d99f2d605f9b7551bbd918 | /src/main/java/com/roma/elettorale/modelli3D/helpers/enumerators/tipologiastream.java | 62b38f0bb391d448ad17afd69e31b7fbd0e75a49 | [] | no_license | angew74/modelli3D | eac77f4359a0e7db0f200b3f7c0ae8941a703d9c | 024b39c3afb25cf8acdeb448fc3582ed43f6571d | refs/heads/master | 2022-07-15T03:13:12.132615 | 2019-11-30T12:21:41 | 2019-11-30T12:21:41 | 216,188,220 | 0 | 0 | null | 2022-03-08T21:23:24 | 2019-10-19T10:26:16 | Java | UTF-8 | Java | false | false | 129 | java | package com.roma.elettorale.modelli3D.helpers.enumerators;
public enum tipologiastream {
NIENTE,
MAIL,
PROTOCOLLO
}
| [
"agnew74@gmail.com"
] | agnew74@gmail.com |
21b757ad5825f78185f78999c4436a2b6843c277 | 18720fe6f59710527c31b1e6ff9cc4039174f689 | /src/main/java/com/yigou/entity/Category.java | ec87a08cddedec41c073d943e7f7cbcd3fee51ec | [] | no_license | yigouteam/yigou | 49d4487615a5e7dd0dfdf94369ab2b9d39cd7033 | f1f445ff6ec4c0ae5f556678e31a79c21892312c | refs/heads/master | 2022-12-23T01:04:53.373599 | 2019-08-10T12:07:27 | 2019-08-10T12:07:27 | 201,627,895 | 0 | 0 | null | 2022-12-16T02:34:34 | 2019-08-10T12:34:01 | JavaScript | UTF-8 | Java | false | false | 635 | java | package com.yigou.entity;
import java.util.List;
public class Category {
private Integer id;
private String classname;
private List<Goods> goods;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getClassname() {
return classname;
}
public void setClassname(String classname) {
this.classname = classname == null ? null : classname.trim();
}
public List<Goods> getGoods() {
return goods;
}
public void setGoods(List<Goods> goods) {
this.goods = goods;
}
} | [
"Lenovo@DESKTOP-BKFF39V"
] | Lenovo@DESKTOP-BKFF39V |
1cdbd9a6fbc609d2a2980e9edd5c5f4a99a8ee80 | 5fedb08590b97e71f65b6854cac40f4679e4ae93 | /woooqi-bpm-logic/src/main/java/com/woooqi/bpm/repository/organization/UserAndSignSpecialRepository.java | 1c5a8f219743cc61ae27b15d4b868a0f07eed99e | [] | no_license | xeon-ye/woooqi-bpm | c234156eb75420f4835800e3b25aa2b0f3df6fff | 64dc99312eb91de4bb2008d60e0cd963a2d1c683 | refs/heads/master | 2021-09-05T12:20:37.785041 | 2018-01-27T13:57:11 | 2018-01-27T13:57:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 897 | java | package com.woooqi.bpm.repository.organization;
import java.util.List;
import com.woooqi.bpm.entity.bpm.manage.ProcessNodeSignSpecial;
import com.woooqi.bpm.entity.organization.User;
import com.woooqi.bpm.entity.organization.UserAndSignSpecial;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import com.titan.entity.bpm.manage.ProcessNodeSignSpecial;
import com.titan.entity.organization.User;
import com.titan.entity.organization.UserAndSignSpecial;
public interface UserAndSignSpecialRepository extends JpaRepository<UserAndSignSpecial,String>,JpaSpecificationExecutor<UserAndSignSpecial>{
public List<UserAndSignSpecial> findBySignSpecial(ProcessNodeSignSpecial signSpecial);
public List<UserAndSignSpecial> findBySignSpecialAndUser(ProcessNodeSignSpecial signSpecial , User user);
}
| [
"wangqi528528@qq.com"
] | wangqi528528@qq.com |
fa04360097b8b251ab09f7e08eb7d19f34c52cfd | d386180708ed8be5ce1eccfce4eac05f2dd1982a | /PlayersAndTeams/src/test/java/com/codingdojo/mvc/PlayersAndTeamsApplicationTests.java | 1b5775c7d1f95d87e2487aaf4f98b399a9ae052f | [] | no_license | AnindoKhan/Java | 720ced87ce9a68fabc3b2120bbd0bbf3d5bb7f5a | 9d10534a9c92da19a13f58a8f47f7af43e081c22 | refs/heads/master | 2023-06-21T03:28:01.808640 | 2021-07-21T20:27:53 | 2021-07-21T20:27:53 | 388,227,476 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 219 | java | package com.codingdojo.mvc;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class PlayersAndTeamsApplicationTests {
@Test
void contextLoads() {
}
}
| [
"72222468+AnindoKhan@users.noreply.github.com"
] | 72222468+AnindoKhan@users.noreply.github.com |
55bcaf38fa9114aa27cf2bcb2e81800ecbdf0033 | 0451be0cedc507c47a30123a4042c1cd52e7970c | /main/mcheli/eval/eval/exp/LetDivExpression.java | add9441ec512b3b69328f5e5dc4ca9f58e4d4601 | [] | no_license | 9Valjew/intellectual-property-is-overrated | 70e8b2dc4c6513d80e01cf202b4f4fb93a8b5f0a | c79b499e0f37a67fa4492f2705b1da9371f10958 | refs/heads/master | 2023-05-06T14:33:27.610380 | 2021-05-15T22:10:24 | 2021-05-15T22:10:24 | 367,691,296 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,092 | java | package mcheli.eval.eval.exp;
public class LetDivExpression extends DivExpression
{
public LetDivExpression() {
this.setOperator("/=");
}
protected LetDivExpression(final LetDivExpression from, final ShareExpValue s) {
super(from, s);
}
@Override
public AbstractExpression dup(final ShareExpValue s) {
return new LetDivExpression(this, s);
}
@Override
public long evalLong() {
final long val = super.evalLong();
this.expl.let(val, this.pos);
return val;
}
@Override
public double evalDouble() {
final double val = super.evalDouble();
this.expl.let(val, this.pos);
return val;
}
@Override
public Object evalObject() {
final Object val = super.evalObject();
this.expl.let(val, this.pos);
return val;
}
@Override
protected AbstractExpression replace() {
this.expl = this.expl.replaceVar();
this.expr = this.expr.replace();
return this.share.repl.replaceLet(this);
}
}
| [
"nirkorenfiles@gmail.com"
] | nirkorenfiles@gmail.com |
fd91e63727c1607f3b5ece86951ddd864090f881 | 176fd4dd8ba40cdc05d43d853ce826dfd6ed8562 | /code/api-usage-mining/src/edu/ucla/cs/verify/threshold/RandomAccessFileClose.java | 52b5172613a3cbb88f0d27b8af66f3dc574cef8c | [
"BSD-3-Clause"
] | permissive | UCLA-SEAL/ExampleCheck | f9e22982f264a305fb0ad78ca473b527f0fe9ff7 | 243582982bec98d928a56a44cfb18a7c0e2c39f8 | refs/heads/main | 2023-08-06T06:59:47.559451 | 2021-09-27T03:11:14 | 2021-09-27T03:11:14 | 405,176,081 | 7 | 0 | null | null | null | null | UTF-8 | Java | false | false | 750 | java | package edu.ucla.cs.verify.threshold;
import java.util.ArrayList;
import edu.ucla.cs.mine.SequencePatternVerifier;
import edu.ucla.cs.utils.FileUtils;
public class RandomAccessFileClose {
public static void main(String[] args) {
String seq_output = "/home/troy/research/BOA/example/RandomAccessFile.close/NO/large-output.txt";
ArrayList<String> pattern1 = new ArrayList<String>();
pattern1.add("FINALLY {");
pattern1.add("close(0)");
pattern1.add("}");
int size = FileUtils.countLines(seq_output);
// verify sequence
SequencePatternVerifier pv1 = new SequencePatternVerifier(pattern1);
pv1.verify(seq_output);
double r1 = ((double) pv1.support.size()) / size;
System.out.println("sequence threshold: " + r1);
}
}
| [
"tianyi.zhang@cs.ucla.edu"
] | tianyi.zhang@cs.ucla.edu |
ca857146f4c562e8c9d4d51ff8ea3e26ff7e713d | ed5159d056e98d6715357d0d14a9b3f20b764f89 | /test/irvine/oeis/a039/A039148Test.java | 5a00f3370e7b5cd6bc3aa920d91fb9e2b81fec1e | [] | no_license | flywind2/joeis | c5753169cf562939b04dd246f8a2958e97f74558 | e5efd6971a0062ac99f4fae21a7c78c9f9e74fea | refs/heads/master | 2020-09-13T18:34:35.080552 | 2019-11-19T05:40:55 | 2019-11-19T05:40:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 195 | java | package irvine.oeis.a039;
import irvine.oeis.AbstractSequenceTest;
/**
* Tests the corresponding class.
* @author Sean A. Irvine
*/
public class A039148Test extends AbstractSequenceTest {
}
| [
"sean.irvine@realtimegenomics.com"
] | sean.irvine@realtimegenomics.com |
c63c35978c9b0ab16d9a0dfac18ad7722b1b6bf0 | 9870f862633d3ba6ce4babc41ca0f12afdf18766 | /cakesClub/src/test/java/com/cakesclub/qa/testcases/OrdersPageTest.java | b3ed36ba8224d02c24155ce63975358450a4f8dd | [] | no_license | sanjibautomation/cakesClub | c4b7bda64c4403accbddd7199250882d5abdcef2 | c194938324a4879501973bab369740773d583c07 | refs/heads/master | 2023-05-11T20:33:41.967759 | 2019-07-30T06:32:55 | 2019-07-30T06:32:55 | 198,579,118 | 0 | 0 | null | 2023-05-09T18:12:12 | 2019-07-24T07:10:17 | Java | UTF-8 | Java | false | false | 2,248 | java | package com.cakesclub.qa.testcases;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.cakesclub.qa.base.TestBase;
import com.cakesclub.qa.pages.DashBoardPage;
import com.cakesclub.qa.pages.LoginPage;
import com.cakesclub.qa.pages.OrdersPage;
import qa.cakesclub.qa.util.PaidOrderSelection;
public class OrdersPageTest extends TestBase {
OrdersPage ordersPage;
DashBoardPage dashBoardPage;
LoginPage loginPage;
PaidOrderSelection paidOrderSelection;
int orderFunctionality;
public OrdersPageTest(){
super();
}
@BeforeMethod
public void setUp(){
initialization();
loginPage = new LoginPage();
dashBoardPage = loginPage.login(prop.getProperty("username"), prop.getProperty("password"));
ordersPage = new OrdersPage();
dashBoardPage.ClickOnOrdersModule();
paidOrderSelection = new PaidOrderSelection();
}
@Test
public void validateOrdersPageTest(){
String actPageName = ordersPage.validateOrdersPageName();
String reqPageName = prop.getProperty("reqOrdersPageName");
Assert.assertEquals(actPageName, reqPageName,"Error: Orders PageName Not Matching.");
}
@Test
public void paymentOrderTest() throws InterruptedException{
orderFunctionality = 1;
paidOrderSelection.selectOrder(driver, prop.getProperty("ReqOrderId"), orderFunctionality);
ordersPage.paymentOrders();
}
@Test
public void viewOrderTest() throws InterruptedException{
orderFunctionality = 2;
paidOrderSelection.selectOrder(driver, prop.getProperty("ReqOrderId"), orderFunctionality);
ordersPage.viewOrders();
}
// Track Orders is not working
// @Test
// public void trackOrderTest() throws InterruptedException{
// orderFunctionality = 3;
// paidOrderSelection.selectOrder(driver, prop.getProperty("ReqOrderId"), orderFunctionality);
// ordersPage.trackOrders();
//
// }
@Test
public void searchOrderTest(){
ordersPage.searchOrder();
}
// Failed Order Tab Actions
@Test
public void viewFailedOrdersTest() throws InterruptedException{
ordersPage.failedViewOrder();
}
@Test
public void searchFailedOrderTest(){
ordersPage.searchFailedOrder();
}
}
| [
"Sanjib@Sanjib-PC"
] | Sanjib@Sanjib-PC |
1a5f20cd5ff58ea7da8895ffb2cfcc30ba3c3612 | 0bb0b942edd9e6a4a051202361fc824723ec29ea | /android/app/src/main/java/com/recyclertest/MainActivity.java | 8b8a8229c56d2be6a3505346d13111c35712dff1 | [] | no_license | pravynandas/RecyclerTest | 4ec381081ced67bdde79b903ca77b31af75ead8c | a4bb080cf26ab63185d2283a750975924c7cf1b9 | refs/heads/master | 2022-11-18T04:20:00.929102 | 2020-07-15T13:34:35 | 2020-07-15T13:34:35 | 279,876,789 | 0 | 0 | null | 2020-07-15T13:32:20 | 2020-07-15T13:32:19 | null | UTF-8 | Java | false | false | 369 | java | package com.recyclertest;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "recyclerTest";
}
}
| [
"cory.mcaboy@gmail.com"
] | cory.mcaboy@gmail.com |
6640fd8b601d26735307dacb94315140368f343d | 6fc4eba8df16e0c2d86a6ecd3ba5523ab6662e20 | /codeEnv/src/Main.java | 1fbc0478180b0d59df977079a1c85cdfac774da9 | [] | no_license | AdarshaNayak/code-env | 2e13a90e673f132c84f8a830b9363c95dd62496e | 2b2a928373b2f617ba02558f0a0cfed9ac781640 | refs/heads/master | 2022-03-15T03:57:28.823030 | 2019-11-14T14:21:57 | 2019-11-14T14:21:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,159 | java |
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.layout.*;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.Group;
import javafx.scene.control.*;
//import javafx.scene.layout.BorderPane;
public class Main extends Application {
@FXML
private ComboBox<String> languages;
@Override
public void start(Stage primaryStage) {
try {
//Load external fxml file
//Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("SolveCode.fxml"));
Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("DisplayQuestions.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setTitle("Coding Platform");
primaryStage.setMaximized(true);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
| [
"adarshnayak64@gmail.com"
] | adarshnayak64@gmail.com |
d198aecede8d22603690649bd9e1095bbdc5abc4 | 9f5f40df25ff4e80b5a9f2ef91529c3aba69021a | /kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/adIfRelevant/AdIfRelevantContainer.java | 858f2d165c1d962b3147e476e56ffe733eb5e568 | [
"LicenseRef-scancode-unknown",
"OLDAP-2.8",
"ANTLR-PD",
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-jdbm-1.00",
"Apache-2.0",
"LicenseRef-scancode-ietf"
] | permissive | isabella232/directory-server | d5a627c2e16157f9662d388884de07e7ac7823e0 | 2ec1117fec41919a68d04ba3a51724562e3b46f8 | refs/heads/master | 2023-03-08T19:14:47.065238 | 2020-11-06T15:25:43 | 2020-11-06T15:25:43 | 311,733,075 | 0 | 0 | Apache-2.0 | 2021-02-23T13:28:34 | 2020-11-10T17:20:04 | null | UTF-8 | Java | false | false | 1,675 | 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.directory.shared.kerberos.codec.adIfRelevant;
import org.apache.directory.shared.kerberos.codec.authorizationData.AuthorizationDataContainer;
import org.apache.directory.shared.kerberos.components.AdIfRelevant;
/**
* The AD-IF-RELEVANT container stores the AD-IF-RELEVANT decoded by the Asn1Decoder.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class AdIfRelevantContainer extends AuthorizationDataContainer
{
/**
* Creates a new AdIfRelevantContainer object.
*/
public AdIfRelevantContainer()
{
super();
setAuthorizationData( new AdIfRelevant() );
}
/**
* @return Returns the AD-IF-RELEVANT.
*/
public AdIfRelevant getAdIfRelevant()
{
return ( AdIfRelevant ) getAuthorizationData();
}
}
| [
"elecharny@apache.org"
] | elecharny@apache.org |
ba541dcc43635b375ff25bbb0c2530c2404ae882 | 61aa8af548ec9f440038e150ac6a6530dda34494 | /Projeto_1/src/main/java/br/ufscar/dc/dsw/POJO/Consulta.java | 7db95ebca9e8b2ea04602c34b76dea359847b946 | [] | no_license | reynold125/web1 | f0d158439d62a090eeff305b91c3a701f87af3e6 | 2b73ae46c356db35d0b0add6bcba0968bb41d4dd | refs/heads/main | 2023-09-05T22:36:11.353683 | 2021-11-24T11:51:39 | 2021-11-24T11:51:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 878 | java | package br.ufscar.dc.dsw.POJO;
import java.util.Date;
public class Consulta{
private String cpfCliente;
private String cpfProfissional;
private Date data;
public Consulta(String cpfCliente, String cpfProfissional, Date data) {
this.cpfCliente = cpfCliente;
this.cpfProfissional = cpfProfissional;
this.data = data;
}
public void setCpfCliente(String cpfCliente) {
this.cpfCliente = cpfCliente;
}
public String getCpfCliente() {
return this.cpfCliente;
}
public void setCpfProfissional(String cpfProfissional) {
this.cpfProfissional = cpfProfissional;
}
public String getCpfProfissional() {
return this.cpfProfissional;
}
public void setData(Date data) {
this.data = data;
}
public Date getData() {
return this.data;
}
} | [
"reynold_mazo@hotmail.com"
] | reynold_mazo@hotmail.com |
9b4edf63faaf7d947aa16cb98e5847c7c167fcd5 | bbdfdcc197523fc8033d2489e418f97ac97a123a | /FJ-93/src/br/com/alura/aula/javaavancado/Pagamento.java | 4b90a03cc7c046354fc56d37b5d8e6c510f5da9f | [] | no_license | robinsonbrz/estudos | 7a6615de3d06469d50a26f501a8f22524993ce99 | 3bf61f0253320486616cb2f652c585f7cce2e24e | refs/heads/master | 2021-05-13T23:45:33.846564 | 2017-04-25T19:30:26 | 2017-04-25T19:30:26 | 116,524,224 | 1 | 0 | null | 2018-01-06T23:55:24 | 2018-01-06T23:55:24 | null | UTF-8 | Java | false | false | 706 | java | package br.com.alura.aula.javaavancado;
import java.util.Calendar;
public class Pagamento{
private String nome;
private double valor;
private Calendar data;
private Documento documentoPagador;
public Documento getCnpjPagador() {
return documentoPagador;
}
public void setCnpjPagador(Documento cnpjPagador) {
this.documentoPagador = cnpjPagador;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public double getValor() {
return this.valor;
}
public void setValor(double valor) {
this.valor = valor;
}
public Calendar getData() {
return this.data;
}
public void setData(Calendar data) {
this.data = data;
}
} | [
"victor.fsouza2@gmail.com"
] | victor.fsouza2@gmail.com |
5e5abc684483a6d7e34b4a8ef61d52771104324f | 8aa3696a5d29811f729e1bd98c7709dce767c42d | /src/main/java/uk/co/mysterymayhem/vmcplayback/osc/RecordingPacketListener.java | cda442a5b6be29d2449bd917b5bd2ebe1dd2ccc6 | [
"MIT"
] | permissive | Mysteryem/EmVMCPlayback | 39aa9dd8884dfc64a501b36fd0cd3cf625157668 | 130e6dff95d29840e62bffafedc6ed0875efc5d2 | refs/heads/master | 2023-07-14T16:12:50.811536 | 2021-08-25T22:08:11 | 2021-08-25T22:08:11 | 393,205,885 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,346 | java | package uk.co.mysterymayhem.vmcplayback.osc;
import com.illposed.osc.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.function.Predicate;
/**
* Packet listener that records received OSC packets.
* <p>
* Created by Mysteryem on 31/07/2021.
*/
public class RecordingPacketListener implements OSCPacketListener {
private static final Logger LOG = LoggerFactory.getLogger(RecordingPacketListener.class);
private final Predicate<RecordedMessage> messageSelector;
private int packetCount;
private int messageCount;
private long startTime;
private ArrayList<RecordedPacket<?, ?>> recordedPackets = new ArrayList<>();
public RecordingPacketListener(Predicate<RecordedMessage> messageSelector) {
this.messageSelector = messageSelector;
}
public void startRecording() {
// ditch any old messages
this.recordedPackets = new ArrayList<>();
// get the time now for use when calculating time offsets of when messages have been received
this.startTime = System.currentTimeMillis();
}
public int getPacketCount() {
return packetCount;
}
public int countMessages() {
return messageCount;
// Could calculate with this instead of counting as the packets get handled
//return this.recordedPackets.stream().map(RecordedPacket::getPacketData).mapToInt(RecordedPacketData::getMessageCount).sum();
}
public long getStartTime() {
return startTime;
}
public ArrayList<RecordedPacket<?, ?>> getRecordedPackets() {
return recordedPackets;
}
@Override
public void handlePacket(OSCPacketEvent event) {
long timeReceived = System.currentTimeMillis();
packetCount++;
long offsetTime = timeReceived - this.startTime;
OSCPacket packet = event.getPacket();
if (packet instanceof OSCMessage) {
OSCMessage message = (OSCMessage) packet;
RecordedMessagePacket recordedMessagePacket = new RecordedMessagePacket(offsetTime, message);
if (this.messageSelector.test(recordedMessagePacket.getPacketData())) {
this.recordedPackets.add(recordedMessagePacket);
// Should always be +1 since OSCMessages have a single message
this.messageCount += recordedMessagePacket.getPacketData().getMessageCount();
}
} else if (packet instanceof OSCBundle) {
OSCBundle bundle = (OSCBundle) packet;
RecordedBundlePacket recordedBundlePacket = RecordedBundlePacket.fromOscBundle(offsetTime, bundle, this.messageSelector);
// If the bundle has no recorded packet data (it has no messages), ignore it
if (recordedBundlePacket != null && !recordedBundlePacket.getPacketData().getRecordedPacketData().isEmpty()) {
this.recordedPackets.add(recordedBundlePacket);
this.messageCount += recordedBundlePacket.getPacketData().getMessageCount();
}
} else {
throw new RuntimeException("Unexpected OSCPacket '" + packet + "' of class '" + packet.getClass() + "'");
}
}
@Override
public void handleBadData(OSCBadDataEvent event) {
LOG.warn("Got bad data packet", event.getException());
}
}
| [
"github@mysterymayhem.co.uk"
] | github@mysterymayhem.co.uk |
a0483f8bee1fbd5f1bbb1c4d40e0c7bc36064824 | 77e407ac1bb6ce56456d824f3b4374403b9f263a | /src/com/badlogic/androidgames/framework/gl/Animation.java | af88edff7016d9f94927c228a79ab55d9ad2f9bd | [] | no_license | nhatuhoang91/magic-box | a21e4d1d9d937c54e5f4fad8fa711515ff4a7437 | e95d0a84492e2905e24ec767f5c442d3b83214f0 | refs/heads/master | 2020-12-01T15:29:57.348589 | 2019-12-29T00:00:56 | 2019-12-29T00:00:56 | 230,668,813 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 717 | java | package com.badlogic.androidgames.framework.gl;
public class Animation {
public static final int ANIMATION_LOOPING = 0;
public static final int ANIMATION_NONLOOPING = 1;
final TextureRegion[] keyFrames;
final float frameDuration;
public Animation(float frameDuration, TextureRegion ... keyFrames){
this.frameDuration = frameDuration;
this.keyFrames = keyFrames;
}
public TextureRegion getKeyFrame(float stateTime, int mode){
int frameNumber = (int)(stateTime/frameDuration);
if(mode == ANIMATION_NONLOOPING){
frameNumber = Math.min(keyFrames.length - 1, frameNumber);
}else{
frameNumber = frameNumber % keyFrames.length;
}
return keyFrames[frameNumber];
}
}
| [
"nhahoang@users-MBP.attlocal.net"
] | nhahoang@users-MBP.attlocal.net |
ea926f8822fe3bc0ad08d4a0f44a9acbe71d9844 | b2b273579dd0e6d4fcd7bcde0fb503dfd6d12aee | /app/src/main/java/com/example/android/diamondcell/Sales.java | 2c13213fc629f2a2b40f8bc491091e06e1ffb4b7 | [] | no_license | raysodorus10/DiamondCell | 65b0e27734012b9bebbc5b1ffbae028043fa4f90 | 32adceb83851e94d5e265c82a1fe4a41e341a758 | refs/heads/master | 2020-06-30T07:51:52.072325 | 2019-08-16T11:18:33 | 2019-08-16T11:18:33 | 200,770,953 | 0 | 0 | null | 2019-08-07T14:09:40 | 2019-08-06T03:39:15 | Java | UTF-8 | Java | false | false | 8,507 | java | package com.example.android.diamondcell;
import android.os.Parcel;
import android.os.Parcelable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class Sales implements Parcelable
{
private String mKode;
private Date mTglMasuk;
private String mNama;
private String mAlamat;
private String mTelp;
private String mKodeJabatan;
private JenisKelamin mJenisKelamin;
private Agama mAgama;
private Date mTanggalLahir;
private String mTempatLahir;
private String mEmail;
private boolean mStatusAktif;
private String mFoto;
protected Sales(Parcel in) {
mKode = in.readString();
mTglMasuk= new Date(in.readLong());
mNama = in.readString();
mAlamat = in.readString();
mTelp = in.readString();
mKodeJabatan = in.readString();
int jk= in.readByte();
switch (jk){
case 0: mJenisKelamin=JenisKelamin.PRIA;
break;
case 1: mJenisKelamin=JenisKelamin.WANITA;
break;
}
int agm= in.readByte();
switch (agm){
case 0:
mAgama=Agama.HINDU;
break;
case 1:
mAgama=Agama.ISLAM;
break;
case 2:
mAgama=Agama.BUDDHA;
break;
case 3:
mAgama=Agama.KATOLIK;
break;
case 4:
mAgama=Agama.KRISTEN;
break;
case 5:
mAgama=Agama.KONGHUCU;
break;
case 6:
mAgama=Agama.LAINNYA;
break;
}
mTempatLahir = in.readString();
mTanggalLahir=new Date(in.readLong());
mEmail = in.readString();
mStatusAktif = in.readByte() != 0;
mFoto = in.readString();
}
public static final Creator<Sales> CREATOR = new Creator<Sales>() {
@Override
public Sales createFromParcel(Parcel in) {
return new Sales(in);
}
@Override
public Sales[] newArray(int size) {
return new Sales[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(mKode);
parcel.writeLong(mTglMasuk.getTime());
parcel.writeString(mNama);
parcel.writeString(mAlamat);
parcel.writeString(mTelp);
parcel.writeString(mKodeJabatan);
switch (mJenisKelamin){
case PRIA:
parcel.writeByte((byte) 0);
break;
case WANITA:
parcel.writeByte((byte) 1);
break;
}
switch (mAgama){
case HINDU:
parcel.writeByte((byte) 0);
break;
case ISLAM:
parcel.writeByte((byte) 1);
break;
case BUDDHA:
parcel.writeByte((byte) 2);
break;
case KATOLIK:
parcel.writeByte((byte) 3);
break;
case KRISTEN:
parcel.writeByte((byte) 4);
break;
case KONGHUCU:
parcel.writeByte((byte) 5);
break;
case LAINNYA:
parcel.writeByte((byte) 6);
break;
}
parcel.writeString(mTempatLahir);
parcel.writeLong(mTanggalLahir.getTime());
parcel.writeString(mEmail);
parcel.writeByte((byte) (mStatusAktif ? 1 : 0));
parcel.writeString(mFoto);
}
public Sales(String mKode){
this.mKode=mKode;
//Todo: Dapatkan data dari database berdasarkan Kode Sales
}
public Sales(String mKode, Date mTglMasuk, String mNama, String mAlamat, String mTelp, String mKodeJabatan,
JenisKelamin mJenisKelamin, Agama mAgama, Date mTanggalLahir, String mTempatLahir, String mEmail,
boolean mStatusAktif, String mFoto) {
this.mKode = mKode;
this.mTglMasuk = mTglMasuk;
this.mNama = mNama;
this.mAlamat = mAlamat;
this.mTelp = mTelp;
this.mKodeJabatan = mKodeJabatan;
this.mJenisKelamin = mJenisKelamin;
this.mAgama = mAgama;
this.mTanggalLahir = mTanggalLahir;
this.mTempatLahir = mTempatLahir;
this.mEmail = mEmail;
this.mStatusAktif = mStatusAktif;
this.mFoto = mFoto;
}
public String getmKode() {
return mKode;
}
public void setmKode(String mKode) {
this.mKode = mKode;
}
public Date getmTglMasuk() {
return mTglMasuk;
}
public void setmTglMasuk(Date mTglMasuk) {
this.mTglMasuk = mTglMasuk;
}
public String getmNama() {
return mNama;
}
public void setmNama(String mNama) {
this.mNama = mNama;
}
public String getmAlamat() {
return mAlamat;
}
public void setmAlamat(String mAlamat) {
this.mAlamat = mAlamat;
}
public String getmTelp() {
return mTelp;
}
public void setmTelp(String mTelp) {
this.mTelp = mTelp;
}
public String getmKodeJabatan() {
return mKodeJabatan;
}
public void setmKodeJabatan(String mKodeJabatan) {
this.mKodeJabatan = mKodeJabatan;
}
public JenisKelamin getmJenisKelamin() {
return mJenisKelamin;
}
public void setmJenisKelamin(JenisKelamin mJenisKelamin) {
this.mJenisKelamin = mJenisKelamin;
}
public Agama getmAgama() {
return mAgama;
}
public void setmAgama(Agama mAgama) {
this.mAgama = mAgama;
}
public Date getmTanggalLahir() {
return mTanggalLahir;
}
public void setmTanggalLahir(Date mTanggalLahir) {
this.mTanggalLahir = mTanggalLahir;
}
public String getmTempatLahir() {
return mTempatLahir;
}
public void setmTempatLahir(String mTempatLahir) {
this.mTempatLahir = mTempatLahir;
}
public String getmEmail() {
return mEmail;
}
public void setmEmail(String mEmail) {
this.mEmail = mEmail;
}
public boolean ismStatusAktif() {
return mStatusAktif;
}
public void setmStatusAktif(boolean mStatusAktif) {
this.mStatusAktif = mStatusAktif;
}
public String getmFoto() {
return mFoto;
}
public void setmFoto(String mFoto) {
this.mFoto = mFoto;
}
public String getmJenisKelaminAsString(){
if (mJenisKelamin==JenisKelamin.PRIA){
return "Pria";
}else if (mJenisKelamin==JenisKelamin.WANITA){
return "Wanita";
}else return "Unkown";
}
public String getmAgamaAsString(){
switch (mAgama){
case HINDU:
return "Hindu";
case ISLAM:
return "Islam";
case BUDDHA:
return "Buddha";
case KATOLIK:
return "Katolik";
case KRISTEN:
return "Kristen";
case KONGHUCU:
return "Konghucu";
case LAINNYA:
return "Lainnya";
default:
return "Unkown";
}
}
public String getmStatusAktifAsString(){
if (mStatusAktif){
return "Aktif";
}else if (!mStatusAktif){
return "Tidak Aktif";
}else return "Unkown";
}
public String getmTanggalLahirAsString(){
SimpleDateFormat dateFormat= new SimpleDateFormat("dd MMMM yyyy", Locale.getDefault());
return dateFormat.format(mTanggalLahir);
}
public String getmTglMasukAsString(){
SimpleDateFormat dateFormat= new SimpleDateFormat("dd MMMM yyyy", Locale.getDefault());
return dateFormat.format(mTglMasuk);
}
public Jabatan getJabatan(){
//Todo: Definisikan Proses Kueri Untuk Mendapatkan Jabatan Berdasarkan Kode Jabatan
return new Jabatan("mKode","namaJabatan",2);
}
public void save(){
//Todo: Definisikan Proses Save
}
public void update(){
//Todo: Definisikan Proses Update
}
public void fetch(){
//Todo: Definisikan Proses Load Data
}
public void delete(){
//Todo: Definisikan Proses Delete
}
}
| [
"fudiantociuandi_17@kharisma.ac.id"
] | fudiantociuandi_17@kharisma.ac.id |
018169ad3399abfea80e0c7d8603fda570328c4a | 16e238a3b3e5fbe6bdc3f13bba3226d64a0caa71 | /app/src/main/java/dporras/nanodegree/quizapp/MainActivity.java | 8d24c34ca4f785c04e8d8ef7448d7b79e864c033 | [] | no_license | dporr/nanodegree_project3 | 5240fdd6ed2e2fe82da552a8d2abca7ad92d8c77 | eaeb8e73187b3415ea03ca5bee8e10d9958d8157 | refs/heads/master | 2021-06-05T02:27:20.153780 | 2016-07-01T18:58:30 | 2016-07-01T18:58:30 | 61,954,266 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,855 | java | package dporras.nanodegree.quizapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity{
private RadioGroup rGroupQuestion1;
private RadioGroup rGroupQuestion5;
private CheckBox q2_hendrix;
private CheckBox q2_trump;
private CheckBox q2_watters;
private CheckBox q2_clapton;
private EditText q3_mannish_boy;
private EditText q4_harmonica;
private int totalScore;
private String Q3_ANSWER="Mannish Boy";
private String Q4_ANSWER="Harmonica";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initLayoutComponents();
}
private void initLayoutComponents(){
rGroupQuestion1 = (RadioGroup) findViewById(R.id.rGroupQuestion1);
rGroupQuestion5 = (RadioGroup) findViewById(R.id.rGroupQuestion5);
q2_hendrix = (CheckBox) findViewById(R.id.q2_hendrix);
q2_trump = (CheckBox) findViewById(R.id.q2_trump);
q2_watters = (CheckBox) findViewById(R.id.q2_watters);
q2_clapton = (CheckBox) findViewById(R.id.q2_clapton);
q3_mannish_boy = (EditText) findViewById(R.id.q3_mannish_boy);
q4_harmonica = (EditText) findViewById(R.id.q4_harmonica);
}
/**
* Sumbit the quiz for evaluating
* @param view
*/
public void submitQuizz(View view){
//Retrieve question 1 rigth answer
switch (rGroupQuestion1.getCheckedRadioButtonId()){
case R.id.q1_radio_ukulele:
break;
case R.id.q1_radio_drums:
break;
case R.id.q1_radio_guitar:
totalScore++;
}
//Lower case q3 answer is the same as expected, give 1 point
if(q3_mannish_boy.getText().toString().trim().toLowerCase().equals(Q3_ANSWER.toLowerCase()))
totalScore++;
//Lower case q4 answer is the same as expected, give 1 point
if(q4_harmonica.getText().toString().trim().toLowerCase().equals(Q4_ANSWER.toLowerCase()))
totalScore++;
//If any blues player is checked gives 1 point, if trump is checked user failed to answer
if(!q2_trump.isChecked() &&
(q2_clapton.isChecked() || q2_hendrix.isChecked() || q2_watters.isChecked()))
totalScore++;
//Retrieve question 5 rigth answer
switch (rGroupQuestion5.getCheckedRadioButtonId()){
case R.id.q5_radio_electro:
break;
case R.id.q5_radio_nu_metal:
break;
case R.id.q5_radio_delta_blues:
totalScore++;
}
//Displays the final result
String result;
if(totalScore>0) {
result = "Congrats! Your total Score is: " + totalScore + " of 5 total possible points!";
}else{
result = "Sorry! Your total Score is: " + totalScore + " keep trying!";
}
Toast.makeText(MainActivity.this, result , Toast.LENGTH_SHORT).show();
cleanInputs();
}
private void cleanInputs(){
totalScore=0;
//Reset question 1 answer
rGroupQuestion1.clearCheck();
//Reset question 2 answers
q2_clapton.setChecked(false);
q2_hendrix.setChecked(false);
q2_trump.setChecked(false);
q2_watters.setChecked(false);
//Reset question 3 answer
q3_mannish_boy.setText("");
//Reset question 4 answer
q4_harmonica.setText("");
//Reset question 5 answers
rGroupQuestion5.clearCheck();
}
}
| [
"po6xsecpo@gmail.com"
] | po6xsecpo@gmail.com |
dd9b45b8961a1eefd447422582d1cdea1ab953a5 | c6663674288b84a1a56eb3ecdc5dc63743d58ac7 | /src/main/java/com/pheu/consumer/IConsumerManager.java | 3b3930d0eb96b892d59588ff45f1bd13140dd760 | [] | no_license | quynt-tiki/search-util | e7334d76262cbed3a5a7ce6d8687148b96b10062 | f780c84e43011e3d05acdbbe02ac73fc38d0b76a | refs/heads/master | 2020-04-17T04:09:19.931684 | 2019-01-17T11:44:51 | 2019-01-17T11:44:51 | 166,216,483 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 482 | java | package com.pheu.consumer;
import java.util.List;
public interface IConsumerManager
{
public String registerConsumer(String paramString, IConsumer paramIConsumer);
public void removeConsumer(String paramString);
public void startConsumer(String paramString);
public void stopConsumer(String paramString);
public IConsumer getConsumer(String paramString);
public List<IConsumer> listConsumer();
public void startAll();
public void stopAll();
}
| [
"quy.nguyen@tiki.vn"
] | quy.nguyen@tiki.vn |
57ee5e331ca7c0a48416bae25a8f19e672f78730 | 3eb8a014643d54a3ac186039879bd517e63b130c | /src/main/java/indi/zqc/warehouse/enums/DWZStatusCode.java | 73e10bdf5378c0e8cd2400156a2e88dc813e2730 | [] | no_license | zhuqianchang/warehouse | 0a170cb58b2067581fbc8675dc95670d6dae08df | 42b475a77d7c05b3ea716e81650e2a5964536c31 | refs/heads/master | 2021-05-10T10:40:45.295602 | 2018-05-07T01:43:29 | 2018-05-07T01:43:29 | 118,389,758 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 744 | java | package indi.zqc.warehouse.enums;
/**
* Title : DwzStatusCode.java
* Package : indi.zqc.warehouse.enums
* Description : DWZ异步请求响应码
* Create on : 2018/1/24 20:11
*
* @author zhu.qianchang
* @version v1.0.0
*/
public enum DWZStatusCode {
OK(200, "成功"),
ERROR(300, "失败"),
TIMEOUT(301, "超时");
private int key;
private String value;
DWZStatusCode(int key, String value) {
this.key = key;
this.value = value;
}
public int getKey() {
return key;
}
public void setKey(int key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
| [
"Zhu.Qianchang@geely.com"
] | Zhu.Qianchang@geely.com |
fedfbc4cb597a4f5d70ff47b7a3b130dc1003f57 | c35c47d59fbafe61ea4617de89fe109ab418f47e | /src/com/zzu/dao/Userdao.java | c9721fa7ddf110c3a17f735c61c0e3e50fc08fcc | [] | no_license | cpt1234/gitLoveZZU | 11ca4d2c5035487877a75e7d21e90897720b6538 | ea2aaec5719ea04baaea7891c3096304cbe13974 | refs/heads/master | 2021-07-16T14:09:35.972622 | 2018-04-12T06:41:29 | 2018-04-12T06:41:29 | 95,945,255 | 0 | 0 | null | 2018-04-12T06:41:30 | 2017-07-01T05:56:40 | Java | GB18030 | Java | false | false | 1,343 | java | package com.zzu.dao;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Repository;
import com.zzu.entity.User;
import com.zzu.entity.UserInfo;
@Repository(value="userDao")
public class Userdao implements Dao{
@Resource(name="hibernateTemplate")
private HibernateTemplate hibernateTemplate;
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
boolean isSuccessful=false;
String[] userinfoDatas=new String[9];
//保存用户并返回id
public <T> Serializable save(T t) {
Serializable id=null;
hibernateTemplate.clear();
id=hibernateTemplate.save(t);
hibernateTemplate.flush();
return id;
}
//查询用户并返回用户对象
public <T> List<T> query(String sql, String values) {
List<T> list = new ArrayList<T>();
hibernateTemplate.clear();
hibernateTemplate.flush();
list.clear();
list=(List<T>) hibernateTemplate.find(sql, values);
hibernateTemplate.flush();
return list;
}
//更新操作
@Override
public <T> T update(T t) {
hibernateTemplate.clear();
hibernateTemplate.update(t);
hibernateTemplate.flush();
return null;
}
}
| [
"weiqi.han@qq.com"
] | weiqi.han@qq.com |
b9551e712189e280bc78b106fb2a7c8197a5ba1c | bd6eaaa5e9df17cd8a0e08d6268d413a8ff5a8f7 | /src/tp5/ex7/TestJList1.java | 4c8b619f9436fb86ed0217357e579fa027f14de6 | [] | no_license | said-grich/tp_ihm | 0df5f296cb2a8c6514c56a72ee069a5a06a37615 | a171c1d6226f7e5a10b04896592936d088036ceb | refs/heads/master | 2023-03-20T08:05:47.617864 | 2021-03-17T11:03:09 | 2021-03-17T11:03:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,440 | java | package tp5.ex7;
import java.awt.*; import java.awt.event.*;
import java.util.Objects;
import javax.swing.*;
import javax.swing.event.* ; // utile pour ListSelectionListener
class FenList1 extends JFrame /*implements ListSelectionListener*/{
public FenList1(){
setTitle("Essais boite de liste"); setSize (480, 360) ;
Container contenu = getContentPane();
liste = new JList(couleurs) ;
liste.setBounds(150,10,100,30);
JLabel selectedValue=new JLabel();
selectedValue.setBounds(120,200,300,30);
contenu.add(selectedValue);
contenu.add(liste);
liste.addListSelectionListener((e)->{
if(!e.getValueIsAdjusting()){
Object valeurs = liste.getSelectedValue();
selectedValue.setText("le couleur sélectionné est :"+(String) valeurs);
}
}) ;
}
/* public void valueChanged(ListSelectionEvent e){
if (!e.getValueIsAdjusting()){//(1)
Object[] valeurs = liste.getSelectedValues();
for(var i = 0 ; i<valeurs.length ; i++)
System.out.println((String) valeurs[i]);}}
*/
private String[] couleurs = {"rouge", "bleu", "gris", "vert", "jaune",
"noir" } ;
private JList liste;
}
public class TestJList1{
public static void main(String args[]){
FenList1 fen = new FenList1();
fen.setVisible(true);
}
} | [
"said.grich@edu.uca.ma"
] | said.grich@edu.uca.ma |
7439b92e24bbc877c9825c0e968e6df8aedf6b53 | 8def0c93d257cf05ed218754e3f07f6c9c363e94 | /Application/src/main/java/io/github/antijava/marjio/graphics/Viewport.java | 15195c8ac3c7c2edb2b89df4e56259f9e1fff18b | [] | no_license | NCU-Anti-Java/Marjio | 8efdf89077601a66f4e7946ac8274f4ea052b5fa | a4955f3db882e2a121b31871dd098f1e074c1d05 | refs/heads/develop | 2020-11-30T16:18:49.211743 | 2016-01-04T09:00:58 | 2016-01-04T09:00:58 | 42,847,984 | 2 | 2 | null | 2016-01-04T08:56:51 | 2015-09-21T06:30:04 | Java | UTF-8 | Java | false | false | 1,041 | java | package io.github.antijava.marjio.graphics;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Davy on 2015/12/29.
*/
public class Viewport extends io.github.antijava.marjio.common.graphics.Viewport
implements Comparable {
private final List<Sprite> mSpriteList = new ArrayList<>();
// region Sprite List
void addSprite(Sprite sprite) {
if (sprite.getViewport() == this)
return;
mSpriteList.add(sprite);
}
void removeSprite(Sprite sprite) {
if (sprite.getViewport() != this)
return;
mSpriteList.remove(sprite);
}
List<Sprite> getSprites() {
return mSpriteList;
}
@Override
public int compareTo(@NotNull Object o) {
if (!(o instanceof Viewport))
return 0;
final Viewport v = (Viewport) o;
if (v.z == this.z)
return this.y > v.y ? 1 : -1;
return this.z > v.z ? 1 : -1;
}
// endregion Sprite List
}
| [
"s50407s@gmail.com"
] | s50407s@gmail.com |
411edc822efe6ddf409389a181f28da10f5cfc33 | 74b47b895b2f739612371f871c7f940502e7165b | /aws-java-sdk-imagebuilder/src/main/java/com/amazonaws/services/imagebuilder/model/transform/PutContainerRecipePolicyResultJsonUnmarshaller.java | 328c286ef0864883be322591b4f6ab53b5af4258 | [
"Apache-2.0"
] | permissive | baganda07/aws-sdk-java | fe1958ed679cd95b4c48f971393bf03eb5512799 | f19bdb30177106b5d6394223a40a382b87adf742 | refs/heads/master | 2022-11-09T21:55:43.857201 | 2022-10-24T21:08:19 | 2022-10-24T21:08:19 | 221,028,223 | 0 | 0 | Apache-2.0 | 2019-11-11T16:57:12 | 2019-11-11T16:57:11 | null | UTF-8 | Java | false | false | 3,227 | java | /*
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.imagebuilder.model.transform;
import java.math.*;
import javax.annotation.Generated;
import com.amazonaws.services.imagebuilder.model.*;
import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
import com.amazonaws.transform.*;
import com.fasterxml.jackson.core.JsonToken;
import static com.fasterxml.jackson.core.JsonToken.*;
/**
* PutContainerRecipePolicyResult JSON Unmarshaller
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class PutContainerRecipePolicyResultJsonUnmarshaller implements Unmarshaller<PutContainerRecipePolicyResult, JsonUnmarshallerContext> {
public PutContainerRecipePolicyResult unmarshall(JsonUnmarshallerContext context) throws Exception {
PutContainerRecipePolicyResult putContainerRecipePolicyResult = new PutContainerRecipePolicyResult();
int originalDepth = context.getCurrentDepth();
String currentParentElement = context.getCurrentParentElement();
int targetDepth = originalDepth + 1;
JsonToken token = context.getCurrentToken();
if (token == null)
token = context.nextToken();
if (token == VALUE_NULL) {
return putContainerRecipePolicyResult;
}
while (true) {
if (token == null)
break;
if (token == FIELD_NAME || token == START_OBJECT) {
if (context.testExpression("requestId", targetDepth)) {
context.nextToken();
putContainerRecipePolicyResult.setRequestId(context.getUnmarshaller(String.class).unmarshall(context));
}
if (context.testExpression("containerRecipeArn", targetDepth)) {
context.nextToken();
putContainerRecipePolicyResult.setContainerRecipeArn(context.getUnmarshaller(String.class).unmarshall(context));
}
} else if (token == END_ARRAY || token == END_OBJECT) {
if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) {
if (context.getCurrentDepth() <= originalDepth)
break;
}
}
token = context.nextToken();
}
return putContainerRecipePolicyResult;
}
private static PutContainerRecipePolicyResultJsonUnmarshaller instance;
public static PutContainerRecipePolicyResultJsonUnmarshaller getInstance() {
if (instance == null)
instance = new PutContainerRecipePolicyResultJsonUnmarshaller();
return instance;
}
}
| [
""
] | |
5b69327ef894fe64135befc38f4a4e6e7a6cd213 | 3761a78d0049d3ca1efd8dc28555888463d746ec | /src/main/java/pl/saltsoft/ReadFile.java | 7102a2ba276dc3273e592a29c2448c9755ea5591 | [] | no_license | pkwiecinski/ExamplesNewest | 473edbf4c071bb0f72779f2994660b2f31d1f7fd | f09627aa925f4f00c13d1e40010b6f2cac7896a9 | refs/heads/master | 2020-04-26T12:35:06.254220 | 2019-03-03T14:32:46 | 2019-03-03T14:32:46 | 173,554,387 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 758 | java | package pl.saltsoft;
import java.io.*;
public class ReadFile {
public void readLinesFromFile(String filePath) throws Exception {
File file = new File(filePath);
FileReader r = new FileReader(file);
BufferedReader br = new BufferedReader(r);
String st = br.readLine();
while ( st != null) {
System.out.println(st);
st = br.readLine();
}
}
public void writeLinesFromFile(String filePath) throws Exception {
File file = new File(filePath);
FileWriter r = new FileWriter(file);
BufferedWriter br = new BufferedWriter(r);
br.write("Hello World. I wrote this.");
br.newLine();
br.flush();
br.close();
}
}
| [
"pa.kwiecinski96@gmail.com"
] | pa.kwiecinski96@gmail.com |
4218c6e5401af73d37d7c0310d90a522bece52d3 | e258c02ff7a029daa57d8db03fa71d8d0fced58b | /app/src/main/java/com/github/kingaza/aspree/bean/StockItem.java | f02fa0f8834d8e5367d41456c6121eafa832a85b | [
"MIT"
] | permissive | kingaza/aSpree | bcb7974be6b24d1014bca9a8fcca2068a945adf0 | cba8d99f202ff63abf80f48594fb5bb0ce10b021 | refs/heads/master | 2020-05-15T04:51:04.548984 | 2015-05-27T12:56:40 | 2015-05-27T12:56:40 | 34,668,459 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 252 | java | package com.github.kingaza.aspree.bean;
/**
* Created by abu on 2015/5/11.
*/
public class StockItem {
int id;
int count_on_hand;
int stock_location_id;
boolean backorderable;
boolean available;
String stock_location_name;
}
| [
"kingaza@gmail.com"
] | kingaza@gmail.com |
1bbefb5621d0fe94b0ec0fc1d1bb61318fa2b35a | 6a48246db56e3ea89762a789c0482a7c06d21ab8 | /opensource/easeui/src/main/java/com/hyphenate/easeui/ui/EaseGroupListener.java | 403bbbdf18c7046a994db4f7783be0f99978454a | [
"Apache-2.0"
] | permissive | y1xian/What | d7cddb60010723dfed83bb2dafebe57ffec8f91c | ddd57d3a5095510773041df08af184ef6ce8ceae | refs/heads/master | 2021-06-21T19:30:34.174368 | 2021-04-09T02:27:39 | 2021-04-09T02:27:39 | 208,196,833 | 55 | 8 | Apache-2.0 | 2019-10-20T14:56:18 | 2019-09-13T04:44:31 | Kotlin | UTF-8 | Java | false | false | 2,450 | java | package com.hyphenate.easeui.ui;
import com.hyphenate.EMGroupChangeListener;
import com.hyphenate.chat.EMMucSharedFile;
import java.util.List;
/**
* group change listener
*
*/
public abstract class EaseGroupListener implements EMGroupChangeListener{
@Override
public void onInvitationReceived(String groupId, String groupName, String inviter, String reason) {
}
@Override
public void onRequestToJoinReceived(String groupId, String groupName, String applyer, String reason) {
}
@Override
public void onRequestToJoinAccepted(String groupId, String groupName, String accepter) {
}
@Override
public void onRequestToJoinDeclined(String groupId, String groupName, String decliner, String reason) {
}
@Override
public void onInvitationAccepted(String groupId, String inviter, String reason) {
}
@Override
public void onInvitationDeclined(String groupId, String invitee, String reason) {
}
@Override
public void onAutoAcceptInvitationFromGroup(String groupId, String inviter, String inviteMessage) {
}
@Override
public void onMuteListAdded(String groupId, final List<String> mutes, final long muteExpire) {
}
@Override
public void onMuteListRemoved(String groupId, final List<String> mutes) {
}
@Override
public void onWhiteListAdded(String groupId, List<String> whitelist) {
}
@Override
public void onWhiteListRemoved(String groupId, List<String> whitelist) {
}
@Override
public void onAllMemberMuteStateChanged(String groupId, boolean isMuted) {
}
@Override
public void onAdminAdded(String groupId, String administrator) {
}
@Override
public void onAdminRemoved(String groupId, String administrator) {
}
@Override
public void onOwnerChanged(String groupId, String newOwner, String oldOwner) {
}
@Override
public void onMemberJoined(final String groupId, final String member){
}
@Override
public void onMemberExited(final String groupId, final String member) {
}
@Override
public void onAnnouncementChanged(final String groupId, final String announcement) {
}
@Override
public void onSharedFileAdded(final String groupId, final EMMucSharedFile shareFile) {
}
@Override
public void onSharedFileDeleted(final String groupId, final String fileId) {
}
}
| [
"yyxnb@outlook.com"
] | yyxnb@outlook.com |
440dd8855bfa5b3868e86473e8accdc99f40489b | 4992e2e03d9fcd64b05c013fdcf5f7177f8b4f61 | /zuul-server2/src/main/java/pers/guzx/zuulserver2/base/ResponseData.java | 471f19f3c2ec59037409543f62eb0dab34241050 | [] | no_license | hnguzx/spring-cloud-study | d6a79d71022d994c6977dccdc975903bbbb422b3 | 9aa6fa696683c00a5749e14f27a294be30eeda00 | refs/heads/main | 2023-06-06T12:20:14.167104 | 2021-07-02T11:03:49 | 2021-07-02T11:03:49 | 353,667,787 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,276 | java | package pers.guzx.zuulserver2.base;
public class ResponseData {
private int code = 200;
private String message = "";
private Object data;
public static ResponseData ok(Object data) {
return new ResponseData(data);
}
public static ResponseData fail() {
return new ResponseData(null);
}
public static ResponseData fail(String message) {
return new ResponseData(message);
}
public static ResponseData fail(String message, int code) {
return new ResponseData(message, code);
}
public static ResponseData failByParam(String message) {
return new ResponseData(message, ResponseCode.PARAM_ERROR_CODE.getCode());
}
public ResponseData(Object data) {
super();
this.data = data;
}
public ResponseData(String message) {
super();
this.message = message;
}
public ResponseData(String message, int code) {
super();
this.message = message;
this.code = code;
}
public ResponseData() {
super();
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}
| [
"hnguzx@qq.com"
] | hnguzx@qq.com |
d79e18cdc7b1099dbb74b9cbeb6d10e27c340445 | e0861d43361e72cd53080c96ed06383c7208df3f | /Final/src/com/blakebartenbach/thefinal/ManyLinkedListsDriver.java | b13665b28a4c694db46f917a67dff85626ebdf0c | [] | no_license | bartenbach/Data-Structures-Using-Java | e6df059397bfae632a75b2b17502c00c921532f0 | 6f4174a9150a27301cbc6575ffccf5d3840d82b7 | refs/heads/master | 2021-09-08T18:45:35.147091 | 2017-08-13T18:08:01 | 2017-08-13T18:08:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,120 | 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.blakebartenbach.thefinal;
/**
*
* @author blake
*/
public class ManyLinkedListsDriver {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// double-ended list test
DoubleEndedList dEndedList = (DoubleEndedList) ManyLinkedLists.createLinkedList(ListType.DOUBLEENDEDLIST);
dEndedList.insertFirst(50000L);
dEndedList.insertFirst(40000L);
dEndedList.insertFirst(30000L);
dEndedList.insertLast(60000L); // element inserted at the end
dEndedList.displayList();
// doubly linked list test
DoublyLinkedList dLinkedList = (DoublyLinkedList) ManyLinkedLists.createLinkedList(ListType.DOUBLYLINKEDLIST);
dLinkedList.insertFirst(50000L);
dLinkedList.insertLast(60000L);
dLinkedList.insertAfter(50000L, 55000L); // element inserted in between elements
dLinkedList.displayList();
dLinkedList.displayBackward(); // list efficiently traversed backwards
}
}
| [
"proxa@users.noreply.github.com"
] | proxa@users.noreply.github.com |
46c03cd5ee1e059bfa4201ee050df4ecd248e21d | e929834e3b8d80d6171fc7858ba29479a376cfa2 | /SumoNextGen/src/net/sumo/nextgen/task/cooking/Cook.java | 3f4c4d673f5877664020b61291194fd348178e8a | [] | no_license | itggot-william-holmberg/SumoScripts | 1aa566affa5f0f606d3a486c0c51ca1caafadf5b | 525888b3928e3a2afef4edfcc6e438805eba5a45 | refs/heads/master | 2021-01-15T14:42:21.006729 | 2016-05-14T14:21:31 | 2016-05-14T14:21:31 | 55,257,137 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,560 | java | package net.sumo.nextgen.task.cooking;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Skill;
import net.sumo.nextgen.resources.Resources;
import net.sumo.nextgen.task.Task;
public class Cook extends Task {
@Override
public boolean active() {
if (shouldCook() && playerInArea(currentCookingAssignment().getCookingArea()) && readyToCook()) {
return true;
}
return false;
}
@Override
public void execute() {
Resources.CURRENT_STATE = "lets cook";
checkContinue();
while ((playerIsBusy()) || playerIsMoving()) {
updateMessage("We are already cooking, lets sleep");
checkContinue();
try {
SkillingAntiBan();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
sleep(750);
}
cook();
}
public void cook() {
String food = currentCookingAssignment().getRawFoodName();
if(widgetIsVisible(307,2)){
int amount = getAmount(currentCookingAssignment().getRawFoodName());
int xp = currentCookingAssignment().getXpGiven();
int xpLeft = s.skills.experienceToLevel(Skill.COOKING);
int minFoodToLevel = xpLeft/xp;
s.widgets.interact(307, 2, "Cook all");
if(minFoodToLevel<= amount){
s.log("sleep for " + 1500*minFoodToLevel);
sleep(1500*minFoodToLevel);
}else{
sleep(1650*amount);
}
}else{
if(inventoryContains(food)){
interactItemWithObject(food, currentCookingAssignment().getCookingObject());
sleep(3500);
}
}
}
} | [
"william.holmberg@itggot.se"
] | william.holmberg@itggot.se |
5e3da19e15437afe273327ca141e1ec0dea8ba1c | f3c0028d4138c69c4ce24b2fd01e4ca595a6af4d | /app/src/main/java/com/siweisoft/nurse/ui/day/adapter/LeftDayAdapter.java | a74be07ebf03f45304550ceb9d2f98afdf29e6cb | [] | no_license | canvaser/desktop | 83138fa37b36a02d4663d5e9cb136313f501a43e | 7652ece27d050d627c95fe0934734bf05db2cb0e | refs/heads/master | 2021-01-13T03:09:42.346997 | 2017-02-07T01:43:59 | 2017-02-07T01:43:59 | 77,433,645 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,251 | java | package com.siweisoft.nurse.ui.day.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import com.siweisoft.app.R;
import com.siweisoft.base.ui.adapter.AppRecycleAdapter;
import com.siweisoft.base.ui.interf.view.OnAppItemLongClickListener;
import com.siweisoft.nurse.ui.day.bean.dbbean.DayDBBean;
import com.siweisoft.nurse.ui.day.bean.uibean.LeftDayUIBean;
import com.siweisoft.util.data.FormatUtil;
import java.util.ArrayList;
/**
* Created by ${viwmox} on 2017-01-03.
*/
public class LeftDayAdapter extends AppRecycleAdapter implements View.OnLongClickListener{
ArrayList<DayDBBean> data;
OnAppItemLongClickListener longClickListener;
public LeftDayAdapter(Context context,ArrayList<DayDBBean> data) {
super(context);
this.data = data;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = layoutInflater.inflate(R.layout.list_left_day,parent,false);
LeftDayUIBean uiBean = new LeftDayUIBean(context,v);
return uiBean;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
LeftDayUIBean uiBean = (LeftDayUIBean) holder;
uiBean.getTimeTV().setText(FormatUtil.getInstance().toNowHHMMTime(data.get(position).getStartTime())+"--"+FormatUtil.getInstance().toNowHHMMTime(data.get(position).getEndTime()));
uiBean.getContentTV().setText(data.get(position).getContentTxt()+"");
uiBean.getRootV().setOnLongClickListener(this);
uiBean.getRootV().setTag(R.id.position,position);
uiBean.getRootV().setTag(R.id.data,data.get(position));
}
@Override
public int getItemCount() {
return data.size();
}
@Override
public void onClick(View v) {
}
@Override
public boolean onLongClick(View v) {
if(longClickListener!=null){
longClickListener.onAppItemLongClick(v, (Integer) v.getTag(R.id.position));
}
return true;
}
public void setLongClickListener(OnAppItemLongClickListener longClickListener) {
this.longClickListener = longClickListener;
}
}
| [
"18721607438@163.com"
] | 18721607438@163.com |
744e40a7ad0ef89d72b9aaad814511e6ba9d7a5d | 19f62661e9862219d83dd1b2a8dc08d9161f0f8d | /testamation-core/src/main/java/nz/co/testamation/core/mock/HttpServletRequestWrapperImpl.java | 31d0e7b0bb4317ab51af4d25a52c543fe44ccf40 | [
"Apache-2.0"
] | permissive | rlon008/testamation | 5d048da19b1e6fe04802e7a738e97fdb856ede63 | da060eacc4bad1bbe677b31955854e4e6e419d41 | refs/heads/master | 2023-05-30T19:41:42.971093 | 2018-03-12T22:30:40 | 2018-03-12T22:30:40 | 76,214,500 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,433 | java | /*
* Copyright 2016 Ratha Long
*
* 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 nz.co.testamation.core.mock;
import nz.co.testamation.common.util.StringConcat;
import org.springframework.util.FileCopyUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
public class HttpServletRequestWrapperImpl implements HttpServletRequestWrapper {
private final HttpServletRequest request;
private final String body;
private final Map<String, String> headers = new HashMap<>();
private final Map<String, String[]> parameterMap;
public HttpServletRequestWrapperImpl( HttpServletRequest request ) throws IOException {
this.request = request;
this.parameterMap = request.getParameterMap();
Enumeration headerNames = request.getHeaderNames();
while ( headerNames.hasMoreElements() ) {
String key = (String) headerNames.nextElement();
headers.put( key, request.getHeader( key ) );
}
this.body = FileCopyUtils.copyToString( new InputStreamReader( this.request.getInputStream() ) );
}
@Override
public String getBody() {
return body;
}
@Override
public String getMethod() {
return request.getMethod();
}
@Override
public String getRequestURI() {
return request.getRequestURI();
}
@Override
public String getHeader( String key ) {
return request.getHeader( key );
}
@Override
public String getContentType() {
return request.getContentType();
}
@Override
public String getParameter( String key ) {
return request.getParameter( key );
}
@Override
public String toString() {
StringConcat concat = new StringConcat( "\n" );
try {
concat.append( request.getRequestURL().toString() );
} catch ( Exception e ) {
concat.append( "URL NOT AVAILABLE IN REQUEST" );
}
concat.append( "\nHeaders:" );
for ( Map.Entry<String, String> entry : headers.entrySet() ) {
concat.append( entry );
}
concat.append( "Parameters: {" );
for ( Map.Entry<String, String[]> entry : parameterMap.entrySet() ) {
concat.append( String.format( "%s: %s", entry.getKey(), getValue( entry.getValue() ) ) );
}
concat.append( "}" );
concat.append( "Body: " + body );
return concat.toString();
}
private String getValue( String[] values ) {
StringConcat concat = new StringConcat( ", " );
for ( String value : values ) {
concat.append( value );
}
return concat.toString();
}
@Override
public Map<String, String[]> getParameterMap() {
return parameterMap;
}
}
| [
"rlon008@gmail.com"
] | rlon008@gmail.com |
932ffae02992860b657223bd2779aafefa8a56a1 | 72a43944b2d92b3c3d3a9d87d4c01bcdb4673b7b | /Weitu/src/main/java/com/quanjing/weitu/app/ui/category/MWTStaggeredCategoryFlowFragment.java | 49bf3c7dc2260be13a895004121f74fa53a26a33 | [] | no_license | JokeLook/QuanjingAPP | ef5d5c21284bc29d0594b45ec36ac456c24186b8 | 40b2c1c286ffcca46c88942374fdd67a14611260 | refs/heads/master | 2020-07-15T01:02:27.443815 | 2015-04-27T06:08:19 | 2015-04-27T06:08:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,767 | java | package com.quanjing.weitu.app.ui.category;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.etsy.android.grid.StaggeredGridView;
import com.quanjing.weitu.app.common.MWTCallback;
import com.quanjing.weitu.app.model.MWTCategory;
import com.quanjing.weitu.app.model.MWTCategoryManager;
import com.quanjing.weitu.app.model.MWTFeed;
import com.quanjing.weitu.app.model.MWTFeedManager;
import com.quanjing.weitu.app.ui.common.MWTDataRetriever;
import com.quanjing.weitu.app.ui.common.MWTItemClickHandler;
import com.quanjing.weitu.app.ui.common.MWTWaterFlowFragment;
import com.quanjing.weitu.app.ui.feed.MWTFeedFlowActivity;
public class MWTStaggeredCategoryFlowFragment extends MWTWaterFlowFragment implements MWTItemClickHandler
{
private static final String ARG_CATEGORY_ID = "ARG_CATEGORY_ID";
private String _categoryID;
private MWTCategory _category;
private MWTCategoriesAdapter _categoriesAdapter;
private StaggeredGridView _gridView;
private MWTItemClickHandler _extraItemClickHandler;
public static MWTStaggeredCategoryFlowFragment newInstance()
{
MWTStaggeredCategoryFlowFragment fragment = new MWTStaggeredCategoryFlowFragment();
return fragment;
}
public static MWTStaggeredCategoryFlowFragment newInstance(String categoryID)
{
MWTStaggeredCategoryFlowFragment fragment = new MWTStaggeredCategoryFlowFragment();
Bundle args = new Bundle();
args.putString(ARG_CATEGORY_ID, categoryID);
fragment.setArguments(args);
return fragment;
}
public MWTStaggeredCategoryFlowFragment()
{
super();
setPullToRefreshEnabled(true, false);
setDataRetriver(new MWTDataRetriever()
{
@Override
public void refresh(MWTCallback callback)
{
if (_categoriesAdapter != null)
{
_categoriesAdapter.refresh(callback);
}
else
{
if (callback != null)
{
callback.success();
}
}
}
@Override
public void loadMore(MWTCallback callback)
{
if (callback != null)
{
callback.success();
}
}
});
setItemClickHandler(this);
}
@Override
public void onAttach(Activity activity)
{
super.onAttach(activity);
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setRetainInstance(true);
if (getArguments() != null)
{
_categoryID = getArguments().getString(ARG_CATEGORY_ID);
}
if (_categoryID != null)
{
MWTCategoryManager cm = MWTCategoryManager.getInstance();
_category = cm.getCategoryByID(_categoryID);
}
else
{
_category = null;
}
_categoriesAdapter = new MWTDynamicCategoriesAdapter(getActivity(), _category);
setGridViewAdapter(_categoriesAdapter);
}
@Override
public void onResume()
{
super.onResume();
_categoriesAdapter.refreshIfNeeded();
}
public void setExtraItemClickHandler(MWTItemClickHandler extraItemClickHandler)
{
_extraItemClickHandler = extraItemClickHandler;
}
@Override
public boolean handleItemClick(Object item)
{
if (_extraItemClickHandler != null)
{
boolean handled = _extraItemClickHandler.handleItemClick(item);
if (handled)
{
return true;
}
}
if (item instanceof MWTCategory)
{
MWTCategory category = (MWTCategory) item;
if (category.isMultiLevel())
{
Intent intent = new Intent(getActivity(), MWTCategoryFlowActivity.class);
intent.putExtra(MWTCategoryFlowActivity.ARG_CATEGORY_ID, category.getFeedID());
intent.putExtra(MWTCategoryFlowActivity.ARG_IS_SINGLE_COLUMN, isSingleColumn());
startActivity(intent);
return true;
}
else
{
MWTFeed feed = MWTFeedManager.getInstance().getFeedForCategory(category);
Intent intent = new Intent(getActivity(), MWTFeedFlowActivity.class);
intent.putExtra(MWTFeedFlowActivity.ARG_FEED_ID, feed.getFeedID());
startActivity(intent);
return true;
}
}
return false;
}
}
| [
"forevertxp@gmail.com"
] | forevertxp@gmail.com |
1befc6d0709c8f6aabf955d054bdefb4540412d6 | 6249a2b3928e2509b8a5d909ef9d8e18221d9637 | /revolsys-swing/src/main/java/com/revolsys/swing/undo/CannotUndoException.java | 291050cd6ccd3f82b47ec6c444a1ed851849ec2c | [
"Apache-2.0"
] | permissive | revolsys/com.revolsys.open | dbcdc3bdcee3276dc3680311948e91ec64e1264e | 7f4385c632094eb5ed67c0646ee3e2e258fba4e4 | refs/heads/main | 2023-08-22T17:18:48.499931 | 2023-05-31T01:59:22 | 2023-05-31T01:59:22 | 2,709,026 | 5 | 11 | NOASSERTION | 2023-05-31T01:59:23 | 2011-11-04T12:33:49 | Java | UTF-8 | Java | false | false | 449 | java | package com.revolsys.swing.undo;
public class CannotUndoException extends javax.swing.undo.CannotUndoException {
/**
*
*/
private static final long serialVersionUID = 1L;
private final String message;
public CannotUndoException(final String message) {
this.message = message;
}
@Override
public String getMessage() {
return this.message;
}
@Override
public String toString() {
return this.message;
}
}
| [
"paul.austin@revolsys.com"
] | paul.austin@revolsys.com |
18395575e82128460788aef73fc95af0ee13bc5d | 952789d549bf98b84ffc02cb895f38c95b85e12c | /V_3.x/Server/tags/SpagoBI-3.3(20111222)/SpagoBIQbeEngine/src/it/eng/spagobi/engines/worksheet/services/designer/GetWorksheetFieldsAction.java | 8a8c0415c2a1502f1e68136e5f35e24f04b4eb04 | [] | no_license | emtee40/testingazuan | de6342378258fcd4e7cbb3133bb7eed0ebfebeee | f3bd91014e1b43f2538194a5eb4e92081d2ac3ae | refs/heads/master | 2020-03-26T08:42:50.873491 | 2015-01-09T16:17:08 | 2015-01-09T16:17:08 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 7,679 | java | /*
* SpagoBI, the Open Source Business Intelligence suite
* © 2005-2015 Engineering Group
*
* This file is part of SpagoBI. SpagoBI is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or any later version.
* SpagoBI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received
* a copy of the GNU Lesser General Public License along with SpagoBI. If not, see: http://www.gnu.org/licenses/.
* The complete text of SpagoBI license is included in the COPYING.LESSER file.
*/
package it.eng.spagobi.engines.worksheet.services.designer;
import it.eng.spago.base.SourceBean;
import it.eng.spagobi.engines.worksheet.WorksheetEngineInstance;
import it.eng.spagobi.engines.worksheet.services.AbstractWorksheetEngineAction;
import it.eng.spagobi.tools.dataset.bo.IDataSet;
import it.eng.spagobi.tools.dataset.common.metadata.IFieldMetaData;
import it.eng.spagobi.tools.dataset.common.metadata.IFieldMetaData.FieldType;
import it.eng.spagobi.tools.dataset.common.metadata.IMetaData;
import it.eng.spagobi.tools.dataset.common.query.AggregationFunctions;
import it.eng.spagobi.utilities.assertion.Assert;
import it.eng.spagobi.utilities.engines.SpagoBIEngineServiceException;
import it.eng.spagobi.utilities.engines.SpagoBIEngineServiceExceptionHandler;
import it.eng.spagobi.utilities.service.JSONSuccess;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONObject;
/**
* @author Davide Zerbetto (davide.zerbetto@eng.it)
*/
public class GetWorksheetFieldsAction extends AbstractWorksheetEngineAction {
private static final long serialVersionUID = -5874137232683097175L;
/** Logger component. */
private static transient Logger logger = Logger.getLogger(GetWorksheetFieldsAction.class);
// PROPERTIES TO LOOK FOR INTO THE FIELDS
public static final String PROPERTY_VISIBLE = "visible";
public static final String PROPERTY_IS_SEGMENT_ATTRIBUTE = "isSegmentAttribute";
public static final String PROPERTY_IS_MANDATORY_MEASURE = "isMandatoryMeasure";
public static final String PROPERTY_AGGREGATION_FUNCTION = "aggregationFunction";
public void service(SourceBean request, SourceBean response) {
JSONObject resultsJSON;
logger.debug("IN");
try {
super.service(request, response);
WorksheetEngineInstance engineInstance = this.getEngineInstance();
Assert.assertNotNull(engineInstance, "It's not possible to execute " + this.getActionName() + " service before having properly created an instance of EngineInstance class");
IDataSet dataset = engineInstance.getDataSet();
Assert.assertNotNull(dataset, "The engine instance is missing the dataset!!");
IMetaData metadata = dataset.getMetadata();
Assert.assertNotNull(metadata, "No metadata retrieved by the dataset");
JSONArray fieldsJSON = writeFields(metadata);
logger.debug("Metadata read:");
logger.debug(fieldsJSON);
resultsJSON = new JSONObject();
resultsJSON.put("results", fieldsJSON);
try {
writeBackToClient( new JSONSuccess( resultsJSON ) );
} catch (IOException e) {
throw new SpagoBIEngineServiceException(getActionName(), "Impossible to write back the responce to the client [" + resultsJSON.toString(2)+ "]", e);
}
} catch(Throwable t) {
throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
} finally {
logger.debug("OUT");
}
}
public JSONArray writeFields(IMetaData metadata) throws Exception {
// field's meta
JSONArray fieldsMetaDataJSON = new JSONArray();
int fieldCount = metadata.getFieldCount();
logger.debug("Number of fields = " + fieldCount);
Assert.assertTrue(fieldCount > 0, "Dataset has no fields!!!");
for (int i = 0; i < fieldCount; i++) {
IFieldMetaData fieldMetaData = metadata.getFieldMeta(i);
Assert.assertNotNull(fieldMetaData, "Field metadata for position " + i + " not found.");
logger.debug("Evaluating field with name [" + fieldMetaData.getName() + "], alias [" + fieldMetaData.getAlias() + "] ...");
Object propertyRawValue = fieldMetaData.getProperty(PROPERTY_VISIBLE);
logger.debug("Read property " + PROPERTY_VISIBLE + ": its value is [" + propertyRawValue + "]");
if (propertyRawValue != null
&& (propertyRawValue instanceof Boolean)
&& ((Boolean) propertyRawValue).booleanValue() == false) {
logger.debug("The field is not visible");
continue;
} else {
logger.debug("The field is visible");
}
String fieldName = getFieldName(fieldMetaData);
String fieldHeader = getFieldAlias(fieldMetaData);
JSONObject fieldMetaDataJSON = new JSONObject();
fieldMetaDataJSON.put("id", fieldName);
fieldMetaDataJSON.put("alias", fieldHeader);
FieldType type = fieldMetaData.getFieldType();
logger.debug("The field type is " + type.name());
switch (type) {
case ATTRIBUTE:
Object isSegmentAttributeObj = fieldMetaData.getProperty(PROPERTY_IS_SEGMENT_ATTRIBUTE);
logger.debug("Read property " + PROPERTY_IS_SEGMENT_ATTRIBUTE + ": its value is [" + propertyRawValue + "]");
String attributeNature = (isSegmentAttributeObj != null
&& (isSegmentAttributeObj instanceof Boolean)
&& ((Boolean) isSegmentAttributeObj).booleanValue()) ? "segment_attribute" : "attribute";
logger.debug("The nature of the attribute is recognized as " + attributeNature);
fieldMetaDataJSON.put("nature", attributeNature);
fieldMetaDataJSON.put("funct", AggregationFunctions.NONE);
fieldMetaDataJSON.put("iconCls", attributeNature);
break;
case MEASURE:
Object isMandatoryMeasureObj = fieldMetaData.getProperty(PROPERTY_IS_MANDATORY_MEASURE);
logger.debug("Read property " + PROPERTY_IS_MANDATORY_MEASURE + ": its value is [" + isMandatoryMeasureObj + "]");
String measureNature = (isMandatoryMeasureObj != null
&& (isMandatoryMeasureObj instanceof Boolean)
&& ((Boolean) isMandatoryMeasureObj).booleanValue()) ? "mandatory_measure" : "measure";
logger.debug("The nature of the measure is recognized as " + measureNature);
fieldMetaDataJSON.put("nature", measureNature);
String aggregationFunction = (String) fieldMetaData.getProperty(PROPERTY_AGGREGATION_FUNCTION);
logger.debug("Read property " + PROPERTY_AGGREGATION_FUNCTION + ": its value is [" + aggregationFunction + "]");
fieldMetaDataJSON.put("funct", AggregationFunctions.get(aggregationFunction).getName());
fieldMetaDataJSON.put("iconCls", measureNature);
String decimalPrecision= (String) fieldMetaData.getProperty(IFieldMetaData.DECIMALPRECISION);
if(decimalPrecision!=null){
fieldMetaDataJSON.put("precision", decimalPrecision);
}else{
fieldMetaDataJSON.put("precision", "2");
}
break;
}
fieldsMetaDataJSON.put(fieldMetaDataJSON);
}
return fieldsMetaDataJSON;
}
protected String getFieldAlias(IFieldMetaData fieldMetaData) {
String fieldAlias = fieldMetaData.getAlias() != null ? fieldMetaData.getAlias() : fieldMetaData.getName();
return fieldAlias;
}
protected String getFieldName(IFieldMetaData fieldMetaData) {
String fieldName = fieldMetaData.getName();
return fieldName;
}
}
| [
"franceschini@99afaf0d-6903-0410-885a-c66a8bbb5f81"
] | franceschini@99afaf0d-6903-0410-885a-c66a8bbb5f81 |
eb3e683710dfa62dd4d3b2de48e57de50c2ed7c0 | 973d21457baffcf7d6c82476e744fb030f4a4aa7 | /src/codigo/VentanaCalculadora.java | 4738bb03c36898b3cad57d2cc8e5b50a46c6d7a4 | [] | no_license | Geletejo/Calculadora | 419ad1dba19491a86dd5a4a1d660733ad402cf6d | 177b8f86f75b17675f33f3e3a5e2d256a92d857c | refs/heads/master | 2020-04-16T03:21:12.812738 | 2019-01-11T12:03:43 | 2019-01-11T12:03:43 | 165,229,121 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 27,552 | 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 codigo;
/**
*
* @author xp
*/
public class VentanaCalculadora extends javax.swing.JFrame {
double operando1 = 0; //Primer operando.
String operacion = ""; //Guarda que opercaion se ha pulsado
/**
* Creates new form VentanaCalculadora
*/
public VentanaCalculadora() {
initComponents();
}
private void numeroPulsado(String numero){
if (pantalla.getText() == "0"){
pantalla.setText(numero);
}
else {
pantalla.setText(pantalla.getText() + numero);
}
}
private void operacionPulsada(String _operacion){
operacion = _operacion;
//Se convierte los escrito en la pantalla (el numero pero que ahora es un String) a su equivalente double, para poder operar.
operando1 = Double.valueOf (pantalla.getText());
//borro pantalla
pantalla.setText("0");
pantalla2.setText(String.valueOf(operando1));
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
pantalla = new javax.swing.JLabel();
button7 = new javax.swing.JButton();
button8 = new javax.swing.JButton();
button9 = new javax.swing.JButton();
button4 = new javax.swing.JButton();
button5 = new javax.swing.JButton();
button6 = new javax.swing.JButton();
button1 = new javax.swing.JButton();
button2 = new javax.swing.JButton();
button3 = new javax.swing.JButton();
suma = new javax.swing.JButton();
resta = new javax.swing.JButton();
multiplicacion = new javax.swing.JButton();
button0 = new javax.swing.JButton();
igual = new javax.swing.JButton();
division = new javax.swing.JButton();
pantalla2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
pantalla.setBackground(java.awt.Color.black);
pantalla.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N
pantalla.setForeground(new java.awt.Color(0, 51, 255));
pantalla.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
pantalla.setText("0");
pantalla.setOpaque(true);
button7.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
button7.setText("7");
button7.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
button7MousePressed(evt);
}
});
button7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button7ActionPerformed(evt);
}
});
button8.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
button8.setText("8");
button8.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
button8MousePressed(evt);
}
});
button8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button8ActionPerformed(evt);
}
});
button9.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
button9.setText("9");
button9.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
button9MousePressed(evt);
}
});
button9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button9ActionPerformed(evt);
}
});
button4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
button4.setText("4");
button4.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
button4MousePressed(evt);
}
});
button4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button4ActionPerformed(evt);
}
});
button5.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
button5.setText("5");
button5.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
button5MousePressed(evt);
}
});
button5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button5ActionPerformed(evt);
}
});
button6.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
button6.setText("6");
button6.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
button6MousePressed(evt);
}
});
button6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button6ActionPerformed(evt);
}
});
button1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
button1.setText("1");
button1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
button1MousePressed(evt);
}
});
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button1ActionPerformed(evt);
}
});
button2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
button2.setText("2");
button2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
button2MousePressed(evt);
}
});
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button2ActionPerformed(evt);
}
});
button3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
button3.setText("3");
button3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
button3MousePressed(evt);
}
});
button3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button3ActionPerformed(evt);
}
});
suma.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
suma.setText("+");
suma.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
sumaMousePressed(evt);
}
});
suma.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sumaActionPerformed(evt);
}
});
resta.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
resta.setText("-");
resta.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
restaMousePressed(evt);
}
});
resta.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
restaActionPerformed(evt);
}
});
multiplicacion.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
multiplicacion.setText("*");
multiplicacion.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
multiplicacionMousePressed(evt);
}
});
multiplicacion.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
multiplicacionActionPerformed(evt);
}
});
button0.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
button0.setText("0");
button0.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
button0MousePressed(evt);
}
});
button0.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button0ActionPerformed(evt);
}
});
igual.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
igual.setText("=");
igual.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
igualMousePressed(evt);
}
});
igual.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
igualActionPerformed(evt);
}
});
division.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
division.setText("/");
division.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
divisionMousePressed(evt);
}
});
division.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
divisionActionPerformed(evt);
}
});
pantalla2.setBackground(java.awt.Color.black);
pantalla2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
pantalla2.setForeground(java.awt.Color.blue);
pantalla2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
pantalla2.setText("0");
pantalla2.setOpaque(true);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(pantalla2, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(pantalla, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(multiplicacion, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(button5, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(button6, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(resta, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(button7, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(button8, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(button9, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(52, 52, 52)
.addComponent(suma, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(button0, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(igual, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(division, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(pantalla2, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(pantalla, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(button7, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button8, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button9, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(suma, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(button6, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(resta, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(multiplicacion, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(button0, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(igual, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(division, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void button7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button7ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_button7ActionPerformed
private void button7MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button7MousePressed
numeroPulsado("7");
}//GEN-LAST:event_button7MousePressed
private void button8MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button8MousePressed
numeroPulsado("8");
}//GEN-LAST:event_button8MousePressed
private void button8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button8ActionPerformed
}//GEN-LAST:event_button8ActionPerformed
private void button9MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button9MousePressed
numeroPulsado("9");
}//GEN-LAST:event_button9MousePressed
private void button9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button9ActionPerformed
}//GEN-LAST:event_button9ActionPerformed
private void button4MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button4MousePressed
numeroPulsado("4");
}//GEN-LAST:event_button4MousePressed
private void button4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button4ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_button4ActionPerformed
private void button5MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button5MousePressed
numeroPulsado("5");
}//GEN-LAST:event_button5MousePressed
private void button5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button5ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_button5ActionPerformed
private void button6MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button6MousePressed
numeroPulsado("6");
}//GEN-LAST:event_button6MousePressed
private void button6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button6ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_button6ActionPerformed
private void button1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button1MousePressed
numeroPulsado("1");
}//GEN-LAST:event_button1MousePressed
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_button1ActionPerformed
private void button2MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button2MousePressed
numeroPulsado("2");
}//GEN-LAST:event_button2MousePressed
private void button2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button2ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_button2ActionPerformed
private void button3MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button3MousePressed
numeroPulsado("3");
}//GEN-LAST:event_button3MousePressed
private void button3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button3ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_button3ActionPerformed
private void sumaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sumaMousePressed
operacionPulsada("+");
}//GEN-LAST:event_sumaMousePressed
private void sumaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sumaActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_sumaActionPerformed
private void restaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_restaMousePressed
operacionPulsada("-");
}//GEN-LAST:event_restaMousePressed
private void restaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_restaActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_restaActionPerformed
private void multiplicacionMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_multiplicacionMousePressed
operacionPulsada("*");
}//GEN-LAST:event_multiplicacionMousePressed
private void multiplicacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multiplicacionActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_multiplicacionActionPerformed
private void button0MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_button0MousePressed
numeroPulsado("0");
}//GEN-LAST:event_button0MousePressed
private void button0ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button0ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_button0ActionPerformed
private void igualMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_igualMousePressed
//Leo el segundo operando que esta en la pantalla y lo convierto a un Double.
double operando2 = Double.valueOf (pantalla.getText());
if (operacion.equals("+")){
operando1= operando1 + operando2;
}
if (operacion.equals("-")){
operando1= operando1 - operando2;
}
if (operacion.equals("*")){
operando1= operando1 * operando2;
}
if (operacion.equals("/")){
operando1= operando1 / operando2;
}
//Dibujo en la pantalla el resultado convertido a string
pantalla.setText(String.valueOf (operando1));
}//GEN-LAST:event_igualMousePressed
private void igualActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_igualActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_igualActionPerformed
private void divisionMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_divisionMousePressed
operacionPulsada("/");
}//GEN-LAST:event_divisionMousePressed
private void divisionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_divisionActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_divisionActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(VentanaCalculadora.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(VentanaCalculadora.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(VentanaCalculadora.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(VentanaCalculadora.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new VentanaCalculadora().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton button0;
private javax.swing.JButton button1;
private javax.swing.JButton button2;
private javax.swing.JButton button3;
private javax.swing.JButton button4;
private javax.swing.JButton button5;
private javax.swing.JButton button6;
private javax.swing.JButton button7;
private javax.swing.JButton button8;
private javax.swing.JButton button9;
private javax.swing.JButton division;
private javax.swing.JButton igual;
private javax.swing.JButton multiplicacion;
private javax.swing.JLabel pantalla;
private javax.swing.JLabel pantalla2;
private javax.swing.JButton resta;
private javax.swing.JButton suma;
// End of variables declaration//GEN-END:variables
}
| [
"xp@CETYSDAM026"
] | xp@CETYSDAM026 |
98eccd3fb62d273cf5b8961afc4217beb8af489e | 40f29ee0776953a747d772703bd98a49fc64cd81 | /com-tensquare-article/src/main/java/com/excepiton/ArticleException.java | 7c67bd3ed1b2ffad1210e78d4ca5d6bd48897cd7 | [] | no_license | ludan2019/tensquere | b42820444753bd399b8033cf3edf46264ac50b69 | abf17f4d8959ad982aeca48fa88558b313401752 | refs/heads/master | 2020-07-05T03:28:04.506973 | 2019-09-10T09:37:48 | 2019-09-10T09:37:48 | 202,507,975 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 431 | java | package com.excepiton;
import com.excepition.CommonExcepition;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpStatus;
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum ArticleException implements CommonExcepition {
NOT_FIND_ARTICLE(HttpStatus.NOT_FOUND.value(),"未发现文章");
private Integer code;
private String message;
}
| [
"luludandan1@163.com"
] | luludandan1@163.com |
3d8d07db97b5ddfe53a87e4f2aa638af71201743 | 54c57aca670ed160533175033fc67e3864a571d1 | /src/com/sundyn/service/IInteTicketService.java | b0e515d35d0716057c1637a88f3ebd1ea559009e | [] | no_license | beango/sundyn | e33ee9adc9659a73ae565f1a86f826586ab4dc59 | 0981b5b8ff1327835cf277a51de66bdc2d243555 | refs/heads/master | 2022-12-24T02:31:27.188517 | 2019-07-26T02:52:09 | 2019-07-26T02:52:09 | 83,861,523 | 0 | 1 | null | 2022-12-16T04:33:54 | 2017-03-04T03:18:14 | JavaScript | UTF-8 | Java | false | false | 265 | java | package com.sundyn.service;
import com.sundyn.entity.InteTicket;
import com.baomidou.mybatisplus.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author oKong
* @since 2018-09-13
*/
public interface IInteTicketService extends IService<InteTicket> {
}
| [
"6588617@gmail.com"
] | 6588617@gmail.com |
fe27fe79a972560c15cef7eb1bd7cf7825267eb1 | e0f6050cad4e80200ca471c4382562a75172e95c | /src/org/stevens/cs562/sql/ComparisonAndComputeOperator.java | 6cb7f82003e86f77df7c583657c63c09a8d9faf2 | [] | no_license | faireprogram/CS562 | cc2ca96a2fee4bfda3d12cf95267c1775c2ebf14 | 0c32334edf2308aa30c24e7face62bea74c574ec | refs/heads/master | 2020-05-18T16:04:26.314230 | 2015-09-13T04:32:04 | 2015-09-13T04:32:04 | 31,145,848 | 3 | 3 | null | null | null | null | UTF-8 | Java | false | false | 830 | java | package org.stevens.cs562.sql;
/**
* @author faire_000
*
*/
public enum ComparisonAndComputeOperator {
GREATER(">",">"),GREATER_EQUAL(">=",">="),LESS("<","<"),LESS_EQUAL("<=","<="),EQUAL("=","=="), NOT_EQUAL("<>","!="),
ADDITION("+", "+"), MINUS("-", "-"), MULTIPLICATION("*", "*"), DIVID("/", "/"), AND("and", "&&"), OR("or", "||");
private String java_name;
private String symbol;
private ComparisonAndComputeOperator(String symbol, String java_name) {
this.java_name = java_name;
this.symbol = symbol;
}
/**
* @return the java_name
*/
public String getJava_name() {
return java_name;
}
/**
* @return the symbol
*/
public String getSymbol() {
return symbol;
}
/* (non-Javadoc)
* @see java.lang.Enum#toString()
*/
@Override
public String toString() {
return this.symbol;
}
}
| [
"michael.zhangwen@yahoo.com"
] | michael.zhangwen@yahoo.com |
d6787c0f593d0a0f533b19db35bf7a162e74bc2e | b3917c299d559c7f93b1fee7491ebd3dcd85f811 | /app/src/main/java/com/narij/checkv2/retrofit/model/RetrofitGroups.java | a7f75e9ec6368fa7adbaa545ee4c09c8d56bde91 | [] | no_license | kamisaberi/check-social-network-frontend-android | 0da21c69e7f91b2c54c22a4194a1a601d172a65c | 7acf5424ee9b495b22063b89bfb42a1cabb919c8 | refs/heads/master | 2022-06-20T16:18:17.186968 | 2020-05-08T09:13:41 | 2020-05-08T09:13:41 | 262,278,029 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,238 | java | package com.narij.checkv2.retrofit.model;
import com.narij.checkv2.model.Group;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
/**
* Created by kami on 8/15/2017.
*/
public class RetrofitGroups {
@SerializedName("id")
private int id;
@SerializedName("error")
private boolean error;
@SerializedName("groups")
private ArrayList<Group> groups = new ArrayList<>();
public ArrayList<Group> getGroups() {
return groups;
}
public void setGroups(ArrayList<Group> groups) {
this.groups = groups;
}
public boolean isError() {
return error;
}
public void setError(boolean error) {
this.error = error;
}
@SerializedName("message")
private String message;
public RetrofitGroups() {
}
public RetrofitGroups(int id, boolean error, String content) {
this.id = id;
this.error = error;
this.message = content;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
| [
"kamisaberi@yahoo.com"
] | kamisaberi@yahoo.com |
a8e6f8fbfd873b5069d96ed4e288d8b12f67c3e8 | 597ae0da8444c42e33583ae5e34aafb787a25fbc | /hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/UriParam.java | 025a17b23cf35101f5cf9c7d5cdc1238f6b2ee13 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | artonio/hapi-fhir | 6d0979d6da54fd01ca3a80e944ad2ab0ccb5534d | c8a3e99d8f34fbe1e077be2ebe7cdecf787b170d | refs/heads/master | 2021-08-06T18:45:43.165648 | 2020-05-14T21:50:19 | 2020-05-14T21:50:19 | 179,379,046 | 1 | 0 | Apache-2.0 | 2020-05-14T21:51:55 | 2019-04-03T22:22:40 | Java | UTF-8 | Java | false | false | 3,063 | java | package ca.uhn.fhir.rest.param;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2020 University Health Network
* %%
* 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.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.defaultString;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.model.primitive.UriDt;
public class UriParam extends BaseParam implements IQueryParameterType {
private UriParamQualifierEnum myQualifier;
private String myValue;
/**
* Constructor
*/
public UriParam() {
super();
}
public UriParam(String theValue) {
setValue(theValue);
}
@Override
String doGetQueryParameterQualifier() {
return myQualifier != null ? myQualifier.getValue() : null;
}
@Override
String doGetValueAsQueryToken(FhirContext theContext) {
return ParameterUtil.escape(myValue);
}
@Override
void doSetValueAsQueryToken(FhirContext theContext, String theParamName, String theQualifier, String theValue) {
myQualifier = UriParamQualifierEnum.forValue(theQualifier);
myValue = ParameterUtil.unescape(theValue);
}
/**
* Gets the qualifier for this param (may be <code>null</code> and generally will be)
*/
public UriParamQualifierEnum getQualifier() {
return myQualifier;
}
public String getValue() {
return myValue;
}
public StringDt getValueAsStringDt() {
return new StringDt(myValue);
}
public UriDt getValueAsUriDt() {
return new UriDt(myValue);
}
public String getValueNotNull() {
return defaultString(myValue);
}
public boolean isEmpty() {
return StringUtils.isEmpty(myValue);
}
/**
* Sets the qualifier for this param (may be <code>null</code> and generally will be)
*
* @return Returns a reference to <code>this</code> for easy method chanining
*/
public UriParam setQualifier(UriParamQualifierEnum theQualifier) {
myQualifier = theQualifier;
return this;
}
/**
* Sets the value for this param
*
* @return Returns a reference to <code>this</code> for easy method chanining
*/
public UriParam setValue(String theValue) {
myValue = theValue;
return this;
}
@Override
public String toString() {
ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
builder.append("value", getValue());
return builder.toString();
}
}
| [
"jamesagnew@gmail.com"
] | jamesagnew@gmail.com |
96efbed182c0ed6eb2ef215db1fd6ee611aee207 | 830a0c753b5dd2c06d0f25f7b5c4ebf8e59341e5 | /jaxrs-hibernate-client/src/test/java/com/atomikos/jaxrshibernateclient/JaxrsHibernateClientApplicationTests.java | 55518de903ca67a72a00f75de7748007712ec9ee | [] | no_license | atomikos/transactions-over-rest-with-hybrid-jaxrs-stack | e9d31d5f812a4fc7808f6b247c3d5d9c8c0bbd07 | e44ad5711b1581025a25f93e4d7f4120e737a26c | refs/heads/master | 2023-07-09T14:53:42.982725 | 2020-03-31T12:17:37 | 2020-03-31T12:17:37 | 251,315,079 | 0 | 3 | null | null | null | null | UTF-8 | Java | false | false | 227 | java | package com.atomikos.jaxrshibernateclient;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class JaxrsHibernateClientApplicationTests {
@Test
void contextLoads() {
}
}
| [
"pascal.leclercq@gmail.com"
] | pascal.leclercq@gmail.com |
63881a2ddede308250e3d3370d2f0784ed9359b0 | c4a14d70951d7ec5aac7fe7ebb2db891cfe6c0b1 | /modulos/apps/LOCALGIS-Workbench/src/main/java/com/vividsolutions/jump/workbench/ui/plugin/ViewSchemaPlugIn.java | d35e8e68573d5df751966ea17a2cd58d78e501dc | [] | no_license | pepeysusmapas/allocalgis | 925756321b695066775acd012f9487cb0725fcde | c14346d877753ca17339f583d469dbac444ffa98 | refs/heads/master | 2020-09-14T20:15:26.459883 | 2016-09-27T10:08:32 | 2016-09-27T10:08:32 | null | 0 | 0 | null | null | null | null | WINDOWS-1258 | Java | false | false | 36,048 | java | /*
* The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
* for visualizing and manipulating spatial features with geometry and attributes.
*
* Copyright (C) 2003 Vivid Solutions
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* For more information, contact:
*
* Vivid Solutions
* Suite #1A
* 2328 Government Street
* Victoria BC V8T 5G5
* Canada
*
* (250)385-6040
* www.vividsolutions.com
*/
package com.vividsolutions.jump.workbench.ui.plugin;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import com.geopista.app.AppContext;
import com.geopista.editor.WorkbenchGuiComponent;
import com.geopista.feature.Column;
import com.geopista.feature.Domain;
import com.geopista.feature.GeopistaSchema;
import com.geopista.feature.Table;
import com.geopista.util.ApplicationContext;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.io.ParseException;
import com.vividsolutions.jts.io.WKTReader;
import com.vividsolutions.jts.util.Assert;
import com.vividsolutions.jump.feature.AttributeType;
import com.vividsolutions.jump.feature.BasicFeature;
import com.vividsolutions.jump.feature.Feature;
import com.vividsolutions.jump.feature.FeatureDataset;
import com.vividsolutions.jump.feature.FeatureSchema;
import com.vividsolutions.jump.util.Blackboard;
import com.vividsolutions.jump.util.FlexibleDateParser;
import com.vividsolutions.jump.util.StringUtil;
import com.vividsolutions.jump.workbench.WorkbenchContext;
import com.vividsolutions.jump.workbench.model.CategoryEvent;
import com.vividsolutions.jump.workbench.model.FeatureEvent;
import com.vividsolutions.jump.workbench.model.Layer;
import com.vividsolutions.jump.workbench.model.LayerEvent;
import com.vividsolutions.jump.workbench.model.LayerEventType;
import com.vividsolutions.jump.workbench.model.LayerListener;
import com.vividsolutions.jump.workbench.model.LayerManager;
import com.vividsolutions.jump.workbench.model.LayerManagerProxy;
import com.vividsolutions.jump.workbench.model.Layerable;
import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
import com.vividsolutions.jump.workbench.plugin.PlugInContext;
import com.vividsolutions.jump.workbench.ui.LayerNamePanel;
import com.vividsolutions.jump.workbench.ui.LayerNamePanelListener;
import com.vividsolutions.jump.workbench.ui.LayerNamePanelProxy;
import com.vividsolutions.jump.workbench.ui.SchemaPanel;
import com.vividsolutions.jump.workbench.ui.TreeLayerNamePanel;
import com.vividsolutions.jump.workbench.ui.cursortool.editing.EditingPlugIn;
import com.vividsolutions.jump.workbench.ui.images.IconLoader;
public class ViewSchemaPlugIn extends AbstractPlugIn {
private ApplicationContext aplicacion=AppContext.getApplicationContext();
private Blackboard blackboard = aplicacion.getBlackboard();
private static final String KEY = ViewSchemaPlugIn.class + " - FRAME";
private EditingPlugIn editingPlugIn;
private GeometryFactory factory = new GeometryFactory();
private WKTReader wktReader = new WKTReader(factory);
private FlexibleDateParser dateParser = new FlexibleDateParser();
private DateFormat dateFormatter = DateFormat.getDateInstance();
public ViewSchemaPlugIn(EditingPlugIn editingPlugIn) {
this.editingPlugIn = editingPlugIn;
}
public ViewSchemaPlugIn() {
}
public String getName() {
return "View / Edit Schema";
}
private void applyChanges(final Layer layer, final SchemaPanel panel)
throws Exception {
if (!panel.isModified()) {
//User just pressed the Apply button even though he made no edits.
//Don't truncate the undo history; instead, exit. [Jon Aquino]
return;
}
if (panel.validateInput() != null) {
throw new Exception(panel.validateInput());
}
panel.getModel().removeBlankRows();
if (!(layer.getFeatureCollectionWrapper().getFeatureSchema() instanceof GeopistaSchema)){
FeatureSchema newSchema = new FeatureSchema();
for (int i = 0; i < panel.getModel().getRowCount(); i++) {
newSchema.addAttribute(panel.getModel().get(i).getName(),
panel.getModel().get(i).getType());
}
List originalFeatures = layer.getFeatureCollectionWrapper().getFeatures(); //¿que pasa con el Geometry index y con el coordinateSystem?
ArrayList tempFeatures = new ArrayList();
//Two-phase commit. Phase 1: check that no conversion errors occur. [Jon Aquino]
for (Iterator i = layer.getFeatureCollectionWrapper().iterator();
i.hasNext();) {
Feature feature = (Feature) i.next();
tempFeatures.add(convert(feature, panel, newSchema));
}
//Phase 2: commit. [Jon Aquino]
for (int i = 0; i < originalFeatures.size(); i++) {
Feature originalFeature = (Feature) originalFeatures.get(i);
Feature tempFeature = (Feature) tempFeatures.get(i);
//Modify existing features rather than creating new features, because
//there may be references to the existing features (e.g. Attribute Viewers).
//[Jon Aquino]
originalFeature.setSchema(tempFeature.getSchema());
originalFeature.setAttributesRaw(tempFeature.getAttributes());
}
//Non-undoable. [Jon Aquino]
layer.getLayerManager().getUndoableEditReceiver().getUndoManager()
.discardAllEdits();
layer.setFeatureCollection(new FeatureDataset(originalFeatures,
newSchema));
layer.fireLayerChanged(LayerEventType.METADATA_CHANGED);
panel.markAsUnmodified();
}else{
GeopistaSchema newSchema=new GeopistaSchema();
// GeopistaSchema currentSchema=(GeopistaSchema)layer.getFeatureCollectionWrapper().getFeatureSchema();
// List currentAttrib=currentSchema.getAttributes();
//
// SchemaTableModel tableModel=(SchemaTableModel)blackboard.get("schemaModel");
// List fields =tableModel.getFields();
Table tableDummy = new Table("Table por defecto","Table por defecto");
GeopistaSchema schema=(GeopistaSchema)layer.getFeatureCollectionWrapper().getFeatureSchema();
//List atributes=schema.getAttributes();
for (int i = 0; i < panel.getModel().getRowCount(); i++) {
// if(panel.getModel().get(i).getOriginalIndex()==-1){
AttributeType atributeType = panel.getModel().get(i).getType();
String atributeName= panel.getModel().get(i).getName();
// Domain domainDummy = null;
// Refactorizado hacia la clase Domain
Domain domainDummy=Domain.getDomainForType(atributeType.toJavaClass());
// if(atributeType.equals(AttributeType.STRING)){
// domainDummy= new StringDomain("?[.*]","");
// }else if(atributeType.equals(AttributeType.INTEGER) || atributeType.equals(AttributeType.LONG )){
// domainDummy= new NumberDomain("?[-INF:INF]","");
// }else if(atributeType.equals(AttributeType.DOUBLE) || atributeType.equals(AttributeType.FLOAT)){
// domainDummy= new NumberDomain("?[-INF:INF]","");
// }else if(atributeType.equals(AttributeType.DATE)){
// domainDummy= new DateDomain("?[*:*]","");
// }else
// domainDummy= new StringDomain("?[.*]","");
Column columnDummy = new Column(atributeName, "", tableDummy,domainDummy);
newSchema.addAttribute(atributeName, atributeType, columnDummy,
GeopistaSchema.READ_WRITE);
// }else{
//
// newSchema.addAttribute((Attribute)atributes.get(panel.getModel().get(i).getOriginalIndex()));
// }
}
List originalFeatures = layer.getFeatureCollectionWrapper().getFeatures();
ArrayList tempFeatures = new ArrayList();
//Two-phase commit. Phase 1: check that no conversion errors occur. [Jon Aquino]
for (Iterator i = layer.getFeatureCollectionWrapper().iterator();
i.hasNext();) {
Feature feature = (Feature) i.next();
tempFeatures.add(convert(feature, panel, newSchema));
}
//Phase 2: commit. [Jon Aquino]
for (int i = 0; i < originalFeatures.size(); i++) {
Feature originalFeature = (Feature) originalFeatures.get(i);
Feature tempFeature = (Feature) tempFeatures.get(i);
//Modify existing features rather than creating new features, because
//there may be references to the existing features (e.g. Attribute Viewers).
//[Jon Aquino]
originalFeature.setSchema(tempFeature.getSchema());
originalFeature.setAttributesRaw(tempFeature.getAttributes());
}
//Non-undoable. [Jon Aquino]
layer.getLayerManager().getUndoableEditReceiver().getUndoManager()
.discardAllEdits();
layer.setFeatureCollection(new FeatureDataset(originalFeatures,
newSchema));
layer.fireLayerChanged(LayerEventType.METADATA_CHANGED);
panel.markAsUnmodified();
}
}
/*private Feature convert(Feature oldFeature, SchemaPanel panel,
GeopistaSchema newSchema) throws ConversionException {
Feature newFeature = new BasicFeature(newSchema);
for (int i = 0; i < panel.getModel().getRowCount(); i++) {
if (newSchema.getAttributeIndex(panel.getModel().get(i).getName()) == -1) {
newFeature.setAttribute(i,
(panel.getModel().get(i).getType() == AttributeType.GEOMETRY)
? oldFeature.getGeometry() : null);
} else {
try
{
if(panel.getModel().get(i).getOriginalIndex()==-1){
//Esto significa que el atributo no existia antes en la antigua feature
throw new IllegalArgumentException();
}else{
newFeature.setAttribute(i,convert(oldFeature.getAttribute(panel.getModel().get(i).getOriginalIndex()),
oldFeature.getSchema().getAttributeType(panel.getModel().get(i).getOriginalIndex()),
newFeature.getSchema().getAttributeType(panel.getModel().get(i).getName()),
panel.getModel().get(i).getName(),
panel.isForcingInvalidConversionsToNull()));
}
}catch (IllegalArgumentException e)
{
newFeature.setAttribute(i,null);
//return newFeature;
}
}
}
return newFeature;
}*/
private Feature convert(Feature oldFeature, SchemaPanel panel,
FeatureSchema newSchema) throws ConversionException {
Feature newFeature = new BasicFeature(newSchema);
for (int i = 0; i < panel.getModel().getRowCount(); i++) {
if (newSchema.getAttributeIndex(panel.getModel().get(i).getName()) == -1) { //CHECK: este esquema no devuelve -1
newFeature.setAttribute(i,
(panel.getModel().get(i).getType() == AttributeType.GEOMETRY)
? oldFeature.getGeometry() : null);
} else {
try
{
String newAttName=panel.getModel().get(i).getName();
int oldIndex=panel.getModel().get(i).getOriginalIndex();
// CHECK: Esto esta patas arriba!!
// newFeature.setAttribute(i,
// convert(oldFeature.getAttribute(oldFeature.getSchema().getAttributeIndex(newAttName)),
// oldFeature.getSchema().getAttributeType(oldFeature.getSchema().getAttributeIndex(newAttName)),
// newFeature.getSchema().getAttributeType(newAttName),
//
// panel.getModel().get(i).getName(),
// panel.isForcingInvalidConversionsToNull()));
Object oldValue = null;
AttributeType oldAttributeType = null;
if(oldIndex>-1)
{
oldValue = oldFeature.getAttribute(oldIndex);
oldAttributeType = oldFeature.getSchema().getAttributeType(oldIndex);
}
newFeature.setAttribute(i,
convert(oldValue,
oldAttributeType,
newFeature.getSchema().getAttributeType(i),
newAttName,
panel.isForcingInvalidConversionsToNull()));
}catch (IllegalArgumentException e)
{
newFeature.setAttribute(i,null);
}
}
}
return newFeature;
}
private String limitLength(String s) {
//Limit length of values reported in error messages -- WKT is potentially large.
//[Jon Aquino]
return StringUtil.limitLength(s, 30);
}
private Object convert(Object oldValue, AttributeType oldType,
AttributeType newType, String name,
boolean forcingInvalidConversionsToNull) throws ConversionException {
try {
if (oldValue == null) {
return (newType == AttributeType.GEOMETRY)
? factory.createPoint((Coordinate)null) : null;
}
if (oldType == AttributeType.STRING) {
String oldString = (String) oldValue;
if (newType == AttributeType.STRING) {
return oldString;
}
if (newType == AttributeType.INTEGER) {
try {
return new Integer(oldString);
} catch (NumberFormatException e) {
throw new ConversionException(
"Cannot convert to integer: \"" +
limitLength(oldValue.toString()) + "\" (" + name +
")");
}
}
if (newType == AttributeType.LONG) {
try {
return new Long(oldString);
} catch (NumberFormatException e) {
throw new ConversionException(
"Cannot convert to long: \"" +
limitLength(oldValue.toString()) + "\" (" + name +
")");
}
}
if (newType == AttributeType.DOUBLE) {
try {
return new Double(oldString);
} catch (NumberFormatException e) {
throw new ConversionException(
"Cannot convert to double: \"" +
limitLength(oldValue.toString()) + "\" (" + name +
")");
}
}
if (newType == AttributeType.FLOAT) {
try {
return new Float(oldString);
} catch (NumberFormatException e) {
throw new ConversionException(
"Cannot convert to float: \"" +
limitLength(oldValue.toString()) + "\" (" + name +
")");
}
}
if (newType == AttributeType.GEOMETRY) {
try {
return wktReader.read(oldString);
} catch (ParseException e) {
throw new ConversionException(
"Cannot convert to geometry: \"" +
limitLength(oldValue.toString()) + "\" (" + name +
")");
}
}
if (newType == AttributeType.DATE) {
try {
return dateParser.parse(oldString, false);
} catch (java.text.ParseException e) {
throw new ConversionException(
"Cannot convert to date: \"" +
limitLength(oldValue.toString()) + "\" (" + name +
")");
}
}
}
if (oldType == AttributeType.INTEGER) {
int oldInt = ((Number) oldValue).intValue();
//int oldInt = Integer.valueOf((String)oldValue).intValue();
if (newType == AttributeType.STRING) {
return "" + oldInt;
}
if (newType == AttributeType.INTEGER) {
return oldValue;
}
if (newType == AttributeType.LONG) {
return new Long(oldInt);
}
if (newType == AttributeType.DOUBLE) {
return new Double(oldInt);
}
if (newType == AttributeType.FLOAT) {
return new Float(oldInt);
}
if (newType == AttributeType.GEOMETRY) {
throw new ConversionException(
"Cannot convert to geometry: \"" +
limitLength(oldValue.toString()) + "\" (" + name + ")");
}
if (newType == AttributeType.DATE) {
try {
return dateParser.parse("" + oldInt, false);
} catch (java.text.ParseException e) {
throw new ConversionException(
"Cannot convert to date: \"" +
limitLength(oldValue.toString()) + "\" (" + name +
")");
}
}
}
if (oldType == AttributeType.LONG) {
// long oldlng = ((Number) oldValue).longValue();
long oldlng = Long.valueOf((String)oldValue).longValue();
if (newType == AttributeType.STRING) {
return "" + oldlng;
}
if (newType == AttributeType.INTEGER) {
throw new ConversionException(
"Cannot convert to Integer: \"" +
limitLength(oldValue.toString()) + "\" (" + name + ")");
}
if (newType == AttributeType.LONG) {
return oldValue;
}
if (newType == AttributeType.DOUBLE) {
return new Double(oldlng);
}
if (newType == AttributeType.FLOAT) {
return new Float(oldlng);
}
if (newType == AttributeType.GEOMETRY) {
throw new ConversionException(
"Cannot convert to geometry: \"" +
limitLength(oldValue.toString()) + "\" (" + name + ")");
}
if (newType == AttributeType.DATE) {
try {
return dateParser.parse("" + oldlng, false);
} catch (java.text.ParseException e) {
throw new ConversionException(
"Cannot convert to date: \"" +
limitLength(oldValue.toString()) + "\" (" + name +
")");
}
}
}
if (oldType == AttributeType.DOUBLE) {
double oldDouble = ((Double) oldValue).doubleValue();
if (newType == AttributeType.STRING) {
return "" + oldDouble;
}
if (newType == AttributeType.INTEGER) {
return new Integer((int) oldDouble);
}
if (newType == AttributeType.LONG) {
return new Long((long) oldDouble);
}
if (newType == AttributeType.DOUBLE) {
return oldValue;
}
if (newType == AttributeType.FLOAT) {
return new Float(oldDouble);
}
if (newType == AttributeType.GEOMETRY) {
throw new ConversionException(
"Cannot convert to geometry: \"" +
limitLength(oldValue.toString()) + "\" (" + name + ")");
}
if (newType == AttributeType.DATE) {
throw new ConversionException("Cannot convert to date: \"" +
limitLength(oldValue.toString()) + "\" (" + name + ")");
}
}
if (oldType == AttributeType.GEOMETRY) {
Geometry oldGeometry = (Geometry) oldValue;
if (newType == AttributeType.STRING) {
return oldGeometry.toString();
}
if (newType == AttributeType.INTEGER) {
throw new ConversionException(
"Cannot convert to integer: \"" +
limitLength(oldValue.toString()) + "\" (" + name + ")");
}
if (newType == AttributeType.LONG) {
throw new ConversionException(
"Cannot convert to long: \"" +
limitLength(oldValue.toString()) + "\" (" + name + ")");
}
if (newType == AttributeType.DOUBLE) {
throw new ConversionException(
"Cannot convert to double: \"" +
limitLength(oldValue.toString()) + "\" (" + name + ")");
}
if (newType == AttributeType.FLOAT) {
throw new ConversionException(
"Cannot convert to float: \"" +
limitLength(oldValue.toString()) + "\" (" + name + ")");
}
if (newType == AttributeType.GEOMETRY) {
return oldGeometry;
}
if (newType == AttributeType.DATE) {
throw new ConversionException("Cannot convert to date: \"" +
limitLength(oldValue.toString()) + "\" (" + name + ")");
}
}
if (oldType == AttributeType.DATE) {
Date oldDate = (Date) oldValue;
if (newType == AttributeType.STRING) {
return dateFormatter.format(oldDate);
}
if (newType == AttributeType.INTEGER) {
return new Integer((int) oldDate.getTime());
}
if (newType == AttributeType.LONG) {
return new Long( oldDate.getTime());
}
if (newType == AttributeType.DOUBLE) {
return new Double(oldDate.getTime());
}
if (newType == AttributeType.FLOAT) {
return new Float(oldDate.getTime());
}
if (newType == AttributeType.GEOMETRY) {
throw new ConversionException(
"Cannot convert to geometry: \"" +
limitLength(oldValue.toString()) + "\" (" + name + ")");
}
if (newType == AttributeType.DATE) {
return oldValue;
}
}
Assert.shouldNeverReachHere(newType.toString());
return null;
} catch (ConversionException e) {
if (forcingInvalidConversionsToNull) {
return (newType == AttributeType.GEOMETRY)
? factory.createPoint((Coordinate)null) : null;
}
throw e;
}
}
private void commitEditsInProgress(final SchemaPanel panel) {
//Skip if nothing is being edited, otherwise may get false positive. [Jon Aquino]
if (panel.getTable().getEditingRow() != -1) {
//If user is in the middle of editing a field name, call stopCellEditing
//so that new field name is committed (if valid) or an error is recorded
//(if invalid). [Jon Aquino]
panel.getTable()
.getCellEditor(panel.getTable().getEditingRow(),
panel.getTable().getEditingColumn()).stopCellEditing();
}
}
public boolean execute(PlugInContext context) throws Exception {
reportNothingToUndoYet(context);
//Can't simply use Blackboard#get(key, default) because default requires that
//we create a new EditSchemaFrame, and we don't want to do this unless we
//have to because the EditSchemaFrame constructor modifies the blackboard.
//Result: Executing this plug-in twice creates two frames, even if we don't close
//the first. [Jon Aquino]
if (frame(context) == null) {
context.getSelectedLayer(0).getBlackboard().put(KEY,
new EditSchemaFrame((WorkbenchGuiComponent) context.getWorkbenchGuiComponent(),
(Layer) context.getSelectedLayer(0), editingPlugIn));
}
frame(context).surface();
return true;
}
private EditSchemaFrame frame(PlugInContext context) {
return (EditSchemaFrame) context.getSelectedLayer(0).getBlackboard()
.get(KEY);
}
public static MultiEnableCheck createEnableCheck(
final WorkbenchContext workbenchContext) {
EnableCheckFactory checkFactory = new EnableCheckFactory(workbenchContext);
return new MultiEnableCheck().add(checkFactory.createWindowWithLayerNamePanelMustBeActiveCheck())
.add(checkFactory.createExactlyNLayersMustBeSelectedCheck(
1));
}
private static class ConversionException extends Exception {
public ConversionException(String message) {
super(message);
}
}
public static final ImageIcon ICON = IconLoader.icon("Object.gif");
private class EditSchemaFrame extends JInternalFrame
implements LayerNamePanelProxy, LayerNamePanel, LayerManagerProxy {
private LayerManager layerManager;
private Layer layer;
private WorkbenchGuiComponent workbenchFrame;
public EditSchemaFrame(final WorkbenchGuiComponent workbenchFrame,
final Layer layer, EditingPlugIn editingPlugIn) {
this.layer = layer;
this.workbenchFrame = workbenchFrame;
layer.getBlackboard().put(KEY, this);
this.layerManager = (LayerManager)layer.getLayerManager();
addInternalFrameListener(new InternalFrameAdapter() {
public void internalFrameClosed(InternalFrameEvent e) {
layer.getBlackboard().put(KEY, null);
}
});
final SchemaPanel panel = new SchemaPanel(layer, editingPlugIn,
workbenchFrame.getContext());
setResizable(true);
setClosable(true);
setMaximizable(true);
setIconifiable(true);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(panel, BorderLayout.CENTER);
setSize(500, 300);
updateTitle(layer);
layer.getLayerManager().addLayerListener(new LayerListener() {
public void categoryChanged(CategoryEvent e) {
}
public void featuresChanged(FeatureEvent e) {
}
public void layerChanged(LayerEvent e) {
updateTitle(layer);
}
});
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
panel.add(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
commitEditsInProgress(panel);
applyChanges(layer, panel);
} catch (Exception x) {
workbenchFrame.handleThrowable(x);
}
}
});
addInternalFrameListener(new InternalFrameAdapter() {
public void internalFrameClosing(InternalFrameEvent e) {
commitEditsInProgress(panel);
if (!layer.isEditable() || !panel.isModified()) {
dispose();
return;
}
switch (JOptionPane.showConfirmDialog(EditSchemaFrame.this,
aplicacion.getI18nString("ApplyChangesToTheSchema"), aplicacion.getI18nString("ViewSchemaPlugIn.Geopista"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE)) {
case JOptionPane.YES_OPTION:
try {
applyChanges(layer, panel);
} catch (Exception x) {
workbenchFrame.handleThrowable(x);
return;
}
dispose();
return;
case JOptionPane.NO_OPTION:
dispose();
return;
case JOptionPane.CANCEL_OPTION:
return;
default:
Assert.shouldNeverReachHere();
}
}
});
}
private void updateTitle(Layer layer) {
setTitle((SchemaPanel.isEditableAndSystemLayer(layer) ? aplicacion.getI18nString("ViewSchemaPlugIn.Edit") : aplicacion.getI18nString("ViewSchemaPlugIn.View")) + " " + aplicacion.getI18nString("ViewSchemaPlugIn.Schema") + " " +
layer.getName());
}
public LayerManager getLayerManager() {
return layerManager;
}
public Layer chooseEditableLayer() {
return TreeLayerNamePanel.chooseEditableLayer(this);
}
public void surface() {
if (!workbenchFrame.hasInternalFrame(this)) {
workbenchFrame.addInternalFrame(this, false, true);
}
workbenchFrame.activateFrame( this);
moveToFront();
}
public LayerNamePanel getLayerNamePanel() {
return this;
}
public Collection getSelectedCategories() {
return new ArrayList();
}
public Layer[] getSelectedLayers() {
return new Layer[] { layer };
}
public Layerable[] getSelectedLayerables() {
return getSelectedLayers();
}
public Collection selectedNodes(Class c) {
if (!Layerable.class.isAssignableFrom(c)) {
return new ArrayList();
}
return Arrays.asList(getSelectedLayers());
}
public void addListener(LayerNamePanelListener listener) {}
public void removeListener(LayerNamePanelListener listener) {}
/* (non-Javadoc)
* @see com.vividsolutions.jump.workbench.ui.LayerNamePanel#selectLayers(com.vividsolutions.jump.workbench.model.Layer[])
*/
public void selectLayers(Layer[] layers)
{
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see com.vividsolutions.jump.workbench.ui.LayerNamePanel#selectLayers(com.vividsolutions.jump.workbench.model.Layerable[])
*/
public void selectLayerables(Layerable[] layers)
{
// TODO Auto-generated method stub
}
@Override
public void setTargetSelectedLayers(Layerable[] layers) {
// TODO Auto-generated method stub
}
}
public void initialize(PlugInContext context) throws Exception {
JPopupMenu layerNamePopupMenu = context.getWorkbenchContext().getIWorkbench()
.getGuiComponent()
.getLayerNamePopupMenu();
FeatureInstaller featureInstaller = new FeatureInstaller(context.getWorkbenchContext());
featureInstaller.addPopupMenuItem(layerNamePopupMenu,
this, AppContext.getApplicationContext().getI18nString(this.getName()), false, null,
ViewSchemaPlugIn.createEnableCheck(context.getWorkbenchContext()));
}
}
| [
"jorge.martin@cenatic.es"
] | jorge.martin@cenatic.es |
d9395e6c7dbfc164efaccc313aaf93ed882c92fb | c89d3c27eee0f4f2fd7151f58490b98f7d9d72d9 | /src/main/java/com/sunan/model/DiscountOrderType.java | f2d68531f6ee4059ca453750d104dce452c20fcb | [] | no_license | sunan-technology/hotel-pos-api | 263acbacfc1114825080290f530859d0d3a618f7 | 6c3b675ceface2419fca20a95ac1ae9a43ddd4d1 | refs/heads/main | 2023-06-04T12:01:40.857699 | 2021-06-24T07:34:56 | 2021-06-24T07:34:56 | 343,310,928 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,866 | java | package com.sunan.model;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.UpdateTimestamp;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Entity
@Data
@EqualsAndHashCode(callSuper = false)
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "discount_ordertype")
public class DiscountOrderType implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
@GenericGenerator(name = "native", strategy = "native")
private int id;
@JoinColumn(name = "ordertype_id")
@ManyToOne
private OrderType orderType;
@JoinColumn(name = "discount_id")
@ManyToOne
private Discount discount;
@Column(name = "is_active")
private String isActive;
@JoinColumn(name = "hotel_id")
@ManyToOne
public Hotel hotel;
@JsonIgnore
@Column(name = "created_at", nullable = false, updatable = false)
@CreationTimestamp
@JsonFormat(pattern = "yyyy-MM-dd")
public Timestamp createdAt;
@JsonIgnore
@Temporal(TemporalType.DATE)
@Column(name = "updated_at")
@UpdateTimestamp
@JsonFormat(pattern = "yyyy-MM-dd")
public Date updatedAt;
}
| [
"vaibhavsawant61@gmail.com"
] | vaibhavsawant61@gmail.com |
1207ff8d5ac24b35265c79d24675c3c644400ad0 | 3c7b188736fbfea778c45edd7e6bb9e6789f7306 | /src/main/java/locadora/rn/VeiculoRN.java | 723b972716f83960e1617192f9bf99a2d4752de1 | [] | no_license | jhonatans01/locadora-SIN5005 | 84b48901d43b0e3b30c0914292b3fcfff5767fb2 | ea93ef323119cc2fcdbc293b20dd9d1e6b397e72 | refs/heads/master | 2021-05-01T12:11:28.931851 | 2018-02-11T04:19:57 | 2018-02-11T04:19:57 | 121,060,816 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,243 | 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 locadora.rn;
import java.util.List;
import locadora.dao.VeiculoDAO;
import locadora.entity.Aluguel;
import locadora.entity.Veiculo;
/**
*
* @author jhonatan
*/
public class VeiculoRN {
private final VeiculoDAO dao = new VeiculoDAO();
public VeiculoRN() {
}
public boolean salvar(Veiculo veiculo) {
boolean salvou = true;
if (veiculo.getId() == null) {
salvou &= dao.criar(veiculo);
} else {
salvou &= dao.alterar(veiculo);
}
return salvou;
}
public boolean excluir(Veiculo v) {
v = dao.obter(Veiculo.class, v.getId());
return dao.excluir(v);
}
public List<Veiculo> obterTodos() {
return dao.obterTodos(Veiculo.class);
}
public List<Veiculo> obterMaisAlugados() {
return dao.obterVeiculosMaisAlugados();
}
public List<Veiculo> obterPorBusca(Aluguel a) {
return dao.obterVeiculosBusca(a);
}
public Veiculo obter(Integer id) {
return dao.obter(Veiculo.class, id);
}
}
| [
"jhonatansilva96@gmail.com"
] | jhonatansilva96@gmail.com |
d78987253d4cc221ce62d913589d3353c4747394 | de8f0f09b3e9b06653514ffd61b74f5aa9bfeef2 | /src/main/java/com/lectureemail/protocol/implementation/Pop3ImapStoreManager.java | 941ef86997b5e7666406b3829388a91325755921 | [] | no_license | DanielSpartacus/projectLectureMail | f16fd5e043caa274b388470686ca11f963ed3331 | 9083c6cd5e01281d4234575823f56df88f0784e5 | refs/heads/master | 2020-03-18T12:04:13.088808 | 2018-05-25T17:14:37 | 2018-05-25T17:14:37 | 134,706,907 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,931 | java | package com.lectureemail.protocol.implementation;
import com.lectureemail.protocol.interfaces.IlectureEmail;
import configuration.Configuration;
import constants.ConfigurationConstants;
import exceptions.ConfigurationException;
import exceptions.MailException;
import exceptions.Pop3ImapStoreManagerException;
import filtreMail.Pop3ImapMailFilter;
import model.Mail;
import org.apache.commons.lang3.StringUtils;
import javax.mail.*;
import java.util.List;
import java.util.Properties;
public class Pop3ImapStoreManager implements IlectureEmail {
Properties props = new Properties();
private Store store;
public void init() throws Pop3ImapStoreManagerException, ConfigurationException {
// Get the configuration
String protocol = Configuration.getInstance().getProtocol();
props.setProperty(ConfigurationConstants.MAIL_STORE_PROTOCOL, protocol);
props.setProperty(ConfigurationConstants.MAIL_HOST_POP3,protocol);
props.setProperty(ConfigurationConstants.MAIL_POP3_PORT,protocol);
props.setProperty(ConfigurationConstants.MAIL_IMAP_STARTTLS_ENABLE, Boolean.TRUE.toString());
// Get The session and set the related configuration
Session session = Session.getDefaultInstance(props);
session.setDebug(Configuration.getInstance().getPropertyValueAsBoolean(ConfigurationConstants.MAIL_DEBUG_ENABLE));
// On récupère le store
try {
store = session.getStore(protocol);
}
catch (NoSuchProviderException e) {
throw new Pop3ImapStoreManagerException(e);
}
}
/**
* Opening a connection to the store
*
* @throws Pop3ImapStoreManagerException
*/
public void openConnection() throws Pop3ImapStoreManagerException, ConfigurationException {
if (store != null && !store.isConnected()) {
// Get connection specific parameters
String host = Configuration.getInstance().getPropertyValueAsString(ConfigurationConstants.MAIL_HOST);
String user = Configuration.getInstance().getPropertyValueAsString(ConfigurationConstants.MAIL_USER);
String password = Configuration.getInstance().getPropertyValueAsString(ConfigurationConstants.MAIL_PASSWORD);
if (StringUtils.isNotEmpty(host) && StringUtils.isNotEmpty(user) && StringUtils.isNotEmpty(password)) {
try {
store.connect(host, user, password);
}
catch (MessagingException e) {
throw new Pop3ImapStoreManagerException(e);
}
}
else {
throw new Pop3ImapStoreManagerException("Connection failed. " +
"It's mandatory to provide the host, user et password of the mail server");
}
}
else {
throw new Pop3ImapStoreManagerException("The store hasn't been initialized.");
}
}
/**
* Close the store connection
*
* @throws Pop3ImapStoreManagerException
*/
public void closeConnection() throws Pop3ImapStoreManagerException {
if (store != null && store.isConnected()) {
try {
store.close();
}
catch (MessagingException e) {
throw new Pop3ImapStoreManagerException("Closing the store has failed", e);
}
}
}
@Override
public List<Mail> listeMail() throws Pop3ImapStoreManagerException, ConfigurationException {
List<Mail> messageList;
if (store != null && store.isConnected()) {
Folder emailFolder;
try {
emailFolder = store.getFolder(ConfigurationConstants.MAIL_ROOT_DIRECTORY_NAME);
}
catch (MessagingException e) {
emailFolder = null;
}
if (emailFolder == null) {
// Trying to retrieve the default directory
try {
emailFolder = store.getDefaultFolder();
}
catch (MessagingException e) {
throw new Pop3ImapStoreManagerException(e);
}
}
// Opening the mail folder in read only
try {
emailFolder.open(Folder.READ_ONLY);
}
catch (MessagingException e) {
throw new Pop3ImapStoreManagerException(e);
}
try {
messageList = Pop3ImapMailFilter.filterMessages(emailFolder);
}
catch (MailException e) {
throw new Pop3ImapStoreManagerException(e);
}
}
else {
throw new Pop3ImapStoreManagerException("The store initialization failed " +
"or the connexion hasn't been established");
}
return messageList;
}
}
| [
"daniel.spartacus@wanadoo.fr"
] | daniel.spartacus@wanadoo.fr |
5981f0e1ebbbb2dd764db87fbc0f3d63d6b538b1 | 8e01452d417904c95244d82639aaca40e5fb7754 | /intells-web/src/main/java/cn/edu/ujs/lp/intells/Application.java | 9893f86a000ae83b796a5cd8523190c6d916a850 | [] | no_license | SherZhai1996/GYZK | 50c173efb53139997d0e9b782324a1baa8e729e9 | 2cea32a4fc5045190e8c5952cd6b39aae4d9091a | refs/heads/master | 2022-08-16T17:11:49.705440 | 2020-03-27T11:31:53 | 2020-03-27T11:31:53 | 250,510,784 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 322 | java | package cn.edu.ujs.lp.intells;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
| [
"963801573@qq.com"
] | 963801573@qq.com |
9eb9cfcdaa934d05260ca9e9d9acd89734d6ddf1 | 93c99ee9770362d2917c9494fd6b6036487e2ebd | /server/decompiled_apps/2b7122657dcb75ede8840eff964dd94a/com.bankeen.ui.transfer.account.sender/-$$Lambda$f$gynxAL_qwxqXXreFUCK6CHcmxx0.java | 331abb137c9f7d4cc162ddda2f141c8e607c6652 | [] | no_license | YashJaveri/Satic-Analysis-Tool | e644328e50167af812cb2f073e34e6b32279b9ce | d6f3be7d35ded34c6eb0e38306aec0ec21434ee4 | refs/heads/master | 2023-05-03T14:29:23.611501 | 2019-06-24T09:01:23 | 2019-06-24T09:01:23 | 192,715,309 | 0 | 1 | null | 2023-04-21T20:52:07 | 2019-06-19T11:00:47 | Smali | UTF-8 | Java | false | false | 384 | java | package com.bankeen.ui.transfer.account.sender;
/* compiled from: lambda */
public final /* synthetic */ class -$$Lambda$f$gynxAL_qwxqXXreFUCK6CHcmxx0 implements Runnable {
private final /* synthetic */ f f$0;
public /* synthetic */ -$$Lambda$f$gynxAL_qwxqXXreFUCK6CHcmxx0(f fVar) {
this.f$0 = fVar;
}
public final void run() {
this.f$0.c();
}
} | [
"root@localhost.localdomain"
] | root@localhost.localdomain |
32d3dafd936816c9161fe5b28711bffacfb1168d | 552fc1444b4ac6782861eaf9ec672cec6df84094 | /src/test/java/com/custom/junit/junitdemo/BasicTest.java | b52427b5b91462d459ecdfb94a24489caf588241 | [] | no_license | lotusfan/junit-demo | 61d8dc5600a0f1a0b3033d0a0a4aa7f0eb1458f0 | bfcaa02ec46e3302d65fb388245b06e678ff58a0 | refs/heads/master | 2020-03-24T16:57:24.905823 | 2018-07-30T08:00:19 | 2018-07-30T08:00:19 | 142,844,166 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 476 | java | package com.custom.junit.junitdemo;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @title: BasicTest
* @description:
* @author: zhangfan
* @data: 2018年07月16日 11:29
*/
public class BasicTest {
@Before
public void fe() {
System.out.println("before");
}
@Test
public void print() {
System.out.println("basic test");
}
}
| [
"zhangfan2010aa@163.com"
] | zhangfan2010aa@163.com |
75dcf6efe2d51a774c5bb201025e32bf053f985b | ee86bd8be523153f83e82e0944cd3c6a01c986d6 | /src/main/java/com/councel/service/UserManagementService.java | a9ead29b58beacd8507bb8388534f4963fe5aec7 | [] | no_license | bvshukla/councel | 00b046fb20a902fac5201b5372d69b2650ae6faf | e94062c15750601b7795d75595c80af3134e558f | refs/heads/master | 2021-01-20T17:49:56.538189 | 2017-06-13T17:31:25 | 2017-06-13T17:31:25 | 90,891,844 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,702 | java | package com.councel.service;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.ws.rs.*;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.apache.commons.io.IOUtils;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.councel.model.pojo.Client;
import com.councel.model.pojo.Lawyer;
import com.councel.model.pojo.ServiceError;
import com.councel.model.pojo.User;
import com.councel.model.pojo.User.UserType;
import com.councel.model.service.UserService;
import com.councel.model.utils.ErrorCode;
import com.councel.model.utils.ErrorMsg;
import com.councel.model.utils.ErrorUtils;
import com.councel.model.utils.FileUtils;
import com.councel.model.utils.ParseUtils;
@Path("/client")
public class UserManagementService {
public static final String UPLOAD_FILE_SERVER = "C:\\Users\\bvshukla.ORADEV\\workspace\\councelApp\\src\\main\\webapp\\ProfilePic\\";
@Path("/findUser.json")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Object findUser(@QueryParam("userId") Long userId) {
User user = UserService.findUser(userId);
if (user != null && user.getUserType() == UserType.LAWYER) {
user = UserService.findLawyer(userId, user);
}
return user;
}
@Path("/createUser.json")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Object createUser(String inputJSON) {
ParseUtils pu = new ParseUtils();
try {
User user = pu.parseUser(inputJSON);
if (user instanceof Lawyer) {
Lawyer lawyer = (Lawyer) user;
UserService.createUser(lawyer);
return lawyer;
} else {
Client cl = (Client) user;
UserService.createUser(cl);
return cl;
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "{}";
}
@Path("/updateUser.json")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Object updateUser(String inputJSON) {
JSONParser parser = new JSONParser();
JSONObject jo;
try {
jo = (JSONObject) parser.parse(inputJSON);
Long userId = (Long) jo.getOrDefault("userId", 0L);
User u = UserService.findUser(userId);
Lawyer lawyer = null;
Client client = null;
String userTypeStr = (String) jo.getOrDefault("userType", "Client");
UserType userType = UserType.valueOf(userTypeStr.toUpperCase());
if (jo.containsKey("firstName")) {
String firstName = (String) jo.getOrDefault("firstName", "");
u.setFirstName(firstName);
}
if (jo.containsKey("lastName")) {
String lastName = (String) jo.getOrDefault("lastName", "");
u.setLastName(lastName);
}
if (jo.containsKey("address")) {
String address = (String) jo.getOrDefault("address", "");
u.setAddress(address);
}
if (jo.containsKey("mobile")) {
String mobile = (String) jo.getOrDefault("mobile", "");
u.setMobile(mobile);
}
if (jo.containsKey("email")) {
String email = (String) jo.getOrDefault("email", "");
u.setEmail(email);
}
if (jo.containsKey("gender")) {
String gender = (String) jo.getOrDefault("gender", "");
u.setGender(gender);
}
if (jo.containsKey("dob")) {
String dob = (String) jo.getOrDefault("dob", "");
u.setDob(dob);
}
if (userType == UserType.LAWYER) {
lawyer = (Lawyer) u;
if (jo.containsKey("lawFirm")) {
String lawFirm = (String) jo.getOrDefault("lawFirm", "");
lawyer.setLawFirm(lawFirm);
}
if (jo.containsKey("courtName")) {
String courtName = (String) jo.getOrDefault("courtName", "");
lawyer.setCourtName(courtName);
}
if (jo.containsKey("location")) {
String location = (String) jo.getOrDefault("location", "");
lawyer.setLocation(location);
}
if (jo.containsKey("contactFor")) {
String contactFor = (String) jo.getOrDefault("contactFor", "");
lawyer.setContactFor(contactFor);
}
if (jo.containsKey("experience")) {
String experience = (String) jo.getOrDefault("experience", "");
lawyer.setExperience(experience);
}
if (jo.containsKey("bio")) {
String bio = (String) jo.getOrDefault("bio", "");
lawyer.setBio(bio);
}
UserService.updateLawyer(lawyer);
return lawyer;
} else {
Client cl = (Client) u;
UserService.updateClient(cl);
return cl;
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "{}";
}
@Path("/assignClient.json")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Object assignClient(String inputJSON) {
JSONParser parser = new JSONParser();
Client clR = null;
try {
JSONObject jo = (JSONObject) parser.parse(inputJSON);
Long lawyerId = (Long) jo.getOrDefault("lawyerId", 0L);
Long clientId = (Long) jo.getOrDefault("clientId", 0L);
Lawyer lawyer = (Lawyer) UserService.findUser(lawyerId);
Client cl = (Client) UserService.findUser(clientId);
cl.setLawyer(lawyer);
UserService.updateClient(cl);
clR = (Client) UserService.findUser(clientId);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return clR;
}
@Path("/login.json")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Object login(String inputJSON) {
JSONParser parser = new JSONParser();
Client clR = null;
try {
JSONObject jo = (JSONObject) parser.parse(inputJSON);
String email = (String) jo.getOrDefault("email", null);
String mobile = (String) jo.getOrDefault("mobileNo", null);
String password = (String) jo.getOrDefault("password", null);
User user = UserService.findUserFromEmailOrPhone(email, mobile);
if (user == null) {
ServiceError error = new ServiceError();
error.setErrorCode(ErrorCode.USER_NOT_REGISTERED);
error.setErrorMsg(ErrorMsg.USER_NOT_REGISTERED);
error.setErrorId(ErrorUtils.errorIds.get(ErrorCode.USER_NOT_REGISTERED));
return error;
} else {
String passwordStr = ParseUtils.getMD5Hash(password);
if (user.getPassword().equals(passwordStr)) {
return user;
} else {
ServiceError error = new ServiceError();
error.setErrorCode(ErrorCode.USER_PASSWORD_INCORRECT);
error.setErrorMsg(ErrorMsg.USER_PASSWORD_INCORRECT);
error.setErrorId(ErrorUtils.errorIds.get(ErrorCode.USER_PASSWORD_INCORRECT));
return error;
}
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return clR;
}
@Path("/upload.json")
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Object uploadPic(@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileFormDataContentDisposition,
@FormDataParam("userId") Long userId, @FormDataParam("fileType") String fileType) {
String fileName = null;
String uploadFilePath = null;
try {
fileName = fileType + "_" + userId + "_" + System.nanoTime() + ".jpg";
uploadFilePath = writeToFileServer(fileInputStream, fileName);
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
// release resources, if any
}
User user = UserService.findUser(userId);
user.setProfilePic(uploadFilePath);
if (user.getUserType() == UserType.LAWYER) {
UserService.updateLawyer((Lawyer) user);
} else {
UserService.updateClient((Client) user);
}
return user;
}
private String writeToFileServer(InputStream inputStream, String fileName) throws IOException {
OutputStream outputStream = null;
String qualifiedUploadFilePath = fileName;
File f = new File(qualifiedUploadFilePath);
if (!f.exists()) {
f.createNewFile();
}
try {
outputStream = new FileOutputStream(f);
IOUtils.copy(inputStream, outputStream);
qualifiedUploadFilePath = FileUtils.uploadToCloudinary(f);
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
// release resource, if any
outputStream.close();
}
return qualifiedUploadFilePath;
}
}
| [
"bhaktavatsalshukla@gmail.com"
] | bhaktavatsalshukla@gmail.com |
33ad73d6f508b1db5f67342f06621fbf8ada0fb1 | 5561d1d98c86e345e4f3465231ba8a29bc667180 | /src/module-info.java | 7d5765dd74451be880180bd3d33a2fce83799e26 | [] | no_license | Akash2248/SeleniumBasic | 125a5441343b1f655c41b63131bde9d8a3ebfd53 | 691ad140139f1c3487c163631a2a295552e44def | refs/heads/master | 2020-05-17T20:24:18.215936 | 2019-04-28T20:34:56 | 2019-04-28T20:34:56 | 183,944,211 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 67 | java | /**
*
*/
/**
* @author mohammad
*
*/
module SeleniumBasic {
} | [
"mislam2248@gmail.com"
] | mislam2248@gmail.com |
00ee09d98f33c711969ed81dfb2a1cead42aed4f | e31ebd9d6aafee4d5a0c0a92e6a9e3de2a804718 | /user-service/src/main/java/com/syraven/cloud/dao/UserGeohashMapper.java | a6c3ff649d310f510f2be334f155b1c01ff3e0d2 | [] | no_license | EverettSy/Spring-Cloud | 4185c74cb515444a53238ef007f858f77100e1d5 | 01906acc334a3f248aada478821acebf2adda932 | refs/heads/master | 2023-07-17T05:07:16.778406 | 2023-03-27T14:41:45 | 2023-03-27T14:41:45 | 220,041,373 | 2 | 0 | null | 2023-06-14T22:52:12 | 2019-11-06T16:27:56 | Java | UTF-8 | Java | false | false | 330 | java | package com.syraven.cloud.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.syraven.cloud.domain.UserGeohash;
import org.apache.ibatis.annotations.Mapper;
/**
* <<功能简述>>
*
* @author Raven
* @date 2020/5/8 16:17
*/
@Mapper
public interface UserGeohashMapper extends BaseMapper<UserGeohash> {
} | [
"sy759770423@163.com"
] | sy759770423@163.com |
ccb6d0f282ac54e957a5c418ded866235e3840d2 | 435016c5e2d4cfbfe9f939db725aab59dd8b9240 | /java-basic/src/main/java/ch23/e/CalculatorServer.java | f8b5f40ec5818c45dbfd21babde3d647cc3fb147 | [] | no_license | kmincheol/bitcamp-java-2018-12 | 59b3c5709b1aa905035a390d553002547243a13a | 32b2df6e295412207a27bfc57069e9069f85a0a4 | refs/heads/master | 2021-08-06T22:04:08.819338 | 2019-06-12T02:16:22 | 2019-06-12T02:16:22 | 163,650,686 | 1 | 1 | null | 2020-04-30T03:50:33 | 2018-12-31T08:00:45 | Java | UTF-8 | Java | false | false | 3,531 | java | // TCP : connectionful(Stateless) 응용 - 서버에서 계산 결과 유지하기
package ch23.e;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashMap;
public class CalculatorServer {
public static void main(String[] args) {
// 클라이언트의 작업 결과를 저장할 맵 객체
HashMap<Long, Integer> resultMap = new HashMap<>();
try (ServerSocket serverSocket = new ServerSocket(8888)) {
System.out.println("서버 실행 중...");
// 서버의 Stateless 통신 방법에서 클라이언트를 구분하여 각 클라이언트의 계산 결과를 유지하려면?
// => 커피숍에서는 고객의 쿠폰 포인트를 어떻게 관리할까?
while (true) {
try (Socket socket = serverSocket.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintStream out = new PrintStream(socket.getOutputStream());) {
System.out.println("클라이언트와 연결됨! 요청처리 중...");
// 먼저 클라이언트가 보낸 세션 ID를 읽는다.
long sessionId = Long.parseLong(in.readLine());
System.out.printf("세션ID : %d\n", sessionId);
int result = 0;
boolean isNewSessionId = false;
if (sessionId == 0) {
// 클라이언트에게 세션ID를 발급한 적이 없다면, 새 세션 ID를 발급한다.
sessionId = System.currentTimeMillis();
isNewSessionId = true; // 세션 ID를 새로 발급했다고 표시한다.
} else {
// 클라이언트의 세션 ID로 기존에 저장된 결과 값을 가져온다.
result = resultMap.get(sessionId); // auto-unboxing => Integer.intValue()
}
String[] input = in.readLine().split(" ");
int b = 0;
String op = null;
try {
op = input[0];
b = Integer.parseInt(input[1]);
} catch (Exception e) {
out.println("식의 형식이 바르지 않습니다.");
out.flush();
continue;
}
switch (op) {
case "+":
result += b;
break;
case "-":
result -= b;
break;
case "*":
result *= b;
break;
case "/":
result /= b;
break;
case "%":
result %= b;
break;
default:
out.printf("%s 연산자를 지원하지 않습니다.\n", op);
out.flush();
continue;
}
// 계산결과를 세션 ID를 사용해서 서버에 저장한다.
resultMap.put(sessionId, result);
// 세션 ID를 새로 발급했다면 클라이언트에게 알려준다
if (isNewSessionId) {
out.println(sessionId);
}
out.printf("현재 결과는 %d 입니다.\n", result);
out.flush();
} catch (Exception e) {
// 클라이언트 요청을 처리하다가 예외가 발생하면 무시하고 연결을 끊는다.
System.out.println("클라이언트와 통신 중 오류 발생!");
}
System.out.println("클라이언트와 연결 끊음!");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
| [
"mincheol.kmc@gmail.com"
] | mincheol.kmc@gmail.com |
ed4acb2967af97f7673bf761b225578e7795d62c | 27c060ca18ce6ad575ae8ee642c571fffd9b2b9c | /HoneycombMatchThree/src/com/handknittedapps/honeycombmatchthree/logic/moves/ConvertToBombMove.java | ef4327e859d28cf00a388952dc7afc1692ab0150 | [] | no_license | porke/HoneycombMatchThree | cfb7ba2d66f3c0cad44f36e85fcd5eeecca89291 | 3f109ba3119055e2b4d02388bf06baaa9eca3656 | refs/heads/master | 2020-12-03T09:26:53.463553 | 2018-08-06T17:19:11 | 2018-08-06T17:19:11 | 29,539,997 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,007 | java | package com.handknittedapps.honeycombmatchthree.logic.moves;
import com.handknittedapps.honeycombmatchthree.logic.Block;
import com.handknittedapps.honeycombmatchthree.logic.BlockType;
import com.handknittedapps.honeycombmatchthree.logic.DestructionSequence;
import com.handknittedapps.honeycombmatchthree.logic.Map;
import com.handknittedapps.honeycombmatchthree.logic.graph.GraphVertex;
public class ConvertToBombMove extends Move
{
ConvertToBombMove()
{
// Disable instantiation
}
@Override
public DestructionSequence perform(GraphVertex<Block> src,
GraphVertex<Block> dest, Map map)
{
src.getData().setType(BlockType.Bomb);
this.affectedBlocks.add(src.getData());
return null;
}
@Override
public boolean canMove(GraphVertex<Block> src, GraphVertex<Block> dest, int numDirections)
{
return (src != null
&& src.getData().getType() == BlockType.Normal
&& src.getData().getStrength() == 1);
}
@Override
public MoveType getType()
{
return MoveType.BombChange;
}
}
| [
"porke90@gmail.com"
] | porke90@gmail.com |
2008ac4c5319ba058275090f83184afe2ba0b4d1 | fa5d0de6a923e349a77ce38408cbf02154134037 | /ClayUI_android/src/com/netinfocentral/ClayUI/ElementDatabaseHelper.java | e7f79cc3ed630146d89545a9fb9aeb7a658f36ea | [] | no_license | lwllovewf2010/ClayUI_android | 8b2ed7fab052325a8621c00e318a6d4ae51232c2 | d786be564365327c6b891dfe634b83ae63122327 | refs/heads/master | 2020-03-29T20:56:59.006823 | 2012-05-01T20:28:40 | 2012-05-01T20:28:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,956 | java | package com.netinfocentral.ClayUI;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class ElementDatabaseHelper extends SQLiteOpenHelper {
// define class variables
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "ClayUI.db";
public static final String TABLE_NAME = "Elements";
// column definitions
public static final String COLUMN_ID = "_id";
public static final String COLUMN_APP_PART_ID = "AppPartID";
public static final String COLUMN_ELEMENT_NAME = "ElementName";
public static final String COLUMN_ELEMENT_TYPE = "ElementType";
public static final String COLUMN_ELEMENT_LABEL = "ElementLabel";
public static final String COLUMN_VERSION = "Version";
// command to create the table
private static final String DATABASE_CREATE =
"CREATE TABLE " + TABLE_NAME + " (" +
COLUMN_ID + " integer primary key, " +
COLUMN_APP_PART_ID + " integer, " +
COLUMN_ELEMENT_NAME + " text, " +
COLUMN_ELEMENT_TYPE + " integer, " +
COLUMN_ELEMENT_LABEL + " text, " +
COLUMN_VERSION + " integer);";
// default constructor
ElementDatabaseHelper(Context context) {
//this.databaseName = applicationName;
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// create database if it does not exist
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DATABASE_CREATE);
}
// upgrade database if necessary
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(ElementDatabaseHelper.class.getName(),
"Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
}
| [
"alize@netinfocentral.com"
] | alize@netinfocentral.com |
9631adb671c464564af1784e462c8bcc307144a1 | 94da56591d22ae6f8b437e749db213131a4881c8 | /src/main/java/com/github/shyykoserhiy/gfm/toolwindow/browser/resources/Resources.java | 6404b96f0584fb69d1a3eea967f9b0f8504a3bc6 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | ShyykoSerhiy/gfm-plugin | e1a4e29427e72da9389afa243c3ea47f80637160 | d3ac45d818004e8374ef08576e0c588d53d08b79 | refs/heads/master | 2021-07-06T09:46:36.920489 | 2021-05-19T18:14:30 | 2021-05-19T18:14:30 | 31,247,843 | 114 | 24 | MIT | 2019-04-25T14:45:27 | 2015-02-24T06:34:09 | C | UTF-8 | Java | false | false | 247 | java | package com.github.shyykoserhiy.gfm.toolwindow.browser.resources;
import javax.swing.*;
public class Resources {
public static ImageIcon getIcon(String fileName) {
return new ImageIcon(Resources.class.getResource(fileName));
}
}
| [
"shyyko.serhiy@gmail.com"
] | shyyko.serhiy@gmail.com |
e9a7733e0d8a04340126303042109e58ceb51359 | c4a011cc435f2634d728e29ceab9ed1c3e07cab9 | /src/main/java/top/easyblog/sharding/demo/mapper/OrderItemMapper.java | c9f82dd85dc89fc653c6d5ba862a9d5ad7c09906 | [] | no_license | LoverITer/shrding-jdbc-fragmentation | 9d2bb0652fa7ec6935764d5a738bc504199e3081 | f8985e414b271fba380017a9896626805b8533c6 | refs/heads/master | 2022-06-15T22:32:13.976104 | 2020-05-05T14:03:58 | 2020-05-05T14:03:58 | 261,352,269 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 649 | java | package top.easyblog.sharding.demo.mapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import top.easyblog.sharding.demo.entity.OrderItem;
/**
* Description
*
* @author hujy
* @version 1.0
* @date 2019-09-19 16:46
*/
@Mapper
public interface OrderItemMapper {
@Insert("insert into t_order_item(order_id,remark) values(#{orderId},#{remark})")
Integer save(OrderItem orderItem);
@Select("select * from t_order_item where item_id=#{id}")
OrderItem selectById(@Param(value = "id") Long id);
}
| [
"2489868503@qq.com"
] | 2489868503@qq.com |
26c9185dcc9b5c868fd7df4df5571876e8d4ca4e | cfb53d106cef28377aaf5c15a65e2c479fbbb812 | /kodilla-testing/src/test/java/com/kodilla/testing/forum/ForumTestSuite.java | 68fd60ae098b24c97c3a3a986a651a72bf3dea03 | [] | no_license | robertwojtkowski/Robert-Wojtkowski-kodilla-Java | e67c9bffbccd70965bf9489453865e4ec98e99c9 | d749b3795d419820c277e56c008ae747ccd48824 | refs/heads/master | 2022-07-13T01:12:41.429661 | 2020-01-07T11:17:56 | 2020-01-07T11:17:56 | 194,789,833 | 0 | 0 | null | 2022-06-21T02:35:20 | 2019-07-02T04:46:16 | Java | UTF-8 | Java | false | false | 1,221 | java | package com.kodilla.testing.forum;
import com.kodilla.testing.user.SimpleUser;
import org.junit.*;
public class ForumTestSuite {
//wszystko ze strony skopiowane
@Before
public void before(){
System.out.println("Test Case: begin");
}
@After
public void after(){
System.out.println("Test Case: end");
}
@BeforeClass
public static void beforeClass() {
System.out.println("Test Suite: begin");
}
@AfterClass
public static void afterClass() {
System.out.println("Test Suite: end");
}
@Test
public void testCaseUsername(){
//Given
SimpleUser simpleUser = new SimpleUser("theForumUser", "John Smith");
//When
String result = simpleUser.getUsername();
System.out.println("Testing " + result);
//Then
Assert.assertEquals("theForumUser", result);
}
@Test
public void testCaseRealName(){
//Given
SimpleUser simpleUser = new SimpleUser("theForumUser", "John Smith");
//When
String result = simpleUser.getRealName();
System.out.println("Testing " + result);
//Then
Assert.assertEquals("John Smith", result);
}
} | [
"m.mrozek2@pwpw.pl"
] | m.mrozek2@pwpw.pl |
a251c98b8d9976a0d230f604bae1519a459608e4 | 593e94f91a7d578aa718cc44942606ff5a368c07 | /app/src/main/java/com/gmail/hanivisushiva/aksharafinserve/Models/Login/Data.java | 105ff88e763646a84da0ea3dcbe40443604359a3 | [] | no_license | nshivaprasadreddy/akshara_customer_model | 0ce18d1950f1c6619d782ba097fd2188779c8481 | 24e2663dc5ea0b80782475043d2b76642330c268 | refs/heads/master | 2020-04-07T12:45:57.174472 | 2019-03-27T07:03:18 | 2019-03-27T07:03:46 | 158,380,262 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,289 | java | package com.gmail.hanivisushiva.aksharafinserve.Models.Login;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Data {
@SerializedName("rid")
@Expose
private String rid;
@SerializedName("serivces")
@Expose
private String serivces;
@SerializedName("others")
@Expose
private String others;
@SerializedName("image")
@Expose
private String image;
@SerializedName("client_code")
@Expose
private String clientCode;
@SerializedName("name")
@Expose
private String name;
@SerializedName("password")
@Expose
private String password;
@SerializedName("email")
@Expose
private String email;
@SerializedName("contact_person")
@Expose
private String contactPerson;
@SerializedName("phone")
@Expose
private String phone;
@SerializedName("message")
@Expose
private String message;
@SerializedName("role")
@Expose
private String role;
@SerializedName("status")
@Expose
private String status;
@SerializedName("date")
@Expose
private String date;
@SerializedName("service_agreement")
@Expose
private String serviceAgreement;
@SerializedName("motp")
@Expose
private String motp;
@SerializedName("motpver")
@Expose
private String motpver;
@SerializedName("eotp")
@Expose
private String eotp;
@SerializedName("eotpver")
@Expose
private String eotpver;
public String getRid() {
return rid;
}
public void setRid(String rid) {
this.rid = rid;
}
public String getSerivces() {
return serivces;
}
public void setSerivces(String serivces) {
this.serivces = serivces;
}
public String getOthers() {
return others;
}
public void setOthers(String others) {
this.others = others;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getClientCode() {
return clientCode;
}
public void setClientCode(String clientCode) {
this.clientCode = clientCode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getContactPerson() {
return contactPerson;
}
public void setContactPerson(String contactPerson) {
this.contactPerson = contactPerson;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getServiceAgreement() {
return serviceAgreement;
}
public void setServiceAgreement(String serviceAgreement) {
this.serviceAgreement = serviceAgreement;
}
public String getMotp() {
return motp;
}
public void setMotp(String motp) {
this.motp = motp;
}
public String getMotpver() {
return motpver;
}
public void setMotpver(String motpver) {
this.motpver = motpver;
}
public String getEotp() {
return eotp;
}
public void setEotp(String eotp) {
this.eotp = eotp;
}
public String getEotpver() {
return eotpver;
}
public void setEotpver(String eotpver) {
this.eotpver = eotpver;
}
} | [
"nshivaprasadreddy1998@gmail.com"
] | nshivaprasadreddy1998@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.