hexsha
stringlengths
40
40
size
int64
3
1.05M
ext
stringclasses
1 value
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
5
1.02k
max_stars_repo_name
stringlengths
4
126
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
list
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
5
1.02k
max_issues_repo_name
stringlengths
4
114
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
list
max_issues_count
float64
1
92.2k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
5
1.02k
max_forks_repo_name
stringlengths
4
136
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
list
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
avg_line_length
float64
2.55
99.9
max_line_length
int64
3
1k
alphanum_fraction
float64
0.25
1
index
int64
0
1M
content
stringlengths
3
1.05M
3e0b29e9e3897748f28ddf004e282d18b38997be
1,130
java
Java
_src/javapath/javapath/src/main/java/com/packt/javapath/ch19demo/reactivesystem/Demo.java
paullewallencom/programming-978-1-7888-3912-9
098df56700cfaaa83be6b999449376f2fa12f084
[ "Apache-2.0" ]
7
2020-07-18T22:31:23.000Z
2021-11-08T13:10:32.000Z
_src/javapath/javapath/src/main/java/com/packt/javapath/ch19demo/reactivesystem/Demo.java
paullewallencom/programming-978-1-7888-3912-9
098df56700cfaaa83be6b999449376f2fa12f084
[ "Apache-2.0" ]
1
2022-02-16T00:54:41.000Z
2022-02-16T00:54:41.000Z
_src/javapath/javapath/src/main/java/com/packt/javapath/ch19demo/reactivesystem/Demo.java
paullewallencom/programming-978-1-7888-3912-9
098df56700cfaaa83be6b999449376f2fa12f084
[ "Apache-2.0" ]
5
2018-09-16T06:15:56.000Z
2021-12-25T13:29:55.000Z
25.681818
75
0.644248
4,723
package com.packt.javapath.ch19demo.reactivesystem; import io.vertx.rxjava.core.RxHelper; import io.vertx.rxjava.core.Vertx; import java.util.concurrent.TimeUnit; import static io.vertx.rxjava.core.Vertx.vertx; public class Demo { public static void main(String... args) { send(); //publish(); } private static void send() { String address = "One"; Vertx vertx = vertx(); RxHelper.deployVerticle(vertx, new MsgConsumer("1",address)); RxHelper.deployVerticle(vertx, new MsgConsumer("2",address)); RxHelper.deployVerticle(vertx, new EventBusSend(8082, address)); } private static void publish() { String address = "One"; Vertx vertx = vertx(); RxHelper.deployVerticle(vertx, new MsgConsumer("1",address)); RxHelper.deployVerticle(vertx, new MsgConsumer("2",address)); RxHelper.deployVerticle(vertx, new EventBusPublish(8082, address)); } private static void delayMs(int ms) { try { TimeUnit.MILLISECONDS.sleep(ms); } catch (InterruptedException e) { } } }
3e0b29ee7c5fcf1b88c14ececa860130b1d3bea0
4,987
java
Java
test-butler-app-core/src/main/java/com/linkedin/android/testbutler/ButlerAccessibilityService.java
chao2zhang/test-butler
30786d33a29f89d2e269783c66da98df63f3ed2a
[ "Apache-2.0" ]
1,094
2016-08-04T04:54:00.000Z
2022-03-28T16:28:53.000Z
test-butler-app-core/src/main/java/com/linkedin/android/testbutler/ButlerAccessibilityService.java
chao2zhang/test-butler
30786d33a29f89d2e269783c66da98df63f3ed2a
[ "Apache-2.0" ]
73
2016-08-04T18:18:59.000Z
2022-02-24T08:47:22.000Z
test-butler-app-core/src/main/java/com/linkedin/android/testbutler/ButlerAccessibilityService.java
chao2zhang/test-butler
30786d33a29f89d2e269783c66da98df63f3ed2a
[ "Apache-2.0" ]
102
2016-08-04T17:29:46.000Z
2022-03-08T11:54:04.000Z
36.137681
130
0.599759
4,724
/** * Copyright (C) 2019 LinkedIn Corp. * <p> * 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.linkedin.android.testbutler; import android.accessibilityservice.AccessibilityService; import android.os.SystemClock; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; public class ButlerAccessibilityService extends AccessibilityService { static final String SERVICE_NAME = ButlerAccessibilityService.class.getSimpleName(); // From com.android.server.accessibility.AccessibilityManagerService#COMPONENT_NAME_SEPARATOR static final String COMPONENT_NAME_SEPARATOR = ":"; static final long CREATE_DESTROY_TIMEOUT = 30000; private static final Object sInstanceCreateLock = new Object(); private static final Object sInstanceDestroyLock = new Object(); private static volatile ButlerAccessibilityService sInstance; private AccessibilityManager accessibilityManager; @Override public void onCreate() { super.onCreate(); accessibilityManager = (AccessibilityManager) this.getSystemService(ACCESSIBILITY_SERVICE); } @Override public void onAccessibilityEvent(AccessibilityEvent event) { // stub } @Override public void onInterrupt() { // stub } @Override protected void onServiceConnected() { super.onServiceConnected(); sInstance = this; if (accessibilityManager.isEnabled()) { synchronized (sInstanceCreateLock) { sInstanceCreateLock.notifyAll(); } } else { accessibilityManager.addAccessibilityStateChangeListener(new AccessibilityManager.AccessibilityStateChangeListener() { @Override public void onAccessibilityStateChanged(boolean enabled) { if (enabled) { synchronized (sInstanceCreateLock) { sInstanceCreateLock.notifyAll(); } accessibilityManager.removeAccessibilityStateChangeListener(this); } } }); } } @Override public void onDestroy() { super.onDestroy(); sInstance = null; if (!accessibilityManager.isEnabled()) { synchronized (sInstanceDestroyLock) { sInstanceDestroyLock.notifyAll(); } } else { accessibilityManager.addAccessibilityStateChangeListener(new AccessibilityManager.AccessibilityStateChangeListener() { @Override public void onAccessibilityStateChanged(boolean enabled) { if (!enabled) { synchronized (sInstanceDestroyLock) { sInstanceDestroyLock.notifyAll(); } accessibilityManager.removeAccessibilityStateChangeListener(this); } } }); } } static boolean waitForLaunch() { if (sInstance == null) { synchronized (sInstanceCreateLock) { try { long timeSlept = 0; while (sInstance == null && timeSlept < CREATE_DESTROY_TIMEOUT) { long sleepStart = SystemClock.uptimeMillis(); sInstanceCreateLock.wait(CREATE_DESTROY_TIMEOUT - timeSlept); timeSlept += SystemClock.uptimeMillis() - sleepStart; } } catch (InterruptedException e) { throw new RuntimeException(e); } } } return sInstance != null; } static boolean waitForDestroy() { if (sInstance != null) { synchronized (sInstanceDestroyLock) { try { long timeSlept = 0; while (sInstance != null && timeSlept < CREATE_DESTROY_TIMEOUT) { long sleepStart = SystemClock.uptimeMillis(); sInstanceDestroyLock.wait(CREATE_DESTROY_TIMEOUT - timeSlept); timeSlept += SystemClock.uptimeMillis() - sleepStart; } } catch (InterruptedException e) { throw new RuntimeException(e); } } } return sInstance == null; } }
3e0b2a1533444ede9919d2d8ed3f690709eec802
360
java
Java
imagedemo02/src/main/java/com/example/imagedemo02/BitmapShaderTest.java
LiuchangDuan/demo
15b4b6dc7fc1d60de72d923bbf1bf58aee1c9348
[ "Apache-2.0" ]
3
2017-12-05T08:42:33.000Z
2020-04-27T01:44:46.000Z
imagedemo02/src/main/java/com/example/imagedemo02/BitmapShaderTest.java
LiuchangDuan/demo
15b4b6dc7fc1d60de72d923bbf1bf58aee1c9348
[ "Apache-2.0" ]
null
null
null
imagedemo02/src/main/java/com/example/imagedemo02/BitmapShaderTest.java
LiuchangDuan/demo
15b4b6dc7fc1d60de72d923bbf1bf58aee1c9348
[ "Apache-2.0" ]
1
2020-09-27T08:46:42.000Z
2020-09-27T08:46:42.000Z
21.176471
56
0.730556
4,725
package com.example.imagedemo02; import android.app.Activity; import android.os.Bundle; /** * Created by Administrator on 2016/6/3. */ public class BitmapShaderTest extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bitmap_shader); } }
3e0b2bac87ad2fa1b79d8c44ae03434a6e410841
1,890
java
Java
app/src/main/java/cos/mos/utils/widget/chart/ColunmnarBean.java
KosmoSakura/KosmosToolkit
2a00daee23ee496a4a460d4d0ca22a6bf4603f10
[ "Apache-2.0" ]
21
2019-04-25T02:59:50.000Z
2021-07-12T13:12:59.000Z
app/src/main/java/cos/mos/utils/widget/chart/ColunmnarBean.java
KosmoSakura/KosmosUtils
2a00daee23ee496a4a460d4d0ca22a6bf4603f10
[ "Apache-2.0" ]
1
2019-04-12T01:48:55.000Z
2019-04-12T03:18:21.000Z
app/src/main/java/cos/mos/utils/widget/chart/ColunmnarBean.java
KosmoSakura/KosmosUtils
2a00daee23ee496a4a460d4d0ca22a6bf4603f10
[ "Apache-2.0" ]
4
2019-06-19T08:00:35.000Z
2020-07-28T12:28:15.000Z
18.407767
89
0.560654
4,726
package cos.mos.utils.widget.chart; import java.io.Serializable; /** * Description:饼状图数据实体 * <p> * Author: Kosmos * Time: 2017/3/14 001413:40 * Email:lyhxr@example.com * Events: */ public class ColunmnarBean implements Serializable { private float humidity;// private int color = -1;// private int txt_color = -1; private String name;// private float l, t, r, b; private int id; public ColunmnarBean(int id, float humidity, int color, int txt_color, String name) { this.id = id; this.humidity = humidity; this.color = color; this.txt_color = txt_color; this.name = name; } public ColunmnarBean() { } public ColunmnarBean(float humidity, int color, String name) { this.humidity = humidity; this.color = color; this.name = name; } public void setRect(float l, float t, float r, float b) { this.l = l; this.t = t; this.r = r; this.b = b; } public int getId() { return id; } public void setId(int id) { this.id = id; } public float getL() { return l; } public float getTop() { return t; } public float getR() { return r; } public float getB() { return b; } public int getTxt_color() { return txt_color; } public void setTxt_color(int txt_color) { this.txt_color = txt_color; } public float getHumidity() { return humidity; } public void setHumidity(float humidity) { this.humidity = humidity; } public int getColor() { return color; } public void setColor(int color) { this.color = color; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
3e0b2d7f8a7ff5724571e335f92b4e83bfb17660
192
java
Java
src/main/java/com/cfg/strategy/Strategy.java
chenfugui/design_pattern
f0116ced9f1ea67389d67ca2df6712afc2ebe4c3
[ "Apache-2.0" ]
null
null
null
src/main/java/com/cfg/strategy/Strategy.java
chenfugui/design_pattern
f0116ced9f1ea67389d67ca2df6712afc2ebe4c3
[ "Apache-2.0" ]
null
null
null
src/main/java/com/cfg/strategy/Strategy.java
chenfugui/design_pattern
f0116ced9f1ea67389d67ca2df6712afc2ebe4c3
[ "Apache-2.0" ]
null
null
null
12
40
0.520833
4,727
package com.cfg.strategy; /** * 策略接口 */ public interface Strategy { /** * 策略执行方法 * @param a * @param b * @return */ public int doOperation(int a,int b); }
3e0b2deda03c62d02db0b23bbf0ddf04210e7198
1,227
java
Java
languages.test/languageDesign/lang.editor.editorTest/source_gen/jetbrains/mps/lang/editor/editorTest/editor/TestLanguage_StyleSheet_StyleSheet.java
trespasserw/MPS
dbc5c76496e8ccef46dd420eefcd5089b1bc234b
[ "Apache-2.0" ]
null
null
null
languages.test/languageDesign/lang.editor.editorTest/source_gen/jetbrains/mps/lang/editor/editorTest/editor/TestLanguage_StyleSheet_StyleSheet.java
trespasserw/MPS
dbc5c76496e8ccef46dd420eefcd5089b1bc234b
[ "Apache-2.0" ]
null
null
null
languages.test/languageDesign/lang.editor.editorTest/source_gen/jetbrains/mps/lang/editor/editorTest/editor/TestLanguage_StyleSheet_StyleSheet.java
trespasserw/MPS
dbc5c76496e8ccef46dd420eefcd5089b1bc234b
[ "Apache-2.0" ]
null
null
null
33.162162
88
0.763651
4,728
package jetbrains.mps.lang.editor.editorTest.editor; /*Generated by MPS */ import jetbrains.mps.openapi.editor.style.Style; import jetbrains.mps.openapi.editor.cells.EditorCell; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.openapi.editor.EditorContext; import jetbrains.mps.editor.runtime.style.AbstractStyleClass; import jetbrains.mps.editor.runtime.style.StyleAttributes; import jetbrains.mps.nodeEditor.MPSFonts; public class TestLanguage_StyleSheet_StyleSheet { /** * * @deprecated Since MPS 3.5 use generated StyleClass */ @Deprecated public static void apply_baseStyle(Style style, EditorCell editorCell) { SNode node = (editorCell == null ? null : editorCell.getSNode()); EditorContext editorContext = (editorCell == null ? null : editorCell.getContext()); new baseStyleStyleClass(editorContext, node).apply(style, editorCell); } public static class baseStyleStyleClass extends AbstractStyleClass { public baseStyleStyleClass(EditorContext editorContext, SNode node) { super(editorContext, node); } @Override public void apply(Style style, EditorCell editorCell) { style.set(StyleAttributes.FONT_STYLE, MPSFonts.PLAIN); } } }
3e0b2e8d3a155e60534eaf6897a409186b9eb7c5
2,420
java
Java
baaas-decision-fleet-manager/src/test/java/org/kie/baaas/dfm/app/dao/DecisionDecisionFleetShardDAOTest.java
r00ta/baaas-decision-fleet-manager
386eea48639686e1753e7c87ab28d39f93830a24
[ "Apache-2.0" ]
null
null
null
baaas-decision-fleet-manager/src/test/java/org/kie/baaas/dfm/app/dao/DecisionDecisionFleetShardDAOTest.java
r00ta/baaas-decision-fleet-manager
386eea48639686e1753e7c87ab28d39f93830a24
[ "Apache-2.0" ]
5
2021-07-09T16:06:46.000Z
2021-07-26T14:18:41.000Z
baaas-decision-fleet-manager/src/test/java/org/kie/baaas/dfm/app/dao/DecisionDecisionFleetShardDAOTest.java
r00ta/baaas-decision-fleet-manager
386eea48639686e1753e7c87ab28d39f93830a24
[ "Apache-2.0" ]
6
2021-06-24T08:02:20.000Z
2021-07-12T10:29:49.000Z
35.588235
107
0.745868
4,729
/* * Copyright 2021 Red Hat, Inc. and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * 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.kie.baaas.dfm.app.dao; import javax.inject.Inject; import org.junit.jupiter.api.Test; import org.kie.baaas.dfm.app.config.DecisionFleetManagerConfig; import org.kie.baaas.dfm.app.model.DecisionFleetShard; import org.kie.baaas.dfm.app.model.ListResult; import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; @QuarkusTest public class DecisionDecisionFleetShardDAOTest { @Inject DecisionFleetManagerConfig controlPlaneConfig; @Inject DecisionFleetShardDAO decisionFleetShardDAO; @TestTransaction @Test public void init_createsNewFleetShard() { DecisionFleetShard fleetShard = decisionFleetShardDAO.findById(1); assertFleetShard(fleetShard); } @Test @TestTransaction public void listAll() { ListResult<DecisionFleetShard> listResult = decisionFleetShardDAO.listAll(0, 100); assertThat(listResult.getPage(), equalTo(0L)); assertThat(listResult.getTotal(), equalTo(1L)); assertThat(listResult.getSize(), equalTo(1L)); DecisionFleetShard fleetShard = listResult.getItems().get(0); assertFleetShard(fleetShard); } private void assertFleetShard(DecisionFleetShard fleetShard) { assertThat(fleetShard.getId(), equalTo(1)); assertThat(fleetShard, is(notNullValue())); assertThat(fleetShard.getKubernetesApiUrl(), equalTo(controlPlaneConfig.getDfsKubernetesApiUrl())); assertThat(fleetShard.getDmnJitUrl(), equalTo(controlPlaneConfig.getDfsDmnJitUrl())); assertThat(fleetShard.getNamespace(), equalTo(controlPlaneConfig.getDfsNamespace())); } }
3e0b2ed047fe8e050dc75e53e866de3e36c3e7e7
538
java
Java
src/warmup/CountingValleys.java
yevgeniy-batulin/hacker-rank
c447f501f3f4183181ce7ddd832d565beaf8810d
[ "MIT" ]
null
null
null
src/warmup/CountingValleys.java
yevgeniy-batulin/hacker-rank
c447f501f3f4183181ce7ddd832d565beaf8810d
[ "MIT" ]
null
null
null
src/warmup/CountingValleys.java
yevgeniy-batulin/hacker-rank
c447f501f3f4183181ce7ddd832d565beaf8810d
[ "MIT" ]
null
null
null
26.9
58
0.54461
4,730
package warmup; // https://www.hackerrank.com/challenges/counting-valleys/ public class CountingValleys { private static int countingValleys(String s) { int level = upOrDown(s.charAt(0)); int count = 0; for (int i = 1; i < s.length(); i++) { int nextLevel = level + upOrDown(s.charAt(i)); if (level < 0 && nextLevel == 0) count++; level = nextLevel; } return count; } private static int upOrDown(char c) { return c == 'U' ? 1 : -1; } }
3e0b2efc0726a01fde121a7fe1b75721de1352b5
2,207
java
Java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
recordingblog/socket-im
7598a29ff4f4e7425e9a8a5308145b1f667472de
[ "MIT" ]
null
null
null
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
recordingblog/socket-im
7598a29ff4f4e7425e9a8a5308145b1f667472de
[ "MIT" ]
null
null
null
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
recordingblog/socket-im
7598a29ff4f4e7425e9a8a5308145b1f667472de
[ "MIT" ]
null
null
null
18.863248
100
0.581332
4,731
package com.ruoyi.system.mapper; import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.common.core.domain.PageData; import org.apache.ibatis.annotations.Param; import com.ruoyi.common.core.domain.entity.SysUser; /** * 用户表 数据层 * * @author ruoyi */ public interface SysUserMapper extends BaseMapper<SysUser> { /** * 根据条件分页查询用户列表 * * @param sysUser 用户信息 * @return 用户信息集合信息 */ public List<SysUser> selectUserList(SysUser sysUser); /** * 通过用户名查询用户 * * @param userName 用户名 * @return 用户对象信息 */ public SysUser selectUserByUserName(String userName); /** * 通过用户ID查询用户 * * @param userId 用户ID * @return 用户对象信息 */ public SysUser selectUserById(Long userId); /** * 新增用户信息 * * @param user 用户信息 * @return 结果 */ public int insertUser(SysUser user); /** * 修改用户信息 * * @param user 用户信息 * @return 结果 */ public int updateUser(SysUser user); /** * 修改用户头像 * * @param userName 用户名 * @param avatar 头像地址 * @return 结果 */ public int updateUserAvatar(@Param("userName") String userName, @Param("avatar") String avatar); /** * 重置用户密码 * * @param userName 用户名 * @param password 密码 * @return 结果 */ public int resetUserPwd(@Param("userName") String userName, @Param("password") String password); /** * 通过用户ID删除用户 * * @param userId 用户ID * @return 结果 */ public int deleteUserById(Long userId); /** * 批量删除用户信息 * * @param userIds 需要删除的用户ID * @return 结果 */ public int deleteUserByIds(Long[] userIds); /** * 校验用户名称是否唯一 * * @param userName 用户名称 * @return 结果 */ public int checkUserNameUnique(String userName); /** * 校验手机号码是否唯一 * * @param phonenumber 手机号码 * @return 结果 */ public SysUser checkPhoneUnique(String phonenumber); /** * 校验email是否唯一 * * @param email 用户邮箱 * @return 结果 */ public SysUser checkEmailUnique(String email); void updateOnlineStatus(PageData pd); }
3e0b2f24fae95f06de75df086777a2720fd73186
709
java
Java
nam/nam-data/src/test/java/nam/map/NamMapperFixture.java
tfisher1226/ARIES
814e3a4b4b48396bcd6d082e78f6519679ccaa01
[ "Apache-2.0" ]
2
2019-09-16T10:06:07.000Z
2021-02-25T11:46:23.000Z
nam/nam-data/src/test/java/nam/map/NamMapperFixture.java
tfisher1226/ARIES
814e3a4b4b48396bcd6d082e78f6519679ccaa01
[ "Apache-2.0" ]
null
null
null
nam/nam-data/src/test/java/nam/map/NamMapperFixture.java
tfisher1226/ARIES
814e3a4b4b48396bcd6d082e78f6519679ccaa01
[ "Apache-2.0" ]
null
null
null
19.162162
63
0.74048
4,732
package nam.map; public class NamMapperFixture { private static FileMapper fileMapper; private static ProjectMapper projectMapper; private static WorkspaceMapper workspaceMapper; public static FileMapper getFileMapper() { if (fileMapper == null) { fileMapper = new FileMapper(); } return fileMapper; } public static ProjectMapper getProjectMapper() { if (projectMapper == null) { projectMapper = new ProjectMapper(); projectMapper.fileMapper = NamMapperFixture.getFileMapper(); } return projectMapper; } public static WorkspaceMapper getWorkspaceMapper() { if (workspaceMapper == null) { workspaceMapper = new WorkspaceMapper(); } return workspaceMapper; } }
3e0b30f20f5dd9e01396d2cfb7a8a87373cede44
9,843
java
Java
FundamentosProyectoFinal/src/fundamentosproyectofinal/InterfazMenuPrincipal.java
Hikhuj/fundamentos_proyectoFinal
7b61a8d307813947aeee3c82f2f5aae9037d55f6
[ "MIT" ]
null
null
null
FundamentosProyectoFinal/src/fundamentosproyectofinal/InterfazMenuPrincipal.java
Hikhuj/fundamentos_proyectoFinal
7b61a8d307813947aeee3c82f2f5aae9037d55f6
[ "MIT" ]
1
2018-12-02T18:50:03.000Z
2018-12-02T18:50:03.000Z
FundamentosProyectoFinal/src/fundamentosproyectofinal/InterfazMenuPrincipal.java
Hikhuj/fundamentos_proyectoFinal
7b61a8d307813947aeee3c82f2f5aae9037d55f6
[ "MIT" ]
1
2018-11-04T15:16:34.000Z
2018-11-04T15:16:34.000Z
50.476923
218
0.698872
4,733
/* * 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 fundamentosproyectofinal; /** * * @author Karla */ public class InterfazMenuPrincipal extends javax.swing.JFrame { /** * Creates new form InterfazMenuPrincipal */ public InterfazMenuPrincipal() { initComponents(); } /** * 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() { jPanel1 = new javax.swing.JPanel(); MenuPrincipalMenuUsuarioBtn = new javax.swing.JButton(); MenuPrincipalMenuPeliculasBtn = new javax.swing.JButton(); MenuPrincipalConsultarInformacionBtn = new javax.swing.JButton(); MenuPrincipalSalirBtn = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); MenuPrincipalMenuUsuarioBtn.setBackground(new java.awt.Color(255, 255, 255)); MenuPrincipalMenuUsuarioBtn.setText("Menu usuarios"); MenuPrincipalMenuUsuarioBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { MenuPrincipalMenuUsuarioBtnActionPerformed(evt); } }); MenuPrincipalMenuPeliculasBtn.setBackground(new java.awt.Color(255, 255, 255)); MenuPrincipalMenuPeliculasBtn.setText("Menú películas"); MenuPrincipalMenuPeliculasBtn.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { MenuPrincipalMenuPeliculasBtnMouseClicked(evt); } }); MenuPrincipalConsultarInformacionBtn.setBackground(new java.awt.Color(255, 255, 255)); MenuPrincipalConsultarInformacionBtn.setText("Consultar Información"); MenuPrincipalConsultarInformacionBtn.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { MenuPrincipalConsultarInformacionBtnMouseClicked(evt); } }); MenuPrincipalSalirBtn.setBackground(new java.awt.Color(255, 255, 255)); MenuPrincipalSalirBtn.setText("Salir"); MenuPrincipalSalirBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { MenuPrincipalSalirBtnActionPerformed(evt); } }); jLabel1.setFont(new java.awt.Font("Gill Sans Ultra Bold", 1, 18)); // NOI18N jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setText("MENU PRINCIPAL VIDEOTEK"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(37, 37, 37) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE) .addComponent(MenuPrincipalMenuUsuarioBtn) .addComponent(MenuPrincipalMenuPeliculasBtn) .addComponent(MenuPrincipalConsultarInformacionBtn) .addComponent(MenuPrincipalSalirBtn)) .addGap(37, 37, 37)) ); jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {MenuPrincipalConsultarInformacionBtn, MenuPrincipalMenuPeliculasBtn, MenuPrincipalMenuUsuarioBtn, MenuPrincipalSalirBtn}); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(18, 18, 18) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(MenuPrincipalMenuUsuarioBtn) .addGap(34, 34, 34) .addComponent(MenuPrincipalMenuPeliculasBtn) .addGap(32, 32, 32) .addComponent(MenuPrincipalConsultarInformacionBtn) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE) .addComponent(MenuPrincipalSalirBtn) .addGap(30, 30, 30)) ); jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {MenuPrincipalConsultarInformacionBtn, MenuPrincipalMenuPeliculasBtn, MenuPrincipalMenuUsuarioBtn, MenuPrincipalSalirBtn}); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); pack(); setLocationRelativeTo(null); }// </editor-fold>//GEN-END:initComponents private void MenuPrincipalSalirBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuPrincipalSalirBtnActionPerformed System.exit(0); }//GEN-LAST:event_MenuPrincipalSalirBtnActionPerformed private void MenuPrincipalMenuUsuarioBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuPrincipalMenuUsuarioBtnActionPerformed // con este codigo vamos al menu de Usuario y cerramos esta ventana InterfazMenuUsuarios menuUsuario= new InterfazMenuUsuarios(); menuUsuario.setVisible(true); this.dispose(); }//GEN-LAST:event_MenuPrincipalMenuUsuarioBtnActionPerformed private void MenuPrincipalMenuPeliculasBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_MenuPrincipalMenuPeliculasBtnMouseClicked // con este codigo vamos al menu de peliculas y cerramos esta ventan InterfazMenuPeliculas menuPeliculas= new InterfazMenuPeliculas(); menuPeliculas.setVisible(true); this.dispose(); }//GEN-LAST:event_MenuPrincipalMenuPeliculasBtnMouseClicked private void MenuPrincipalConsultarInformacionBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_MenuPrincipalConsultarInformacionBtnMouseClicked // con este codigo vamos al menu de Consultar informacion InterfazConsultarInformacion consultarInformacion= new InterfazConsultarInformacion (); consultarInformacion.setVisible(true); this.dispose(); }//GEN-LAST:event_MenuPrincipalConsultarInformacionBtnMouseClicked /** * @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(InterfazMenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(InterfazMenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(InterfazMenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(InterfazMenuPrincipal.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 InterfazMenuPrincipal().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton MenuPrincipalConsultarInformacionBtn; private javax.swing.JButton MenuPrincipalMenuPeliculasBtn; private javax.swing.JButton MenuPrincipalMenuUsuarioBtn; private javax.swing.JButton MenuPrincipalSalirBtn; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; // End of variables declaration//GEN-END:variables }
3e0b3132a5b6486030c6d5d2e7004157c7a23e09
1,107
java
Java
hbase-book-master/src/test/java/com/elephantscale/hbase/book/chapter1/SimpleMRTest.java
paullewallencom/hbase-978-1-7839-8104-5
4fc639093f624a84193cc4b8aed251e71e38de2a
[ "Apache-2.0" ]
null
null
null
hbase-book-master/src/test/java/com/elephantscale/hbase/book/chapter1/SimpleMRTest.java
paullewallencom/hbase-978-1-7839-8104-5
4fc639093f624a84193cc4b8aed251e71e38de2a
[ "Apache-2.0" ]
null
null
null
hbase-book-master/src/test/java/com/elephantscale/hbase/book/chapter1/SimpleMRTest.java
paullewallencom/hbase-978-1-7839-8104-5
4fc639093f624a84193cc4b8aed251e71e38de2a
[ "Apache-2.0" ]
null
null
null
33.545455
113
0.653117
4,734
package com.elephantscale.hbase.book.chapter1; import java.io.File; import org.apache.commons.io.FileUtils; import org.junit.Test; import static org.junit.Assert.assertTrue; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * * @author mark */ public class SimpleMRTest { private static final Logger logger = LoggerFactory.getLogger(SimpleMRTest.class); /** * Test of main method, of class SimpleMR. */ @Test public void testMain() throws Exception { String[] args = new String[2]; args[0] = "data/small-file"; args[1] = "output"; // since this function runs either in the IDE or as part of 'mvn install', we can use local file command // to delete the output directory. We are using the Apache commons io, // which will work correctly if the directory is not present. logger.debug("Delete directory: {}", args[1]); FileUtils.deleteDirectory(new File(args[1])); logger.debug("Two arguments: {} and {}", args[0], args[1]); SimpleMR.main(args); assertTrue (true); } }
3e0b3156d058e131d5fdaa6426d90681307cd500
910
java
Java
tests/Java.Interop-Tests/java/com/xamarin/interop/CallNonvirtualDerived.java
jonathanpeppers/java.interop
e56a8c8e2076b3eebc16b35d9385282e7b35265c
[ "MIT" ]
167
2016-04-27T14:04:07.000Z
2022-03-28T03:48:06.000Z
tests/Java.Interop-Tests/java/com/xamarin/interop/CallNonvirtualDerived.java
jonathanpeppers/java.interop
e56a8c8e2076b3eebc16b35d9385282e7b35265c
[ "MIT" ]
510
2016-04-27T23:18:21.000Z
2022-03-29T14:49:31.000Z
tests/Java.Interop-Tests/java/com/xamarin/interop/CallNonvirtualDerived.java
jonathanpeppers/java.interop
e56a8c8e2076b3eebc16b35d9385282e7b35265c
[ "MIT" ]
58
2016-04-27T19:46:07.000Z
2021-11-18T17:58:36.000Z
22.195122
113
0.737363
4,735
package com.xamarin.interop; import java.util.ArrayList; import com.xamarin.java_interop.GCUserPeerable; public class CallNonvirtualDerived extends CallNonvirtualBase implements GCUserPeerable { static final String assemblyQualifiedName = "Java.InteropTests.CallNonvirtualDerived, Java.Interop-Tests"; ArrayList<Object> managedReferences = new ArrayList<Object>(); public CallNonvirtualDerived () { if (CallNonvirtualDerived.class == getClass ()) { com.xamarin.java_interop.ManagedPeer.construct ( this, assemblyQualifiedName, "" ); } } boolean methodInvoked; public void method () { System.out.println ("CallNonvirtualDerived.method() invoked!"); methodInvoked = true; } public void jiAddManagedReference (java.lang.Object obj) { managedReferences.add (obj); } public void jiClearManagedReferences () { managedReferences.clear (); } }
3e0b31c2ef8f8766bb7f7c34d125901899dc0058
1,408
java
Java
08-1-Stack/2-Advance/0331-verify-preorder-serialization-of-a-binary-tree/src/Solution.java
cynthiaZV/LeetCode-Solutions-in-Good-Style
acc8661338cc7c1ae067915fb16079a9e3e66847
[ "Apache-2.0" ]
461
2019-06-27T03:15:28.000Z
2019-12-17T15:17:42.000Z
08-1-Stack/2-Advance/0331-verify-preorder-serialization-of-a-binary-tree/src/Solution.java
dahui888/LeetCode-Solutions-in-Good-Style
acc8661338cc7c1ae067915fb16079a9e3e66847
[ "Apache-2.0" ]
62
2019-07-09T05:27:33.000Z
2019-10-12T07:10:48.000Z
08-1-Stack/2-Advance/0331-verify-preorder-serialization-of-a-binary-tree/src/Solution.java
dahui888/LeetCode-Solutions-in-Good-Style
acc8661338cc7c1ae067915fb16079a9e3e66847
[ "Apache-2.0" ]
47
2019-06-27T08:34:18.000Z
2019-12-17T03:14:46.000Z
28.16
145
0.511364
4,736
import java.util.ArrayDeque; import java.util.Deque; public class Solution { // # 代表一个空节点 // 参考:https://leetcode-cn.com/problems/verify-preorder-serialization-of-a-binary-tree/solution/zhong-gui-zhong-ju-pan-duan-you-xiao-shu-kr64/ public boolean isValidSerialization(String preorder) { String[] splits = preorder.split(","); int len = splits.length; // 特判 if (len == 1 && "#".equals(splits[0])) { return true; } // 因为空子树需要表示 if (len < 3) { return false; } // 还没想清楚 if (!"#".equals(splits[len - 1]) && !"#".equals(splits[len - 2])) { return false; } Deque<String> stack = new ArrayDeque<>(); stack.push(splits[0]); for (int i = 1; i < len; i++) { while (!stack.isEmpty() && "#".equals(stack.peekLast())) { stack.removeLast(); if (stack.isEmpty()) { return false; } stack.removeLast(); } stack.addLast(splits[i]); } return !stack.isEmpty() && "#".equals(stack.peekLast()); } public static void main(String[] args) { Solution solution = new Solution(); String preorder = "1,#"; boolean res = solution.isValidSerialization(preorder); System.out.println(res); } }
3e0b32fb5b5199df29428602d45ffe636824f168
3,237
java
Java
src/edu/wpi/first/wpilibj/templates/RobotCode.java
JohnDickinsonHS/FRC-2015_1
135c57a0d9c43ba11e210deed34d9afd8b995e7f
[ "BSD-3-Clause" ]
null
null
null
src/edu/wpi/first/wpilibj/templates/RobotCode.java
JohnDickinsonHS/FRC-2015_1
135c57a0d9c43ba11e210deed34d9afd8b995e7f
[ "BSD-3-Clause" ]
null
null
null
src/edu/wpi/first/wpilibj/templates/RobotCode.java
JohnDickinsonHS/FRC-2015_1
135c57a0d9c43ba11e210deed34d9afd8b995e7f
[ "BSD-3-Clause" ]
null
null
null
35.184783
119
0.602101
4,737
/*----------------------------------------------------------------------------*/ /* Copyright (c) FIRST 2008. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ /*----------------------------------------------------------------------------*/ package edu.wpi.first.wpilibj.templates; import edu.wpi.first.wpilibj.IterativeRobot; import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.RobotDrive; import edu.wpi.first.wpilibj.Talon; import edu.wpi.first.wpilibj.Timer; /** * The VM is configured to automatically run this class, and to call the * functions corresponding to each mode, as described in the IterativeRobot * documentation. If you change the name of this class or the package after * creating this project, you must also update the manifest file in the resource * directory. */ public class RobotCode extends IterativeRobot { //individual motors need to be delcared because we are using Talons, and RobotDrive assumes Jaguars Talon leftMotor = new Talon(0); Talon rightMotor = new Talon(1); RobotDrive mainDrive = new RobotDrive(leftMotor, rightMotor); //joystick numbers correspond with USB channels Joystick move = new Joystick(1); Joystick lift = new Joystick(2); /** * This function is run when the robot is first started up and should be * used for any initialization code. */ public void robotInit() { } /** * This function is called periodically during autonomous */ public void autonomousPeriodic() { mainDrive.setSafetyEnabled(false); mainDrive.drive(-0.5, 0.0); Timer.delay(2.0); mainDrive.drive(0.0, 0.0); } /** * This function is called periodically during operator control */ public void teleopPeriodic() { /* Tank drive is called as (left motor, right motor) * Tank drive requires two joysticks - could be done * with Xbox controller like it was for FTC * mainDrive.tankDrive(leftDrive, rightDrive); */ /* Plans for arcade drive instead. Arcade drive uses * only one joystick - very simple, could be done on * Xbox controller or with joystick already mounted * to driver control station. */ //http://wpilib.screenstepslive.com/s/3120/m/7912/l/95588-getting-your-robot-to-drive-with-the-robotdrive-class mainDrive.setSafetyEnabled(true); while (isOperatorControl() && isEnabled()) { mainDrive.arcadeDrive(move); Timer.delay(0.01); } //remember that "forward" on Y-axis is -1.0, while right on X-axis is 1.0 mainDrive.arcadeDrive(move); } /** * This function is called periodically during test mode */ public void testPeriodic() { } /*Test by Mr. Johnson - unsuccessful *public static void main(String args[]) { * System.out.print("hello"); } */ }
3e0b337f2fdf867ec28fc766d49bc63c9361696c
2,707
java
Java
cwms_radar_api/src/test/java/cwms/radar/data/dao/PoolDaoTest.java
DanielTOsborne/cwms-radar-api
b52d735e3250b6273aed13b890ef4c57c7c54afa
[ "MIT" ]
3
2021-01-16T17:28:19.000Z
2022-03-15T21:40:41.000Z
cwms_radar_api/src/test/java/cwms/radar/data/dao/PoolDaoTest.java
DanielTOsborne/cwms-radar-api
b52d735e3250b6273aed13b890ef4c57c7c54afa
[ "MIT" ]
62
2021-03-26T13:58:36.000Z
2022-03-31T23:37:49.000Z
cwms_radar_api/src/test/java/cwms/radar/data/dao/PoolDaoTest.java
DanielTOsborne/cwms-radar-api
b52d735e3250b6273aed13b890ef4c57c7c54afa
[ "MIT" ]
3
2021-05-14T17:10:32.000Z
2021-08-12T20:48:30.000Z
27.07
111
0.733284
4,738
package cwms.radar.data.dao; import java.sql.SQLException; import java.util.List; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import cwms.radar.data.dto.Pool; import cwms.radar.data.dto.Pools; import cwms.radar.formatters.json.JsonV2; import org.jooq.DSLContext; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static cwms.radar.data.dao.DaoTest.getConnection; import static cwms.radar.data.dao.DaoTest.getDslContext; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; @Disabled public class PoolDaoTest { @Test public void testCatalog() throws SQLException, JsonProcessingException { try(DSLContext lrl = getDslContext(getConnection(), "LRL")) { PoolDao dao = new PoolDao(lrl); String ANY_MASK = "*"; String idMask = ANY_MASK; String nameMask = ANY_MASK; String bottomMask = ANY_MASK; String topMask = ANY_MASK; boolean isExplicit; boolean isImplicit; isExplicit = false; isImplicit = true; List<Pool> impPools = dao.catalogPools(idMask, nameMask, bottomMask, topMask, isExplicit, isImplicit, "LRL"); assertNotNull(impPools); assertFalse(impPools.isEmpty(), "Expected some implicit pools to be found"); isExplicit = true; isImplicit = false; List<Pool> expPools = dao.catalogPools(idMask, nameMask, bottomMask, topMask, isExplicit, isImplicit, "LRL"); assertNotNull(expPools); // Looks like I don't have any explicit pools in db to test against. // assertFalse(expPools.isEmpty()); ObjectMapper mapper = JsonV2.buildObjectMapper(); String json = mapper.writeValueAsString(impPools); assertNotNull(json); } } @Test public void testRetrievePools() throws SQLException, JsonProcessingException { try(DSLContext lrl = getDslContext(getConnection(), "LRL")) { PoolDao dao = new PoolDao(lrl); String ANY_MASK = "*"; String idMask = ANY_MASK; String nameMask = ANY_MASK; String bottomMask = ANY_MASK; String topMask = ANY_MASK; boolean isExplicit = false; boolean isImplicit = true; Pools pools = dao.retrievePools(null, 5, idMask, nameMask, bottomMask, topMask, isExplicit, isImplicit, "LRL"); assertNotNull(pools); String page = pools.getPage(); String nextPage = pools.getNextPage(); Pools pools2 = dao.retrievePools(nextPage, 5, idMask, nameMask, bottomMask, topMask, isExplicit, isImplicit, "LRL"); Pools pools3 = dao.retrievePools(pools2.getNextPage(), 5, idMask, nameMask, bottomMask, topMask, isExplicit, isImplicit, "LRL"); assertNotNull(page); } } }
3e0b33d3cae79eb3ccf536b15b819dfae8a6d27f
1,589
java
Java
openknowledge-cdi-transaction/src/main/java/de/openknowledge/cdi/transaction/package-info.java
openknowledge/openknowledge-cdi-extensions
ffaa71742dc8ce1891168a52489b020cc21e8634
[ "Apache-2.0" ]
2
2016-01-05T16:02:59.000Z
2021-08-05T05:12:44.000Z
openknowledge-cdi-transaction/src/main/java/de/openknowledge/cdi/transaction/package-info.java
openknowledge/openknowledge-cdi-extensions
ffaa71742dc8ce1891168a52489b020cc21e8634
[ "Apache-2.0" ]
null
null
null
openknowledge-cdi-transaction/src/main/java/de/openknowledge/cdi/transaction/package-info.java
openknowledge/openknowledge-cdi-extensions
ffaa71742dc8ce1891168a52489b020cc21e8634
[ "Apache-2.0" ]
1
2015-01-16T13:30:40.000Z
2015-01-16T13:30:40.000Z
45.4
122
0.761485
4,739
/* * Copyright open knowledge GmbH * * 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. */ /** * * This package enables the usage of {@link javax.ejb.TransactionAttribute} * for transaction management. It includes support for {@link javax.ejb.ApplicationException}. * <p/> * CDI-Transactions require a working JTA environment which should be available * within an application server or can be enabled using JTA implementations * such as bitronix. * <p/> * To enable TX management just use {@link javax.ejb.TransactionAttribute} on class * or method level. You may declare a transaction as read-only using the {@link de.openknowledge.cdi.transaction.ReadOnly} * annotation. The transaction will be marked as rollback only ensuring that the communication * with JTA resources will be rolled back in any case. * <p/> * You may use the test dependency of this package to add a CDI UserTransaction/TransactionManager * mockup facility. Simply add the archive to your test project in order to use injectable user transactions. * */ package de.openknowledge.cdi.transaction;
3e0b34977aa9ff24929defcd00ca17df68ae4358
875
java
Java
client-auth/src/main/java/es/tododev/auth/client/AuthoriationXmlFilter.java
jbescos/CentralAuth
1a0d04889f5551b60c5fc1b7eafe57a9a9d0e8c7
[ "Apache-2.0" ]
null
null
null
client-auth/src/main/java/es/tododev/auth/client/AuthoriationXmlFilter.java
jbescos/CentralAuth
1a0d04889f5551b60c5fc1b7eafe57a9a9d0e8c7
[ "Apache-2.0" ]
null
null
null
client-auth/src/main/java/es/tododev/auth/client/AuthoriationXmlFilter.java
jbescos/CentralAuth
1a0d04889f5551b60c5fc1b7eafe57a9a9d0e8c7
[ "Apache-2.0" ]
null
null
null
24.305556
82
0.76
4,740
package es.tododev.auth.client; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; public class AuthoriationXmlFilter extends AuthorizationFilter { private static final String APP_ID = "AppId"; private static final String APP_PASSWORD = "AppPassword"; private IAppProvider appProvider; @Override protected IAppProvider getProvider(HttpServletRequest request, String appToken) { return appProvider; } @Override public void init(FilterConfig arg0) throws ServletException { super.init(arg0); String appId = checkAndGet(APP_ID, arg0); String appPassword = checkAndGet(APP_PASSWORD, arg0); this.appProvider = new IAppProvider() { @Override public String getAppPassword() { return appPassword; } @Override public String getAppId() { return appId; } }; } }
3e0b34ada3ccfd99773affb6432111aa57f8de75
187
java
Java
src/main/java/me/kristoffer/vanillaplus/backend/org/bukkit/entity/Pose.java
SquaredHelix/VanillaPlus
004bcb729c578d7ab78f0ae686d57589436f5870
[ "MIT" ]
1
2020-04-30T16:36:18.000Z
2020-04-30T16:36:18.000Z
src/main/java/me/kristoffer/vanillaplus/backend/org/bukkit/entity/Pose.java
SquaredHelix/VanillaPlus
004bcb729c578d7ab78f0ae686d57589436f5870
[ "MIT" ]
6
2020-03-15T11:24:55.000Z
2021-02-03T23:14:44.000Z
src/main/java/me/kristoffer/vanillaplus/backend/org/bukkit/entity/Pose.java
SquaredHelix/VanillaPlus
004bcb729c578d7ab78f0ae686d57589436f5870
[ "MIT" ]
null
null
null
18.7
60
0.759358
4,741
package me.kristoffer.vanillaplus.backend.org.bukkit.entity; public class Pose { public org.bukkit.entity.Pose from(String name) { return org.bukkit.entity.Pose.valueOf(name); } }
3e0b34f3e824ed2819cddb162b60963463b5597e
4,995
java
Java
src/edu/virginia/vcgr/genii/container/cservices/conf/ContainerServiceConfiguration.java
genesis-2/trunk
9a6b34e8531ef0a1614ee48802b037df6e4fa2d7
[ "Apache-2.0" ]
1
2022-03-16T16:36:00.000Z
2022-03-16T16:36:00.000Z
src/edu/virginia/vcgr/genii/container/cservices/conf/ContainerServiceConfiguration.java
genesis-2/trunk
9a6b34e8531ef0a1614ee48802b037df6e4fa2d7
[ "Apache-2.0" ]
1
2021-06-04T02:05:42.000Z
2021-06-04T02:05:42.000Z
src/edu/virginia/vcgr/genii/container/cservices/conf/ContainerServiceConfiguration.java
genesis-2/trunk
9a6b34e8531ef0a1614ee48802b037df6e4fa2d7
[ "Apache-2.0" ]
null
null
null
30.833333
133
0.762763
4,742
package edu.virginia.vcgr.genii.container.cservices.conf; import java.io.File; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Collection; import java.util.LinkedList; import java.util.Properties; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Element; import edu.virginia.vcgr.genii.client.configuration.HierarchicalDirectory; import edu.virginia.vcgr.genii.client.utils.file.ExtensionFileFilter; import edu.virginia.vcgr.genii.container.cservices.ContainerService; import edu.virginia.vcgr.genii.system.classloader.GenesisClassLoader; @XmlRootElement(name = "container-service") public class ContainerServiceConfiguration { static private Log _logger = LogFactory.getLog(ContainerServiceConfiguration.class); @XmlTransient private File _sourceFile; @XmlTransient private Class<? extends ContainerService> _serviceClass = null; @XmlAttribute(name = "class", required = true) private String _className = null; @XmlElement(name = "property", nillable = true, required = false) private Collection<ContainerServiceProperty> _properties = new LinkedList<ContainerServiceProperty>(); @XmlAnyElement private Collection<Element> _anyElements = new LinkedList<Element>(); ContainerServiceConfiguration() { this(null, null); } public ContainerServiceConfiguration(Class<? extends ContainerService> serviceClass, Properties properties) { _serviceClass = serviceClass; _className = (_serviceClass == null) ? null : _serviceClass.getName(); if (properties == null) properties = new Properties(); for (Object key : properties.keySet()) { String name = key.toString(); _properties.add(new ContainerServiceProperty(name, properties.getProperty(name))); } } final public File configurationFile() { return _sourceFile; } final public Properties properties() { Properties ret = new Properties(); for (ContainerServiceProperty property : _properties) ret.setProperty(property.name(), property.value()); return ret; } @SuppressWarnings("unchecked") final public Class<? extends ContainerService> serviceClass() throws ClassNotFoundException { if (_serviceClass == null) { _serviceClass = (Class<? extends ContainerService>) GenesisClassLoader.classLoaderFactory().loadClass(_className); } return _serviceClass; } final public Collection<Element> anyElements() { return _anyElements; } final public ContainerService instantiate() throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException { ContainerService ret = null; Constructor<? extends ContainerService> cons; serviceClass(); Element[] any; if (_anyElements == null) any = new Element[0]; else { any = new Element[_anyElements.size()]; _anyElements.toArray(any); } try { cons = _serviceClass.getConstructor(Element[].class); ret = cons.newInstance((Object) any); } catch (NoSuchMethodException nsme1) { if (any.length > 1) throw new NoSuchMethodException( String.format("Unable to find suitable constructor for " + "service %s defined in file %s.", _serviceClass, _sourceFile)); try { cons = _serviceClass.getConstructor(Element.class); if (any.length == 0) ret = cons.newInstance((Object) null); else ret = cons.newInstance(any[0]); } catch (NoSuchMethodException nsme2) { cons = _serviceClass.getConstructor(); ret = cons.newInstance(); } } if (ret != null) ret.setProperties(properties()); return ret; } static public Collection<ContainerServiceConfiguration> loadConfigurations(HierarchicalDirectory sourceDirectory) throws IOException { Collection<ContainerServiceConfiguration> ret = new LinkedList<ContainerServiceConfiguration>(); JAXBContext context; Unmarshaller unmarshaller; try { context = JAXBContext.newInstance(ContainerServiceConfiguration.class); unmarshaller = context.createUnmarshaller(); } catch (JAXBException e) { throw new IOException("Unable to load container services.", e); } for (File sourceFile : sourceDirectory.listFiles(ExtensionFileFilter.XML)) { try { ContainerServiceConfiguration conf = (ContainerServiceConfiguration) unmarshaller.unmarshal(sourceFile); conf._sourceFile = sourceFile; ret.add(conf); } catch (JAXBException e) { _logger.error(String.format("Unable to load container service configuration " + "from file \"%s\".", sourceFile), e); } } return ret; } }
3e0b3508367ccd25172755ab158893d1b5f4926f
1,355
java
Java
src/api/java/mekanism/api/recipes/ingredients/creator/IFluidStackIngredientCreator.java
Mekanism/Mekanism
607bf9bf27a1e225059ed6829d69fc152a4e228e
[ "MIT" ]
1
2022-03-30T13:34:28.000Z
2022-03-30T13:34:28.000Z
src/api/java/mekanism/api/recipes/ingredients/creator/IFluidStackIngredientCreator.java
Mekanism/Mekanism
607bf9bf27a1e225059ed6829d69fc152a4e228e
[ "MIT" ]
null
null
null
src/api/java/mekanism/api/recipes/ingredients/creator/IFluidStackIngredientCreator.java
Mekanism/Mekanism
607bf9bf27a1e225059ed6829d69fc152a4e228e
[ "MIT" ]
null
null
null
41.060606
115
0.773432
4,743
package mekanism.api.recipes.ingredients.creator; import java.util.Objects; import javax.annotation.ParametersAreNonnullByDefault; import mekanism.api.providers.IFluidProvider; import mekanism.api.recipes.ingredients.FluidStackIngredient; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.world.level.material.Fluid; import net.minecraftforge.fluids.FluidStack; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public interface IFluidStackIngredientCreator extends IIngredientCreator<Fluid, FluidStack, FluidStackIngredient> { /** * Creates a Fluid Stack Ingredient that matches a provided fluid and amount. * * @param provider Fluid provider that provides the fluid to match. * @param amount Amount needed. * * @throws NullPointerException if the given instance is null. * @throws IllegalArgumentException if the given instance is empty or an amount smaller than one. */ default FluidStackIngredient from(IFluidProvider provider, int amount) { Objects.requireNonNull(provider, "FluidStackIngredients cannot be created from a null fluid provider."); return from(provider.getFluidStack(amount)); } @Override default FluidStackIngredient from(Fluid instance, int amount) { return from(new FluidStack(instance, amount)); } }
3e0b35ff9affcf0b5ddf8e561d43f65e4fe1d230
1,357
java
Java
app/startup/StartupManagerImpl.java
Flux-Coordinator/flux-server
90423cd64efa5455892aefa1df0ba76503326bbb
[ "MIT" ]
2
2018-02-23T14:32:31.000Z
2018-04-15T12:28:42.000Z
app/startup/StartupManagerImpl.java
Flux-Coordinator/flux-server
90423cd64efa5455892aefa1df0ba76503326bbb
[ "MIT" ]
2
2018-03-27T14:12:40.000Z
2018-05-08T19:07:37.000Z
app/startup/StartupManagerImpl.java
Flux-Coordinator/flux-server
90423cd64efa5455892aefa1df0ba76503326bbb
[ "MIT" ]
null
null
null
33.925
107
0.57185
4,744
package startup; import play.Environment; import play.Logger; import repositories.projects.ProjectsRepository; import repositories.utils.DemoDataHelper; import javax.inject.Inject; public class StartupManagerImpl implements StartupManager { private final ProjectsRepository projectsRepository; private final Environment environment; @Inject public StartupManagerImpl(final ProjectsRepository projectsRepository, final Environment environment) { this.projectsRepository = projectsRepository; this.environment = environment; this.init(); } @Override public void init() { if(!environment.isProd()) { this.projectsRepository.resetRepository() .thenAcceptAsync(aVoid -> { this.projectsRepository.addProjects(DemoDataHelper.generateDemoData()) .exceptionally(throwable -> { Logger.error("Could not add demo data", throwable); return null; }); }) .exceptionally(throwable -> { Logger.error("Could not reset the repository", throwable); return null; }) .join(); } } }
3e0b360fd6357053679a0e8ea24a22c8a55ef221
1,049
java
Java
portfolio/src/main/java/com/google/sps/interfaces/DatastoreInterface.java
fuiszgt/Step2020portfolio
8c5a6f10c92063e9c964c16b4a36985d3f149fa8
[ "Apache-2.0" ]
null
null
null
portfolio/src/main/java/com/google/sps/interfaces/DatastoreInterface.java
fuiszgt/Step2020portfolio
8c5a6f10c92063e9c964c16b4a36985d3f149fa8
[ "Apache-2.0" ]
10
2020-07-20T15:19:09.000Z
2020-07-31T16:45:53.000Z
portfolio/src/main/java/com/google/sps/interfaces/DatastoreInterface.java
fuiszgt/Step2020portfolio
8c5a6f10c92063e9c964c16b4a36985d3f149fa8
[ "Apache-2.0" ]
null
null
null
32.78125
87
0.71592
4,745
// Copyright 2019 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package com.google.sps.interfaces; import java.util.List; import com.google.sps.data.Comment; import static com.googlecode.objectify.ObjectifyService.ofy; public class DatastoreInterface{ public void addComment(Comment comment){ ofy().save().entity(comment).now(); } public List<Comment> getComments(){ List<Comment> comments = ofy().load().type(Comment.class).order("date").list(); return comments; } }
3e0b366f35a91f7be93ad0121d4c3e6112f2a5ea
1,550
java
Java
mgmt/java/src/main/java/com/aliyun/pds/mgmt/client/models/BenefitBaseResponse.java
lancer-chen/alibabacloud-pds-sdk
f9cea449693eb96288b4c98078cd43c5559f3bd9
[ "Apache-2.0" ]
4
2020-08-21T08:40:27.000Z
2021-04-04T03:39:06.000Z
mgmt/java/src/main/java/com/aliyun/pds/mgmt/client/models/BenefitBaseResponse.java
lancer-chen/alibabacloud-pds-sdk
f9cea449693eb96288b4c98078cd43c5559f3bd9
[ "Apache-2.0" ]
35
2020-08-31T08:10:53.000Z
2022-03-24T09:43:11.000Z
mgmt/java/src/main/java/com/aliyun/pds/mgmt/client/models/BenefitBaseResponse.java
lancer-chen/alibabacloud-pds-sdk
f9cea449693eb96288b4c98078cd43c5559f3bd9
[ "Apache-2.0" ]
16
2020-08-24T05:42:43.000Z
2022-03-16T03:03:53.000Z
24.603175
92
0.669032
4,746
// This file is auto-generated, don't edit it. Thanks. package com.aliyun.pds.mgmt.client.models; import com.aliyun.tea.*; /** * Benefit base info of benefit package */ public class BenefitBaseResponse extends TeaModel { // 权益的唯一标识 @NameInMap("benefit_id") public String benefitId; @NameInMap("benefit_meta") public BenefitMetaResponse benefitMeta; // 权益包的唯一标识 @NameInMap("benefit_pkg_id") public String benefitPkgId; // 权益的名称 @NameInMap("name") public String name; public static BenefitBaseResponse build(java.util.Map<String, ?> map) throws Exception { BenefitBaseResponse self = new BenefitBaseResponse(); return TeaModel.build(map, self); } public BenefitBaseResponse setBenefitId(String benefitId) { this.benefitId = benefitId; return this; } public String getBenefitId() { return this.benefitId; } public BenefitBaseResponse setBenefitMeta(BenefitMetaResponse benefitMeta) { this.benefitMeta = benefitMeta; return this; } public BenefitMetaResponse getBenefitMeta() { return this.benefitMeta; } public BenefitBaseResponse setBenefitPkgId(String benefitPkgId) { this.benefitPkgId = benefitPkgId; return this; } public String getBenefitPkgId() { return this.benefitPkgId; } public BenefitBaseResponse setName(String name) { this.name = name; return this; } public String getName() { return this.name; } }
3e0b36cc8ae889a89cbe415f94e035bc264459eb
889
java
Java
perun-dispatcher/src/main/java/cz/metacentrum/perun/dispatcher/model/MatchingRule.java
xkureck/perun
266574fcc1ac61c3ff91a26af8e83f9fbf5ccc03
[ "BSD-2-Clause" ]
null
null
null
perun-dispatcher/src/main/java/cz/metacentrum/perun/dispatcher/model/MatchingRule.java
xkureck/perun
266574fcc1ac61c3ff91a26af8e83f9fbf5ccc03
[ "BSD-2-Clause" ]
null
null
null
perun-dispatcher/src/main/java/cz/metacentrum/perun/dispatcher/model/MatchingRule.java
xkureck/perun
266574fcc1ac61c3ff91a26af8e83f9fbf5ccc03
[ "BSD-2-Clause" ]
null
null
null
18.5
85
0.689189
4,747
package cz.metacentrum.perun.dispatcher.model; import java.util.List; import java.util.Objects; /** * Set of MatchingRules. Used to match Event headers to EngineMessageProducer queues. * * @author Michal Karm Babacek * @author Pavel Zlámal <upchh@example.com> */ public class MatchingRule { private final List<String> rules; /** * Create new set of MatchingRules * * @param rules Rules to set */ public MatchingRule(List<String> rules) { this.rules = rules; } /** * Return list of rules * * @return list of rules */ public List<String> getRules() { return rules; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof MatchingRule)) return false; MatchingRule that = (MatchingRule) o; return Objects.equals(rules, that.rules); } @Override public int hashCode() { return Objects.hash(rules); } }
3e0b36f8b4fb85d287a208500df53eff1e3e3565
1,216
java
Java
gtas-parent/gtas-webapp/src/main/java/gov/gtas/controller/NotificationController.java
yashpatil/GTAS
4b74a3fe61af5e255d60c4308425e8861c2a406b
[ "BSD-3-Clause" ]
null
null
null
gtas-parent/gtas-webapp/src/main/java/gov/gtas/controller/NotificationController.java
yashpatil/GTAS
4b74a3fe61af5e255d60c4308425e8861c2a406b
[ "BSD-3-Clause" ]
null
null
null
gtas-parent/gtas-webapp/src/main/java/gov/gtas/controller/NotificationController.java
yashpatil/GTAS
4b74a3fe61af5e255d60c4308425e8861c2a406b
[ "BSD-3-Clause" ]
null
null
null
32.864865
122
0.802632
4,748
/* All GTAS code is Copyright 2016, The Department of Homeland Security (DHS), U.S. Customs and Border Protection (CBP).*/ package gov.gtas.controller; import java.util.HashSet; import java.util.List; import java.util.Set; import gov.gtas.model.Case; import gov.gtas.services.CaseDispositionService; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import gov.gtas.model.MessageStatus; import gov.gtas.vo.ErrorMessageVo; @RestController public class NotificationController { private final CaseDispositionService caseDispositionService; public NotificationController(CaseDispositionService caseDispositionService) { this.caseDispositionService = caseDispositionService; } @RequestMapping(method = RequestMethod.GET, value = "/errorMessage") public List<ErrorMessageVo> getErrorMessage() { Set<MessageStatus> errorStatuses = new HashSet<>(); return null; } @RequestMapping(method = RequestMethod.GET, value = "/hitCount") public Integer getHitCount() { Set<Case> caseList = caseDispositionService.getOpenCasesWithTimeLeft(); return caseList.size(); } }
3e0b370a97cdd0c84e6d1b1143512cb5a75803c8
221
java
Java
laboratorio di MAP/6_esercizioFigura/src/main/java/it/figure/Quadrato.java
Piersilvio/java
5b5d18c62933a0526cd52461c6336e798f16c704
[ "Apache-2.0" ]
1
2022-03-24T08:49:38.000Z
2022-03-24T08:49:38.000Z
laboratorio di MAP/6_esercizioFigura/src/main/java/it/figure/Quadrato.java
Piersilvio/java
5b5d18c62933a0526cd52461c6336e798f16c704
[ "Apache-2.0" ]
3
2022-03-25T18:52:31.000Z
2022-03-27T15:13:47.000Z
laboratorio di MAP/6_esercizioFigura/src/main/java/it/figure/Quadrato.java
Piersilvio/java
5b5d18c62933a0526cd52461c6336e798f16c704
[ "Apache-2.0" ]
1
2022-03-24T18:26:54.000Z
2022-03-24T18:26:54.000Z
17
48
0.61991
4,749
package it.figure; public class Quadrato extends Rettangolo { public Quadrato(double lato) { super(lato, lato); } public String toString() { return "Quadrato di lato " + super.dim1; } }
3e0b370c5b54b942babe5a36ebf06361ec3c5eb0
1,346
java
Java
jaxws-ri/tests/unit-rearch/src/whitebox/handlers/common/BaseSOAPHandler.java
aserkes/metro-jax-ws
b7d7441d8743e54472d928ae1c213ddd2196187f
[ "BSD-3-Clause" ]
40
2018-10-05T10:39:25.000Z
2022-03-31T07:27:39.000Z
jaxws-ri/tests/unit-rearch/src/whitebox/handlers/common/BaseSOAPHandler.java
aserkes/metro-jax-ws
b7d7441d8743e54472d928ae1c213ddd2196187f
[ "BSD-3-Clause" ]
98
2018-10-18T12:20:48.000Z
2022-03-26T13:43:10.000Z
jaxws-ri/tests/unit-rearch/src/whitebox/handlers/common/BaseSOAPHandler.java
aserkes/metro-jax-ws
b7d7441d8743e54472d928ae1c213ddd2196187f
[ "BSD-3-Clause" ]
40
2018-10-17T20:43:51.000Z
2022-03-10T18:01:31.000Z
26.392157
79
0.703566
4,750
/* * Copyright (c) 2005, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at * http://www.eclipse.org/org/documents/edl-v10.php. * * SPDX-License-Identifier: BSD-3-Clause */ package whitebox.handlers.common; import java.util.HashSet; import java.util.Map; import java.util.Set; import jakarta.annotation.PostConstruct; import jakarta.annotation.PreDestroy; import javax.xml.namespace.QName; import jakarta.xml.ws.handler.*; import jakarta.xml.ws.handler.soap.*; import jakarta.xml.ws.ProtocolException; import jakarta.xml.soap.SOAPMessage; public class BaseSOAPHandler implements SOAPHandler<SOAPMessageContext> { String name; public boolean handleMessage(SOAPMessageContext messageContext) { System.out.println("handler " + name); return true; } public void close(MessageContext messageContext) { } public boolean handleFault(SOAPMessageContext messageContext) { return true; } public Set<QName> getHeaders() { Set<QName> headers = new HashSet<QName>(); headers.add(new QName("http://example.com/someheader", "testheader1")); return headers; } }
3e0b38752a3916636d51abb790d95dcf0df390f4
3,549
java
Java
src/main/java/net/accelbyte/sdk/api/gdpr/operations/data_retrieval/PublicGetUserPersonalDataRequests.java
AccelByte/accelbyte-java-sdk
35086513f8f2acaa9b15a78730498fa5e19769ef
[ "MIT" ]
1
2022-02-26T12:15:52.000Z
2022-02-26T12:15:52.000Z
src/main/java/net/accelbyte/sdk/api/gdpr/operations/data_retrieval/PublicGetUserPersonalDataRequests.java
AccelByte/accelbyte-java-sdk
35086513f8f2acaa9b15a78730498fa5e19769ef
[ "MIT" ]
null
null
null
src/main/java/net/accelbyte/sdk/api/gdpr/operations/data_retrieval/PublicGetUserPersonalDataRequests.java
AccelByte/accelbyte-java-sdk
35086513f8f2acaa9b15a78730498fa5e19769ef
[ "MIT" ]
1
2021-12-29T04:01:20.000Z
2021-12-29T04:01:20.000Z
28.620968
149
0.654832
4,751
/* * Copyright (c) 2022 AccelByte Inc. All Rights Reserved * This is licensed software from AccelByte Inc, for limitations * and restrictions contact your company contract manager. * * Code generated. DO NOT EDIT. */ package net.accelbyte.sdk.api.gdpr.operations.data_retrieval; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.Builder; import lombok.Getter; import lombok.Setter; import net.accelbyte.sdk.api.gdpr.models.*; import net.accelbyte.sdk.api.gdpr.models.ModelsUserPersonalDataResponse; import net.accelbyte.sdk.core.Operation; import net.accelbyte.sdk.core.util.Helper; import net.accelbyte.sdk.core.HttpResponseException; import java.io.IOException; import java.io.InputStream; import java.util.*; /** * PublicGetUserPersonalDataRequests * * * * Requires valid user access token */ @Getter @Setter public class PublicGetUserPersonalDataRequests extends Operation { /** * generated field's value */ private String path = "/gdpr/public/namespaces/{namespace}/users/{userId}/requests"; private String method = "GET"; private List<String> consumes = Arrays.asList("application/json"); private List<String> produces = Arrays.asList("application/json"); @Deprecated private String security = "Bearer"; private String locationQuery = null; /** * fields as input parameter */ private String namespace; private String userId; private Integer limit; private Integer offset; /** * @param namespace required * @param userId required */ @Builder public PublicGetUserPersonalDataRequests( String namespace, String userId, Integer limit, Integer offset ) { this.namespace = namespace; this.userId = userId; this.limit = limit; this.offset = offset; securities.add("Bearer"); } @Override public Map<String, String> getPathParams(){ Map<String, String> pathParams = new HashMap<>(); if (this.namespace != null){ pathParams.put("namespace", this.namespace); } if (this.userId != null){ pathParams.put("userId", this.userId); } return pathParams; } @Override public Map<String, List<String>> getQueryParams(){ Map<String, List<String>> queryParams = new HashMap<>(); queryParams.put("limit", this.limit == null ? null : Arrays.asList(String.valueOf(this.limit))); queryParams.put("offset", this.offset == null ? null : Arrays.asList(String.valueOf(this.offset))); return queryParams; } @Override public boolean isValid() { if(this.namespace == null) { return false; } if(this.userId == null) { return false; } return true; } public ModelsUserPersonalDataResponse parseResponse(int code, String contentTpe, InputStream payload) throws HttpResponseException, IOException { String json = Helper.convertInputStreamToString(payload); if(code == 200){ return new ModelsUserPersonalDataResponse().createFromJson(json); } throw new HttpResponseException(code, json); } @Override protected Map<String, String> getCollectionFormatMap() { Map<String, String> result = new HashMap<>(); result.put("limit", "None"); result.put("offset", "None"); return result; } }
3e0b38ded037bc0b6c4b7feb5e9af86569263e52
6,595
java
Java
submarine-server/server-core/src/main/java/org/apache/submarine/server/rest/NotebookRestApi.java
JackLiu00521/submarine
170c5061a0e07a2fe88bab6be8f02638ec443c25
[ "Apache-2.0" ]
544
2019-10-29T02:35:31.000Z
2022-03-31T21:22:44.000Z
submarine-server/server-core/src/main/java/org/apache/submarine/server/rest/NotebookRestApi.java
JackLiu00521/submarine
170c5061a0e07a2fe88bab6be8f02638ec443c25
[ "Apache-2.0" ]
545
2019-10-29T03:21:38.000Z
2022-03-30T05:21:15.000Z
submarine-server/server-core/src/main/java/org/apache/submarine/server/rest/NotebookRestApi.java
JackLiu00521/submarine
170c5061a0e07a2fe88bab6be8f02638ec443c25
[ "Apache-2.0" ]
220
2019-10-29T05:14:03.000Z
2022-03-28T07:29:30.000Z
38.121387
96
0.677635
4,752
/* * 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.submarine.server.rest; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import org.apache.submarine.commons.utils.exception.SubmarineRuntimeException; import org.apache.submarine.server.api.notebook.Notebook; import org.apache.submarine.server.api.spec.NotebookSpec; import org.apache.submarine.server.notebook.NotebookManager; import org.apache.submarine.server.response.JsonResponse; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; /** * Notebook REST API v1. It can accept {@link NotebookSpec} to create a notebook server. */ @Path(RestConstants.V1 + "/" + RestConstants.NOTEBOOK) @Produces({MediaType.APPLICATION_JSON + "; " + RestConstants.CHARSET_UTF8}) public class NotebookRestApi { /* Notebook manager */ private final NotebookManager notebookManager = NotebookManager.getInstance(); /** * Return the Pong message for test the connectivity * @return Pong message */ @GET @Path(RestConstants.PING) @Consumes(MediaType.APPLICATION_JSON) @Operation(summary = "Ping submarine server", tags = {"notebook"}, description = "Return the Pong message for test the connectivity", responses = { @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class)))}) public Response ping() { return new JsonResponse.Builder<String>(Response.Status.OK) .success(true).result("Pong").build(); } /** * Create a notebook with spec * @param spec notebook spec * @return the detailed info about created notebook */ @POST @Consumes({RestConstants.MEDIA_TYPE_YAML, MediaType.APPLICATION_JSON}) @Operation( summary = "Create a notebook instance", tags = {"notebook"}, responses = { @ApiResponse(description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class)))}) public Response createNotebook(NotebookSpec spec) { try { Notebook notebook = notebookManager.createNotebook(spec); return new JsonResponse.Builder<Notebook>(Response.Status.OK).success(true) .message("Create a notebook instance").result(notebook).build(); } catch (SubmarineRuntimeException e) { return parseNotebookServiceException(e); } } /** * List all notebooks * @param id user id * @return notebook list */ @GET @Operation( summary = "List notebooks", tags = {"notebook"}, responses = { @ApiResponse(description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class)))}) public Response listNotebooks(@QueryParam("id") String id) { try { List<Notebook> notebookList = notebookManager.listNotebooksByUserId(id); return new JsonResponse.Builder<List<Notebook>>(Response.Status.OK).success(true) .message("List all notebook instances").result(notebookList).build(); } catch (SubmarineRuntimeException e) { return parseNotebookServiceException(e); } } /** * Get detailed info about the notebook by notebook id * @param id notebook id * @return detailed info about the notebook */ @GET @Path("/{id}") @Operation( summary = "Get detailed info about the notebook", tags = {"notebook"}, responses = { @ApiResponse( description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class))), @ApiResponse(responseCode = "404", description = "Notebook not found")}) public Response getNotebook(@PathParam(RestConstants.NOTEBOOK_ID) String id) { try { Notebook notebook = notebookManager.getNotebook(id); return new JsonResponse.Builder<Notebook>(Response.Status.OK).success(true) .message("Get the notebook instance").result(notebook).build(); } catch (SubmarineRuntimeException e) { return parseNotebookServiceException(e); } } /** * Delete the notebook with notebook id * @param id notebook id * @return the detailed info about deleted notebook */ @DELETE @Path("/{id}") @Operation( summary = "Delete the notebook", tags = {"notebook"}, responses = { @ApiResponse( description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class))), @ApiResponse(responseCode = "404", description = "Notebook not found")}) public Response deleteNotebook(@PathParam(RestConstants.NOTEBOOK_ID) String id) { try { Notebook notebook = notebookManager.deleteNotebook(id); return new JsonResponse.Builder<Notebook>(Response.Status.OK).success(true) .message("Delete the notebook instance").result(notebook).build(); } catch (SubmarineRuntimeException e) { return parseNotebookServiceException(e); } } private Response parseNotebookServiceException(SubmarineRuntimeException e) { return new JsonResponse.Builder<String>(e.getCode()).message(e.getMessage()).build(); } }
3e0b392bfe028c95854f768521a9d60b40cd592b
2,253
java
Java
load-tomcat/src/main/java/tw/howie/load/config/TomcatConfiguration.java
howie/ServletContainerTest
4383f3218196e131111b7150ddb5311637e3831e
[ "Apache-2.0" ]
1
2018-08-06T10:12:03.000Z
2018-08-06T10:12:03.000Z
load-tomcat/src/main/java/tw/howie/load/config/TomcatConfiguration.java
howie/ServletContainerTest
4383f3218196e131111b7150ddb5311637e3831e
[ "Apache-2.0" ]
null
null
null
load-tomcat/src/main/java/tw/howie/load/config/TomcatConfiguration.java
howie/ServletContainerTest
4383f3218196e131111b7150ddb5311637e3831e
[ "Apache-2.0" ]
null
null
null
35.761905
100
0.766534
4,753
package tw.howie.load.config; import org.apache.catalina.core.AprLifecycleListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer; import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; import org.springframework.context.EnvironmentAware; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; /** * @author howie * @since 2015/4/15 */ @Configuration public class TomcatConfiguration implements EnvironmentAware { private final Logger log = LoggerFactory.getLogger(TomcatConfiguration.class); private RelaxedPropertyResolver propertyResolver; @Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, "tomcat."); } @Bean public EmbeddedServletContainerFactory servletContainer() { String protocol = propertyResolver.getProperty("protocol"); log.info("Tomcat Protocol:{}", protocol); TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory(); factory.setProtocol(protocol); factory.addContextLifecycleListeners(new AprLifecycleListener()); factory.setSessionTimeout(10, TimeUnit.MINUTES); List<TomcatConnectorCustomizer> cs = new ArrayList(); cs.add(tomcatConnectorCustomizers()); factory.setTomcatConnectorCustomizers(cs); return factory; } @Bean public TomcatConnectorCustomizer tomcatConnectorCustomizers() { String maxThreads = propertyResolver.getProperty("maxThreads"); String acceptCount = propertyResolver.getProperty("acceptCount"); return connector -> { connector.setAttribute("maxThreads", maxThreads); connector.setAttribute("acceptCount", acceptCount); }; } }
3e0b39f8edf08671446112711e287da50fa00201
6,813
java
Java
sched-assist-api/src/main/java/org/jasig/schedassist/model/AbstractCalendarAccount.java
nblair/bw-sometime
98dfd6cfc80cf4264d7d7350d9e4694c5b0e443d
[ "Apache-2.0" ]
1
2021-04-01T08:20:26.000Z
2021-04-01T08:20:26.000Z
sched-assist-api/src/main/java/org/jasig/schedassist/model/AbstractCalendarAccount.java
uPortal-Attic/sched-assist
e96e41a82370f6f198ba267a1e303a2c6f74d304
[ "Apache-2.0" ]
null
null
null
sched-assist-api/src/main/java/org/jasig/schedassist/model/AbstractCalendarAccount.java
uPortal-Attic/sched-assist
e96e41a82370f6f198ba267a1e303a2c6f74d304
[ "Apache-2.0" ]
1
2016-04-20T17:49:44.000Z
2016-04-20T17:49:44.000Z
25.62406
90
0.703492
4,754
/** * Licensed to Jasig under one or more contributor license * agreements. See the NOTICE file distributed with this work * for additional information regarding copyright ownership. * Jasig 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.jasig.schedassist.model; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Abstract super type for {@link ICalendarAccount}. * * @author Nicholas Blair, dycjh@example.com * @version $Id: AbstractCalendarAccount.java 1898 2010-04-14 21:07:32Z npblair $ */ public abstract class AbstractCalendarAccount implements ICalendarAccount { protected String calendarUniqueId; protected String emailAddress; protected String displayName; protected String username; protected boolean eligible; /** * */ private static final long serialVersionUID = 53706L; /* * (non-Javadoc) * @see org.jasig.schedassist.model.ICalendarAccount#getCalendarUniqueId() */ @Override public String getCalendarUniqueId() { return this.calendarUniqueId; } /* * (non-Javadoc) * @see org.jasig.schedassist.model.ICalendarAccount#getEmailAddress() */ @Override public String getEmailAddress() { return this.emailAddress; } /* * (non-Javadoc) * @see org.jasig.schedassist.model.ICalendarAccount#getDisplayName() */ @Override public String getDisplayName() { return this.displayName; } /* * (non-Javadoc) * @see org.jasig.schedassist.model.ICalendarAccount#getUsername() */ @Override public String getUsername() { return this.username; } /* * (non-Javadoc) * @see org.jasig.schedassist.model.ICalendarAccount#isEligible() */ @Override public boolean isEligible() { return this.eligible; } /** * @param calendarUniqueId the calendarUniqueId to set */ public void setCalendarUniqueId(String calendarUniqueId) { this.calendarUniqueId = calendarUniqueId; } /** * @param emailAddress the emailAddress to set */ public void setEmailAddress(String emailAddress) { this.emailAddress = emailAddress; } /** * @param displayName the name to set */ public void setDisplayName(String displayName) { this.displayName = displayName; } /** * @param username the username to set */ public void setUsername(String username) { this.username = username; } /** * @param eligible the eligible to set */ public void setEligible(boolean eligible) { this.eligible = eligible; } /* (non-Javadoc) * @see org.jasig.schedassist.model.ICalendarAccount#isDelegate() */ @Override public boolean isDelegate() { return false; } /** * * @param attributeName * @return */ protected List<String> getAttributeListSafely(String attributeName) { Map<String, List<String>> map = getAttributes(); List<String> attributes = map.get(attributeName); if(attributes == null) { attributes = new ArrayList<String>(); map.put(attributeName, attributes); } return attributes; } /** * * @param attributeValues * @return */ protected String getSingleAttributeValue(List<String> attributeValues) { if(attributeValues == null) { return null; } if(attributeValues.size() == 1) { return attributeValues.get(0); } return null; } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((calendarUniqueId == null) ? 0 : calendarUniqueId.hashCode()); result = prime * result + ((displayName == null) ? 0 : displayName.hashCode()); result = prime * result + (eligible ? 1231 : 1237); result = prime * result + ((emailAddress == null) ? 0 : emailAddress.hashCode()); result = prime * result + ((username == null) ? 0 : username.hashCode()); return result; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; AbstractCalendarAccount other = (AbstractCalendarAccount) obj; if (calendarUniqueId == null) { if (other.calendarUniqueId != null) return false; } else if (!calendarUniqueId.equals(other.calendarUniqueId)) return false; if (displayName == null) { if (other.displayName != null) return false; } else if (!displayName.equals(other.displayName)) return false; if (eligible != other.eligible) return false; if (emailAddress == null) { if (other.emailAddress != null) return false; } else if (!emailAddress.equals(other.emailAddress)) return false; if (username == null) { if (other.username != null) return false; } else if (!username.equals(other.username)) return false; return true; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("AbstractCalendarAccount [calendarUniqueId="); builder.append(calendarUniqueId); builder.append(", displayName="); builder.append(displayName); builder.append(", eligible="); builder.append(eligible); builder.append(", emailAddress="); builder.append(emailAddress); builder.append(", username="); builder.append(username); builder.append("]"); return builder.toString(); } /* * (non-Javadoc) * @see org.jasig.schedassist.model.ICalendarAccount#getAttributeValue(java.lang.String) */ @Override public final String getAttributeValue(String attributeName) { List<String> values = getAttributeListSafely(attributeName); String value = getSingleAttributeValue(values); return value; } /* * (non-Javadoc) * @see org.jasig.schedassist.model.ICalendarAccount#getAttributes() */ @Override public abstract Map<String, List<String>> getAttributes(); /* * (non-Javadoc) * @see org.jasig.schedassist.model.ICalendarAccount#getCalendarLoginId() */ @Override public abstract String getCalendarLoginId(); /* (non-Javadoc) * @see org.jasig.schedassist.model.ICalendarAccount#getAttributeValues(java.lang.String) */ @Override public final List<String> getAttributeValues(String attributeName) { List<String> values = getAttributeListSafely(attributeName); return values; } }
3e0b3a5665cf00da0bcbc409b4618ed797a335ae
1,857
java
Java
framework/src/java/org/datalift/fwk/project/WfsSource.java
tendrie/datalift
3d61e75bfc5b443bea72f22d976ca207468cfb5b
[ "CECILL-B" ]
2
2021-09-17T13:19:05.000Z
2021-12-25T14:52:41.000Z
framework/src/java/org/datalift/fwk/project/WfsSource.java
tendrie/datalift
3d61e75bfc5b443bea72f22d976ca207468cfb5b
[ "CECILL-B" ]
null
null
null
framework/src/java/org/datalift/fwk/project/WfsSource.java
tendrie/datalift
3d61e75bfc5b443bea72f22d976ca207468cfb5b
[ "CECILL-B" ]
1
2021-07-05T15:17:47.000Z
2021-07-05T15:17:47.000Z
43.302326
75
0.76101
4,755
/* * Copyright / Copr. 2010-2013 Atos - Public Sector France - * BS & Innovation for the DataLift project, * Contributor(s) : L. Bihanic, H. Devos, O. Ventura, M. Chetima * * Contact: upchh@example.com * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, * modify and/or redistribute the software under the terms of the CeCILL * license as circulated by CEA, CNRS and INRIA at the following URL * "http://www.cecill.info". * * As a counterpart to the access to the source code and rights to copy, * modify and redistribute granted by the license, users are provided only * with a limited warranty and the software's author, the holder of the * economic rights, and the successive licensors have only limited * liability. * * In this respect, the user's attention is drawn to the risks associated * with loading, using, modifying and/or developing or reproducing the * software by the user in light of its specific status of free software, * that may mean that it is complicated to manipulate, and that also * therefore means that it is reserved for developers and experienced * professionals having in-depth computer knowledge. Users are therefore * encouraged to load and test the software's suitability as regards their * requirements in conditions enabling the security of their systems and/or * data to be ensured and, more generally, to use and operate it in the * same conditions as regards security. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ package org.datalift.fwk.project; public interface WfsSource extends ServiceSource { public boolean isCompliantInspire(); public void setCompliantInspire(boolean compliant); }
3e0b3ac51f8c1e92188eec5131b30eb88883d85c
329
java
Java
src/main/java/com/tugos/dst/admin/vo/PlayerSettingVO.java
Biubush/dst-admin
753e0af96dcbf43430727b2351dbab3b03809316
[ "MIT" ]
204
2020-10-18T14:57:56.000Z
2022-03-26T11:14:31.000Z
src/main/java/com/tugos/dst/admin/vo/PlayerSettingVO.java
Biubush/dst-admin
753e0af96dcbf43430727b2351dbab3b03809316
[ "MIT" ]
33
2020-12-04T08:59:45.000Z
2022-03-27T10:05:16.000Z
src/main/java/com/tugos/dst/admin/vo/PlayerSettingVO.java
Biubush/dst-admin
753e0af96dcbf43430727b2351dbab3b03809316
[ "MIT" ]
58
2020-11-12T07:13:07.000Z
2022-03-27T10:13:49.000Z
12.653846
35
0.589666
4,756
package com.tugos.dst.admin.vo; import lombok.Data; import java.util.List; /** * @author qinming * @date 2021-07-03 12:53:37 * <p> 玩家管理页黑名单vo </p> */ @Data public class PlayerSettingVO { /** * 管理页列表 */ private List<String> adminList; /** * 黑名单列表 */ private List<String> blackList; }
3e0b3aec3df9a02195a1531f72cb4b67033f87b9
4,860
java
Java
src/rusting/entities/units/CraeUnitEntity.java
parkuristt/Endless-rusting
c58dd2ef845afd3027e24a45b1258a89bf3572ca
[ "MIT" ]
null
null
null
src/rusting/entities/units/CraeUnitEntity.java
parkuristt/Endless-rusting
c58dd2ef845afd3027e24a45b1258a89bf3572ca
[ "MIT" ]
null
null
null
src/rusting/entities/units/CraeUnitEntity.java
parkuristt/Endless-rusting
c58dd2ef845afd3027e24a45b1258a89bf3572ca
[ "MIT" ]
null
null
null
36.818182
226
0.617695
4,757
package rusting.entities.units; import arc.graphics.g2d.Draw; import arc.graphics.g2d.TextureRegion; import arc.math.Mathf; import arc.util.Time; import arc.util.io.Reads; import arc.util.io.Writes; import mindustry.content.StatusEffects; import mindustry.entities.Damage; import mindustry.game.Team; import mindustry.gen.UnitEntity; import mindustry.graphics.Layer; import mindustry.type.StatusEffect; import rusting.content.*; import static mindustry.Vars.state; public class CraeUnitEntity extends UnitEntity { private float shake = 0; public float xOffset = 0, yOffset = 0; public float alphaDraw = 0; public float pulse = 0; private Team lastTeam; public CraeUnitType unitType(){ return type instanceof CraeUnitType ? (CraeUnitType) type : null; } public void addPulse(float pulse){ this.pulse += pulse; clampPulse(); } public void clampPulse(){ pulse = Math.max(Math.min(pulse, unitType().pulseStorage), 0); } public float chargef(){ return pulse/unitType().pulseStorage; } @Override public boolean canShoot() { return !disarmed && (!(isFlying() && type.canBoost) || type.flying && isFlying()); } @Override public void apply(StatusEffect status, float time){ if(status != StatusEffects.none && status != null){ if(this.isImmune(status)) status.effect.at(x, y); else if(status.damage * 60 * 4 < unitType().health && status.speedMultiplier > 0.15f && status.reloadMultiplier > 0.15 && status.damageMultiplier > 0.15 && status.healthMultiplier > 0.55) super.apply(status, time); else if(status.permanent == true && status.damage > 0) this.heal(Math.abs(status.damage) * 60); } } @Override public void update() { super.update(); //self explanatory, since the units shoudn't be able to change teams if(lastTeam == null) lastTeam = team; if(team != lastTeam) team = lastTeam; float timeOffset = 3; if(shake >= timeOffset){ xOffset = (float) (hitSize/8 * 0.3 * Mathf.range(2)); yOffset = (float) (hitSize/8 * 0.3 * Mathf.range(2)); } else shake++; alphaDraw = Mathf.absin(Time.time/100, chargef(), 1); } @Override public void draw() { super.draw(); Draw.reset(); if(pulse > 0) { if(elevation < 0.9) Draw.z(Layer.bullet); else if(type().lowAltitude) Draw.z(Layer.flyingUnitLow + 0.1f); else Draw.z(Layer.flyingUnit + 0.1f); float rotation = this.rotation - 90; Draw.color(unitType().chargeColourStart, unitType().chargeColourEnd, chargef()); Draw.alpha(alphaDraw * unitType().overloadedOpacity); TextureRegion chargeRegion = unitType().pulseRegion; TextureRegion shakeRegion = unitType().shakeRegion; Draw.rect(shakeRegion, x + xOffset, y + yOffset, (chargeRegion.width + yOffset)/4, (chargeRegion.height + xOffset)/4, rotation); Draw.rect(chargeRegion, x, y, rotation); Draw.alpha((float) (alphaDraw * unitType().overloadedOpacity * 0.5)); Draw.rect(chargeRegion, x, y, (float) (chargeRegion.height * 1.5/4), (float) (chargeRegion.width * 1.5/4), rotation); } } @Override public void destroy() { if(!isAdded()) return; float power = chargef() * 150.0F; float explosiveness = 1F; if (!spawnedByCore) { Damage.dynamicExplosion(x, y, 0, explosiveness, power, bounds() / 2.0F, state.rules.damageExplosions, item().flammability > 1, team); int bulletSpawnInterval = type instanceof CraeUnitType ? unitType().projectileDeathSpawnInterval : 10; for(int i = 0; i < chargef() * bulletSpawnInterval; i++){ RustingBullets.craeBolt.create(this, x, y, Mathf.random(360)); RustingBullets.craeShard.create(this, team, x, y, Mathf.random(360), 0.25f * Mathf.random(1.1f), hitSize/RustingBullets.craeShard.range() * 32 * Mathf.random(1.1f)); RustingBullets.craeShard.create(this, team, x, y, Mathf.random(360), 0.25f * Mathf.random(1.4f), hitSize/RustingBullets.craeShard.range() * 32 * Mathf.random(1.4f)); } } if(pulse != 0) Fxr.pulseSmoke.at(x, y, rotation, new float[]{Math.min(chargef() * 3, 1) * hitSize * 5 + 16 + hitSize * 2, chargef() * hitSize / 2 + 3 * chargef(), 1}); super.destroy(); } @Override public void write(Writes w) { super.write(w); w.f(pulse); } @Override public void read(Reads r){ super.read(r); pulse = r.f(); clampPulse(); } @Override public int classId(){ return RustingUnits.classID(CraeUnitEntity.class); } }
3e0b3c13099bfbd4b51c3128adad40ba344d7e75
2,716
java
Java
src/g/VerifyCode.java
Nikunjbansal99/RoadPay
e02ca1b4b97aeb8b15c3cb9e9ad802101741abd6
[ "MIT" ]
1
2021-06-13T04:18:14.000Z
2021-06-13T04:18:14.000Z
src/g/VerifyCode.java
Nikunjbansal99/RoadPay
e02ca1b4b97aeb8b15c3cb9e9ad802101741abd6
[ "MIT" ]
null
null
null
src/g/VerifyCode.java
Nikunjbansal99/RoadPay
e02ca1b4b97aeb8b15c3cb9e9ad802101741abd6
[ "MIT" ]
null
null
null
35.272727
135
0.611193
4,758
package g; import java.io.IOException; import java.io.PrintWriter; import java.rmi.Naming; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @WebServlet("/VerifyCode") public class VerifyCode extends HttpServlet { public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { HttpSession session = request.getSession(); User user= (User) session.getAttribute("authcode"); String firstname = (String) session.getAttribute("firstname"); String lastname= (String) session.getAttribute("lastname"); String address = (String) session.getAttribute("address"); long phone= (Long) session.getAttribute("phone"); String email= (String) session.getAttribute("email"); long aadhar= (Long) session.getAttribute("aadhar"); String rcnum= (String) session.getAttribute("rcnum"); String password = (String) session.getAttribute("password"); String repassword = (String) session.getAttribute("repassword"); String code = request.getParameter("authcode"); if(code.equals(user.getCode())){ //Verification Done int status=RegisterUser.register( firstname, lastname, address, phone, email, aadhar, rcnum, password, repassword); if(status>0){ System.out.println("51"); RequestDispatcher rd=request.getRequestDispatcher("index.html"); rd.include(request, response); } else{ out.print("Sorry,Registration failed. please try later"); System.out.println("57"); RequestDispatcher rd=request.getRequestDispatcher("Create.html"); rd.include(request, response); } }else{ System.out.println("64"); out.println("Incorrect verification code"); } } } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } }
3e0b3c56e78d567b4adb507cfb56972aeb65d637
572
java
Java
src/main/java/com/dilaverdemirel/http/server/util/http/HeaderNamesEnumerator.java
dilaverdemirel/simple-http-server
c762ce650b48b886bc7f31b3a8440c21880283c6
[ "Apache-2.0" ]
null
null
null
src/main/java/com/dilaverdemirel/http/server/util/http/HeaderNamesEnumerator.java
dilaverdemirel/simple-http-server
c762ce650b48b886bc7f31b3a8440c21880283c6
[ "Apache-2.0" ]
null
null
null
src/main/java/com/dilaverdemirel/http/server/util/http/HeaderNamesEnumerator.java
dilaverdemirel/simple-http-server
c762ce650b48b886bc7f31b3a8440c21880283c6
[ "Apache-2.0" ]
null
null
null
27.238095
71
0.716783
4,759
package com.dilaverdemirel.http.server.util.http; import com.dilaverdemirel.http.server.operation.HeaderCollection; import java.util.ArrayList; import java.util.List; /** * @author dilaverd on 7/17/2017. */ public class HeaderNamesEnumerator extends StringCollectionEnumerator { public HeaderNamesEnumerator(HeaderCollection collection) { List<String> headerNames = new ArrayList<>(); collection.getHeaders().forEach(header ->{ headerNames.add(header.getName()); }); super.setIterator(headerNames.iterator()); } }
3e0b3f52993740fc254f1b4673215604f1563f59
5,973
java
Java
src/main/java/ibot/bot/step/steps/FollowPathStep.java
robbai/ibot
409086ac6198f580ab1c93756e5818712ea40cce
[ "MIT" ]
null
null
null
src/main/java/ibot/bot/step/steps/FollowPathStep.java
robbai/ibot
409086ac6198f580ab1c93756e5818712ea40cce
[ "MIT" ]
null
null
null
src/main/java/ibot/bot/step/steps/FollowPathStep.java
robbai/ibot
409086ac6198f580ab1c93756e5818712ea40cce
[ "MIT" ]
null
null
null
35.135294
108
0.724259
4,760
package ibot.bot.step.steps; import java.awt.Color; import java.util.OptionalDouble; import ibot.bot.input.Bundle; import ibot.bot.input.Pencil; import ibot.bot.path.Path; import ibot.bot.stack.PopStack; import ibot.bot.step.Priority; import ibot.bot.step.Step; import ibot.bot.utils.maths.MathsUtils; import ibot.bot.utils.rl.Constants; import ibot.input.Car; import ibot.input.DataPacket; import ibot.output.Controls; import ibot.output.Output; import ibot.vectors.Vector2; public class FollowPathStep extends Step { public final static double STEER_LOOKAHEAD = 0.285, SPEED_LOOKAHEAD = 0.05; private final static boolean VERBOSE_RENDER = true; private Path path; private OptionalDouble targetTime; public boolean renderPredictionToTargetTime = false; public boolean dodge = false, linearTarget = false; private final DriveStep drive; public FollowPathStep(Bundle bundle, Path path, boolean dodge, OptionalDouble targetTime){ super(bundle); this.path = path; this.dodge = dodge; this.targetTime = (!targetTime.isPresent()/** || targetTime.getAsDouble() < path.getTime() */ ? OptionalDouble.empty() : targetTime); this.drive = new DriveStep(bundle); this.drive.reverse = false; this.drive.dodge = false; this.drive.routing = false; // this.drive.ignoreRadius = true; } public FollowPathStep(Bundle bundle, Path path, OptionalDouble targetTime){ this(bundle, path, false, targetTime); } public FollowPathStep(Bundle bundle, Path path){ this(bundle, path, false, OptionalDouble.empty()); } public FollowPathStep(Bundle bundle, Path path, boolean dodge){ this(bundle, path, dodge, OptionalDouble.empty()); } public FollowPathStep(Bundle bundle, Path path, double targetTime){ this(bundle, path, false, OptionalDouble.of(targetTime)); } public FollowPathStep(Bundle bundle, Path path, boolean dodge, double targetTime){ this(bundle, path, dodge, OptionalDouble.of(targetTime)); } @Override public Output getOutput(){ DataPacket packet = this.bundle.packet; Pencil pencil = this.bundle.pencil; if(!this.targetTime.isPresent() && this.expire()) return new PopStack(); // Target and acceleration. double carS = this.path.findClosestS(packet.car.position.flatten(), false); double initialVelocity = packet.car.forwardVelocityAbs; double timeElapsed = packet.time - this.getStartTime(); double guessedTimeLeft = (this.path.getTime() - timeElapsed); double updatedTimeLeft = (this.path.getTime() * (1 - carS / this.path.getDistance())); Vector2 target = getTarget(carS, initialVelocity); double targetVelocity = this.path .getSpeed(MathsUtils.clamp((carS + initialVelocity * SPEED_LOOKAHEAD) / this.path.getDistance(), 0, 1)); // targetVelocity = Math.max(400, targetVelocity); if(updatedTimeLeft > guessedTimeLeft + 0.4) return new PopStack(); double targetAcceleration = (targetVelocity - initialVelocity) / SPEED_LOOKAHEAD; if(this.targetTime.isPresent()){ double targetTimeLeft = (this.targetTime.getAsDouble() - packet.time); if(this.linearTarget){ targetAcceleration = ((this.path.getDistance() - carS) / targetTimeLeft - initialVelocity) / SPEED_LOOKAHEAD; // Enforce! }else{ double arrivalAcceleration = ((2 * (this.path.getDistance() - carS - targetTimeLeft * initialVelocity)) / Math.pow(targetTimeLeft, 2)); targetAcceleration = Math.min(targetAcceleration, arrivalAcceleration); } } // Render. pencil.stackRenderString("Distance: " + (int)this.path.getDistance() + "uu", Color.WHITE); if(!this.targetTime.isPresent()){ pencil.stackRenderString("Est Time: " + MathsUtils.round(updatedTimeLeft) + "s (" + (guessedTimeLeft < updatedTimeLeft ? "+" : "") + MathsUtils.round(updatedTimeLeft - guessedTimeLeft) + "s)", Color.WHITE); }else{ pencil.stackRenderString("Est Time: " + MathsUtils.round(updatedTimeLeft) + "s (Want: " + MathsUtils.round(this.targetTime.getAsDouble() - packet.time) + "s)", Color.WHITE); } if(VERBOSE_RENDER){ pencil.stackRenderString("Current Vel.: " + (int)initialVelocity + "uu/s", Color.WHITE); pencil.stackRenderString("Target Vel.: " + (int)targetVelocity + "uu/s", Color.WHITE); pencil.stackRenderString("Target Acc.: " + (int)targetAcceleration + "uu/s^2", Color.WHITE); } this.path.render(pencil, Color.BLUE); pencil.renderer.drawCenteredRectangle3d(Color.CYAN, target.withZ(Constants.CAR_HEIGHT), 10, 10, true); pencil.renderer.drawCenteredRectangle3d(Color.RED, this.path.S(Math.min(this.path.getDistance(), carS + initialVelocity * SPEED_LOOKAHEAD)) .withZ(Constants.CAR_HEIGHT), 5, 5, true); // Dodge. if(this.dodge && targetAcceleration >= 0){ // Low time results in a chip shot, high time results in a low shot if(updatedTimeLeft < 0.2){ return new FastDodgeStep(this.bundle, this.path.T(1).minus(packet.car.position.flatten()).withZ(0)); } } // Handling. this.drive.target = target.withZ(0); this.drive.withTargetVelocity(packet.car.forwardVelocity + targetAcceleration * SPEED_LOOKAHEAD); return ((Controls)this.drive.getOutput()).withHandbrake(false); } private Vector2 getTarget(double carS, double initialVelocity){ return this.path .S(Math.min(this.path.getDistance() - 1, carS + Math.max(500, initialVelocity) * STEER_LOOKAHEAD)); } private boolean expire(){ Car car = this.bundle.packet.car; // if(!car.onFlatGround) // return true; double distanceError = this.path.findClosestS(car.position.flatten(), true); if(distanceError > 80) return true; double carS = this.path.findClosestS(car.position.flatten(), false); if(this.dodge){ return (carS + Math.abs(car.forwardVelocity) * STEER_LOOKAHEAD / 8) / this.path.getDistance() >= 1; } // return getTarget(carS, car.forwardVelocityAbs) == null; return carS > this.path.getDistance() - 100; } @Override public int getPriority(){ return this.dodge ? Priority.STRIKE : Priority.DRIVE; } }
3e0b3f543b0cc55d3a1f4053268cd02bd240c08e
875
java
Java
fate-serving-core/src/main/java/com/webank/ai/fate/serving/core/timer/Timer.java
ychy00001/FATE-Serving
21de6ae91cf5bd13d494017d062d23d4072ff220
[ "Apache-2.0" ]
119
2019-09-10T14:07:04.000Z
2022-03-22T08:01:41.000Z
fate-serving-core/src/main/java/com/webank/ai/fate/serving/core/timer/Timer.java
ychy00001/FATE-Serving
21de6ae91cf5bd13d494017d062d23d4072ff220
[ "Apache-2.0" ]
62
2019-10-24T06:16:39.000Z
2022-03-29T10:47:22.000Z
fate-serving-core/src/main/java/com/webank/ai/fate/serving/core/timer/Timer.java
ychy00001/FATE-Serving
21de6ae91cf5bd13d494017d062d23d4072ff220
[ "Apache-2.0" ]
76
2019-09-18T01:34:05.000Z
2022-03-22T08:01:56.000Z
30.172414
75
0.737143
4,761
/* * Copyright 2019 The FATE Authors. 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. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.webank.ai.fate.serving.core.timer; import java.util.Set; import java.util.concurrent.TimeUnit; public interface Timer { Timeout newTimeout(TimerTask task, long delay, TimeUnit unit); Set<Timeout> stop(); boolean isStop(); }
3e0b3f6519940c199a714e63971c18946828dda7
7,718
java
Java
swigwin-4.0.2/Examples/test-suite/java/cpp11_strongly_typed_enumerations_runme.java
kennydn99/tf-pose-estimation
dbbb424cbafbee8a0f70183e5d8ba16febca1c42
[ "Apache-2.0" ]
1,031
2015-01-02T14:08:47.000Z
2022-03-29T02:25:27.000Z
swigwin-4.0.2/Examples/test-suite/java/cpp11_strongly_typed_enumerations_runme.java
kennydn99/tf-pose-estimation
dbbb424cbafbee8a0f70183e5d8ba16febca1c42
[ "Apache-2.0" ]
240
2015-01-11T04:27:19.000Z
2022-03-30T00:35:57.000Z
swigwin-4.0.2/Examples/test-suite/java/cpp11_strongly_typed_enumerations_runme.java
kennydn99/tf-pose-estimation
dbbb424cbafbee8a0f70183e5d8ba16febca1c42
[ "Apache-2.0" ]
224
2015-01-05T06:13:54.000Z
2022-02-25T14:39:51.000Z
43.60452
155
0.684504
4,762
import cpp11_strongly_typed_enumerations.*; public class cpp11_strongly_typed_enumerations_runme { static { try { System.loadLibrary("cpp11_strongly_typed_enumerations"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } public static int enumCheck(int actual, int expected) { if (actual != expected) throw new RuntimeException("Enum value mismatch. Expected " + expected + " Actual: " + actual); return expected + 1; } public static void main(String argv[]) { int val = 0; val = enumCheck(Enum1.Val1.swigValue(), val); val = enumCheck(Enum1.Val2.swigValue(), val); val = enumCheck(Enum1.Val3.swigValue(), 13); val = enumCheck(Enum1.Val4.swigValue(), val); val = enumCheck(Enum1.Val5a.swigValue(), 13); val = enumCheck(Enum1.Val6a.swigValue(), val); val = 0; val = enumCheck(Enum2.Val1.swigValue(), val); val = enumCheck(Enum2.Val2.swigValue(), val); val = enumCheck(Enum2.Val3.swigValue(), 23); val = enumCheck(Enum2.Val4.swigValue(), val); val = enumCheck(Enum2.Val5b.swigValue(), 23); val = enumCheck(Enum2.Val6b.swigValue(), val); val = 0; val = enumCheck(Enum4.Val1.swigValue(), val); val = enumCheck(Enum4.Val2.swigValue(), val); val = enumCheck(Enum4.Val3.swigValue(), 43); val = enumCheck(Enum4.Val4.swigValue(), val); val = 0; val = enumCheck(Enum5.Val1.swigValue(), val); val = enumCheck(Enum5.Val2.swigValue(), val); val = enumCheck(Enum5.Val3.swigValue(), 53); val = enumCheck(Enum5.Val4.swigValue(), val); val = 0; val = enumCheck(Enum6.Val1.swigValue(), val); val = enumCheck(Enum6.Val2.swigValue(), val); val = enumCheck(Enum6.Val3.swigValue(), 63); val = enumCheck(Enum6.Val4.swigValue(), val); val = 0; val = enumCheck(Enum7td.Val1.swigValue(), val); val = enumCheck(Enum7td.Val2.swigValue(), val); val = enumCheck(Enum7td.Val3.swigValue(), 73); val = enumCheck(Enum7td.Val4.swigValue(), val); val = 0; val = enumCheck(Enum8.Val1.swigValue(), val); val = enumCheck(Enum8.Val2.swigValue(), val); val = enumCheck(Enum8.Val3.swigValue(), 83); val = enumCheck(Enum8.Val4.swigValue(), val); val = 0; val = enumCheck(Enum10.Val1.swigValue(), val); val = enumCheck(Enum10.Val2.swigValue(), val); val = enumCheck(Enum10.Val3.swigValue(), 103); val = enumCheck(Enum10.Val4.swigValue(), val); val = 0; val = enumCheck(Class1.Enum12.Val1.swigValue(), 1121); val = enumCheck(Class1.Enum12.Val2.swigValue(), 1122); val = enumCheck(Class1.Enum12.Val3.swigValue(), val); val = enumCheck(Class1.Enum12.Val4.swigValue(), val); val = enumCheck(Class1.Enum12.Val5c.swigValue(), 1121); val = enumCheck(Class1.Enum12.Val6c.swigValue(), val); val = 0; val = enumCheck(Class1.Enum13.Val1.swigValue(), 1131); val = enumCheck(Class1.Enum13.Val2.swigValue(), 1132); val = enumCheck(Class1.Enum13.Val3.swigValue(), val); val = enumCheck(Class1.Enum13.Val4.swigValue(), val); val = enumCheck(Class1.Enum13.Val5d.swigValue(), 1131); val = enumCheck(Class1.Enum13.Val6d.swigValue(), val); val = 0; val = enumCheck(Class1.Enum14.Val1.swigValue(), 1141); val = enumCheck(Class1.Enum14.Val2.swigValue(), 1142); val = enumCheck(Class1.Enum14.Val3.swigValue(), val); val = enumCheck(Class1.Enum14.Val4.swigValue(), val); val = enumCheck(Class1.Enum14.Val5e.swigValue(), 1141); val = enumCheck(Class1.Enum14.Val6e.swigValue(), val); val = 0; val = enumCheck(Class1.Struct1.Enum12.Val1.swigValue(), 3121); val = enumCheck(Class1.Struct1.Enum12.Val2.swigValue(), 3122); val = enumCheck(Class1.Struct1.Enum12.Val3.swigValue(), val); val = enumCheck(Class1.Struct1.Enum12.Val4.swigValue(), val); val = enumCheck(Class1.Struct1.Enum12.Val5f.swigValue(), 3121); val = enumCheck(Class1.Struct1.Enum12.Val6f.swigValue(), val); val = 0; val = enumCheck(Class1.Struct1.Enum13.Val1.swigValue(), 3131); val = enumCheck(Class1.Struct1.Enum13.Val2.swigValue(), 3132); val = enumCheck(Class1.Struct1.Enum13.Val3.swigValue(), val); val = enumCheck(Class1.Struct1.Enum13.Val4.swigValue(), val); val = 0; val = enumCheck(Class1.Struct1.Enum14.Val1.swigValue(), 3141); val = enumCheck(Class1.Struct1.Enum14.Val2.swigValue(), 3142); val = enumCheck(Class1.Struct1.Enum14.Val3.swigValue(), val); val = enumCheck(Class1.Struct1.Enum14.Val4.swigValue(), val); val = enumCheck(Class1.Struct1.Enum14.Val5g.swigValue(), 3141); val = enumCheck(Class1.Struct1.Enum14.Val6g.swigValue(), val); val = 0; val = enumCheck(Class2.Enum12.Val1.swigValue(), 2121); val = enumCheck(Class2.Enum12.Val2.swigValue(), 2122); val = enumCheck(Class2.Enum12.Val3.swigValue(), val); val = enumCheck(Class2.Enum12.Val4.swigValue(), val); val = enumCheck(Class2.Enum12.Val5h.swigValue(), 2121); val = enumCheck(Class2.Enum12.Val6h.swigValue(), val); val = 0; val = enumCheck(Class2.Enum13.Val1.swigValue(), 2131); val = enumCheck(Class2.Enum13.Val2.swigValue(), 2132); val = enumCheck(Class2.Enum13.Val3.swigValue(), val); val = enumCheck(Class2.Enum13.Val4.swigValue(), val); val = enumCheck(Class2.Enum13.Val5i.swigValue(), 2131); val = enumCheck(Class2.Enum13.Val6i.swigValue(), val); val = 0; val = enumCheck(Class2.Enum14.Val1.swigValue(), 2141); val = enumCheck(Class2.Enum14.Val2.swigValue(), 2142); val = enumCheck(Class2.Enum14.Val3.swigValue(), val); val = enumCheck(Class2.Enum14.Val4.swigValue(), val); val = enumCheck(Class2.Enum14.Val5j.swigValue(), 2141); val = enumCheck(Class2.Enum14.Val6j.swigValue(), val); val = 0; val = enumCheck(Class2.Struct1.Enum12.Val1.swigValue(), 4121); val = enumCheck(Class2.Struct1.Enum12.Val2.swigValue(), 4122); val = enumCheck(Class2.Struct1.Enum12.Val3.swigValue(), val); val = enumCheck(Class2.Struct1.Enum12.Val4.swigValue(), val); val = enumCheck(Class2.Struct1.Enum12.Val5k.swigValue(), 4121); val = enumCheck(Class2.Struct1.Enum12.Val6k.swigValue(), val); val = 0; val = enumCheck(Class2.Struct1.Enum13.Val1.swigValue(), 4131); val = enumCheck(Class2.Struct1.Enum13.Val2.swigValue(), 4132); val = enumCheck(Class2.Struct1.Enum13.Val3.swigValue(), val); val = enumCheck(Class2.Struct1.Enum13.Val4.swigValue(), val); val = enumCheck(Class2.Struct1.Enum13.Val5l.swigValue(), 4131); val = enumCheck(Class2.Struct1.Enum13.Val6l.swigValue(), val); val = 0; val = enumCheck(Class2.Struct1.Enum14.Val1.swigValue(), 4141); val = enumCheck(Class2.Struct1.Enum14.Val2.swigValue(), 4142); val = enumCheck(Class2.Struct1.Enum14.Val3.swigValue(), val); val = enumCheck(Class2.Struct1.Enum14.Val4.swigValue(), val); val = enumCheck(Class2.Struct1.Enum14.Val5m.swigValue(), 4141); val = enumCheck(Class2.Struct1.Enum14.Val6m.swigValue(), val); Class1 class1 = new Class1(); enumCheck(class1.class1Test1(Enum1.Val5a).swigValue(), 13); enumCheck(class1.class1Test2(Class1.Enum12.Val5c).swigValue(), 1121); enumCheck(class1.class1Test3(Class1.Struct1.Enum12.Val5f).swigValue(), 3121); enumCheck(cpp11_strongly_typed_enumerations.globalTest1(Enum1.Val5a).swigValue(), 13); enumCheck(cpp11_strongly_typed_enumerations.globalTest2(Class1.Enum12.Val5c).swigValue(), 1121); enumCheck(cpp11_strongly_typed_enumerations.globalTest3(Class1.Struct1.Enum12.Val5f).swigValue(), 3121); } }
3e0b3fd5497bf87083af228e2a7f174b8dd6122d
8,426
java
Java
ADS/geode-core/src/test/java/io/ampool/monarch/table/quickstart/MTableCheckClient.java
deepakddixit/monarch
21ac4f538fe695fd7481003084fd2f0a8982cd32
[ "Apache-2.0" ]
1
2020-12-10T03:02:16.000Z
2020-12-10T03:02:16.000Z
ADS/geode-core/src/test/java/io/ampool/monarch/table/quickstart/MTableCheckClient.java
deepakddixit/monarch
21ac4f538fe695fd7481003084fd2f0a8982cd32
[ "Apache-2.0" ]
null
null
null
ADS/geode-core/src/test/java/io/ampool/monarch/table/quickstart/MTableCheckClient.java
deepakddixit/monarch
21ac4f538fe695fd7481003084fd2f0a8982cd32
[ "Apache-2.0" ]
2
2019-08-05T18:03:29.000Z
2021-02-17T10:19:19.000Z
35.70339
100
0.653098
4,763
/* * Copyright (c) 2017 Ampool, Inc. 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. 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. See accompanying LICENSE file. */ package io.ampool.monarch.table.quickstart; import io.ampool.conf.Constants; import io.ampool.monarch.table.*; import io.ampool.monarch.table.client.MClientCache; import io.ampool.monarch.table.client.MClientCacheFactory; import java.util.Arrays; import java.util.List; /** * Sample MTable Quickstart example showing use of checkAndPut and checkAndDelete. * * @since 0.5.0.0 */ public class MTableCheckClient { public static void printRow(MTable table, int rownum, boolean shouldExist, String msg) { System.out.println("\nColumns for row " + rownum + " " + msg); Get get = new Get(Bytes.toBytes("rowKey" + rownum)); Row result = table.get(get); if (shouldExist) { List<Cell> row = result.getCells(); for (Cell cell : row) { System.out.println("ColumnName => " + Bytes.toString(cell.getColumnName()) + " AND ColumnValue => " + Bytes.toString(((byte[]) cell.getColumnValue()))); } } else { if (result == null) { System.out.println("row for key rowKey" + rownum + " does not exist"); } else { if (result.isEmpty()) { System.out.println("row for key rowKey" + rownum + " does not exist (result was empty)"); } else { System.out.println("row for key rowKey" + rownum + " exists"); } } } System.out.println("\n"); } public static void main(String args[]) { System.out.println("MTable Quickstart example for checkAndPut and checkAndDelete"); MClientCache clientCache = new MClientCacheFactory().set("log-file", "/tmp/MTableClient.log") .addPoolLocator("127.0.0.1", 10334).create(); System.out.println("Connection to monarch distributed system is successfully done!"); List<String> columnNames = Arrays.asList("NAME", "ID", "AGE", "SALARY", "DEPT", "DOJ"); MTableDescriptor tableDescriptor = new MTableDescriptor(); tableDescriptor.addColumn(Bytes.toBytes(columnNames.get(0))) .addColumn(Bytes.toBytes(columnNames.get(1))).addColumn(Bytes.toBytes(columnNames.get(2))) .addColumn(Bytes.toBytes(columnNames.get(3))).addColumn(Bytes.toBytes(columnNames.get(4))) .addColumn(Bytes.toBytes(columnNames.get(5))).setRedundantCopies(1). // setTableType(MTableType.UNORDERED). setTotalNumOfSplits(4).setMaxVersions(1); Admin admin = clientCache.getAdmin(); String tableName = "CheckTable"; try { admin.deleteTable(tableName); } catch (Exception exc) { } try { Thread.sleep(2); } catch (Exception exc) { } MTable table = admin.createTable(tableName, tableDescriptor); System.out.println("Table " + tableName + " created successfully!"); int NUM_OF_COLUMNS = 6; Put record = new Put(Bytes.toBytes("rowKey")); for (int i = 0; i < 10000; i++) { record.setRowKey(Bytes.toBytes("rowKey" + i)); for (int colIndex = 0; colIndex < NUM_OF_COLUMNS; colIndex++) { record.addColumn(Bytes.toBytes(columnNames.get(colIndex)), Bytes.toBytes("val" + i + "" + colIndex)); } table.put(record); record.clear(); } printRow(table, 5, true, "after initial row put"); // modify the row with a basic put Put put = new Put(Bytes.toBytes("rowKey" + 5)); put.addColumn(Bytes.toBytes(columnNames.get(4)), Bytes.toBytes("testput")); try { table.put(put); } catch (Exception exc) { exc.printStackTrace(); } printRow(table, 5, true, "after put to row 5 col 4"); put = new Put(Bytes.toBytes("rowKey" + 5)); put.addColumn(Bytes.toBytes(columnNames.get(4)), Bytes.toBytes("testput2")); try { table.put(put); } catch (Exception exc) { exc.printStackTrace(); } printRow(table, 5, true, "after put again to row 5 col 4"); printRow(table, 3, true, "before row 3 check operations"); // put a change that should fail (check will fail) // do checkAndPut Put cput = new Put(Bytes.toBytes("rowKey" + 3)); cput.addColumn(Bytes.toBytes(columnNames.get(4)), Bytes.toBytes("testcheckandput")); boolean result = false; try { result = table.checkAndPut(Bytes.toBytes("rowKey" + 3), Bytes.toBytes(columnNames.get(5)), Bytes.toBytes("foobar"), cput); } catch (Exception ioe) { ioe.printStackTrace(); } if (result) System.out.println("checkAndPut succeeded (--> SHOULD FAIL)"); else System.out.println("checkAndPut failed (should fail)"); printRow(table, 3, true, "after failed check and put"); // put a change that should succeed (check will pass) cput = new Put(Bytes.toBytes("rowKey" + 3)); cput.addColumn(Bytes.toBytes(columnNames.get(4)), Bytes.toBytes("testcheckandput")); try { result = table.checkAndPut(Bytes.toBytes("rowKey" + 3), Bytes.toBytes(columnNames.get(5)), Bytes.toBytes("val35"), cput); } catch (Exception ioe) { ioe.printStackTrace(); } if (result) System.out.println("checkAndPut succeeded (should succeed)"); else System.out.println("checkAndPut failed (--> SHOULD SUCCEED)"); printRow(table, 3, true, "after succeeded check and put"); // put a change where check row is same as change row cput = new Put(Bytes.toBytes("rowKey" + 3)); cput.addColumn(Bytes.toBytes(columnNames.get(3)), Bytes.toBytes("testcheckandputsame")); try { result = table.checkAndPut(Bytes.toBytes("rowKey" + 3), Bytes.toBytes(columnNames.get(3)), Bytes.toBytes("val33"), cput); } catch (Exception ioe) { ioe.printStackTrace(); } if (result) System.out.println("checkAndPut succeeded (should succeed)"); else System.out.println("checkAndPut failed (--> SHOULD SUCCEED)"); printRow(table, 3, true, "after succeeded check and put to same col"); // delete a row with a check that will fail (row not changed) Delete del = new Delete(Bytes.toBytes("rowKey" + 3)); try { result = table.checkAndDelete(Bytes.toBytes("rowKey" + 3), Bytes.toBytes(columnNames.get(3)), Bytes.toBytes("foobar"), del); } catch (Exception exc) { exc.printStackTrace(); } if (result) System.out.println("checkAndDelete succeeded (--> SHOULD FAIL)"); else System.out.println("checkAndDelete failed (should fail)"); printRow(table, 3, true, "after failed check and delete"); // delete a column (should succeed) del = new Delete(Bytes.toBytes("rowKey" + 3)); del.addColumn(Bytes.toBytes(columnNames.get(4))); try { result = table.checkAndDelete(Bytes.toBytes("rowKey" + 3), Bytes.toBytes(columnNames.get(1)), Bytes.toBytes("val31"), del); } catch (Exception exc) { exc.printStackTrace(); } if (result) System.out.println("checkAndDelete succeeded (should succeed)"); else System.out.println("checkAndDelete failed (--> SHOULD SUCCEED)"); printRow(table, 3, true, "after succeeded check and delete col 4"); // delete a row with a check that will pass (row deleted) del = new Delete(Bytes.toBytes("rowKey" + 3)); try { result = table.checkAndDelete(Bytes.toBytes("rowKey" + 3), Bytes.toBytes(columnNames.get(2)), Bytes.toBytes("val32"), del); } catch (Exception exc) { exc.printStackTrace(); } if (result) System.out.println("checkAndDelete succeeded (should succeed)"); else System.out.println("checkAndDelete failed (--> SHOULD SUCCEED)"); printRow(table, 3, false, "after succeeded check and delete entire row"); admin.deleteTable(tableName); System.out.println("Table is deleted successfully!"); clientCache.close(); System.out.println("Connection to monarch DS closed successfully!"); } }
3e0b403906dee3b070f3debbce29c93858c277d8
11,487
java
Java
zprj-Sc2gears-parsing-engine/src-sc2gearspluginapi/hu/belicza/andras/sc2gearspluginapi/api/sc2replay/IReplay.java
icza/sc2gears
7152b33798124bfaf107ea31d5ec62f01c73842b
[ "Apache-2.0" ]
32
2015-11-12T03:06:48.000Z
2022-01-24T00:43:25.000Z
zprj-Sc2gears-parsing-engine/src-sc2gearspluginapi/hu/belicza/andras/sc2gearspluginapi/api/sc2replay/IReplay.java
icza/sc2gears
7152b33798124bfaf107ea31d5ec62f01c73842b
[ "Apache-2.0" ]
null
null
null
zprj-Sc2gears-parsing-engine/src-sc2gearspluginapi/hu/belicza/andras/sc2gearspluginapi/api/sc2replay/IReplay.java
icza/sc2gears
7152b33798124bfaf107ea31d5ec62f01c73842b
[ "Apache-2.0" ]
5
2016-01-07T20:07:14.000Z
2020-12-17T13:38:44.000Z
30.876344
156
0.601515
4,764
/* * Project Sc2gears * * Copyright (c) 2010 Andras Belicza <kenaa@example.com> * * This software is the property of Andras Belicza. * Copying, modifying, distributing, refactoring without the authors permission * is prohibited and protected by Law. */ package hu.belicza.andras.sc2gearspluginapi.api.sc2replay; import hu.belicza.andras.sc2gearspluginapi.api.enums.ReplayOrigin; import hu.belicza.andras.sc2gearspluginapi.api.sc2replay.ReplayConsts.ExpansionLevel; import hu.belicza.andras.sc2gearspluginapi.api.sc2replay.ReplayConsts.Format; import hu.belicza.andras.sc2gearspluginapi.api.sc2replay.ReplayConsts.GameSpeed; import hu.belicza.andras.sc2gearspluginapi.api.sc2replay.ReplayConsts.GameType; import hu.belicza.andras.sc2gearspluginapi.api.sc2replay.ReplayConsts.Gateway; import java.io.File; import java.util.Comparator; import java.util.Date; import java.util.List; /** * An interface representing StarCraft II replays. * * <p>Example usage:<br> * <blockquote><pre> * IReplay replay = generalServices.getReplayFactoryApi().parseReplay( "C:\\someReplay.SC2Replay", EnumSet.allOf( ReplayFactoryApi.ReplayContent.class ) ); * * if ( replay == null ) * System.out.println( "Failed to parse replay!" ); * else { * System.out.println( "Players: " + replay.getPlayerNamesGrouped() ); * System.out.println( "Race match-up: " + replay.getRaceMatchup() ); * System.out.println( "Map name: " + replay.getMapName() ); * if ( replay.getMapInfo() != null ) * System.out.println( "Map size: " + replay.getMapInfo().getSizeString() ); * } * </pre></blockquote></p> * * @since "2.0" * * @version {@value #VERSION} * * @author Andras Belicza * * @see ReplayFactoryApi * @see ReplayUtilsApi */ public interface IReplay { /** Interface version. */ String VERSION = "4.2"; /** * Returns the general services implementation version. * @return the general services implementation version */ String getImplementationVersion(); /** * Returns the version of the replay, for example <code>"1.3.4.18701"</code>.<br> * This is the version of StarCraft II that saved the replay. * * @return the version of the replay */ String getReplayVersion(); /** * Returns the components of the replay version, for example <code>{1, 3, 4, 18701}</code>. * @return the components of the replay version */ int[] getBuildNumbers(); /** * Returns the length of the game in half seconds. * @return the length of the game in half seconds * @see #getGameLengthSec() * @see #getFrames() */ int getGameLength(); /** * Returns the length of the game in seconds. * @return the length of the game in seconds * @see #getGameLength() * @see #getFrames() */ int getGameLengthSec(); /** * Returns the length of the game in frames. * @return the length of the game in frames * @see #getGameLength() * @see #getGameLengthSec() */ int getFrames(); /** * Returns the excluded initial frames from the APM calculation. * @return the excluded initial frames from the APM calculation */ int getExcludedInitialFrames(); /** * Returns the game speed object that is used to calculate time values (game-time or real-time). * * <p>Initially it is set to reflect the {@link InfoApi#isRealTimeConversionEnabled()} setting.</p> * * @return the game speed object that is used to calculate time values (game-time or real-time) * * @see InfoApi#isRealTimeConversionEnabled() * @see IGameEvents#isDisplayInSeconds() */ GameSpeed getConverterGameSpeed(); /** * Returns the origin of the replay which tells where/how the replay was assembled. * @return the origin of the replay * @since "2.7" * @see ReplayOrigin */ ReplayOrigin getReplayOrigin(); // ================================================================================== // ********************************** INIT DATA *********************************** // ================================================================================== /** * Returns the client names (player names and observers). * * <p>Returns the names in the order they are recorded in the replay.</p> * * @return the client names (player names and observers) * @see #getArrangedClientNames() */ String[] getClientNames(); /** * Returns the game type. * @return the game type * @see GameType */ GameType getGameType(); /** * Returns the game speed. * @return the game speed * @see GameSpeed */ GameSpeed getGameSpeed(); /** * Returns the game format. * @return the game format * @see Format */ Format getFormat(); /** * Returns the name of the map file. * * <p>The map file name is usually the SHA-256 hash value of the map file content.</p> * * <p>The returned file name is relative to the SC2 maps folder.</p> * * @return the name of the map file * * @see InfoApi#getSc2MapsFolder() * @see #getMapFile() * @see #getMapName() * @see #getOriginalMapName() */ String getMapFileName(); /** * Returns the map file. * @return the map file * * @see #getMapFileName() * @see #getMapName() * @see #getOriginalMapName() */ File getMapFile(); /** * Returns the gateway. * @return the gateway * @see Gateway */ Gateway getGateway(); /** * Tells if the game is a competitive game (ranked or unranked game).<br> * AutoMM vs AI matches are not competitive.<br> * This info is available only from replay version 2.0. * @return if the game is a competitive game * @since "4.2" */ Boolean isCompetitive(); /** * Returns the rearranged client names. * * <p> Arranged: first names are the player names, then the client names in reversed order; * this is the order used in chat client indices and "Leave game" action indices.</p> * * @return the rearranged client names * @see #getClientNames() */ String[] getArrangedClientNames(); // ================================================================================== // *********************************** DETAILS ************************************ // ================================================================================== /** * Returns the players of the replay. * @return the players of the replay * @see IPlayer */ IPlayer[] getPlayers(); /** * Returns the name of the map. * <p>The name might be a map alias defined by the user.</p> * @return the name of the map. * @see #getOriginalMapName() * @see #getMapFileName() * @see #getMapFile() */ String getMapName(); /** * Returns the original name of the map as it is recorded in the replay. * @return the name of the map. * @see #getMapName() * @see #getMapFileName() * @see #getMapFile() */ String getOriginalMapName(); /** * Returns the save time (and date) of the replay. * @return the save time (and date) of the replay */ Date getSaveTime(); /** * Returns the time zone of the recorder of the replay in hours. * @return the time zone of the recorder of the replay in hours */ float getSaveTimeZone(); /** * Returns the expansion level. * @return the expansion level * @since "4.1" */ ExpansionLevel getExpansion(); /** * Returns the game dependencies. * @return the game dependencies * @since "4.1" */ String[] getDependencies(); /** * Returns the comma separated list of player names. * @return the comma separated list of player names */ String getPlayerNames(); /** * Returns the comma separated list of player names grouped by teams. * @return the comma separated list of player names grouped by teams */ String getPlayerNamesGrouped(); /** * Returns the comma separated list of the names of the winners. * @return the comma separated list of the names of the winners * @since "2.2" */ String getWinnerNames(); /** * Returns the race match-up, for example: "ZTvPP". * @return the race match-up */ String getRaceMatchup(); /** * Returns the league match-up, for example: "DI, PT vs PT, GO". * @return the league match-up * @since "4.2" */ String getLeagueMatchup(); /** * Returns player indices in team order. * * <p>If there is already a stored teamOrderPlayerIndices, it will be returned. Else a new array will be created and stored as follows:<br> * Lower teams are put before higher ones, and players without a team will be listed in the end.<br> * For example if player 1 and player 4 are in team 1, player 2 and player 3 are in team 2, and player 0 has no team, this returns:<br> * <code>{ 1, 4, 2, 3, 0 }</code></p> * * @return player indices in team order * @see #getTeamOrderPlayerIndices(Comparator) */ int[] getTeamOrderPlayerIndices(); /** * Returns player indices in an order defined by the <code>teamIndexComparator</code>.<br> * * <b>The teamIndexComparator might define a unique team order, but players in the same team must be next to each other!</b> * * @return player indices in an order defined by the <code>teamIndexComparator</code> * @see #getTeamOrderPlayerIndices() */ int[] getTeamOrderPlayerIndices( Comparator< int[] > teamIndexComparator ); /** * Rearranges the players based on a favored player list. * * <p>Players with lower index in the list has higher priority. Moving a player also moves his/her team.<br> * This method also sets the "teamOrderPlayerIndices" (see {@link #getTeamOrderPlayerIndices()}) * so that teams of (higher) favored players will be in the front of list.<br> * Calling this method with an empty list will not change anything. * * @param favoredPlayerList list of favored players to use when rearranging * * @see InfoApi#getFavoredPlayerList() */ void rearrangePlayers( List< String > favoredPlayerList ); // ================================================================================== // ********************************* GAME EVENTS ********************************** // ================================================================================== /** * Returns the Game events of the replay. * * <p>This will return <code>null</code> if game events are not parsed * (see {@link ReplayFactoryApi#parseReplay(String, java.util.Set)}).</p> * * @return the Game events of the replay * @see IGameEvents * @see ReplayFactoryApi#parseReplay(String, java.util.Set) */ IGameEvents getGameEvents(); // ================================================================================== // ******************************** MESSAGE EVENTS ******************************** // ================================================================================== /** * Returns the Message events of the replay. * * <p>This will return <code>null</code> if message events are not parsed * (see {@link ReplayFactoryApi#parseReplay(String, java.util.Set)}).</p> * * @return the Message events of the replay * @see IMessageEvents * @see ReplayFactoryApi#parseReplay(String, java.util.Set) */ IMessageEvents getMessageEvents(); }
3e0b40f1a34a402406e2ca12ac2a0adea7efb7fb
902
java
Java
spring-batch-core/src/test/java/org/springframework/batch/core/jsr/step/batchlet/BatchletSupport.java
rchandavaram/spring-batch
d3fa7d084b95938b1c91f11bd76b70c7f6a76ae7
[ "Apache-2.0" ]
5
2018-09-04T08:33:22.000Z
2021-12-19T07:19:30.000Z
spring-batch-core/src/test/java/org/springframework/batch/core/jsr/step/batchlet/BatchletSupport.java
AlanBinu007/spring-batch
d6419f4479157ac666159403f7ba0908d817fab6
[ "Apache-2.0" ]
2
2021-03-27T11:30:49.000Z
2021-03-27T11:31:08.000Z
spring-batch-core/src/test/java/org/springframework/batch/core/jsr/step/batchlet/BatchletSupport.java
AlanBinu007/spring-batch
d6419f4479157ac666159403f7ba0908d817fab6
[ "Apache-2.0" ]
3
2015-09-11T06:18:03.000Z
2021-07-09T10:14:00.000Z
28.1875
75
0.741685
4,765
/* * Copyright 2013 the original author or authors. * * 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 * * https://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.springframework.batch.core.jsr.step.batchlet; import javax.batch.api.Batchlet; public class BatchletSupport implements Batchlet { @Override public String process() throws Exception { return null; } @Override public void stop() throws Exception { // no-op } }
3e0b41d761662f12391f9b01ca5825159af1e6a6
1,085
java
Java
src/test/java/de/exaphex/parser/LendsecuredParserTest.java
exAphex/P2PParser
5314b74022868c73ba8e50cd521cebef660643c0
[ "BSD-3-Clause" ]
null
null
null
src/test/java/de/exaphex/parser/LendsecuredParserTest.java
exAphex/P2PParser
5314b74022868c73ba8e50cd521cebef660643c0
[ "BSD-3-Clause" ]
4
2021-12-23T22:15:57.000Z
2022-02-07T22:27:02.000Z
src/test/java/de/exaphex/parser/LendsecuredParserTest.java
exAphex/p2pconverter-parser
5314b74022868c73ba8e50cd521cebef660643c0
[ "BSD-3-Clause" ]
null
null
null
31
107
0.745622
4,766
package de.exaphex.parser; import java.io.Writer; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; import com.opencsv.CSVWriter; import org.junit.jupiter.api.Test; import de.exaphex.model.PortfolioPerformanceLine; public class LendsecuredParserTest { @Test void testLendsecuredParser() throws Exception { String fileName = "./tests/lendsecured/statement.xlsx"; String exportFileName = "./tests/lendsecured/export.csv"; List<PortfolioPerformanceLine> beans = new LendsecuredParser().parseFileFromPath(fileName); try (Writer writer = Files.newBufferedWriter(Paths.get(exportFileName)); CSVWriter csvWriter = new CSVWriter(writer, ';', CSVWriter.DEFAULT_QUOTE_CHARACTER, CSVWriter.DEFAULT_ESCAPE_CHARACTER, CSVWriter.DEFAULT_LINE_END);) { String[] headerRecord = { "Datum", "Wert", "Buchungswährung", "Typ", "Notiz" }; csvWriter.writeNext(headerRecord); for (PortfolioPerformanceLine ms : beans) { csvWriter.writeNext(new String[] { ms.getDate(), ms.getAmount(), ms.getCurrency(), ms.getType(), "" }); } } } }
3e0b4236bc27f5bd4418319cd032effe0a628345
218
java
Java
src/main/java/dependencyinjection/authentication/Authenticator.java
ccampo133/art-of-sw-testing-talk-examples
e3bc1d7bf815d1ee7e417c09ff7b0b49279d1287
[ "MIT" ]
null
null
null
src/main/java/dependencyinjection/authentication/Authenticator.java
ccampo133/art-of-sw-testing-talk-examples
e3bc1d7bf815d1ee7e417c09ff7b0b49279d1287
[ "MIT" ]
null
null
null
src/main/java/dependencyinjection/authentication/Authenticator.java
ccampo133/art-of-sw-testing-talk-examples
e3bc1d7bf815d1ee7e417c09ff7b0b49279d1287
[ "MIT" ]
null
null
null
24.222222
106
0.793578
4,767
package dependencyinjection.authentication; /** * @author Chris Campo */ public interface Authenticator { public void authenticate(final String username, final String password) throws AuthenticationException; }
3e0b42c407cd7b37f31773cf80ad97aeb68ab811
252
java
Java
src/main/java/com/contentbig/kgdatalake/graphql/generated/AddFollowerRolePayloadTueryDefinition.java
covid19angels/kgis-datalake-dgraph
66e3bfabcd24dc1bfd6b8776f563b117362dbf2d
[ "Apache-2.0" ]
null
null
null
src/main/java/com/contentbig/kgdatalake/graphql/generated/AddFollowerRolePayloadTueryDefinition.java
covid19angels/kgis-datalake-dgraph
66e3bfabcd24dc1bfd6b8776f563b117362dbf2d
[ "Apache-2.0" ]
null
null
null
src/main/java/com/contentbig/kgdatalake/graphql/generated/AddFollowerRolePayloadTueryDefinition.java
covid19angels/kgis-datalake-dgraph
66e3bfabcd24dc1bfd6b8776f563b117362dbf2d
[ "Apache-2.0" ]
null
null
null
36
78
0.849206
4,768
// Generated from graphql_java_gen gem with template TueryDefinition.java.erb package com.contentbig.kgdatalake.graphql.generated; public interface AddFollowerRolePayloadTueryDefinition { void define(AddFollowerRolePayloadTuery _queryBuilder); }
3e0b42eb3e7464e742f7679955e90097f56df9cf
267
java
Java
develop/server/project/base/src/main/java/com/home/base/constlist/generate/GRoleGroupTitleType.java
shineTeam7/tank
1d37e93474bc00ca3923be08d0742849c73f1049
[ "Apache-2.0" ]
2
2020-12-18T03:32:56.000Z
2021-01-06T11:43:11.000Z
develop/server/project/base/src/main/java/com/home/base/constlist/generate/GRoleGroupTitleType.java
shineTeam7/tank
1d37e93474bc00ca3923be08d0742849c73f1049
[ "Apache-2.0" ]
null
null
null
develop/server/project/base/src/main/java/com/home/base/constlist/generate/GRoleGroupTitleType.java
shineTeam7/tank
1d37e93474bc00ca3923be08d0742849c73f1049
[ "Apache-2.0" ]
1
2021-01-09T12:50:18.000Z
2021-01-09T12:50:18.000Z
16.6875
42
0.632959
4,769
package com.home.base.constlist.generate; /** 玩家群职位表(generated by shine) */ public class GRoleGroupTitleType { /** 群主 */ public static final int Leader=1; /** 普通成员 */ public static final int Member=2; /** 长度 */ public static int size=3; }
3e0b42ed19d08a564d7f767f18dd62187ad3608d
1,766
java
Java
huaweicloud-sdk-java-dis-iface/src/main/java/com/huaweicloud/dis/iface/transfertask/ITransferTaskService.java
StephenLi6/huaweicloud-sdk-java-dis
c193555bb15a691f0811467044efdde24c5111ea
[ "BSD-3-Clause" ]
8
2019-04-12T06:58:08.000Z
2020-12-24T13:30:37.000Z
huaweicloud-sdk-java-dis-iface/src/main/java/com/huaweicloud/dis/iface/transfertask/ITransferTaskService.java
StephenLi6/huaweicloud-sdk-java-dis
c193555bb15a691f0811467044efdde24c5111ea
[ "BSD-3-Clause" ]
14
2018-08-13T03:15:52.000Z
2022-02-15T06:31:11.000Z
huaweicloud-sdk-java-dis-iface/src/main/java/com/huaweicloud/dis/iface/transfertask/ITransferTaskService.java
StephenLi6/huaweicloud-sdk-java-dis
c193555bb15a691f0811467044efdde24c5111ea
[ "BSD-3-Clause" ]
15
2018-07-27T08:22:05.000Z
2022-02-15T06:23:22.000Z
27.59375
109
0.704417
4,770
/* * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.huaweicloud.dis.iface.transfertask; import com.huaweicloud.dis.iface.transfertask.request.*; import com.huaweicloud.dis.iface.transfertask.response.*; /** * DIS服务管理面转储任务的相关接口 */ public interface ITransferTaskService { /** * <p> * 创建转储任务。 * </p> */ CreateTransferTaskResult createTransferTask(CreateTransferTaskRequest createTransferTaskRequest); /** * <p> * 更新转储任务。 * </p> */ UpdateTransferTaskResult updateTransferTask(UpdateTransferTaskRequest updateTransferTaskRequest); /** * <p> * 删除转储任务。 * </p> */ DeleteTransferTaskResult deleteTransferTask(DeleteTransferTaskRequest deleteTransferTaskRequest); /** * <p> * 查询转储任务清单。 * </p> */ ListTransferTasksResult listTransferTasks(ListTransferTasksRquest listTransferTasksRquest); /** * <p> * 查询指定转储任务的详情。 * </p> */ DescribeTransferTaskResult describeTransferTask(DescribeTransferTaskRequest describeTransferTaskRequest); BatchTransferTaskResult batchTransferTask(BatchTransferTaskRequest batchTransferTaskRequest); }
3e0b439a60df1af720a09fcb73371e5388753fec
22,955
java
Java
android/upstream/gov/nist/javax/sip/EventScanner.java
gordonjohnpatrick/XobotOS
888ed3b8cc8d8e0a54b1858bfa5a3572545f4d2f
[ "Apache-2.0" ]
263
2015-01-04T16:39:18.000Z
2022-01-05T17:52:38.000Z
android/upstream/gov/nist/javax/sip/EventScanner.java
mcanthony/XobotOS
f20db6295e878a2f298c5e3896528e240785805b
[ "Apache-2.0" ]
3
2015-09-06T09:06:39.000Z
2019-10-15T00:52:49.000Z
android/upstream/gov/nist/javax/sip/EventScanner.java
mcanthony/XobotOS
f20db6295e878a2f298c5e3896528e240785805b
[ "Apache-2.0" ]
105
2015-01-11T11:45:12.000Z
2022-02-22T07:26:36.000Z
43.311321
122
0.492355
4,771
/* * Conditions Of Use * * This software was developed by employees of the National Institute of * Standards and Technology (NIST), an agency of the Federal Government. * Pursuant to title 15 Untied States Code Section 105, works of NIST * employees are not subject to copyright protection in the United States * and are considered to be in the public domain. As a result, a formal * license is not needed to use the software. * * This software is provided by NIST as a service and is expressly * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT * AND DATA ACCURACY. NIST does not warrant or make any representations * regarding the use of the software or the results thereof, including but * not limited to the correctness, accuracy, reliability or usefulness of * the software. * * Permission to use this software is contingent upon your acceptance * of the terms of this agreement * * . * */ package gov.nist.javax.sip; import java.util.*; import gov.nist.javax.sip.stack.*; import gov.nist.javax.sip.message.*; import javax.sip.message.*; import javax.sip.*; import gov.nist.core.ThreadAuditor; /* bug fixes SIPQuest communications and Shu-Lin Chen. */ /** * Event Scanner to deliver events to the Listener. * * @version 1.2 $Revision: 1.41 $ $Date: 2009/11/18 02:35:17 $ * * @author M. Ranganathan <br/> * * */ class EventScanner implements Runnable { private boolean isStopped; private int refCount; // SIPquest: Fix for deadlocks private LinkedList pendingEvents = new LinkedList(); private int[] eventMutex = { 0 }; private SipStackImpl sipStack; public void incrementRefcount() { synchronized (eventMutex) { this.refCount++; } } public EventScanner(SipStackImpl sipStackImpl) { this.pendingEvents = new LinkedList(); Thread myThread = new Thread(this); // This needs to be set to false else the // main thread mysteriously exits. myThread.setDaemon(false); this.sipStack = sipStackImpl; myThread.setName("EventScannerThread"); myThread.start(); } public void addEvent(EventWrapper eventWrapper) { if (sipStack.isLoggingEnabled()) sipStack.getStackLogger().logDebug("addEvent " + eventWrapper); synchronized (this.eventMutex) { pendingEvents.add(eventWrapper); // Add the event into the pending events list eventMutex.notify(); } } /** * Stop the event scanner. Decrement the reference count and exit the * scanner thread if the ref count goes to 0. */ public void stop() { synchronized (eventMutex) { if (this.refCount > 0) this.refCount--; if (this.refCount == 0) { isStopped = true; eventMutex.notify(); } } } /** * Brutally stop the event scanner. This does not wait for the refcount to * go to 0. * */ public void forceStop() { synchronized (this.eventMutex) { this.isStopped = true; this.refCount = 0; this.eventMutex.notify(); } } public void deliverEvent(EventWrapper eventWrapper) { EventObject sipEvent = eventWrapper.sipEvent; if (sipStack.isLoggingEnabled()) sipStack.getStackLogger().logDebug( "sipEvent = " + sipEvent + "source = " + sipEvent.getSource()); SipListener sipListener = null; if (!(sipEvent instanceof IOExceptionEvent)) { sipListener = ((SipProviderImpl) sipEvent.getSource()).getSipListener(); } else { sipListener = sipStack.getSipListener(); } if (sipEvent instanceof RequestEvent) { try { // Check if this request has already created a // transaction SIPRequest sipRequest = (SIPRequest) ((RequestEvent) sipEvent) .getRequest(); if (sipStack.isLoggingEnabled()) { sipStack.getStackLogger().logDebug( "deliverEvent : " + sipRequest.getFirstLine() + " transaction " + eventWrapper.transaction + " sipEvent.serverTx = " + ((RequestEvent) sipEvent) .getServerTransaction()); } // Discard the duplicate request if a // transaction already exists. If the listener chose // to handle the request statelessly, then the listener // will see the retransmission. // Note that in both of these two cases, JAIN SIP will allow // you to handle the request statefully or statelessly. // An example of the latter case is REGISTER and an example // of the former case is INVITE. SIPServerTransaction tx = (SIPServerTransaction) sipStack .findTransaction(sipRequest, true); if (tx != null && !tx.passToListener()) { // JvB: make an exception for a very rare case: some // (broken) UACs use // the same branch parameter for an ACK. Such an ACK should // be passed // to the listener (tx == INVITE ST, terminated upon sending // 2xx but // lingering to catch retransmitted INVITEs) if (sipRequest.getMethod().equals(Request.ACK) && tx.isInviteTransaction() && ( tx.getLastResponse().getStatusCode()/100 == 2 || sipStack.isNon2XXAckPassedToListener())) { if (sipStack.isLoggingEnabled()) sipStack .getStackLogger() .logDebug( "Detected broken client sending ACK with same branch! Passing..."); } else { if (sipStack.isLoggingEnabled()) sipStack.getStackLogger().logDebug( "transaction already exists! " + tx); return; } } else if (sipStack.findPendingTransaction(sipRequest) != null) { if (sipStack.isLoggingEnabled()) sipStack.getStackLogger().logDebug( "transaction already exists!!"); return; } else { // Put it in the pending list so that if a repeat // request comes along it will not get assigned a // new transaction SIPServerTransaction st = (SIPServerTransaction) eventWrapper.transaction; sipStack.putPendingTransaction(st); } // Set up a pointer to the transaction. sipRequest.setTransaction(eventWrapper.transaction); // Change made by SIPquest try { if (sipStack.isLoggingEnabled()) { sipStack.getStackLogger() .logDebug( "Calling listener " + sipRequest.getFirstLine()); sipStack.getStackLogger().logDebug( "Calling listener " + eventWrapper.transaction); } if (sipListener != null) sipListener.processRequest((RequestEvent) sipEvent); if (sipStack.isLoggingEnabled()) { sipStack.getStackLogger().logDebug( "Done processing Message " + sipRequest.getFirstLine()); } if (eventWrapper.transaction != null) { SIPDialog dialog = (SIPDialog) eventWrapper.transaction .getDialog(); if (dialog != null) dialog.requestConsumed(); } } catch (Exception ex) { // We cannot let this thread die under any // circumstances. Protect ourselves by logging // errors to the console but continue. sipStack.getStackLogger().logException(ex); } } finally { if (sipStack.isLoggingEnabled()) { sipStack.getStackLogger().logDebug( "Done processing Message " + ((SIPRequest) (((RequestEvent) sipEvent) .getRequest())).getFirstLine()); } if (eventWrapper.transaction != null && ((SIPServerTransaction) eventWrapper.transaction) .passToListener()) { ((SIPServerTransaction) eventWrapper.transaction) .releaseSem(); } if (eventWrapper.transaction != null) sipStack .removePendingTransaction((SIPServerTransaction) eventWrapper.transaction); if (eventWrapper.transaction.getOriginalRequest().getMethod() .equals(Request.ACK)) { // Set the tx state to terminated so it is removed from the // stack // if the user configured to get notification on ACK // termination eventWrapper.transaction .setState(TransactionState.TERMINATED); } } } else if (sipEvent instanceof ResponseEvent) { try { ResponseEvent responseEvent = (ResponseEvent) sipEvent; SIPResponse sipResponse = (SIPResponse) responseEvent .getResponse(); SIPDialog sipDialog = ((SIPDialog) responseEvent.getDialog()); try { if (sipStack.isLoggingEnabled()) { sipStack.getStackLogger().logDebug( "Calling listener for " + sipResponse.getFirstLine()); } if (sipListener != null) { SIPTransaction tx = eventWrapper.transaction; if (tx != null) { tx.setPassToListener(); } sipListener.processResponse((ResponseEvent) sipEvent); } /* * If the response for a request within a dialog is a 481 * (Call/Transaction Does Not Exist) or a 408 (Request * Timeout), the UAC SHOULD terminate the dialog. */ if ((sipDialog != null && (sipDialog.getState() == null || !sipDialog .getState().equals(DialogState.TERMINATED))) && (sipResponse.getStatusCode() == Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST || sipResponse .getStatusCode() == Response.REQUEST_TIMEOUT)) { if (sipStack.isLoggingEnabled()) { sipStack.getStackLogger().logDebug( "Removing dialog on 408 or 481 response"); } sipDialog.doDeferredDelete(); } /* * The Client tx disappears after the first 2xx response * However, additional 2xx responses may arrive later for * example in the following scenario: * * Multiple 2xx responses may arrive at the UAC for a single * INVITE request due to a forking proxy. Each response is * distinguished by the tag parameter in the To header * field, and each represents a distinct dialog, with a * distinct dialog identifier. * * If the Listener does not ACK the 200 then we assume he * does not care about the dialog and gc the dialog after * some time. However, this is really an application bug. * This garbage collects unacknowledged dialogs. * */ if (sipResponse.getCSeq().getMethod() .equals(Request.INVITE) && sipDialog != null && sipResponse.getStatusCode() == 200) { if (sipStack.isLoggingEnabled()) { sipStack.getStackLogger().logDebug( "Warning! unacknowledged dialog. " + sipDialog.getState()); } /* * If we dont see an ACK in 32 seconds, we want to tear down the dialog. */ sipDialog.doDeferredDeleteIfNoAckSent(sipResponse.getCSeq().getSeqNumber()); } } catch (Exception ex) { // We cannot let this thread die under any // circumstances. Protect ourselves by logging // errors to the console but continue. sipStack.getStackLogger().logException(ex); } // The original request is not needed except for INVITE // transactions -- null the pointers to the transactions so // that state may be released. SIPClientTransaction ct = (SIPClientTransaction) eventWrapper.transaction; if (ct != null && TransactionState.COMPLETED == ct.getState() && ct.getOriginalRequest() != null && !ct.getOriginalRequest().getMethod().equals( Request.INVITE)) { // reduce the state to minimum // This assumes that the application will not need // to access the request once the transaction is // completed. ct.clearState(); } // mark no longer in the event queue. } finally { if (eventWrapper.transaction != null && eventWrapper.transaction.passToListener()) { eventWrapper.transaction.releaseSem(); } } } else if (sipEvent instanceof TimeoutEvent) { // Change made by SIPquest try { // Check for null as listener could be removed. if (sipListener != null) sipListener.processTimeout((TimeoutEvent) sipEvent); } catch (Exception ex) { // We cannot let this thread die under any // circumstances. Protect ourselves by logging // errors to the console but continue. sipStack.getStackLogger().logException(ex); } } else if (sipEvent instanceof DialogTimeoutEvent) { try { // Check for null as listener could be removed. if (sipListener != null && sipListener instanceof SipListenerExt) { ((SipListenerExt)sipListener).processDialogTimeout((DialogTimeoutEvent) sipEvent); } } catch (Exception ex) { // We cannot let this thread die under any // circumstances. Protect ourselves by logging // errors to the console but continue. sipStack.getStackLogger().logException(ex); } } else if (sipEvent instanceof IOExceptionEvent) { try { if (sipListener != null) sipListener.processIOException((IOExceptionEvent) sipEvent); } catch (Exception ex) { sipStack.getStackLogger().logException(ex); } } else if (sipEvent instanceof TransactionTerminatedEvent) { try { if (sipStack.isLoggingEnabled()) { sipStack.getStackLogger().logDebug( "About to deliver transactionTerminatedEvent"); sipStack.getStackLogger().logDebug( "tx = " + ((TransactionTerminatedEvent) sipEvent) .getClientTransaction()); sipStack.getStackLogger().logDebug( "tx = " + ((TransactionTerminatedEvent) sipEvent) .getServerTransaction()); } if (sipListener != null) sipListener .processTransactionTerminated((TransactionTerminatedEvent) sipEvent); } catch (AbstractMethodError ame) { // JvB: for backwards compatibility, accept this if (sipStack.isLoggingEnabled()) sipStack .getStackLogger() .logWarning( "Unable to call sipListener.processTransactionTerminated"); } catch (Exception ex) { sipStack.getStackLogger().logException(ex); } } else if (sipEvent instanceof DialogTerminatedEvent) { try { if (sipListener != null) sipListener .processDialogTerminated((DialogTerminatedEvent) sipEvent); } catch (AbstractMethodError ame) { // JvB: for backwards compatibility, accept this if (sipStack.isLoggingEnabled()) sipStack.getStackLogger().logWarning( "Unable to call sipListener.processDialogTerminated"); } catch (Exception ex) { sipStack.getStackLogger().logException(ex); } } else { sipStack.getStackLogger().logFatalError("bad event" + sipEvent); } } /** * For the non-re-entrant listener this delivers the events to the listener * from a single queue. If the listener is re-entrant, then the stack just * calls the deliverEvent method above. */ public void run() { try { // Ask the auditor to monitor this thread ThreadAuditor.ThreadHandle threadHandle = sipStack.getThreadAuditor().addCurrentThread(); while (true) { EventWrapper eventWrapper = null; LinkedList eventsToDeliver; synchronized (this.eventMutex) { // First, wait for some events to become available. while (pendingEvents.isEmpty()) { // There's nothing in the list, check to make sure we // haven't // been stopped. If we have, then let the thread die. if (this.isStopped) { if (sipStack.isLoggingEnabled()) sipStack.getStackLogger().logDebug( "Stopped event scanner!!"); return; } // We haven't been stopped, and the event list is indeed // rather empty. Wait for some events to come along. try { // Send a heartbeat to the thread auditor threadHandle.ping(); // Wait for events (with a timeout) eventMutex.wait(threadHandle.getPingIntervalInMillisecs()); } catch (InterruptedException ex) { // Let the thread die a normal death if (sipStack.isLoggingEnabled()) sipStack.getStackLogger().logDebug("Interrupted!"); return; } } // There are events in the 'pending events list' that need // processing. Hold onto the old 'pending Events' list, but // make a new one for the other methods to operate on. This // tap-dancing is to avoid deadlocks and also to ensure that // the list is not modified while we are iterating over it. eventsToDeliver = pendingEvents; pendingEvents = new LinkedList(); } ListIterator iterator = eventsToDeliver.listIterator(); while (iterator.hasNext()) { eventWrapper = (EventWrapper) iterator.next(); if (sipStack.isLoggingEnabled()) { sipStack.getStackLogger().logDebug( "Processing " + eventWrapper + "nevents " + eventsToDeliver.size()); } try { deliverEvent(eventWrapper); } catch (Exception e) { if (sipStack.isLoggingEnabled()) { sipStack.getStackLogger().logError( "Unexpected exception caught while delivering event -- carrying on bravely", e); } } } } // end While } finally { if (sipStack.isLoggingEnabled()) { if (!this.isStopped) { sipStack.getStackLogger().logFatalError("Event scanner exited abnormally"); } } } } }
3e0b43b0097f5e10106d19fae09989ff817eb3f6
3,701
java
Java
protege-editor-owl/src/main/java/org/protege/editor/owl/ui/ontology/OntologyIDJDialog.java
Rena-Yang-cell/protege
093b336088e323afea9108eb7361dbcf4d8384c0
[ "BSD-2-Clause" ]
746
2015-01-09T14:51:00.000Z
2022-03-30T06:33:55.000Z
protege-editor-owl/src/main/java/org/protege/editor/owl/ui/ontology/OntologyIDJDialog.java
Rena-Yang-cell/protege
093b336088e323afea9108eb7361dbcf4d8384c0
[ "BSD-2-Clause" ]
941
2015-01-06T16:02:28.000Z
2022-03-28T09:58:34.000Z
protege-editor-owl/src/main/java/org/protege/editor/owl/ui/ontology/OntologyIDJDialog.java
Rena-Yang-cell/protege
093b336088e323afea9108eb7361dbcf4d8384c0
[ "BSD-2-Clause" ]
213
2015-01-10T17:56:43.000Z
2022-03-23T15:03:06.000Z
36.019417
128
0.657682
4,772
package org.protege.editor.owl.ui.ontology; import com.google.common.base.Optional; import org.protege.editor.owl.OWLEditorKit; import org.semanticweb.owlapi.model.IRI; import org.semanticweb.owlapi.model.OWLOntologyID; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.URI; import java.net.URISyntaxException; /** * Author: Matthew Horridge<br> * The University Of Manchester<br> * Medical Informatics Group<br> * Date: 12-May-2006<br><br> * efpyi@example.com.uk<br> * www.cs.man.ac.uk/~horridgm<br><br> */ public class OntologyIDJDialog extends JPanel { private static final long serialVersionUID = -3786605367035342914L; private JTextField ontologyIRIField; private JCheckBox enableVersionCheckBox; private JTextField versionIRIField; public static OWLOntologyID showDialog(OWLEditorKit editorKit, OWLOntologyID id) { OntologyIDJDialog dialog = new OntologyIDJDialog(id); int response = JOptionPane.showConfirmDialog(SwingUtilities.getAncestorOfClass(JFrame.class, editorKit.getOWLWorkspace()), dialog, "Refactor Ontology Name", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); return response == JOptionPane.OK_OPTION ? dialog.getOntologyID() : null; } public OntologyIDJDialog(OWLOntologyID id) { createUI(id); } public void createUI(OWLOntologyID id) { ontologyIRIField = new JTextField(OntologyPreferences.getInstance().generateURI().toString()); if (!id.isAnonymous()) { ontologyIRIField.setText(id.getOntologyIRI().get().toString()); } enableVersionCheckBox = new JCheckBox("Enable Version Iri"); enableVersionCheckBox.setEnabled(true); enableVersionCheckBox.setSelected(!id.isAnonymous() && id.getVersionIRI().isPresent()); enableVersionCheckBox.addActionListener(e -> { versionIRIField.setEnabled(enableVersionCheckBox.isSelected()); if (versionIRIField.isEnabled()) { versionIRIField.setText(ontologyIRIField.getText()); } }); versionIRIField = new JTextField(); if (!id.isAnonymous() && id.getVersionIRI().isPresent()) { versionIRIField.setText(id.getVersionIRI().get().toString()); } else if (id.getOntologyIRI().isPresent()){ versionIRIField.setText(id.getOntologyIRI().get().toString()); } versionIRIField.setEnabled(!id.isAnonymous() && id.getVersionIRI().isPresent()); Box holderPanel = new Box(BoxLayout.PAGE_AXIS); holderPanel.add(new JLabel("Ontology IRI")); holderPanel.add(ontologyIRIField); holderPanel.add(Box.createVerticalStrut(12)); holderPanel.add(new JLabel("Version IRI")); holderPanel.add(versionIRIField); holderPanel.add(enableVersionCheckBox); add(holderPanel); } public OWLOntologyID getOntologyID() { try { URI ontologyURI = new URI(ontologyIRIField.getText()); IRI ontologyIRI = IRI.create(ontologyURI); if (enableVersionCheckBox.isSelected()) { URI versionURI = new URI(versionIRIField.getText()); IRI versionIRI = IRI.create(versionURI); return new OWLOntologyID(Optional.of(ontologyIRI), Optional.of(versionIRI)); } else { return new OWLOntologyID(Optional.of(ontologyIRI), Optional.<IRI>absent()); } } catch (URISyntaxException e) { return null; } } }
3e0b43e50acc3d6ca4ca31395d18532d5fb3ca54
1,544
java
Java
springboot/springboot-jsp/public/src/main/java/com/lx/demo/config/ViewResolverConfiguration.java
offline7LY/demo
c6b8f21a305a5e5f21730549eff3056026acba69
[ "Apache-2.0" ]
null
null
null
springboot/springboot-jsp/public/src/main/java/com/lx/demo/config/ViewResolverConfiguration.java
offline7LY/demo
c6b8f21a305a5e5f21730549eff3056026acba69
[ "Apache-2.0" ]
null
null
null
springboot/springboot-jsp/public/src/main/java/com/lx/demo/config/ViewResolverConfiguration.java
offline7LY/demo
c6b8f21a305a5e5f21730549eff3056026acba69
[ "Apache-2.0" ]
null
null
null
32.166667
87
0.687824
4,773
package com.lx.demo.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.view.InternalResourceViewResolver; /** * 主要配置多视图实现的视图解析器相关bean实例 * <p> * https://www.it399.com/ * <p> * 其实关键点在于两个: * 1、配置order属性 * 2、配置viewnames属性 * <p> * 注意: * return new ModelAndView("jsps/index");//或者return "jsps/index" * 对应 /WEB-INF/jsps/index.jsp * ========================== * 同理: * return "thymeleaf/index";//或者return “thymeleaf/index” * 对应 /WEB-INF/thymeleaf/index.html */ @Configuration public class ViewResolverConfiguration { @Configuration//用来定义 DispatcherServlet 应用上下文中的 bean @EnableWebMvc @ComponentScan("com.csy.spring") public class WebConfig implements WebMvcConfigurer { @Bean public ViewResolver viewResolver() { InternalResourceViewResolver resolver = new InternalResourceViewResolver(); // resolver.setPrefix("/WEB-INF/"); // resolver.setSuffix(".jsp"); // resolver.setViewNames("jsps/*"); resolver.setPrefix("/"); resolver.setSuffix(".jsp"); resolver.setViewNames("*"); resolver.setOrder(2); return resolver; } } }
3e0b44a54beae3e1a2c4e6d6463676d27e7c82b8
688
java
Java
commons/src/main/java/org/fisher/weixin/inmessage/OutMessage.java
fisher002/wx_zjy
179d20fff73cd6663ea47d38282f2a2505be48e8
[ "Apache-2.0" ]
null
null
null
commons/src/main/java/org/fisher/weixin/inmessage/OutMessage.java
fisher002/wx_zjy
179d20fff73cd6663ea47d38282f2a2505be48e8
[ "Apache-2.0" ]
null
null
null
commons/src/main/java/org/fisher/weixin/inmessage/OutMessage.java
fisher002/wx_zjy
179d20fff73cd6663ea47d38282f2a2505be48e8
[ "Apache-2.0" ]
null
null
null
19.111111
56
0.707849
4,774
package org.fisher.weixin.inmessage; import com.fasterxml.jackson.annotation.JsonProperty; //通过客服接口,主动发送给微信用户的消息 public abstract class OutMessage { @JsonProperty("touser") private String toUser; @JsonProperty("msgtype") private String messageType; public OutMessage(String toUser, String messageType) { super(); this.toUser = toUser; this.messageType = messageType; } public String getToUser() { return toUser; } public void setToUser(String toUser) { this.toUser = toUser; } public String getMessageType() { return messageType; } public void setMessageType(String messageType) { this.messageType = messageType; } }
3e0b45649deb76025050669308be851c4a55a998
179
java
Java
AbstractDataTypes/StackException.java
perihill/Algorithms-And-Data-Structures
0077206fc758fdf1803a28cb86c5ab8769ccb881
[ "MIT" ]
null
null
null
AbstractDataTypes/StackException.java
perihill/Algorithms-And-Data-Structures
0077206fc758fdf1803a28cb86c5ab8769ccb881
[ "MIT" ]
null
null
null
AbstractDataTypes/StackException.java
perihill/Algorithms-And-Data-Structures
0077206fc758fdf1803a28cb86c5ab8769ccb881
[ "MIT" ]
null
null
null
17.9
64
0.670391
4,775
public class StackException extends java.lang.RuntimeException { public StackException(String s) { super(s); } // end constructor } // end StackException
3e0b4625d7236352598f0997440934ba9fa21ee3
3,716
java
Java
common/mekanism/common/BinRecipe.java
Vexatos/Mekanism
0b861f71af167ee813f8602125f4ec4af128ee3c
[ "Unlicense", "MIT" ]
null
null
null
common/mekanism/common/BinRecipe.java
Vexatos/Mekanism
0b861f71af167ee813f8602125f4ec4af128ee3c
[ "Unlicense", "MIT" ]
null
null
null
common/mekanism/common/BinRecipe.java
Vexatos/Mekanism
0b861f71af167ee813f8602125f4ec4af128ee3c
[ "Unlicense", "MIT" ]
null
null
null
21.113636
104
0.655813
4,776
package mekanism.common; import mekanism.common.inventory.InventoryBin; import mekanism.common.item.ItemBlockBasic; import mekanism.common.item.ItemProxy; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; import cpw.mods.fml.common.ICraftingHandler; import cpw.mods.fml.common.registry.GameRegistry; public class BinRecipe implements IRecipe, ICraftingHandler { public BinRecipe() { GameRegistry.registerCraftingHandler(this); } @Override public boolean matches(InventoryCrafting inv, World world) { return getCraftingResult(inv) != null; } private boolean isBin(ItemStack itemStack) { if(itemStack == null) { return false; } return itemStack.getItem() instanceof ItemBlockBasic && itemStack.getItemDamage() == 6; } @Override public ItemStack getCraftingResult(InventoryCrafting inv) { return getResult(inv); } public ItemStack getResult(IInventory inv) { ItemStack bin = null; for(int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); if(isBin(stack)) { if(bin != null) { return null; } bin = stack.copy(); } } if(bin == null) { return null; } ItemStack addStack = null; for(int i = 0; i < 9; i++) { ItemStack stack = inv.getStackInSlot(i); if(stack != null && !isBin(stack)) { if(addStack != null) { return null; } addStack = stack.copy(); } } InventoryBin binInv = new InventoryBin(bin); if(addStack != null) { if(binInv.getItemType() != null && !binInv.getItemType().isItemEqual(addStack)) { return null; } binInv.add(addStack); return bin; } else { return binInv.removeStack(); } } @Override public int getRecipeSize() { return 0; } @Override public ItemStack getRecipeOutput() { return null; } @Override public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) { if(getResult(craftMatrix) != null) { if(!isBin(item)) { for(int i = 0; i < craftMatrix.getSizeInventory(); i++) { if(isBin(craftMatrix.getStackInSlot(i))) { ItemStack bin = craftMatrix.getStackInSlot(i); InventoryBin inv = new InventoryBin(bin.copy()); int size = inv.getItemCount(); ItemStack testRemove = inv.removeStack(); bin.stackTagCompound.setInteger("newCount", size-(testRemove != null ? testRemove.stackSize : 0)); } } } else { int bin = -1; int other = -1; for(int i = 0; i < craftMatrix.getSizeInventory(); i++) { if(isBin(craftMatrix.getStackInSlot(i))) { bin = i; } else if(!isBin(craftMatrix.getStackInSlot(i)) && craftMatrix.getStackInSlot(i) != null) { other = i; } } ItemStack binStack = craftMatrix.getStackInSlot(bin); ItemStack otherStack = craftMatrix.getStackInSlot(other); ItemStack testRemain = new InventoryBin(binStack.copy()).add(otherStack.copy()); if(testRemain != null && testRemain.stackSize > 0) { ItemStack proxy = new ItemStack(Mekanism.ItemProxy); ((ItemProxy)proxy.getItem()).setSavedItem(proxy, testRemain.copy()); craftMatrix.setInventorySlotContents(other, proxy); } else { craftMatrix.setInventorySlotContents(other, null); } craftMatrix.setInventorySlotContents(bin, null); } } } @Override public void onSmelting(EntityPlayer player, ItemStack item) {} }
3e0b462b8a803a0b7f22841610e34f61a3a14000
1,557
java
Java
bundles/org.eclipse.e4.ui.progress/src/org/eclipse/e4/ui/progress/IJobRunnable.java
termsuite/termsuite-ui
6a220b72b50b957521126805d06642325d974037
[ "Apache-2.0" ]
1
2016-10-06T12:28:09.000Z
2016-10-06T12:28:09.000Z
bundles/org.eclipse.e4.ui.progress/src/org/eclipse/e4/ui/progress/IJobRunnable.java
termsuite/termsuite-ui
6a220b72b50b957521126805d06642325d974037
[ "Apache-2.0" ]
9
2016-06-02T13:25:17.000Z
2017-08-31T14:57:57.000Z
bundles/org.eclipse.e4.ui.progress/src/org/eclipse/e4/ui/progress/IJobRunnable.java
termsuite/termsuite-ui
6a220b72b50b957521126805d06642325d974037
[ "Apache-2.0" ]
null
null
null
36.209302
80
0.647399
4,777
/******************************************************************************* * Copyright (c) 2006, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation ******************************************************************************/ package org.eclipse.e4.ui.progress; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; /** * Interface for runnables that can be run as jobs. * * @since 3.3 */ public interface IJobRunnable { /** * Executes this runnable. Returns the result of the execution. * <p> * The provided monitor can be used to report progress and respond to * cancellation. If the progress monitor has been canceled, the runnable should * finish its execution at the earliest convenience and return a result * status of severity <code>IStatus.CANCEL</code>. The singleton cancel * status <code>Status.CANCEL_STATUS</code> can be used for this purpose. * <p> * * @param monitor * the monitor to be used for reporting progress and responding * to cancelation. The monitor is never <code>null</code> * @return resulting status of the run. The result must not be * <code>null</code> */ public IStatus run(IProgressMonitor monitor); }
3e0b46702d224e8ab5c3f6089fc99fefc8791154
418
java
Java
src/main/java/com/lyncode/reflection/util/Optionals.java
lyncode/reflection-invoke
4a6b141f661ecd2fb4d8b42e51d615af3e562da8
[ "Apache-2.0" ]
null
null
null
src/main/java/com/lyncode/reflection/util/Optionals.java
lyncode/reflection-invoke
4a6b141f661ecd2fb4d8b42e51d615af3e562da8
[ "Apache-2.0" ]
null
null
null
src/main/java/com/lyncode/reflection/util/Optionals.java
lyncode/reflection-invoke
4a6b141f661ecd2fb4d8b42e51d615af3e562da8
[ "Apache-2.0" ]
null
null
null
22
106
0.633971
4,778
package com.lyncode.reflection.util; import com.google.common.base.Optional; import com.google.common.base.Supplier; public final class Optionals { private Optionals () {} public static <T> Optional<T> orOptionalSupplier (Optional<T> input, Supplier<Optional<T>> supplier) { if (!input.isPresent()) { return supplier.get(); } else { return input; } } }
3e0b47daf239eb1dc86c6e4eb8934d94ef13ebfe
1,715
java
Java
core/src/test/java/com/orientechnologies/orient/core/index/OPropertySBTreeRidBagIndexDefinitionTest.java
bernhardriegler/orientdb
9d1e4ff1bb5ebb52092856baad40c35cf27295f8
[ "Apache-2.0" ]
3,651
2015-01-02T23:58:10.000Z
2022-03-31T21:12:12.000Z
core/src/test/java/com/orientechnologies/orient/core/index/OPropertySBTreeRidBagIndexDefinitionTest.java
bernhardriegler/orientdb
9d1e4ff1bb5ebb52092856baad40c35cf27295f8
[ "Apache-2.0" ]
6,890
2015-01-01T09:41:48.000Z
2022-03-29T08:39:49.000Z
core/src/test/java/com/orientechnologies/orient/core/index/OPropertySBTreeRidBagIndexDefinitionTest.java
bernhardriegler/orientdb
9d1e4ff1bb5ebb52092856baad40c35cf27295f8
[ "Apache-2.0" ]
923
2015-01-01T20:40:08.000Z
2022-03-21T07:26:56.000Z
31.759259
98
0.766764
4,779
package com.orientechnologies.orient.core.index; import com.orientechnologies.orient.core.config.OGlobalConfiguration; import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; import org.junit.After; import org.junit.Before; /** * @author Andrey Lomakin (a.lomakin-at-orientdb.com) * @since 1/30/14 */ public class OPropertySBTreeRidBagIndexDefinitionTest extends OPropertyRidBagAbstractIndexDefinition { protected ODatabaseDocumentTx database; private int topThreshold; private int bottomThreshold; public OPropertySBTreeRidBagIndexDefinitionTest() { final String buildDirectory = System.getProperty("buildDirectory", "."); final String url = "plocal:" + buildDirectory + "/test-db/" + this.getClass().getSimpleName(); database = new ODatabaseDocumentTx(url); if (database.exists()) { database.open("admin", "admin"); database.drop(); } database.create(); database.close(); } @Before public void beforeMethod2() { super.beforeMethod(); topThreshold = OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.getValueAsInteger(); bottomThreshold = OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD.getValueAsInteger(); OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(-1); OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD.setValue(-1); database.open("admin", "admin"); } @After public void afterMethod() { database.close(); OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(topThreshold); OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD.setValue(bottomThreshold); } }
3e0b4997cee33c09e4453442d7663fcfbc855770
4,347
java
Java
core/src/test/java/net/automatalib/automata/oca/DOCATests.java
DocSkellington/automatalib
bf5a0929fc125bfa5247d69321353494b22cd039
[ "Apache-2.0" ]
null
null
null
core/src/test/java/net/automatalib/automata/oca/DOCATests.java
DocSkellington/automatalib
bf5a0929fc125bfa5247d69321353494b22cd039
[ "Apache-2.0" ]
null
null
null
core/src/test/java/net/automatalib/automata/oca/DOCATests.java
DocSkellington/automatalib
bf5a0929fc125bfa5247d69321353494b22cd039
[ "Apache-2.0" ]
null
null
null
41.009434
91
0.659535
4,780
/* Copyright (C) 2021 – University of Mons, University Antwerpen * This file is part of AutomataLib, http://www.automatalib.net/. * * 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 net.automatalib.automata.oca; import org.testng.Assert; import org.testng.annotations.Test; import net.automatalib.words.Alphabet; import net.automatalib.words.Word; import net.automatalib.words.impl.Alphabets; /** * @author Gaëtan Staquet */ public class DOCATests { private DefaultDOCA<Character> buildDOCA(AcceptanceMode mode) { // If mode == ACCEPTING_LOCATION: // L = {a^n b^n | n > 0} U {a^n b^m c b* | 0 < m < n} // If mode == COUNTER_ZERO: // L = {epsilon} U {a^n b^n | n > 0} U {a^n b^m c b^l | n > 0, m > 0 and m + l = n} // If mode == BOTH: // L = {a^n b^n | n > 0} U {a^n b^m c b^l | n > 0 and m + l = n} Alphabet<Character> alphabet = Alphabets.characters('a', 'c'); DefaultDOCA<Character> doca = new DefaultDOCA<>(alphabet, mode); DOCALocation q0 = doca.addInitialLocation(false); DOCALocation q1 = doca.addLocation(false); DOCALocation q2 = doca.addLocation(true); DOCALocation q3 = doca.addLocation(true); doca.setSuccessor(q0, 0, 'a', +1, q0); doca.setSuccessor(q0, 1, 'a', +1, q0); doca.setSuccessor(q0, 1, 'b', -1, q1); doca.setEpsilonSuccessor(q1, 0, 0, q2); doca.setSuccessor(q1, 1, 'b', -1, q1); doca.setSuccessor(q1, 1, 'c', 0, q3); doca.setSuccessor(q3, 1, 'b', -1, q3); return doca; } @Test public void testAcceptanceAccepting() { DefaultDOCA<Character> doca = buildDOCA(AcceptanceMode.ACCEPTING_LOCATION); Assert.assertTrue(doca.accepts(Word.fromString("ab"))); Assert.assertTrue(doca.accepts(Word.fromString("aaabcbb"))); Assert.assertTrue(doca.accepts(Word.fromString("aaabc"))); Assert.assertTrue(doca.accepts(Word.fromString("aaabbb"))); Assert.assertTrue(doca.accepts(Word.fromString("aaabbcb"))); Assert.assertFalse(doca.accepts(Word.epsilon())); Assert.assertFalse(doca.accepts(Word.fromString("aaa"))); Assert.assertFalse(doca.accepts(Word.fromString("abc"))); Assert.assertFalse(doca.accepts(Word.fromString("aab"))); Assert.assertFalse(doca.accepts(Word.fromString("abcb"))); } @Test public void testAcceptanceZero() { DefaultDOCA<Character> doca = buildDOCA(AcceptanceMode.COUNTER_ZERO); Assert.assertTrue(doca.accepts(Word.epsilon())); Assert.assertTrue(doca.accepts(Word.fromString("ab"))); Assert.assertTrue(doca.accepts(Word.fromString("aaabcbb"))); Assert.assertTrue(doca.accepts(Word.fromString("aaabbb"))); Assert.assertTrue(doca.accepts(Word.fromString("aaabbcb"))); Assert.assertFalse(doca.accepts(Word.fromString("aaa"))); Assert.assertFalse(doca.accepts(Word.fromString("abc"))); Assert.assertFalse(doca.accepts(Word.fromString("abcb"))); Assert.assertFalse(doca.accepts(Word.fromString("aab"))); } @Test public void testAcceptanceBoth() { DefaultDOCA<Character> doca = buildDOCA(AcceptanceMode.BOTH); Assert.assertTrue(doca.accepts(Word.fromString("ab"))); Assert.assertTrue(doca.accepts(Word.fromString("aaabcbb"))); Assert.assertTrue(doca.accepts(Word.fromString("aaabbb"))); Assert.assertTrue(doca.accepts(Word.fromString("aaabbcb"))); Assert.assertFalse(doca.accepts(Word.epsilon())); Assert.assertFalse(doca.accepts(Word.fromString("aaa"))); Assert.assertFalse(doca.accepts(Word.fromString("abc"))); Assert.assertFalse(doca.accepts(Word.fromString("abcb"))); Assert.assertFalse(doca.accepts(Word.fromString("aab"))); } }
3e0b4a8994c32aabd7b7ddb2b7f067ecb0767c88
4,010
java
Java
src/main/java/ltd/newbee/mall/service/impl/NewBeeMallIndexConfigServiceImpl.java
zhangbo0118/springboot_cloud
2fed577b6b8ddecc4a5a73db160280121ce0aeb7
[ "MIT" ]
4
2020-09-09T00:49:05.000Z
2021-02-19T15:59:00.000Z
src/main/java/ltd/newbee/mall/service/impl/NewBeeMallIndexConfigServiceImpl.java
pp553933054/newbee-mall
83a8086577761dc3e8d6de9623f1894a75029dd5
[ "MIT" ]
null
null
null
src/main/java/ltd/newbee/mall/service/impl/NewBeeMallIndexConfigServiceImpl.java
pp553933054/newbee-mall
83a8086577761dc3e8d6de9623f1894a75029dd5
[ "MIT" ]
4
2019-12-28T01:59:39.000Z
2021-02-19T15:58:17.000Z
40.1
115
0.702743
4,781
package ltd.newbee.mall.service.impl; import ltd.newbee.mall.common.ServiceResultEnum; import ltd.newbee.mall.controller.vo.NewBeeMallIndexConfigGoodsVO; import ltd.newbee.mall.dao.IndexConfigMapper; import ltd.newbee.mall.dao.NewBeeMallGoodsMapper; import ltd.newbee.mall.entity.IndexConfig; import ltd.newbee.mall.entity.NewBeeMallGoods; import ltd.newbee.mall.service.NewBeeMallIndexConfigService; import ltd.newbee.mall.util.BeanUtil; import ltd.newbee.mall.util.PageQueryUtil; import ltd.newbee.mall.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @Service public class NewBeeMallIndexConfigServiceImpl implements NewBeeMallIndexConfigService { @Autowired private IndexConfigMapper indexConfigMapper; @Autowired private NewBeeMallGoodsMapper goodsMapper; @Override public PageResult getConfigsPage(PageQueryUtil pageUtil) { List<IndexConfig> indexConfigs = indexConfigMapper.findIndexConfigList(pageUtil); int total = indexConfigMapper.getTotalIndexConfigs(pageUtil); PageResult pageResult = new PageResult(indexConfigs, total, pageUtil.getLimit(), pageUtil.getPage()); return pageResult; } @Override public String saveIndexConfig(IndexConfig indexConfig) { //todo 判断是否存在该商品 if (indexConfigMapper.insertSelective(indexConfig) > 0) { return ServiceResultEnum.SUCCESS.getResult(); } return ServiceResultEnum.DB_ERROR.getResult(); } @Override public String updateIndexConfig(IndexConfig indexConfig) { //todo 判断是否存在该商品 IndexConfig temp = indexConfigMapper.selectByPrimaryKey(indexConfig.getConfigId()); if (temp == null) { return ServiceResultEnum.DATA_NOT_EXIST.getResult(); } if (indexConfigMapper.updateByPrimaryKeySelective(indexConfig) > 0) { return ServiceResultEnum.SUCCESS.getResult(); } return ServiceResultEnum.DB_ERROR.getResult(); } @Override public IndexConfig getIndexConfigById(Long id) { return null; } @Override public List<NewBeeMallIndexConfigGoodsVO> getConfigGoodsesForIndex(int configType, int number) { List<NewBeeMallIndexConfigGoodsVO> newBeeMallIndexConfigGoodsVOS = new ArrayList<>(number); List<IndexConfig> indexConfigs = indexConfigMapper.findIndexConfigsByTypeAndNum(configType, number); if (!CollectionUtils.isEmpty(indexConfigs)) { //取出所有的goodsId List<Long> goodsIds = indexConfigs.stream().map(IndexConfig::getGoodsId).collect(Collectors.toList()); List<NewBeeMallGoods> newBeeMallGoods = goodsMapper.selectByPrimaryKeys(goodsIds); newBeeMallIndexConfigGoodsVOS = BeanUtil.copyList(newBeeMallGoods, NewBeeMallIndexConfigGoodsVO.class); for (NewBeeMallIndexConfigGoodsVO newBeeMallIndexConfigGoodsVO : newBeeMallIndexConfigGoodsVOS) { String goodsName = newBeeMallIndexConfigGoodsVO.getGoodsName(); String goodsIntro = newBeeMallIndexConfigGoodsVO.getGoodsIntro(); // 字符串过长导致文字超出的问题 if (goodsName.length() > 30) { goodsName = goodsName.substring(0, 30) + "..."; newBeeMallIndexConfigGoodsVO.setGoodsName(goodsName); } if (goodsIntro.length() > 22) { goodsIntro = goodsIntro.substring(0, 22) + "..."; newBeeMallIndexConfigGoodsVO.setGoodsIntro(goodsIntro); } } } return newBeeMallIndexConfigGoodsVOS; } @Override public Boolean deleteBatch(Long[] ids) { if (ids.length < 1) { return false; } //删除数据 return indexConfigMapper.deleteBatch(ids) > 0; } }
3e0b4b20a3acdb1da54def9c5c09aa4dd9c8af6c
1,007
java
Java
src/main/java/pityoulish/jrmi/client/RegistryBackendHandler.java
pityoulish/origins
220d2648c8844db84b845a765e01a1efa1159ee8
[ "CC0-1.0" ]
9
2016-01-11T15:23:19.000Z
2018-10-07T19:59:55.000Z
src/main/java/pityoulish/jrmi/client/RegistryBackendHandler.java
rolandweber/Pityoulish
220d2648c8844db84b845a765e01a1efa1159ee8
[ "CC0-1.0" ]
97
2015-11-15T15:36:31.000Z
2020-12-16T10:35:48.000Z
src/main/java/pityoulish/jrmi/client/RegistryBackendHandler.java
rolandweber/Pityoulish
220d2648c8844db84b845a765e01a1efa1159ee8
[ "CC0-1.0" ]
null
null
null
22.886364
70
0.716981
4,782
/* * This work is released into the Public Domain under the * terms of the Creative Commons CC0 1.0 Universal license. * https://creativecommons.org/publicdomain/zero/1.0/ */ package pityoulish.jrmi.client; import pityoulish.mbclient.HostPortBackendHandler; import pityoulish.jrmi.api.RemoteMessageBoard; import pityoulish.jrmi.api.RemoteTicketIssuer; /** * Backend handler for contacting the RMI Registry. */ public interface RegistryBackendHandler extends HostPortBackendHandler { /** * Look up the {@link RemoteMessageBoard} in the registry. * * @return a stub for the Message Board * * @throws Exception in case of a problem */ public RemoteMessageBoard getRemoteMessageBoard() throws Exception ; /** * Look up the {@link RemoteTicketIssuer} in the registry. * * @return a stub for the Ticket Issuer * * @throws Exception in case of a problem */ public RemoteTicketIssuer getRemoteTicketIssuer() throws Exception ; }
3e0b4b7ec4f8412a79e7f781a89da33319c10feb
1,757
java
Java
src/main/java/co/ivi/jus/instance/modern/Scope.java
pruidong/java-up
81b5216457873d3d3b19d45c73b887022c47abe5
[ "MIT" ]
11
2021-11-16T10:13:26.000Z
2022-03-27T08:57:34.000Z
src/main/java/co/ivi/jus/instance/modern/Scope.java
pruidong/java-up
81b5216457873d3d3b19d45c73b887022c47abe5
[ "MIT" ]
6
2021-11-17T08:25:29.000Z
2021-11-30T08:26:20.000Z
src/main/java/co/ivi/jus/instance/modern/Scope.java
pruidong/java-up
81b5216457873d3d3b19d45c73b887022c47abe5
[ "MIT" ]
14
2021-11-17T03:11:16.000Z
2022-03-16T10:33:18.000Z
32.537037
77
0.611838
4,783
/* * Copyright (c) 2021, Xuelei Fan. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. */ package co.ivi.jus.instance.modern; import co.ivi.jus.instance.modern.Shape.Square; import co.ivi.jus.instance.modern.Shape.Rectangle; public final class Scope { public static boolean isSquareImplA(Shape shape) { if (shape instanceof Rectangle rect) { // rect is in scope return rect.length() == rect.width(); } // rect is not in scope here return shape instanceof Square; } public static boolean isSquareImplB(Shape shape) { if (!(shape instanceof Rectangle rect)) { // rect is not in scope here return shape instanceof Square; } // rect is in scope return rect.length() == rect.width(); } public static boolean isSquareImplC(Shape shape) { return shape instanceof Square || // rect is not in scope here (shape instanceof Rectangle rect && rect.length() == rect.width()); // rect is in scope here } /* // Comment this method out as it is not compilable. public static boolean isSquareImplD(Shape shape) { return shape instanceof Square || // rect is not in scope here (shape instanceof Rectangle rect || rect.length() == rect.width()); // rect is not in scope here } // Comment this method out as it is not compilable. public static boolean isSquareImplE(Shape shape) { return shape instanceof Square | // rect is not in scope here (shape instanceof Rectangle rect & rect.length() == rect.width()); // rect is in scope here } */ }
3e0b4bea276a82ce91f3e476324b053476343a94
123,109
java
Java
gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/LangScripts_AggBuiltInTest.java
xyxiaoyou/snappy-store
013ff282f888878cc99600e260ec1cde60112304
[ "Apache-2.0" ]
38
2016-01-04T01:31:40.000Z
2020-04-07T06:35:36.000Z
gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/LangScripts_AggBuiltInTest.java
xyxiaoyou/snappy-store
013ff282f888878cc99600e260ec1cde60112304
[ "Apache-2.0" ]
261
2016-01-07T09:14:26.000Z
2019-12-05T10:15:56.000Z
gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/jdbc/LangScripts_AggBuiltInTest.java
xyxiaoyou/snappy-store
013ff282f888878cc99600e260ec1cde60112304
[ "Apache-2.0" ]
22
2016-03-09T05:47:09.000Z
2020-04-02T17:55:30.000Z
87.249468
322
0.586903
4,784
/* * Copyright (c) 2010-2015 Pivotal Software, Inc. 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. 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. See accompanying * LICENSE file. */ package com.pivotal.gemfirexd.jdbc; import java.io.File; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.sql.SQLException; import java.util.HashSet; import java.util.Properties; import java.util.Set; import org.apache.derbyTesting.junit.JDBC; import com.pivotal.gemfirexd.TestUtil; import com.pivotal.gemfirexd.internal.engine.Misc; import junit.framework.TestSuite; import junit.textui.TestRunner; public class LangScripts_AggBuiltInTest extends JdbcTestBase { public static void main(String[] args) { TestRunner.run(new TestSuite(LangScripts_AggBuiltInTest.class)); } public LangScripts_AggBuiltInTest(String name) { super(name); } // This test is the as-is LangScript conversion, without any partitioning clauses public void testLangScript_AggBuiltInTestNoPartitioning() throws Exception { // This is a JUnit conversion of the Derby Lang aggbuiltin.sql script // without any GemFireXD extensions // Catch exceptions from illegal syntax // Tests still not fixed marked FIXME // Array of SQL text to execute and sqlstates to expect // The first object is a String, the second is either // 1) null - this means query returns no rows and throws no exceptions // 2) a string - this means query returns no rows and throws expected SQLSTATE // 3) a String array - this means query returns rows which must match (unordered) given resultset // - for an empty result set, an uninitialized size [0][0] array is used Object[][] Script_AggBuiltInUT = { // create an all types tables { "create table t (i int, s smallint, l bigint, c char(10), v varchar(50), lvc long varchar, d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, lbv long varchar for bit data, dc decimal(5,2))" + getOffHeapSuffix(), null}, { "create table empty (i int, s smallint, l bigint, c char(10), v varchar(50), lvc long varchar, d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, lbv long varchar for bit data, dc decimal(5,2))" + getOffHeapSuffix(), null}, { "insert into t (i) values (null)", null}, { "insert into t (i) values (null)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', x'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (1, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 200, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 222.22)", null}, { "insert into t values (0, 100, 2000000, 'duplicate', 'this is duplicated', 'also duplicated', date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 222.22)", "42802"}, { "insert into t values (0, 100, 1000000, 'goodbye', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'noone is here', 'jimmie noone was here', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 100.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 100.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-09-09'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:55:55'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:55:55'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'ffff', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'1111111111111111', X'1234', 111.11)", null}, // cannot aggregate datatypes that don't support NumberDataValue { "select avg(c) from t", "42Y22"}, { "select avg(v) from t", "42Y22"}, { "select avg(lvc) from t", "42Y22"}, { "select avg(dt) from t", "42Y22"}, { "select avg(t) from t", "42Y22"}, { "select avg(ts) from t", "42Y22"}, { "select avg(b) from t", "42Y22"}, { "select avg(bv) from t", "42Y22"}, { "select avg(lbv) from t", "42Y22"}, { "select avg(c) from t group by c", "42Y22"}, { "select avg(v) from t group by c", "42Y22"}, { "select avg(lvc) from t group by c", "42Y22"}, { "select avg(dt) from t group by c", "42Y22"}, { "select avg(t) from t group by c", "42Y22"}, { "select avg(ts) from t group by c", "42Y22"}, { "select avg(b) from t group by c", "42Y22"}, { "select avg(bv) from t group by c", "42Y22"}, { "select avg(lbv) from t group by c", "42Y22"}, // long varchar datatypes too { "create table t1 (c1 long varchar)" + getOffHeapSuffix(), null }, { "select avg(c1) from t1", "42Y22" }, { "drop table t1", null }, // constants { "select avg('hello') from t", "42Y22" }, { "select avg(X'11') from t", "42Y22" }, { "select avg(date('1999-06-06')) from t", "42Y22" }, { "select avg(time('12:30:30')) from t", "42Y22" }, { "select avg(timestamp('1999-06-06 12:30:30')) from t", "42Y22" }, // NULL AGGREGATION { "select avg(i) from empty", new String [][] { {null} } }, { "select avg(s) from empty", new String [][] { {null} } }, { "select avg(d) from empty", new String [][] { {null} } }, { "select avg(l) from empty", new String [][] { {null} } }, { "select avg(r) from empty", new String [][] { {null} } }, { "select avg(dc) from empty", new String [][] { {null} } }, { "select avg(i), avg(s), avg(r), avg(l) from empty", new String [][] { {null,null,null,null} } }, { "select avg(i+1) from empty", new String [][] { {null} } }, { "select avg(i) from empty group by i", new String[0][0] }, { "select avg(s) from empty group by s", new String[0][0] }, { "select avg(d) from empty group by d", new String[0][0] }, { "select avg(l) from empty group by l", new String[0][0] }, { "select avg(r) from empty group by r", new String[0][0] }, { "select avg(dc) from empty group by dc", new String[0][0] }, // BASIC ACCEPTANCE TESTS { "select avg(i) from t", new String [][] { {"0"} } }, // ignore the WARNINGs given { "select avg(s) from t", new String [][] { {"107"} } }, { "select avg(d) from t", new String [][] { {"192.85714285714286"} } }, { "select avg(l) from t", new String [][] { {"1000000"} } }, { "select avg(r) from t", new String [][] { {"192.85714285714286"} } }, { "select avg(dc) from t", new String [][] { {"119.0464"} } }, { "select avg(i) from t group by i", new String [][] { {"0"}, {"1"}, {null} } }, { "select avg(s) from t group by s", new String [][] { {"100"}, {"200"}, {null} } }, { "select avg(d) from t group by d", new String [][] { {"100.0"}, {"200.0"}, {null} } }, { "select avg(l) from t group by l", new String [][] { {"1000000"}, {null} } }, { "select avg(r) from t group by r", new String [][] { {"100.0"}, {"200.0"}, {null} } }, { "select avg(dc), sum(dc), count(dc) from t group by dc", new String [][] { {"111.1100","1444.43","13"}, {"222.2200","222.22","1"}, {null,null,"0"} } }, // -- constants { "select avg(1) from t", new String [][] { {"1"} } }, // FIXME // If these statements all have one space between AVG() call and FROM, they reuse same prepared statement // and throw casting error. Only happens with prepared statements, not on GFXD { "select avg(1.1) from t", new String [][] { {"1.1000"} } }, { "select avg(1e1) from t", new String [][] { {"10.0"} } }, { "select avg(1) from t group by i", new String [][] { {"1"},{"1"},{"1"} } }, { "select avg(1.1) from t group by r", new String [][] { {"1.1000"},{"1.1000"},{"1.1000"} } }, { "select avg(1e1) from t group by r", new String [][] { {"10.0"},{"10.0"},{"10.0"} } }, // multicolumn grouping { "select avg(i), avg(l), avg(r) from t group by i, dt, b", new String [][] { {"0","1000000","190.9090909090909"}, {"0","1000000","200.0"}, {"0","1000000","200.0"}, {"1","1000000","200.0"}, {null, null, null} } }, { "select i, dt, avg(i), avg(r), avg(l), l from t group by i, dt, b, l", new String [][] { {"0","1992-01-01","0","190.9090909090909","1000000","1000000"}, {"0","1992-01-01","0","200.0","1000000","1000000"}, {"0","1992-09-09","0","200.0","1000000","1000000"}, {"1","1992-01-01","1","200.0","1000000","1000000"}, {null, null, null, null, null, null} } }, { "select avg(expr1), avg(expr2) from (select i * s, r * 2 from t) t (expr1, expr2) group by expr2, expr1", new String [][] { {"0","200.0"}, {"0","400.0"}, {"100","400.0"}, {null,null} } }, { "select distinct avg(i) from t group by i, dt", new String[][] { {"0"},{"1"},{null} } }, { "create table tmp (x int, y smallint)" + getOffHeapSuffix(), null }, { "insert into tmp (x, y) select avg(i), avg(s) from t", null }, { "select * from tmp", new String [][] { {"0","107"} } }, { "insert into tmp (x, y) select avg(i), avg(s) from t group by b", null }, { "select * from tmp", new String [][] { {"0","107"}, {"0","107"}, {"0","100"}, {null,null} } }, { "drop table tmp", null }, { "create table tmp (x int)" + getOffHeapSuffix(), null }, { "insert into tmp values (2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647)", null }, { "select avg(x) from tmp", new String [][] { {"2147483647"} } }, { "select avg(-(x - 1)) from tmp", new String [][] { {"-2147483646"} } }, { "select avg(x) from tmp group by x", new String [][] { {"2147483647"} } }, { "select avg(-(x - 1)) from tmp group by x", new String [][] { {"-2147483646"} } }, { "drop table tmp", null}, { "create table tmp(x double precision, y int)" + getOffHeapSuffix(), null }, { "insert into tmp values (1,1)", null }, { "select avg(x) from tmp", new String [][] { {"1.0" } } }, { "select avg(x) from tmp group by y", new String [][] { {"1.0"} } }, { "insert into tmp values (2,1)", null }, { "select avg(x) from tmp", new String [][] { {"1.5" } } }, { "select avg(x) from tmp group by y", new String [][] { {"1.5"} } }, { "insert into tmp values (3,1)", null }, { "select avg(x) from tmp", new String [][] { {"2.0" } } }, { "select avg(x) from tmp group by y", new String [][] { {"2.0"} } }, { "insert into tmp values (4,1)", null }, { "select avg(x) from tmp", new String [][] { {"2.5" } } }, { "select avg(x) from tmp group by y", new String [][] { {"2.5"} } }, { "insert into tmp values (5,1)", null }, { "select avg(x) from tmp", new String [][] { {"3.0" } } }, { "select avg(x) from tmp group by y", new String [][] { {"3.0"} } }, { "insert into tmp values (6,1)", null }, { "select avg(x) from tmp", new String [][] { {"3.5" } } }, { "select avg(x) from tmp group by y", new String [][] { {"3.5"} } }, { "insert into tmp values (7,1)", null }, { "select avg(x) from tmp", new String [][] { {"4.0" } } }, { "select avg(x) from tmp group by y", new String [][] { {"4.0"} } }, { "insert into tmp values (10000,1)", null }, { "select avg(x) from tmp", new String [][] { {"1253.5" } } }, { "select avg(x) from tmp group by y", new String [][] { {"1253.5"} } }, { "drop table tmp", null }, { "drop table t", null }, { "drop table empty", null }, // COUNT { "create table t (i int, s smallint, l bigint, c char(10), v varchar(50), lvc long varchar, d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, lbv long varchar for bit data, dc decimal(5,2))" + getOffHeapSuffix(), null}, { "create table empty (i int, s smallint, l bigint, c char(10), v varchar(50), lvc long varchar, d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, lbv long varchar for bit data, dc decimal(5,2))" + getOffHeapSuffix(), null}, { "insert into t (i) values (null)", null}, { "insert into t (i) values (null)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', x'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (1, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 200, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 222.22)", null}, { "insert into t values (0, 100, 2000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 222.22)", null}, { "insert into t values (0, 100, 1000000, 'goodbye', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'noone is here', 'jimmie noone was here', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 100.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 100.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-09-09'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:55:55'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:55:55'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'ffff', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'1111111111111111', X'1234', 111.11)", null}, // NULL AGGREGATION { "select count(i) from empty", new String [][] { {"0" } } }, { "select count(s) from empty", new String [][] { {"0" } } }, { "select count(l) from empty", new String [][] { {"0" } } }, { "select count(c) from empty", new String [][] { {"0" } } }, { "select count(v) from empty", new String [][] { {"0" } } }, { "select count(lvc) from empty", new String [][] { {"0" } } }, { "select count(d) from empty", new String [][] { {"0" } } }, { "select count(r) from empty", new String [][] { {"0" } } }, { "select count(dt) from empty", new String [][] { {"0" } } }, { "select count(t) from empty", new String [][] { {"0" } } }, { "select count(ts) from empty", new String [][] { {"0" } } }, { "select count(b) from empty", new String [][] { {"0" } } }, { "select count(bv) from empty", new String [][] { {"0" } } }, { "select count(lbv) from empty", new String [][] { {"0" } } }, { "select count(dc) from empty", new String [][] { {"0" } } }, { "select count(i), count(b), count(i), count(s) from empty", new String [][] { {"0","0","0","0"} } }, { "select count(i+1) from empty", new String [][] { {"0"} } }, { "select count(i) from empty group by i", new String [0][0] }, { "select count(s) from empty group by s", new String [0][0] }, { "select count(l) from empty group by l", new String [0][0] }, { "select count(c) from empty group by c", new String [0][0] }, { "select count(v) from empty group by v", new String [0][0] }, { "select count(d) from empty group by d", new String [0][0] }, { "select count(r) from empty group by r", new String [0][0] }, { "select count(dt) from empty group by dt", new String [0][0] }, { "select count(t) from empty group by t", new String [0][0] }, { "select count(ts) from empty group by ts", new String [0][0] }, { "select count(b) from empty group by b", new String [0][0] }, { "select count(bv) from empty group by bv", new String [0][0] }, { "select count(lbv) from empty group by lbv", "X0X67" }, { "select count(dc) from empty group by dc", new String [0][0] }, { "select count(i) from t", new String [][] { {"15"} } }, { "select count(s) from t", new String [][] { {"15"} } }, { "select count(l) from t", new String [][] { {"15"} } }, { "select count(c) from t", new String [][] { {"15"} } }, { "select count(v) from t", new String [][] { {"15"} } }, { "select count(lvc) from t", new String [][] { {"15"} } }, { "select count(d) from t", new String [][] { {"15"} } }, { "select count(r) from t", new String [][] { {"15"} } }, { "select count(dt) from t", new String [][] { {"15"} } }, { "select count(t) from t", new String [][] { {"15"} } }, { "select count(ts) from t", new String [][] { {"15"} } }, { "select count(b) from t", new String [][] { {"15"} } }, { "select count(bv) from t", new String [][] { {"15"} } }, { "select count(lbv) from t", new String [][] { {"15"} } }, { "select count(dc) from t", new String [][] { {"15"} } }, { "select count(i) from t group by i", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(s) from t group by s", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(l) from t group by l", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(c) from t group by c", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(v) from t group by v", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(d) from t group by d", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(r) from t group by r", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(dt) from t group by dt", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(t) from t group by t", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(ts) from t group by ts", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(b) from t group by b", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(bv) from t group by bv", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(lbv) from t group by lbv", "X0X67" }, { "select count(dc) from t group by dc", new String [][] { {"13"}, {"2"}, {"0"} } }, { "select count(1) from t", new String[][] { {"17"} } }, { "select count('hello') from t", new String[][] { {"17"} } }, { "select count(1.1) from t", new String[][] { {"17"} } }, { "select count(1e1) from t", new String[][] { {"17"} } }, { "select count(X'11') from t", new String[][] { {"17"} } }, { "select count(date('1999-06-06')) from t", new String[][] { {"17"} } }, { "select count(time('12:30:30')) from t", new String[][] { {"17"} } }, { "select count(timestamp('1999-06-06 12:30:30')) from t", new String[][] { {"17"} } }, { "select count(1) from t group by i", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count('hello') from t group by c", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count(1.1) from t group by dc", new String[][] { {"13"}, {"2"}, {"2"} } }, { "select count(1e1) from t group by r", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count(X'11') from t group by b", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count(date('1999-06-06')) from t group by dt", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count(time('12:30:30')) from t group by t", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count(timestamp('1999-06-06 12:30:30')) from t group by ts", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count(i), count(dt), count(b) from t group by i, dt, b", new String[][] { {"12","12","12"}, {"1","1","1"}, {"1","1","1"}, {"1","1","1"}, {"0","0","0"} } }, { "select l, dt, count(i), count(dt), count(b), i from t group by i, dt, b, l", new String [][] { {"1000000", "1992-01-01", "11", "11", "11", "0"}, {"2000000", "1992-01-01", "1", "1", "1", "0"}, {"1000000", "1992-01-01", "1", "1", "1", "0"}, {"1000000", "1992-09-09", "1", "1", "1", "0"}, {"1000000", "1992-01-01", "1", "1", "1", "1"}, {null,null,"0","0","0",null} } }, { "select count(expr1), count(expr2) from (select i * s, c || v from t) t (expr1, expr2) group by expr2, expr1", new String [][] { {"1", "1"}, {"12", "12"}, {"1","1"}, {"1","1"}, {"0","0"} } }, { "select distinct count(i) from t group by i, dt", new String [][] { {"0"}, {"1"}, {"13"} } }, { "create table tmp (x int, y smallint)" + getOffHeapSuffix(), null }, { "insert into tmp (x, y) select count(i), count(c) from t", null }, { "select * from tmp", new String [][] { {"15", "15"} } }, { "insert into tmp (x, y) select count(i), count(c) from t group by b", null }, { "select * from tmp", new String [][] { {"15", "15"}, {"14", "14"}, {"1", "1"}, {"0","0"} } }, { "drop table tmp", null }, { "drop table t", null }, { "drop table empty", null }, // Test the COUNT() aggregate { "create table t (i int, s smallint, l bigint, c char(10), v varchar(50), lvc long varchar, d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, lbv long varchar for bit data)" + getOffHeapSuffix(), null }, { "create table empty (i int, s smallint, l bigint, c char(10), v varchar(50), lvc long varchar, d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, lbv long varchar for bit data)" + getOffHeapSuffix(), null }, { "insert into t (i) values (null)", null }, { "insert into t (i) values (null)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (1, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 200, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 2000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'goodbye', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'noone is here', 'jimmie noone was here', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 100.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 100.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-09-09'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:55:55'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:55:55'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'ffff', X'0000111100001111', X'1234')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated',200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'1111111111111111', X'ABCD')", null }, { "select count(*) from empty", new String [][] { {"0"} } }, { "select count(*), count(*) from empty", new String [][] { {"0","0"} } }, { "select count(*) from empty group by i", new String [0][0] }, { "select count(*) from t", new String [][] { {"17"} } }, { "select count(*) from t group by i", new String [][] { {"14"}, {"1"}, {"2"} } }, { "select count(*), count(*), count(*) from t group by i, dt, b", new String[][] { {"12","12","12"}, {"1","1","1"}, {"1","1","1"}, {"1","1","1"}, {"2","2","2"} } }, { "select count(*), count(*) from (select i * s, c || v from t) t (expr1, expr2) group by expr2, expr1", new String [][] { {"1","1"}, {"12","12"}, {"1","1"}, {"1","1"}, {"2","2"} } }, { "select distinct count(*) from t group by i, dt", new String [][] { {"1"}, {"2"}, {"13"} } }, { "create view v1 as select * from t", null }, { "select count(*) from v1", new String [][] { {"17"} } }, { "select count(*)+count(*) from v1", new String [][] { {"34"} } }, { "drop view v1", null }, { "create table tmp (x int, y smallint)" + getOffHeapSuffix(), null }, { "insert into tmp (x, y) select count(*), count(*) from t", null }, { "select * from tmp", new String [][] { {"17","17"} } }, { "insert into tmp (x, y) select count(*), count(*) from t group by b", null }, { "select * from tmp", new String [][] { {"17","17"}, {"14","14"}, {"1","1"}, {"2","2"} } }, { "drop table tmp", null }, { "drop table t", null }, { "drop table empty", null }, // SUM { "create table t (i int, s smallint, l bigint, c char(10), v varchar(50), d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, dc decimal(5,2))" + getOffHeapSuffix(), null }, { "create table empty (i int, s smallint, l bigint, c char(10), v varchar(50), d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, dc decimal(5,2))" + getOffHeapSuffix(), null }, { "insert into t (i) values (null)", null }, { "insert into t (i) values (null)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (1, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 200, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 222.22)", null }, { "insert into t values (0, 100, 2000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 222.22)", null }, { "insert into t values (0, 100, 1000000,'goodbye', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'noone is here', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000,'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'),X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000,'duplicate', 'this is duplicated', 100.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000,'duplicate', 'this is duplicated', 200.0e0, 100.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-09-09'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:55:55'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:55:55'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'ffff', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'1111111111111111', 111.11)", null }, // cannot aggregate datatypes that don't support NumberDataValue { "select sum(c) from t", "42Y22" }, { "select sum(v) from t", "42Y22" }, { "select sum(dt) from t", "42Y22" }, { "select sum(t) from t", "42Y22" }, { "select sum(ts) from t", "42Y22" }, { "select sum(b) from t", "42Y22" }, { "select sum(bv) from t", "42Y22" }, { "select sum(c) from t group by c", "42Y22" }, { "select sum(v) from t group by c", "42Y22" }, { "select sum(dt) from t group by c", "42Y22" }, { "select sum(t) from t group by c", "42Y22" }, { "select sum(ts) from t group by c", "42Y22" }, { "select sum(b) from t group by c", "42Y22" }, { "select sum(bv) from t group by c", "42Y22" }, { "create table t1 (c1 long varchar)" + getOffHeapSuffix(), null }, { "select sum(c1) from t1", "42Y22" }, { "drop table t1", null }, // constants { "select sum('hello') from t", "42Y22" }, { "select sum(X'11') from t", "42Y22" }, { "select sum(date('1999-06-06')) from t", "42Y22" }, { "select sum(time('12:30:30')) from t", "42Y22" }, { "select sum(timestamp('1999-06-06 12:30:30')) from t", "42Y22" }, { "select sum(i) from empty", new String [][] { {null} } }, { "select sum(s) from empty", new String [][] { {null} } }, { "select sum(d) from empty", new String [][] { {null} } }, { "select sum(l) from empty", new String [][] { {null} } }, { "select sum(r) from empty", new String [][] { {null} } }, { "select sum(dc) from empty", new String [][] { {null} } }, { "select sum(i), sum(s), sum(r), sum(l) from empty", new String [][] { {null,null,null,null} } }, { "select sum(i+1) from empty", new String [][] { {null} } }, { "select sum(i) from empty group by i", new String [0][0] }, { "select sum(s) from empty group by s", new String [0][0] }, { "select sum(d) from empty group by d", new String [0][0] }, { "select sum(l) from empty group by l", new String [0][0] }, { "select sum(r) from empty group by r", new String [0][0] }, { "select sum(dc) from empty group by dc", new String [0][0] }, { "select sum(i) from t", new String [][] { {"1"} } }, { "select sum(s) from t", new String [][] { {"1600"} } }, { "select sum(d) from t", new String [][] { {"2900.0"} } }, { "select sum(l) from t", new String [][] { {"16000000"} } }, { "select sum(r) from t", new String [][] { {"2900.0"} } }, { "select sum(dc) from t", new String [][] { {"1888.87"} } }, { "select sum(i) from t group by i", new String [][] { {"0"}, {"1"}, {null} } }, { "select sum(s) from t group by s", new String [][] { {"1400"}, {"200"}, {null} } }, { "select sum(d) from t group by d", new String [][] { {"100.0"}, {"2800.0"}, {null} } }, { "select sum(l) from t group by l", new String [][] { {"14000000"}, {"2000000"}, {null} } }, { "select sum(r) from t group by r", new String [][] { {"100.0"}, {"2800.0"}, {null} } }, { "select sum(dc) from t group by dc", new String [][] { {"1444.43"}, {"444.44"}, {null} } }, { "select sum(1) from t", new String [][] { {"17"} } }, { "select sum(1.1) from t", new String [][] { {"18.7"} } }, { "select sum(1e1) from t", new String [][] { {"170.0"} } }, { "select sum(1) from t group by i", new String [][] { {"14"}, {"1"}, {"2"} } }, { "select sum(1.1) from t group by r", new String [][] { {"1.1"}, {"15.4"}, {"2.2"} } }, { "select sum(1e1) from t group by r", new String [][] { {"10.0"}, {"140.0"}, {"20.0"} } }, { "select sum(i), sum(l), sum(r) from t group by i, dt, b", new String [][] { {"0","13000000", "2300.0"}, {"0","1000000", "200.0"}, {"0","1000000", "200.0"}, {"1","1000000", "200.0"}, {null,null,null} } }, { "select i, dt, sum(i), sum(r), sum(l), l from t group by i, dt, b, l", new String [][] { {"0","1992-01-01","0","2100.0","11000000", "1000000"}, {"0","1992-01-01","0","200.0","2000000", "2000000"}, {"0","1992-01-01","0","200.0","1000000", "1000000"}, {"0","1992-09-09","0","200.0","1000000", "1000000"}, {"1","1992-01-01","1","200.0","1000000", "1000000"}, {null,null,null,null,null,null} } }, { "select sum(expr1), sum(expr2) from (select i * s, r * 2 from t) t (expr1, expr2) group by expr2, expr1", new String [][] { {"0","200.0"}, {"0","5200.0"}, {"100","400.0"}, {null,null} } }, { "select distinct sum(i) from t group by i, dt", new String [][] { {"0"}, {"1"}, {null} } }, { "create table tmp (x int, y smallint)" + getOffHeapSuffix(), null }, { "insert into tmp (x, y) select sum(i), sum(s) from t", null }, { "select * from tmp", new String [][] { {"1", "1600"} } }, { "insert into tmp (x, y) select sum(i), sum(s) from t group by b", null }, { "select * from tmp", new String [][] { {"1", "1600"}, {"1", "1500"}, {"0", "100"}, {null,null} } }, { "drop table tmp", null }, // overflow { "create table tmp (x int)" + getOffHeapSuffix(), null }, { "insert into tmp values (2147483647),(2147483647)", null }, // FIXME // This does not return an overflow, it returns results! GFXD command line returns an overflow (22003) error as expected //{ "select sum(x) from tmp", "22003"}, { "drop table tmp", null }, { "create table tmp (x double precision)" + getOffHeapSuffix(), null }, { "insert into tmp values (2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647), (2147483647),(2147483647)", null }, { "select sum(x) from tmp", new String [][] { {"1.9327352823E10"} } }, { "drop table tmp", null }, { "drop table t", null }, { "drop table empty", null }, // MAX { "create table t (i int, s smallint, l bigint, c char(10), v varchar(50), d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, dc decimal(5,2))" + getOffHeapSuffix(), null }, { "create table empty (i int, s smallint, l bigint,c char(10), v varchar(50), d double precision, r real, dt date, t time, ts timestamp,b char(2) for bit data, bv varchar(8) for bit data, dc decimal(5,2))" + getOffHeapSuffix(), null }, { "insert into t (i) values (null)", null }, { "insert into t (i) values (null)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (1, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 200, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 222.22)", null }, { "insert into t values (0, 100, 2000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 222.22)", null }, { "insert into t values (0, 100, 1000000, 'goodbye', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'noone is here', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 100.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 100.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-09-09'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:55:55'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:55:55'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'ffff', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'1111111111111111', 111.11)", null }, { "create table t1 (c1 long varchar)" + getOffHeapSuffix(), null }, { "select max(c1) from t1", new String[][] { {null} } }, // GemFireXD allows MAX(LVC) { "drop table t1", null }, { "select max(i) from empty", new String [][] { {null} } }, { "select max(s) from empty", new String [][] { {null} } }, { "select max(l) from empty", new String [][] { {null} } }, { "select max(c) from empty", new String [][] { {null} } }, { "select max(v) from empty", new String [][] { {null} } }, { "select max(d) from empty", new String [][] { {null} } }, { "select max(r) from empty", new String [][] { {null} } }, { "select max(dt) from empty", new String [][] { {null} } }, { "select max(t) from empty", new String [][] { {null} } }, { "select max(ts) from empty", new String [][] { {null} } }, { "select max(b) from empty", new String [][] { {null} } }, { "select max(bv) from empty", new String [][] { {null} } }, { "select max(dc) from empty", new String [][] { {null} } }, { "select max(i), max(b), max(i), max(s) from empty", new String [][] { {null,null,null,null} } }, { "select max(i+1) from empty", new String [][] { {null} } }, { "select max(i) from empty group by i", new String[0][0] }, { "select max(s) from empty group by s", new String[0][0] }, { "select max(l) from empty group by l", new String[0][0] }, { "select max(c) from empty group by c", new String[0][0] }, { "select max(v) from empty group by v", new String[0][0] }, { "select max(d) from empty group by d", new String[0][0] }, { "select max(r) from empty group by r", new String[0][0] }, { "select max(dt) from empty group by dt", new String[0][0] }, { "select max(t) from empty group by t", new String[0][0] }, { "select max(ts) from empty group by ts", new String[0][0] }, { "select max(b) from empty group by b", new String[0][0] }, { "select max(bv) from empty group by bv", new String[0][0] }, { "select max(dc) from empty group by dc", new String[0][0] }, { "select max(i) from t", new String [][] { {"1"} } }, { "select max(s) from t", new String [][] { {"200"} } }, { "select max(l) from t", new String [][] { {"2000000"} } }, { "select max(c) from t", new String [][] { {"goodbye"} } }, { "select max(v) from t", new String [][] { {"this is duplicated"} } }, { "select max(d) from t", new String [][] { {"200.0"} } }, { "select max(r) from t", new String [][] { {"200.0"} } }, { "select max(dt) from t", new String [][] { {"1992-09-09"} } }, { "select max(t) from t", new String [][] { {"12:55:55"} } }, { "select max(ts) from t", new String [][] { {"1992-01-01 12:55:55.0"} } }, { "select max(b) from t", new String [][] { {"ffff"} } }, { "select max(bv) from t", new String [][] { {"1111111111111111"} } }, { "select max(dc) from t", new String [][] { {"222.22"} } }, { "select max(i) from t group by i", new String [][] { {"0"}, {"1"}, {null} } }, { "select max(s) from t group by s", new String [][] { {"100"}, {"200"}, {null} } }, { "select max(l) from t group by l", new String [][] { {"1000000"}, {"2000000"}, {null} } }, { "select max(c) from t group by c", new String [][] { {"duplicate"}, {"goodbye"}, {null} } }, { "select max(v) from t group by v", new String [][] { {"noone is here"}, {"this is duplicated"}, {null} } }, { "select max(d) from t group by d", new String [][] { {"100.0"}, {"200.0"}, {null} } }, { "select max(r) from t group by r", new String [][] { {"100.0"}, {"200.0"}, {null} } }, { "select max(dt) from t group by dt", new String [][] { {"1992-01-01"}, {"1992-09-09"}, {null } } }, { "select max(t) from t group by t", new String [][] { {"12:30:30"}, {"12:55:55"}, {null} } }, { "select max(ts) from t group by ts", new String [][] { {"1992-01-01 12:30:30.0"}, {"1992-01-01 12:55:55.0"}, {null} } }, { "select max(b) from t group by b", new String [][] { {"12af"}, {"ffff"}, {null} } }, { "select max(bv) from t group by bv", new String [][] { {"0000111100001111"}, {"1111111111111111"}, {null} } }, { "select max(dc) from t group by dc", new String [][] { {"111.11"}, {"222.22"}, {null} } }, { "select max(1) from t", new String [][] { {"1"} } }, { "select max('hello') from t", new String [][] { {"hello"} } }, { "select max(1.1) from t", new String [][] { {"1.1"} } }, { "select max(1e1) from t", new String [][] { {"10.0"} } }, { "select max(X'11') from t", new String [][] { {"11"} } }, { "select max(date('1999-06-06')) from t", new String [][] { {"1999-06-06"} } }, { "select max(time('12:30:30')) from t", new String [][] { {"12:30:30"} } }, { "select max(timestamp('1999-06-06 12:30:30')) from t", new String [][] { {"1999-06-06 12:30:30.0"} } }, { "select max(1) from t group by i", new String [][] { {"1"}, {"1"}, {"1"} } }, { "select max('hello') from t group by c", new String [][] { {"hello"}, {"hello"}, {"hello"} } }, { "select max(1.1) from t group by dc", new String [][] { {"1.1"}, {"1.1"}, {"1.1"} } }, { "select max(1e1) from t group by d", new String [][] { {"10.0"}, {"10.0"}, {"10.0"} } }, { "select max(X'11') from t group by b", new String [][] { {"11"}, {"11"}, {"11"} } }, { "select max(date('1999-06-06')) from t group by dt", new String [][] { {"1999-06-06"}, {"1999-06-06"}, {"1999-06-06"} } }, { "select max(time('12:30:30')) from t group by t", new String [][] { {"12:30:30"}, {"12:30:30"}, {"12:30:30"} } }, { "select max(timestamp('1999-06-06 12:30:30')) from t group by ts", new String [][] { {"1999-06-06 12:30:30.0"}, {"1999-06-06 12:30:30.0"}, {"1999-06-06 12:30:30.0"} } }, { "select max(i), max(dt), max(b) from t group by i, dt, b", new String [][] { {"0", "1992-01-01", "12af"}, {"0", "1992-01-01", "ffff"}, {"0", "1992-09-09", "12af"}, {"1", "1992-01-01", "12af"}, {null,null,null} } }, { "select l, dt, max(i), max(dt), max(b), i from t group by i, dt, b, l", new String [][] { {"1000000","1992-01-01","0","1992-01-01","12af","0"}, {"2000000","1992-01-01","0","1992-01-01","12af","0"}, {"1000000","1992-01-01","0","1992-01-01","ffff","0"}, {"1000000","1992-09-09","0","1992-09-09","12af","0"}, {"1000000","1992-01-01","1","1992-01-01","12af","1"}, {null,null,null,null,null,null} } }, { "select max(expr1), max(expr2) from (select i * s, c || v from t) t (expr1, expr2) group by expr2, expr1", new String [][] { {"0","duplicate noone is here"}, {"0", "duplicate this is duplicated"}, {"100","duplicate this is duplicated"}, {"0","goodbye this is duplicated"}, {null,null} } }, { "select distinct max(i) from t group by i, dt", new String [][] { {"0"}, {"1"}, {null} } }, { "create table tmp (x int, y char(20))" + getOffHeapSuffix(), null }, { "insert into tmp (x, y) select max(i), max(c) from t", null }, { "select * from tmp", new String [][] { {"1", "goodbye"} } }, { "insert into tmp (x, y) select max(i), max(c) from t group by b", null }, { "select * from tmp", new String [][] { {"1", "goodbye"}, {"1","goodbye"}, {"0", "duplicate"}, {null,null} } }, { "drop table tmp", null }, { "drop table t", null }, { "drop table empty", null }, // MIN { "create table t (i int, s smallint, l bigint,c char(10), v varchar(50), d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, dc decimal(5,2))" + getOffHeapSuffix(), null }, { "create table empty (i int, s smallint, l bigint,c char(10), v varchar(50), d double precision, r real, dt date, t time, ts timestamp,b char(2) for bit data, bv varchar(8) for bit data, dc decimal(5,2))" + getOffHeapSuffix(), null }, { "insert into t (i) values (null)", null }, { "insert into t (i) values (null)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (1, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 200, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 222.22)", null }, { "insert into t values (0, 100, 2000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 222.22)", null }, { "insert into t values (0, 100, 1000000, 'goodbye', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'noone is here', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000,'duplicate', 'this is duplicated', 100.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 100.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-09-09'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:55:55'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:55:55'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'ffff', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'1111111111111111', 111.11)", null }, { "create table t1 (c1 long varchar)" + getOffHeapSuffix(), null }, { "select min(c1) from t1", new String[][] { {null} } }, // GemFireXD allows MAX(LVC) { "drop table t1", null }, { "select min(i) from empty", new String [][] { {null} } }, { "select min(s) from empty", new String [][] { {null} } }, { "select min(l) from empty", new String [][] { {null} } }, { "select min(c) from empty", new String [][] { {null} } }, { "select min(v) from empty", new String [][] { {null} } }, { "select min(d) from empty", new String [][] { {null} } }, { "select min(r) from empty", new String [][] { {null} } }, { "select min(dt) from empty", new String [][] { {null} } }, { "select min(t) from empty", new String [][] { {null} } }, { "select min(ts) from empty", new String [][] { {null} } }, { "select min(b) from empty", new String [][] { {null} } }, { "select min(bv) from empty", new String [][] { {null} } }, { "select min(dc) from empty", new String [][] { {null} } }, { "select min(i), min(b), min(i), min(s) from empty", new String [][] { {null,null,null,null} } }, { "select min(i+1) from empty", new String [][] { {null} } }, { "select min(i) from empty group by i", new String [0][0] }, { "select min(s) from empty group by s", new String [0][0] }, { "select min(l) from empty group by l", new String [0][0] }, { "select min(c) from empty group by c", new String [0][0] }, { "select min(v) from empty group by v", new String [0][0] }, { "select min(d) from empty group by d", new String [0][0] }, { "select min(r) from empty group by r", new String [0][0] }, { "select min(dt) from empty group by dt", new String [0][0] }, { "select min(t) from empty group by t", new String [0][0] }, { "select min(ts) from empty group by ts", new String [0][0] }, { "select min(b) from empty group by b", new String [0][0] }, { "select min(bv) from empty group by bv", new String [0][0] }, { "select min(dc) from empty group by dc", new String [0][0] }, { "select min(i) from t", new String [][] { {"0"} } }, { "select min(s) from t", new String [][] { {"100"} } }, { "select min(l) from t", new String [][] { {"1000000"} } }, { "select min(c) from t", new String [][] { {"duplicate"} } }, { "select min(v) from t", new String [][] { {"noone is here"} } }, { "select min(d) from t", new String [][] { {"100.0"} } }, { "select min(r) from t", new String [][] { {"100.0"} } }, { "select min(dt) from t", new String [][] { {"1992-01-01"} } }, { "select min(t) from t", new String [][] { {"12:30:30"} } }, { "select min(ts) from t", new String [][] { {"1992-01-01 12:30:30.0"} } }, { "select min(b) from t", new String [][] { {"12af"} } }, { "select min(bv) from t", new String [][] { {"0000111100001111"} } }, { "select min(dc) from t", new String [][] { {"111.11"} } }, { "select min(i) from t group by i", new String [][] { {"0"},{"1"},{null} } }, { "select min(s) from t group by s", new String [][] { {"100"}, {"200"}, {null} } }, { "select min(l) from t group by l", new String [][] { {"1000000"}, {"2000000"}, {null} } }, { "select min(c) from t group by c", new String [][] { {"duplicate"}, {"goodbye"}, {null} } }, { "select min(v) from t group by v", new String [][] { {"noone is here"}, {"this is duplicated"}, {null} } }, { "select min(d) from t group by d", new String [][] { {"100.0"}, {"200.0"}, {null} } }, { "select min(r) from t group by r", new String [][] { {"100.0"}, {"200.0"}, {null} } }, { "select min(dt) from t group by dt", new String [][] { {"1992-01-01"}, {"1992-09-09"}, {null} } }, { "select min(t) from t group by t", new String [][] { {"12:30:30"}, {"12:55:55"}, {null} } }, { "select min(ts) from t group by ts", new String [][] { {"1992-01-01 12:30:30.0"}, {"1992-01-01 12:55:55.0"}, {null} } }, { "select min(b) from t group by b", new String [][] { {"12af"}, {"ffff"}, {null} } }, { "select min(bv) from t group by bv", new String [][] { {"0000111100001111"}, {"1111111111111111"}, {null} } }, { "select min(dc) from t group by dc", new String [][] { {"111.11"}, {"222.22"}, {null} } }, { "select min(1) from t", new String [][] { {"1"} } }, { "select min('hello') from t", new String [][] { {"hello"} } }, { "select min(1.1) from t", new String [][] { {"1.1"} } }, { "select min(1e1) from t", new String [][] { {"10.0"} } }, { "select min(X'11') from t", new String [][] { {"11"} } }, { "select min(date('1999-06-06')) from t", new String [][] { {"1999-06-06"} } }, { "select min(time('12:30:30')) from t", new String [][] { {"12:30:30"} } }, { "select min(timestamp('1999-06-06 12:30:30')) from t", new String [][] { {"1999-06-06 12:30:30.0"} } }, { "select min(1) from t group by i", new String [][] { {"1"}, {"1"}, {"1"} } }, { "select min('hello') from t group by c", new String [][] { {"hello"}, {"hello"}, {"hello"} } }, { "select min(1.1) from t group by dc", new String [][] { {"1.1"}, {"1.1"}, {"1.1"} } }, { "select min(1e1) from t group by d", new String [][] { {"10.0"}, {"10.0"}, {"10.0"} } }, { "select min(X'11') from t group by b", new String [][] { {"11"}, {"11"}, {"11"} } }, { "select min(date('1999-06-06')) from t group by dt", new String [][] { {"1999-06-06"}, {"1999-06-06"}, {"1999-06-06"} } }, { "select min(time('12:30:30')) from t group by t", new String [][] { {"12:30:30"}, {"12:30:30"}, {"12:30:30"} } }, { "select min(timestamp('1999-06-06 12:30:30')) from t group by ts", new String [][] { {"1999-06-06 12:30:30.0"}, {"1999-06-06 12:30:30.0"}, {"1999-06-06 12:30:30.0"} } }, { "select min(i), min(dt), min(b) from t group by i, dt, b", new String [][] { {"0", "1992-01-01", "12af"}, {"0", "1992-01-01", "ffff"}, {"0", "1992-09-09", "12af"}, {"1", "1992-01-01", "12af"}, {null,null,null} } }, { "select l, dt, min(i), min(dt), min(b), i from t group by i, dt, b, l", new String [][] { {"1000000","1992-01-01","0","1992-01-01","12af","0"}, {"2000000","1992-01-01","0","1992-01-01","12af","0"}, {"1000000","1992-01-01","0","1992-01-01","ffff","0"}, {"1000000","1992-09-09","0","1992-09-09","12af","0"}, {"1000000","1992-01-01","1","1992-01-01","12af","1"}, {null,null,null,null,null,null} } }, { "select min(expr1), min(expr2) from (select i * s, c || v from t) t (expr1, expr2) group by expr2, expr1", new String [][] { {"0","duplicate noone is here"}, {"0","duplicate this is duplicated"}, {"100","duplicate this is duplicated"}, {"0","goodbye this is duplicated"}, {null,null} } }, { "select distinct min(i) from t group by i, dt", new String [][] { {"0"}, {"1"}, {null} } }, { "create table tmp (x int, y char(20))" + getOffHeapSuffix(), null }, { "insert into tmp (x, y) select min(i), min(c) from t", null }, { "select * from tmp", new String [][] { {"0","duplicate"} } }, { "insert into tmp (x, y) select min(i), min(c) from t group by b", null }, { "select * from tmp", new String [][] { {"0","duplicate"}, {"0","duplicate"}, {"0","duplicate"}, {null,null} } }, { "drop table tmp", null}, { "drop table t", null}, { "drop table empty", null} }; // Do not use partitioning as default, use replicate // (Some results are expected to be different with partitioning) skipDefaultPartitioned = true; Connection conn = TestUtil.getConnection(); Statement stmt = conn.createStatement(); // Go through the array, execute each string[0], check sqlstate [1] // This will fail on the first one that succeeds where it shouldn't // or throws unknown exception JDBC.SQLUnitTestHelper(stmt,Script_AggBuiltInUT); } // This test is the script enhanced with partitioning public void testLangScript_AggBuiltInWithPartitioning() throws Exception { // This form of the aggbuiltin.sql test has partitioning clauses Object[][] Script_AggBuiltInUTPartitioning = { // create an all types tables { "create table t (i int, s smallint, l bigint, c char(10), v varchar(50), lvc long varchar, d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, lbv long varchar for bit data, dc decimal(5,2)) partition by column(i)" + getOffHeapSuffix(), null}, { "create table empty (i int, s smallint, l bigint, c char(10), v varchar(50), lvc long varchar, d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, lbv long varchar for bit data, dc decimal(5,2)) partition by column(i)" + getOffHeapSuffix(), null}, { "insert into t (i) values (null)", null}, { "insert into t (i) values (null)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', x'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (1, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 200, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 222.22)", null}, { "insert into t values (0, 100, 2000000, 'duplicate', 'this is duplicated', 'also duplicated', date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 222.22)", "42802"}, { "insert into t values (0, 100, 1000000, 'goodbye', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'noone is here', 'jimmie noone was here', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 100.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 100.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-09-09'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:55:55'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:55:55'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'ffff', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'1111111111111111', X'1234', 111.11)", null}, // cannot aggregate datatypes that don't support NumberDataValue { "select avg(c) from t", "42Y22"}, { "select avg(v) from t", "42Y22"}, { "select avg(lvc) from t", "42Y22"}, { "select avg(dt) from t", "42Y22"}, { "select avg(t) from t", "42Y22"}, { "select avg(ts) from t", "42Y22"}, { "select avg(b) from t", "42Y22"}, { "select avg(bv) from t", "42Y22"}, { "select avg(lbv) from t", "42Y22"}, { "select avg(c) from t group by c", "42Y22"}, { "select avg(v) from t group by c", "42Y22"}, { "select avg(lvc) from t group by c", "42Y22"}, { "select avg(dt) from t group by c", "42Y22"}, { "select avg(t) from t group by c", "42Y22"}, { "select avg(ts) from t group by c", "42Y22"}, { "select avg(b) from t group by c", "42Y22"}, { "select avg(bv) from t group by c", "42Y22"}, { "select avg(lbv) from t group by c", "42Y22"}, // long varchar datatypes too { "create table t1 (c1 long varchar) partition by column(c1)" + getOffHeapSuffix(), null }, { "select avg(c1) from t1", "42Y22" }, { "drop table t1", null }, // constants { "select avg('hello') from t", "42Y22" }, { "select avg(X'11') from t", "42Y22" }, { "select avg(date('1999-06-06')) from t", "42Y22" }, { "select avg(time('12:30:30')) from t", "42Y22" }, { "select avg(timestamp('1999-06-06 12:30:30')) from t", "42Y22" }, // NULL AGGREGATION { "select avg(i) from empty", new String [][] { {null} } }, { "select avg(s) from empty", new String [][] { {null} } }, { "select avg(d) from empty", new String [][] { {null} } }, { "select avg(l) from empty", new String [][] { {null} } }, { "select avg(r) from empty", new String [][] { {null} } }, { "select avg(dc) from empty", new String [][] { {null} } }, { "select avg(i), avg(s), avg(r), avg(l) from empty", new String [][] { {null,null,null,null} } }, { "select avg(i+1) from empty", new String [][] { {null} } }, { "select avg(i) from empty group by i", new String[0][0] }, { "select avg(s) from empty group by s", new String[0][0] }, { "select avg(d) from empty group by d", new String[0][0] }, { "select avg(l) from empty group by l", new String[0][0] }, { "select avg(r) from empty group by r", new String[0][0] }, { "select avg(dc) from empty group by dc", new String[0][0] }, // BASIC ACCEPTANCE TESTS { "select avg(i) from t", new String [][] { {"0"} } }, // ignore the WARNINGs given { "select avg(s) from t", new String [][] { {"107"} } }, { "select avg(d) from t", new String [][] { {"192.85714285714286"} } }, { "select avg(l) from t", new String [][] { {"1000000"} } }, { "select avg(r) from t", new String [][] { {"192.85714285714286"} } }, { "select avg(dc) from t", new String [][] { {"119.0464"} } }, { "select avg(i) from t group by i", new String [][] { {"0"}, {"1"}, {null} } }, { "select avg(s) from t group by s", new String [][] { {"100"}, {"200"}, {null} } }, { "select avg(d) from t group by d", new String [][] { {"100.0"}, {"200.0"}, {null} } }, { "select avg(l) from t group by l", new String [][] { {"1000000"}, {null} } }, { "select avg(r) from t group by r", new String [][] { {"100.0"}, {"200.0"}, {null} } }, { "select avg(dc), sum(dc), count(dc) from t group by dc", new String [][] { {"111.1100","1444.43","13"}, {"222.2200","222.22","1"}, {null,null,"0"} } }, // -- constants { "select avg(1) from t", new String [][] { {"1"} } }, // FIXME // If these statements all have one space between AVG() call and FROM, they reuse same prepared statement // and throw casting error. Only happens with prepared statements, not on GFXD { "select avg(1.1) from t", new String [][] { {"1.1000"} } }, { "select avg(1e1) from t", new String [][] { {"10.0"} } }, { "select avg(1) from t group by i", new String [][] { {"1"},{"1"},{"1"} } }, { "select avg(1.1) from t group by r", new String [][] { {"1.1000"},{"1.1000"},{"1.1000"} } }, { "select avg(1e1) from t group by r", new String [][] { {"10.0"},{"10.0"},{"10.0"} } }, // multicolumn grouping { "select avg(i), avg(l), avg(r) from t group by i, dt, b", new String [][] { {"0","1000000","190.9090909090909"}, {"0","1000000","200.0"}, {"0","1000000","200.0"}, {"1","1000000","200.0"}, {null, null, null} } }, { "select i, dt, avg(i), avg(r), avg(l), l from t group by i, dt, b, l", new String [][] { {"0","1992-01-01","0","190.9090909090909","1000000","1000000"}, {"0","1992-01-01","0","200.0","1000000","1000000"}, {"0","1992-09-09","0","200.0","1000000","1000000"}, {"1","1992-01-01","1","200.0","1000000","1000000"}, {null, null, null, null, null, null} } }, { "select avg(expr1), avg(expr2) from (select i * s, r * 2 from t) t (expr1, expr2) group by expr2, expr1", new String [][] { {"0","200.0"}, {"0","400.0"}, {"100","400.0"}, {null,null} } }, { "select distinct avg(i) from t group by i, dt", new String[][] { {"0"},{"1"},{null} } }, { "create table tmp (x int, y smallint) partition by column(x)" + getOffHeapSuffix(), null }, { "insert into tmp (x, y) select avg(i), avg(s) from t", null }, { "select * from tmp", new String [][] { {"0","107"} } }, { "insert into tmp (x, y) select avg(i), avg(s) from t group by b", null }, { "select * from tmp", new String [][] { {"0","107"}, {"0","107"}, {"0","100"}, {null,null} } }, { "drop table tmp", null }, { "create table tmp (x int) partition by column(x)" + getOffHeapSuffix(), null }, { "insert into tmp values (2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647)", null }, { "select avg(x) from tmp", new String [][] { {"2147483647"} } }, { "select avg(-(x - 1)) from tmp", new String [][] { {"-2147483646"} } }, { "select avg(x) from tmp group by x", new String [][] { {"2147483647"} } }, { "select avg(-(x - 1)) from tmp group by x", new String [][] { {"-2147483646"} } }, { "drop table tmp", null}, { "create table tmp(x double precision, y int) partition by column(x)" + getOffHeapSuffix(), null }, { "insert into tmp values (1,1)", null }, { "select avg(x) from tmp", new String [][] { {"1.0" } } }, { "select avg(x) from tmp group by y", new String [][] { {"1.0"} } }, { "insert into tmp values (2,1)", null }, { "select avg(x) from tmp", new String [][] { {"1.5" } } }, { "select avg(x) from tmp group by y", new String [][] { {"1.5"} } }, { "insert into tmp values (3,1)", null }, { "select avg(x) from tmp", new String [][] { {"2.0" } } }, { "select avg(x) from tmp group by y", new String [][] { {"2.0"} } }, { "insert into tmp values (4,1)", null }, { "select avg(x) from tmp", new String [][] { {"2.5" } } }, { "select avg(x) from tmp group by y", new String [][] { {"2.5"} } }, { "insert into tmp values (5,1)", null }, { "select avg(x) from tmp", new String [][] { {"3.0" } } }, { "select avg(x) from tmp group by y", new String [][] { {"3.0"} } }, { "insert into tmp values (6,1)", null }, { "select avg(x) from tmp", new String [][] { {"3.5" } } }, { "select avg(x) from tmp group by y", new String [][] { {"3.5"} } }, { "insert into tmp values (7,1)", null }, { "select avg(x) from tmp", new String [][] { {"4.0" } } }, { "select avg(x) from tmp group by y", new String [][] { {"4.0"} } }, { "insert into tmp values (10000,1)", null }, { "select avg(x) from tmp", new String [][] { {"1253.5" } } }, { "select avg(x) from tmp group by y", new String [][] { {"1253.5"} } }, { "drop table tmp", null }, { "drop table t", null }, { "drop table empty", null }, // COUNT { "create table t (i int, s smallint, l bigint, c char(10), v varchar(50), lvc long varchar, d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, lbv long varchar for bit data, dc decimal(5,2)) partition by column(i)" + getOffHeapSuffix(), null}, { "create table empty (i int, s smallint, l bigint, c char(10), v varchar(50), lvc long varchar, d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, lbv long varchar for bit data, dc decimal(5,2)) partition by column(i)" + getOffHeapSuffix(), null}, { "insert into t (i) values (null)", null}, { "insert into t (i) values (null)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', x'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (1, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 200, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 222.22)", null}, { "insert into t values (0, 100, 2000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 222.22)", null}, { "insert into t values (0, 100, 1000000, 'goodbye', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'noone is here', 'jimmie noone was here', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 100.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 100.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-09-09'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:55:55'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:55:55'), X'12af', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'ffff', X'0000111100001111', X'1234', 111.11)", null}, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'1111111111111111', X'1234', 111.11)", null}, // NULL AGGREGATION { "select count(i) from empty", new String [][] { {"0" } } }, { "select count(s) from empty", new String [][] { {"0" } } }, { "select count(l) from empty", new String [][] { {"0" } } }, { "select count(c) from empty", new String [][] { {"0" } } }, { "select count(v) from empty", new String [][] { {"0" } } }, { "select count(lvc) from empty", new String [][] { {"0" } } }, { "select count(d) from empty", new String [][] { {"0" } } }, { "select count(r) from empty", new String [][] { {"0" } } }, { "select count(dt) from empty", new String [][] { {"0" } } }, { "select count(t) from empty", new String [][] { {"0" } } }, { "select count(ts) from empty", new String [][] { {"0" } } }, { "select count(b) from empty", new String [][] { {"0" } } }, { "select count(bv) from empty", new String [][] { {"0" } } }, { "select count(lbv) from empty", new String [][] { {"0" } } }, { "select count(dc) from empty", new String [][] { {"0" } } }, { "select count(i), count(b), count(i), count(s) from empty", new String [][] { {"0","0","0","0"} } }, { "select count(i+1) from empty", new String [][] { {"0"} } }, { "select count(i) from empty group by i", new String [0][0] }, { "select count(s) from empty group by s", new String [0][0] }, { "select count(l) from empty group by l", new String [0][0] }, { "select count(c) from empty group by c", new String [0][0] }, { "select count(v) from empty group by v", new String [0][0] }, { "select count(d) from empty group by d", new String [0][0] }, { "select count(r) from empty group by r", new String [0][0] }, { "select count(dt) from empty group by dt", new String [0][0] }, { "select count(t) from empty group by t", new String [0][0] }, { "select count(ts) from empty group by ts", new String [0][0] }, { "select count(b) from empty group by b", new String [0][0] }, { "select count(bv) from empty group by bv", new String [0][0] }, { "select count(lbv) from empty group by lbv", "X0X67" }, { "select count(dc) from empty group by dc", new String [0][0] }, { "select count(i) from t", new String [][] { {"15"} } }, { "select count(s) from t", new String [][] { {"15"} } }, { "select count(l) from t", new String [][] { {"15"} } }, { "select count(c) from t", new String [][] { {"15"} } }, { "select count(v) from t", new String [][] { {"15"} } }, { "select count(lvc) from t", new String [][] { {"15"} } }, { "select count(d) from t", new String [][] { {"15"} } }, { "select count(r) from t", new String [][] { {"15"} } }, { "select count(dt) from t", new String [][] { {"15"} } }, { "select count(t) from t", new String [][] { {"15"} } }, { "select count(ts) from t", new String [][] { {"15"} } }, { "select count(b) from t", new String [][] { {"15"} } }, { "select count(bv) from t", new String [][] { {"15"} } }, { "select count(lbv) from t", new String [][] { {"15"} } }, { "select count(dc) from t", new String [][] { {"15"} } }, { "select count(i) from t group by i", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(s) from t group by s", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(l) from t group by l", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(c) from t group by c", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(v) from t group by v", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(d) from t group by d", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(r) from t group by r", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(dt) from t group by dt", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(t) from t group by t", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(ts) from t group by ts", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(b) from t group by b", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(bv) from t group by bv", new String [][] { {"14"}, {"1"}, {"0"} } }, { "select count(lbv) from t group by lbv", "X0X67" }, { "select count(dc) from t group by dc", new String [][] { {"13"}, {"2"}, {"0"} } }, { "select count(1) from t", new String[][] { {"17"} } }, { "select count('hello') from t", new String[][] { {"17"} } }, { "select count(1.1) from t", new String[][] { {"17"} } }, { "select count(1e1) from t", new String[][] { {"17"} } }, { "select count(X'11') from t", new String[][] { {"17"} } }, { "select count(date('1999-06-06')) from t", new String[][] { {"17"} } }, { "select count(time('12:30:30')) from t", new String[][] { {"17"} } }, { "select count(timestamp('1999-06-06 12:30:30')) from t", new String[][] { {"17"} } }, { "select count(1) from t group by i", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count('hello') from t group by c", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count(1.1) from t group by dc", new String[][] { {"13"}, {"2"}, {"2"} } }, { "select count(1e1) from t group by r", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count(X'11') from t group by b", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count(date('1999-06-06')) from t group by dt", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count(time('12:30:30')) from t group by t", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count(timestamp('1999-06-06 12:30:30')) from t group by ts", new String[][] { {"14"}, {"1"}, {"2"} } }, { "select count(i), count(dt), count(b) from t group by i, dt, b", new String[][] { {"12","12","12"}, {"1","1","1"}, {"1","1","1"}, {"1","1","1"}, {"0","0","0"} } }, { "select l, dt, count(i), count(dt), count(b), i from t group by i, dt, b, l", new String [][] { {"1000000", "1992-01-01", "11", "11", "11", "0"}, {"2000000", "1992-01-01", "1", "1", "1", "0"}, {"1000000", "1992-01-01", "1", "1", "1", "0"}, {"1000000", "1992-09-09", "1", "1", "1", "0"}, {"1000000", "1992-01-01", "1", "1", "1", "1"}, {null,null,"0","0","0",null} } }, { "select count(expr1), count(expr2) from (select i * s, c || v from t) t (expr1, expr2) group by expr2, expr1", new String [][] { {"1", "1"}, {"12", "12"}, {"1","1"}, {"1","1"}, {"0","0"} } }, { "select distinct count(i) from t group by i, dt", new String [][] { {"0"}, {"1"}, {"13"} } }, { "create table tmp (x int, y smallint) partition by column(x)" + getOffHeapSuffix(), null }, { "insert into tmp (x, y) select count(i), count(c) from t", null }, { "select * from tmp", new String [][] { {"15", "15"} } }, { "insert into tmp (x, y) select count(i), count(c) from t group by b", null }, { "select * from tmp", new String [][] { {"15", "15"}, {"14", "14"}, {"1", "1"}, {"0","0"} } }, { "drop table tmp", null }, { "drop table t", null }, { "drop table empty", null }, // Test the COUNT() aggregate { "create table t (i int, s smallint, l bigint, c char(10), v varchar(50), lvc long varchar, d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, lbv long varchar for bit data) partition by column(i)" + getOffHeapSuffix(), null }, { "create table empty (i int, s smallint, l bigint, c char(10), v varchar(50), lvc long varchar, d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, lbv long varchar for bit data) partition by column(i)" + getOffHeapSuffix(), null }, { "insert into t (i) values (null)", null }, { "insert into t (i) values (null)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (1, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 200, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 2000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'goodbye', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'noone is here', 'jimmie noone was here', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 100.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 100.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-09-09'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:55:55'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:55:55'), X'12af', X'0000111100001111', X'ABCD')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'ffff', X'0000111100001111', X'1234')", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 'also duplicated',200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'1111111111111111', X'ABCD')", null }, { "select count(*) from empty", new String [][] { {"0"} } }, { "select count(*), count(*) from empty", new String [][] { {"0","0"} } }, { "select count(*) from empty group by i", new String [0][0] }, { "select count(*) from t", new String [][] { {"17"} } }, { "select count(*) from t group by i", new String [][] { {"14"}, {"1"}, {"2"} } }, { "select count(*), count(*), count(*) from t group by i, dt, b", new String[][] { {"12","12","12"}, {"1","1","1"}, {"1","1","1"}, {"1","1","1"}, {"2","2","2"} } }, { "select count(*), count(*) from (select i * s, c || v from t) t (expr1, expr2) group by expr2, expr1", new String [][] { {"1","1"}, {"12","12"}, {"1","1"}, {"1","1"}, {"2","2"} } }, { "select distinct count(*) from t group by i, dt", new String [][] { {"1"}, {"2"}, {"13"} } }, { "create view v1 as select * from t", null }, { "select count(*) from v1", new String [][] { {"17"} } }, { "select count(*)+count(*) from v1", new String [][] { {"34"} } }, { "drop view v1", null }, { "create table tmp (x int, y smallint) partition by column(x)" + getOffHeapSuffix(), null }, { "insert into tmp (x, y) select count(*), count(*) from t", null }, { "select * from tmp", new String [][] { {"17","17"} } }, { "insert into tmp (x, y) select count(*), count(*) from t group by b", null }, { "select * from tmp", new String [][] { {"17","17"}, {"14","14"}, {"1","1"}, {"2","2"} } }, { "drop table tmp", null }, { "drop table t", null }, { "drop table empty", null }, // SUM { "create table t (i int, s smallint, l bigint, c char(10), v varchar(50), d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, dc decimal(5,2)) partition by column(i)" + getOffHeapSuffix(), null }, { "create table empty (i int, s smallint, l bigint, c char(10), v varchar(50), d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, dc decimal(5,2)) partition by column(i)" + getOffHeapSuffix(), null }, { "insert into t (i) values (null)", null }, { "insert into t (i) values (null)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (1, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 200, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 222.22)", null }, { "insert into t values (0, 100, 2000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 222.22)", null }, { "insert into t values (0, 100, 1000000,'goodbye', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'noone is here', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000,'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'),X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000,'duplicate', 'this is duplicated', 100.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000,'duplicate', 'this is duplicated', 200.0e0, 100.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-09-09'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:55:55'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:55:55'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'ffff', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'1111111111111111', 111.11)", null }, // cannot aggregate datatypes that don't support NumberDataValue { "select sum(c) from t", "42Y22" }, { "select sum(v) from t", "42Y22" }, { "select sum(dt) from t", "42Y22" }, { "select sum(t) from t", "42Y22" }, { "select sum(ts) from t", "42Y22" }, { "select sum(b) from t", "42Y22" }, { "select sum(bv) from t", "42Y22" }, { "select sum(c) from t group by c", "42Y22" }, { "select sum(v) from t group by c", "42Y22" }, { "select sum(dt) from t group by c", "42Y22" }, { "select sum(t) from t group by c", "42Y22" }, { "select sum(ts) from t group by c", "42Y22" }, { "select sum(b) from t group by c", "42Y22" }, { "select sum(bv) from t group by c", "42Y22" }, { "create table t1 (c1 long varchar) partition by column(c1)" + getOffHeapSuffix(), null }, { "select sum(c1) from t1", "42Y22" }, { "drop table t1", null }, // constants { "select sum('hello') from t", "42Y22" }, { "select sum(X'11') from t", "42Y22" }, { "select sum(date('1999-06-06')) from t", "42Y22" }, { "select sum(time('12:30:30')) from t", "42Y22" }, { "select sum(timestamp('1999-06-06 12:30:30')) from t", "42Y22" }, { "select sum(i) from empty", new String [][] { {null} } }, { "select sum(s) from empty", new String [][] { {null} } }, { "select sum(d) from empty", new String [][] { {null} } }, { "select sum(l) from empty", new String [][] { {null} } }, { "select sum(r) from empty", new String [][] { {null} } }, { "select sum(dc) from empty", new String [][] { {null} } }, { "select sum(i), sum(s), sum(r), sum(l) from empty", new String [][] { {null,null,null,null} } }, { "select sum(i+1) from empty", new String [][] { {null} } }, { "select sum(i) from empty group by i", new String [0][0] }, { "select sum(s) from empty group by s", new String [0][0] }, { "select sum(d) from empty group by d", new String [0][0] }, { "select sum(l) from empty group by l", new String [0][0] }, { "select sum(r) from empty group by r", new String [0][0] }, { "select sum(dc) from empty group by dc", new String [0][0] }, { "select sum(i) from t", new String [][] { {"1"} } }, { "select sum(s) from t", new String [][] { {"1600"} } }, { "select sum(d) from t", new String [][] { {"2900.0"} } }, { "select sum(l) from t", new String [][] { {"16000000"} } }, { "select sum(r) from t", new String [][] { {"2900.0"} } }, { "select sum(dc) from t", new String [][] { {"1888.87"} } }, { "select sum(i) from t group by i", new String [][] { {"0"}, {"1"}, {null} } }, { "select sum(s) from t group by s", new String [][] { {"1400"}, {"200"}, {null} } }, { "select sum(d) from t group by d", new String [][] { {"100.0"}, {"2800.0"}, {null} } }, { "select sum(l) from t group by l", new String [][] { {"14000000"}, {"2000000"}, {null} } }, { "select sum(r) from t group by r", new String [][] { {"100.0"}, {"2800.0"}, {null} } }, { "select sum(dc) from t group by dc", new String [][] { {"1444.43"}, {"444.44"}, {null} } }, { "select sum(1) from t", new String [][] { {"17"} } }, { "select sum(1.1) from t", new String [][] { {"18.7"} } }, { "select sum(1e1) from t", new String [][] { {"170.0"} } }, { "select sum(1) from t group by i", new String [][] { {"14"}, {"1"}, {"2"} } }, { "select sum(1.1) from t group by r", new String [][] { {"1.1"}, {"15.4"}, {"2.2"} } }, { "select sum(1e1) from t group by r", new String [][] { {"10.0"}, {"140.0"}, {"20.0"} } }, { "select sum(i), sum(l), sum(r) from t group by i, dt, b", new String [][] { {"0","13000000", "2300.0"}, {"0","1000000", "200.0"}, {"0","1000000", "200.0"}, {"1","1000000", "200.0"}, {null,null,null} } }, { "select i, dt, sum(i), sum(r), sum(l), l from t group by i, dt, b, l", new String [][] { {"0","1992-01-01","0","2100.0","11000000", "1000000"}, {"0","1992-01-01","0","200.0","2000000", "2000000"}, {"0","1992-01-01","0","200.0","1000000", "1000000"}, {"0","1992-09-09","0","200.0","1000000", "1000000"}, {"1","1992-01-01","1","200.0","1000000", "1000000"}, {null,null,null,null,null,null} } }, { "select sum(expr1), sum(expr2) from (select i * s, r * 2 from t) t (expr1, expr2) group by expr2, expr1", new String [][] { {"0","200.0"}, {"0","5200.0"}, {"100","400.0"}, {null,null} } }, { "select distinct sum(i) from t group by i, dt", new String [][] { {"0"}, {"1"}, {null} } }, { "create table tmp (x int, y smallint) partition by column(x)" + getOffHeapSuffix(), null }, { "insert into tmp (x, y) select sum(i), sum(s) from t", null }, { "select * from tmp", new String [][] { {"1", "1600"} } }, { "insert into tmp (x, y) select sum(i), sum(s) from t group by b", null }, { "select * from tmp", new String [][] { {"1", "1600"}, {"1", "1500"}, {"0", "100"}, {null,null} } }, { "drop table tmp", null }, // overflow { "create table tmp (x int) partition by column(x)" + getOffHeapSuffix(), null }, { "insert into tmp values (2147483647),(2147483647)", null }, // FIXME // This does not return an overflow, it returns results! GFXD command line returns an overflow (22003) error as expected //{ "select sum(x) from tmp", "22003"}, { "drop table tmp", null }, { "create table tmp (x double precision) partition by column(x)" + getOffHeapSuffix(), null }, { "insert into tmp values (2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647),(2147483647), (2147483647),(2147483647)", null }, { "select sum(x) from tmp", new String [][] { {"1.9327352823E10"} } }, { "drop table tmp", null }, { "drop table t", null }, { "drop table empty", null }, // MAX { "create table t (i int, s smallint, l bigint, c char(10), v varchar(50), d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, dc decimal(5,2)) partition by column(i)" + getOffHeapSuffix(), null }, { "create table empty (i int, s smallint, l bigint,c char(10), v varchar(50), d double precision, r real, dt date, t time, ts timestamp,b char(2) for bit data, bv varchar(8) for bit data, dc decimal(5,2)) partition by column(i)" + getOffHeapSuffix(), null }, { "insert into t (i) values (null)", null }, { "insert into t (i) values (null)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (1, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 200, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 222.22)", null }, { "insert into t values (0, 100, 2000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 222.22)", null }, { "insert into t values (0, 100, 1000000, 'goodbye', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'noone is here', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 100.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 100.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-09-09'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:55:55'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:55:55'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'ffff', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'1111111111111111', 111.11)", null }, { "create table t1 (c1 long varchar) partition by column(c1)" + getOffHeapSuffix(), null }, { "select max(c1) from t1", new String[][] { {null} } }, // GemFireXD allows MAX(LVC) { "drop table t1", null }, { "select max(i) from empty", new String [][] { {null} } }, { "select max(s) from empty", new String [][] { {null} } }, { "select max(l) from empty", new String [][] { {null} } }, { "select max(c) from empty", new String [][] { {null} } }, { "select max(v) from empty", new String [][] { {null} } }, { "select max(d) from empty", new String [][] { {null} } }, { "select max(r) from empty", new String [][] { {null} } }, { "select max(dt) from empty", new String [][] { {null} } }, { "select max(t) from empty", new String [][] { {null} } }, { "select max(ts) from empty", new String [][] { {null} } }, { "select max(b) from empty", new String [][] { {null} } }, { "select max(bv) from empty", new String [][] { {null} } }, { "select max(dc) from empty", new String [][] { {null} } }, { "select max(i), max(b), max(i), max(s) from empty", new String [][] { {null,null,null,null} } }, { "select max(i+1) from empty", new String [][] { {null} } }, { "select max(i) from empty group by i", new String[0][0] }, { "select max(s) from empty group by s", new String[0][0] }, { "select max(l) from empty group by l", new String[0][0] }, { "select max(c) from empty group by c", new String[0][0] }, { "select max(v) from empty group by v", new String[0][0] }, { "select max(d) from empty group by d", new String[0][0] }, { "select max(r) from empty group by r", new String[0][0] }, { "select max(dt) from empty group by dt", new String[0][0] }, { "select max(t) from empty group by t", new String[0][0] }, { "select max(ts) from empty group by ts", new String[0][0] }, { "select max(b) from empty group by b", new String[0][0] }, { "select max(bv) from empty group by bv", new String[0][0] }, { "select max(dc) from empty group by dc", new String[0][0] }, { "select max(i) from t", new String [][] { {"1"} } }, { "select max(s) from t", new String [][] { {"200"} } }, { "select max(l) from t", new String [][] { {"2000000"} } }, { "select max(c) from t", new String [][] { {"goodbye"} } }, { "select max(v) from t", new String [][] { {"this is duplicated"} } }, { "select max(d) from t", new String [][] { {"200.0"} } }, { "select max(r) from t", new String [][] { {"200.0"} } }, { "select max(dt) from t", new String [][] { {"1992-09-09"} } }, { "select max(t) from t", new String [][] { {"12:55:55"} } }, { "select max(ts) from t", new String [][] { {"1992-01-01 12:55:55.0"} } }, { "select max(b) from t", new String [][] { {"ffff"} } }, { "select max(bv) from t", new String [][] { {"1111111111111111"} } }, { "select max(dc) from t", new String [][] { {"222.22"} } }, { "select max(i) from t group by i", new String [][] { {"0"}, {"1"}, {null} } }, { "select max(s) from t group by s", new String [][] { {"100"}, {"200"}, {null} } }, { "select max(l) from t group by l", new String [][] { {"1000000"}, {"2000000"}, {null} } }, { "select max(c) from t group by c", new String [][] { {"duplicate"}, {"goodbye"}, {null} } }, { "select max(v) from t group by v", new String [][] { {"noone is here"}, {"this is duplicated"}, {null} } }, { "select max(d) from t group by d", new String [][] { {"100.0"}, {"200.0"}, {null} } }, { "select max(r) from t group by r", new String [][] { {"100.0"}, {"200.0"}, {null} } }, { "select max(dt) from t group by dt", new String [][] { {"1992-01-01"}, {"1992-09-09"}, {null } } }, { "select max(t) from t group by t", new String [][] { {"12:30:30"}, {"12:55:55"}, {null} } }, { "select max(ts) from t group by ts", new String [][] { {"1992-01-01 12:30:30.0"}, {"1992-01-01 12:55:55.0"}, {null} } }, { "select max(b) from t group by b", new String [][] { {"12af"}, {"ffff"}, {null} } }, { "select max(bv) from t group by bv", new String [][] { {"0000111100001111"}, {"1111111111111111"}, {null} } }, { "select max(dc) from t group by dc", new String [][] { {"111.11"}, {"222.22"}, {null} } }, { "select max(1) from t", new String [][] { {"1"} } }, { "select max('hello') from t", new String [][] { {"hello"} } }, { "select max(1.1) from t", new String [][] { {"1.1"} } }, { "select max(1e1) from t", new String [][] { {"10.0"} } }, { "select max(X'11') from t", new String [][] { {"11"} } }, { "select max(date('1999-06-06')) from t", new String [][] { {"1999-06-06"} } }, { "select max(time('12:30:30')) from t", new String [][] { {"12:30:30"} } }, { "select max(timestamp('1999-06-06 12:30:30')) from t", new String [][] { {"1999-06-06 12:30:30.0"} } }, { "select max(1) from t group by i", new String [][] { {"1"}, {"1"}, {"1"} } }, { "select max('hello') from t group by c", new String [][] { {"hello"}, {"hello"}, {"hello"} } }, { "select max(1.1) from t group by dc", new String [][] { {"1.1"}, {"1.1"}, {"1.1"} } }, { "select max(1e1) from t group by d", new String [][] { {"10.0"}, {"10.0"}, {"10.0"} } }, { "select max(X'11') from t group by b", new String [][] { {"11"}, {"11"}, {"11"} } }, { "select max(date('1999-06-06')) from t group by dt", new String [][] { {"1999-06-06"}, {"1999-06-06"}, {"1999-06-06"} } }, { "select max(time('12:30:30')) from t group by t", new String [][] { {"12:30:30"}, {"12:30:30"}, {"12:30:30"} } }, { "select max(timestamp('1999-06-06 12:30:30')) from t group by ts", new String [][] { {"1999-06-06 12:30:30.0"}, {"1999-06-06 12:30:30.0"}, {"1999-06-06 12:30:30.0"} } }, { "select max(i), max(dt), max(b) from t group by i, dt, b", new String [][] { {"0", "1992-01-01", "12af"}, {"0", "1992-01-01", "ffff"}, {"0", "1992-09-09", "12af"}, {"1", "1992-01-01", "12af"}, {null,null,null} } }, { "select l, dt, max(i), max(dt), max(b), i from t group by i, dt, b, l", new String [][] { {"1000000","1992-01-01","0","1992-01-01","12af","0"}, {"2000000","1992-01-01","0","1992-01-01","12af","0"}, {"1000000","1992-01-01","0","1992-01-01","ffff","0"}, {"1000000","1992-09-09","0","1992-09-09","12af","0"}, {"1000000","1992-01-01","1","1992-01-01","12af","1"}, {null,null,null,null,null,null} } }, { "select max(expr1), max(expr2) from (select i * s, c || v from t) t (expr1, expr2) group by expr2, expr1", new String [][] { {"0","duplicate noone is here"}, {"0", "duplicate this is duplicated"}, {"100","duplicate this is duplicated"}, {"0","goodbye this is duplicated"}, {null,null} } }, { "select distinct max(i) from t group by i, dt", new String [][] { {"0"}, {"1"}, {null} } }, { "create table tmp (x int, y char(20)) partition by column(x)" + getOffHeapSuffix(), null }, { "insert into tmp (x, y) select max(i), max(c) from t", null }, { "select * from tmp", new String [][] { {"1", "goodbye"} } }, { "insert into tmp (x, y) select max(i), max(c) from t group by b", null }, { "select * from tmp", new String [][] { {"1", "goodbye"}, {"1","goodbye"}, {"0", "duplicate"}, {null,null} } }, { "drop table tmp", null }, { "drop table t", null }, { "drop table empty", null }, // MIN { "create table t (i int, s smallint, l bigint,c char(10), v varchar(50), d double precision, r real, dt date, t time, ts timestamp, b char(2) for bit data, bv varchar(8) for bit data, dc decimal(5,2)) partition by column(i)" + getOffHeapSuffix(), null }, { "create table empty (i int, s smallint, l bigint,c char(10), v varchar(50), d double precision, r real, dt date, t time, ts timestamp,b char(2) for bit data, bv varchar(8) for bit data, dc decimal(5,2)) partition by column(i)" + getOffHeapSuffix(), null }, { "insert into t (i) values (null)", null }, { "insert into t (i) values (null)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (1, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 200, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 222.22)", null }, { "insert into t values (0, 100, 2000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 222.22)", null }, { "insert into t values (0, 100, 1000000, 'goodbye', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'noone is here', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000,'duplicate', 'this is duplicated', 100.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 100.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-09-09'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:55:55'), timestamp('1992-01-01 12:30:30'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:55:55'), X'12af', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'ffff', X'0000111100001111', 111.11)", null }, { "insert into t values (0, 100, 1000000, 'duplicate', 'this is duplicated', 200.0e0, 200.0e0, date('1992-01-01'), time('12:30:30'), timestamp('1992-01-01 12:30:30'), X'12af', X'1111111111111111', 111.11)", null }, { "create table t1 (c1 long varchar) partition by column(c1)" + getOffHeapSuffix(), null }, { "select min(c1) from t1", new String[][] { {null} } }, // GemFireXD allows MAX(LVC) { "drop table t1", null }, { "select min(i) from empty", new String [][] { {null} } }, { "select min(s) from empty", new String [][] { {null} } }, { "select min(l) from empty", new String [][] { {null} } }, { "select min(c) from empty", new String [][] { {null} } }, { "select min(v) from empty", new String [][] { {null} } }, { "select min(d) from empty", new String [][] { {null} } }, { "select min(r) from empty", new String [][] { {null} } }, { "select min(dt) from empty", new String [][] { {null} } }, { "select min(t) from empty", new String [][] { {null} } }, { "select min(ts) from empty", new String [][] { {null} } }, { "select min(b) from empty", new String [][] { {null} } }, { "select min(bv) from empty", new String [][] { {null} } }, { "select min(dc) from empty", new String [][] { {null} } }, { "select min(i), min(b), min(i), min(s) from empty", new String [][] { {null,null,null,null} } }, { "select min(i+1) from empty", new String [][] { {null} } }, { "select min(i) from empty group by i", new String [0][0] }, { "select min(s) from empty group by s", new String [0][0] }, { "select min(l) from empty group by l", new String [0][0] }, { "select min(c) from empty group by c", new String [0][0] }, { "select min(v) from empty group by v", new String [0][0] }, { "select min(d) from empty group by d", new String [0][0] }, { "select min(r) from empty group by r", new String [0][0] }, { "select min(dt) from empty group by dt", new String [0][0] }, { "select min(t) from empty group by t", new String [0][0] }, { "select min(ts) from empty group by ts", new String [0][0] }, { "select min(b) from empty group by b", new String [0][0] }, { "select min(bv) from empty group by bv", new String [0][0] }, { "select min(dc) from empty group by dc", new String [0][0] }, { "select min(i) from t", new String [][] { {"0"} } }, { "select min(s) from t", new String [][] { {"100"} } }, { "select min(l) from t", new String [][] { {"1000000"} } }, { "select min(c) from t", new String [][] { {"duplicate"} } }, { "select min(v) from t", new String [][] { {"noone is here"} } }, { "select min(d) from t", new String [][] { {"100.0"} } }, { "select min(r) from t", new String [][] { {"100.0"} } }, { "select min(dt) from t", new String [][] { {"1992-01-01"} } }, { "select min(t) from t", new String [][] { {"12:30:30"} } }, { "select min(ts) from t", new String [][] { {"1992-01-01 12:30:30.0"} } }, { "select min(b) from t", new String [][] { {"12af"} } }, { "select min(bv) from t", new String [][] { {"0000111100001111"} } }, { "select min(dc) from t", new String [][] { {"111.11"} } }, { "select min(i) from t group by i", new String [][] { {"0"},{"1"},{null} } }, { "select min(s) from t group by s", new String [][] { {"100"}, {"200"}, {null} } }, { "select min(l) from t group by l", new String [][] { {"1000000"}, {"2000000"}, {null} } }, { "select min(c) from t group by c", new String [][] { {"duplicate"}, {"goodbye"}, {null} } }, { "select min(v) from t group by v", new String [][] { {"noone is here"}, {"this is duplicated"}, {null} } }, { "select min(d) from t group by d", new String [][] { {"100.0"}, {"200.0"}, {null} } }, { "select min(r) from t group by r", new String [][] { {"100.0"}, {"200.0"}, {null} } }, { "select min(dt) from t group by dt", new String [][] { {"1992-01-01"}, {"1992-09-09"}, {null} } }, { "select min(t) from t group by t", new String [][] { {"12:30:30"}, {"12:55:55"}, {null} } }, { "select min(ts) from t group by ts", new String [][] { {"1992-01-01 12:30:30.0"}, {"1992-01-01 12:55:55.0"}, {null} } }, { "select min(b) from t group by b", new String [][] { {"12af"}, {"ffff"}, {null} } }, { "select min(bv) from t group by bv", new String [][] { {"0000111100001111"}, {"1111111111111111"}, {null} } }, { "select min(dc) from t group by dc", new String [][] { {"111.11"}, {"222.22"}, {null} } }, { "select min(1) from t", new String [][] { {"1"} } }, { "select min('hello') from t", new String [][] { {"hello"} } }, { "select min(1.1) from t", new String [][] { {"1.1"} } }, { "select min(1e1) from t", new String [][] { {"10.0"} } }, { "select min(X'11') from t", new String [][] { {"11"} } }, { "select min(date('1999-06-06')) from t", new String [][] { {"1999-06-06"} } }, { "select min(time('12:30:30')) from t", new String [][] { {"12:30:30"} } }, { "select min(timestamp('1999-06-06 12:30:30')) from t", new String [][] { {"1999-06-06 12:30:30.0"} } }, { "select min(1) from t group by i", new String [][] { {"1"}, {"1"}, {"1"} } }, { "select min('hello') from t group by c", new String [][] { {"hello"}, {"hello"}, {"hello"} } }, { "select min(1.1) from t group by dc", new String [][] { {"1.1"}, {"1.1"}, {"1.1"} } }, { "select min(1e1) from t group by d", new String [][] { {"10.0"}, {"10.0"}, {"10.0"} } }, { "select min(X'11') from t group by b", new String [][] { {"11"}, {"11"}, {"11"} } }, { "select min(date('1999-06-06')) from t group by dt", new String [][] { {"1999-06-06"}, {"1999-06-06"}, {"1999-06-06"} } }, { "select min(time('12:30:30')) from t group by t", new String [][] { {"12:30:30"}, {"12:30:30"}, {"12:30:30"} } }, { "select min(timestamp('1999-06-06 12:30:30')) from t group by ts", new String [][] { {"1999-06-06 12:30:30.0"}, {"1999-06-06 12:30:30.0"}, {"1999-06-06 12:30:30.0"} } }, { "select min(i), min(dt), min(b) from t group by i, dt, b", new String [][] { {"0", "1992-01-01", "12af"}, {"0", "1992-01-01", "ffff"}, {"0", "1992-09-09", "12af"}, {"1", "1992-01-01", "12af"}, {null,null,null} } }, { "select l, dt, min(i), min(dt), min(b), i from t group by i, dt, b, l", new String [][] { {"1000000","1992-01-01","0","1992-01-01","12af","0"}, {"2000000","1992-01-01","0","1992-01-01","12af","0"}, {"1000000","1992-01-01","0","1992-01-01","ffff","0"}, {"1000000","1992-09-09","0","1992-09-09","12af","0"}, {"1000000","1992-01-01","1","1992-01-01","12af","1"}, {null,null,null,null,null,null} } }, { "select min(expr1), min(expr2) from (select i * s, c || v from t) t (expr1, expr2) group by expr2, expr1", new String [][] { {"0","duplicate noone is here"}, {"0","duplicate this is duplicated"}, {"100","duplicate this is duplicated"}, {"0","goodbye this is duplicated"}, {null,null} } }, { "select distinct min(i) from t group by i, dt", new String [][] { {"0"}, {"1"}, {null} } }, { "create table tmp (x int, y char(20)) partition by column(x)" + getOffHeapSuffix(), null }, { "insert into tmp (x, y) select min(i), min(c) from t", null }, { "select * from tmp", new String [][] { {"0","duplicate"} } }, { "insert into tmp (x, y) select min(i), min(c) from t group by b", null }, { "select * from tmp", new String [][] { {"0","duplicate"}, {"0","duplicate"}, {"0","duplicate"}, {null,null} } }, { "drop table tmp", null}, { "drop table t", null}, { "drop table empty", null} }; Connection conn = TestUtil.getConnection(); Statement stmt = conn.createStatement(); // Go through the array, execute each string[0], check sqlstate [1] // This will fail on the first one that succeeds where it shouldn't // or throws unknown exception JDBC.SQLUnitTestHelper(stmt,Script_AggBuiltInUTPartitioning); } protected String getOffHeapSuffix() { return " "; } }
3e0b4bfa927ebc8e6de239a6df30c362e2dd636f
6,664
java
Java
Frameworks/Apollo/DataServices/Sources/org/pachyderm/apollo/data/CXVocabulary.java
gavineadie/Pachyderm
d8ae0a8a88396359b7bec1c6b1ecf4cf78cfe606
[ "CC0-1.0" ]
2
2018-01-23T20:13:57.000Z
2018-04-27T14:46:16.000Z
Frameworks/Apollo/DataServices/Sources/org/pachyderm/apollo/data/CXVocabulary.java
gavineadie/Pachyderm
d8ae0a8a88396359b7bec1c6b1ecf4cf78cfe606
[ "CC0-1.0" ]
null
null
null
Frameworks/Apollo/DataServices/Sources/org/pachyderm/apollo/data/CXVocabulary.java
gavineadie/Pachyderm
d8ae0a8a88396359b7bec1c6b1ecf4cf78cfe606
[ "CC0-1.0" ]
null
null
null
34.528497
139
0.702731
4,785
// // CXVocabulary.java // VocabularySupport // // Created by King Chung Huang on Tue Jul 27 2004. // Copyright (c) 2004 __MyCompanyName__. All rights reserved. // package org.pachyderm.apollo.data; import java.io.IOException; import java.lang.reflect.Constructor; import java.net.URL; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.jdom.Document; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.pachyderm.apollo.core.CoreServices; import org.pachyderm.apollo.core.UTType; import com.webobjects.foundation.NSArray; import com.webobjects.foundation.NSData; import com.webobjects.foundation.NSKeyValueCoding; import com.webobjects.foundation.NSMutableDictionary; import com.webobjects.foundation.NSNotificationCenter; import com.webobjects.foundation.NSSelector; import er.extensions.foundation.ERXProperties; public abstract class CXVocabulary implements NSKeyValueCoding { private static Logger LOG = LoggerFactory.getLogger(CXVocabulary.class.getName()); private static NSMutableDictionary<String, Class<?>> _vocabularyClassesByType; private static final Class[] VocabClassURLConstructorArgumentTypes = new Class[] { URL.class, String.class }; private static final Class[] VocabClassDataConstructorArgumentTypes = new Class[] { NSData.class, String.class }; public static final String VocabularyClassNeededForVocabularyTypeNotification = "VocabularyClassNeededForVocabularyType"; /*------------------------------------------------------------------------------------------------* * S T A T I C I N I T I A L I Z E R . . . *------------------------------------------------------------------------------------------------*/ static { StaticInitializer(); } private static void StaticInitializer() { LOG.info("[-STATIC-]"); _vocabularyClassesByType = new NSMutableDictionary<String, Class<?>>(); _registerDefaultVocabClassesAndTypes(); _autoRegisterAvailableVocabularyClassesInBundles(); } public CXVocabulary(URL url, String type) { super(); } public CXVocabulary(NSData data, String type) { super(); } /** * Creates a vocabulary object from the contents specified by the url. * * @param url the url of the vocabulary document * @param type the type of the vocabulary document at the url * @return a vocabulary object with the vocabulary located at the url */ public static CXVocabulary vocabularyFromURL(URL url, String type) { return _createVocabularyObject(type, VocabClassURLConstructorArgumentTypes, new Object[] { url, type }); } /** * Creates a vocabulary object from the contents of the data. * * @param data the document content to read * @param type the type of vocabulary represented by data * @return a vocabulary object created from the contents of data */ public static CXVocabulary vocabularyFromData(NSData data, String type) { return _createVocabularyObject(type, VocabClassDataConstructorArgumentTypes, new Object[] { data, type }); } @SuppressWarnings("unchecked") static CXVocabulary _createVocabularyObject(String type, Class[] constructorArgumentTypes, Object[] constructorArguments) { Class clazz = _vocabClassForVocabType(type); if (clazz == null) { NSNotificationCenter.defaultCenter().postNotification(VocabularyClassNeededForVocabularyTypeNotification, type); if ((clazz = _vocabClassForVocabType(type)) == null) { throw new IllegalArgumentException("No vocabulary class is available for vocabluary type " + type + "."); } } CXVocabulary vocabulary; try { Constructor constructor = clazz.getConstructor(constructorArgumentTypes); vocabulary = (CXVocabulary)constructor.newInstance(constructorArguments); } catch (Exception e) { LOG.error("_createVocabularyObject: error ...", e); vocabulary = null; } return vocabulary; } // Getting information about a vocabulary /** * Implemented by subclasses to return the document's uniform type identifier (UTI). The default implementation returns public.vocabulary. * * @return the vocabulary class' uniform type identifier (UTI) */ public static String vocabularyType() { return UTType.Vocabulary; } // Getting vocabulary items public abstract NSArray terms(); public NSArray termsIncludingAllSubTerms() { // default implementation should manually gather all sub-terms return terms(); } // Key-value coding public Object valueForKey(String key) { return NSKeyValueCoding.DefaultImplementation.valueForKey(this, key); } public void takeValueForKey(Object value, String key) { NSKeyValueCoding.DefaultImplementation.takeValueForKey(this, value, key); } // Internal - Managing vocabulary classes static Class _vocabClassForVocabType(String type) { return (Class)_vocabularyClassesByType.objectForKey(type); } static void _registerVocabClassForVocabType(Class clazz, String type) { _vocabularyClassesByType.setObjectForKey(clazz, type); } static NSArray _registeredVocabTypes() { return _vocabularyClassesByType.allKeys(); } static void _registerDefaultVocabClassesAndTypes() { //_registerVocabClassForVocabType(VDEXVocabulary.class, UTTypes.VDEX); } // Internal static Document _xmlDocumentFromData(NSData data) { try { SAXBuilder builder = new SAXBuilder(); return builder.build(data.stream()); } catch (JDOMException jdome) { throw new IllegalStateException("An error occurred parsing the document."); } catch (IOException ioe) { throw new IllegalStateException("An error occurred reading the document."); } } @SuppressWarnings("unchecked") private static void _autoRegisterAvailableVocabularyClassesInBundles() { for (Class<?> clazz : CoreServices.kindOfClassInBundles(CXVocabulary.class, (NSArray<String>)ERXProperties.arrayForKey("DataServices.IgnoreBundles"))) { try { NSSelector sel = new NSSelector("vocabularyType"); if (sel.implementedByClass(clazz)) { String type = (String)sel.invoke(clazz); _registerVocabClassForVocabType(clazz, type); LOG.info("Registered vocabulary class <" + clazz.getName() + "> with type " + type + "."); } else { LOG.error("The vocabulary class <" + clazz.getName() + "> does not implement the class method vocabularyType(). " + "This method must be implemented for the vocabulary class to be registered."); } } catch (Throwable x) { } } } }
3e0b4c3126222880a01fd1c23b69b9d0e8cabbc2
8,532
java
Java
src_all/demos_src/MobileIMSDK4jDemoX/src/net/openmob/mobileimsdk/java/demo/MainGUI.java
Koier/MobileIMSDK
4e4371da72f1cdb71805cb7736e5656269049ac3
[ "Apache-2.0" ]
2
2021-04-12T02:11:01.000Z
2021-04-13T01:12:59.000Z
src_all/demos_src/MobileIMSDK4jDemoX/src/net/openmob/mobileimsdk/java/demo/MainGUI.java
beggar1982/MobileIMSDK
4e4371da72f1cdb71805cb7736e5656269049ac3
[ "Apache-2.0" ]
null
null
null
src_all/demos_src/MobileIMSDK4jDemoX/src/net/openmob/mobileimsdk/java/demo/MainGUI.java
beggar1982/MobileIMSDK
4e4371da72f1cdb71805cb7736e5656269049ac3
[ "Apache-2.0" ]
1
2021-04-12T02:11:13.000Z
2021-04-12T02:11:13.000Z
29.215753
89
0.68339
4,786
/* * Copyright (C) 2017 即时通讯网(52im.net) & Jack Jiang. * The MobileIMSDK_X (MobileIMSDK v3.x) Project. * All rights reserved. * * > Github地址: https://github.com/JackJiang2011/MobileIMSDK * > 文档地址: http://www.52im.net/forum-89-1.html * > 即时通讯技术社区:http://www.52im.net/ * > 即时通讯技术交流群:320837163 (http://www.52im.net/topic-qqgroup.html) * * "即时通讯网(52im.net) - 即时通讯开发者社区!" 推荐开源工程。 * * MainGUI.java at 2017-5-1 21:38:37, code by Jack Jiang. * You can contact author with upchh@example.com or kenaa@example.com. */ package net.openmob.mobileimsdk.java.demo; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.text.SimpleDateFormat; import java.util.Date; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextField; import javax.swing.JTextPane; import net.openmob.mobileimsdk.java.ClientCoreSDK; import net.openmob.mobileimsdk.java.core.LocalUDPDataSender; import net.openmob.mobileimsdk.java.utils.Log; import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI; import org.jb2011.swing9patch.toast.Toast; import com.eva.epc.widget.HardLayoutPane; public class MainGUI extends JFrame { private JButton btnLogout = null; private JTextField editId = null; private JTextField editContent = null; private JButton btnSend = null; private JLabel viewMyid = null; private JTextPane debugPane; private JTextPane imInfoPane; private SimpleDateFormat hhmmDataFormat = new SimpleDateFormat("HH:mm:ss"); public MainGUI() { initViews(); initListeners(); initOthers(); } private void initViews() { // 登陆组件初始化 btnLogout = new JButton("退出程序"); btnLogout.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.red)); btnLogout.setForeground(Color.white); viewMyid = new JLabel(); viewMyid.setForeground(new Color(255,0,255)); viewMyid.setText("未登陆"); // 消息发送组件初始化 btnSend = new JButton("发送消息"); btnSend.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green)); btnSend.setForeground(Color.white); editId = new JTextField(20); editContent = new JTextField(20); // debug信息显示面板初始化 debugPane=new JTextPane(); debugPane.setBackground(Color.black); debugPane.setCaretColor(Color.white); // Log.getInstance().setLogDest(debugPane); // IM通讯信息显示面板初始化 imInfoPane=new JTextPane(); // 登陆认证信息布局 JPanel authPane = new JPanel(); authPane.setLayout(new BoxLayout(authPane, BoxLayout.LINE_AXIS)); authPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 12)); authPane.add(new JLabel("状态:")); authPane.add(viewMyid); authPane.add(Box.createHorizontalGlue()); authPane.add(btnLogout); // 消息发送布局 HardLayoutPane toPanel = new HardLayoutPane(); toPanel.addTo(new JLabel("对方账号:"), 1, true); toPanel.addTo(editId, 1, true); toPanel.nextLine(); toPanel.addTo(new JLabel("发送内容:"), 1, true); toPanel.addTo(editContent, 1, true); toPanel.nextLine(); toPanel.addTo(btnSend, 4, true); toPanel.nextLine(); HardLayoutPane oprMainPanel = new HardLayoutPane(); oprMainPanel.addTitledLineSeparator("登陆认证"); oprMainPanel.addTo(authPane, 1, true); oprMainPanel.addTitledLineSeparator("消息发送"); oprMainPanel.addTo(toPanel, 1, true); oprMainPanel.addTitledLineSeparator(); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.add(oprMainPanel, BorderLayout.NORTH); JScrollPane imInfoSc = new JScrollPane(imInfoPane); imInfoSc.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(0, 7, 0, 7), imInfoSc.getBorder())); imInfoSc.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); leftPanel.add(imInfoSc, BorderLayout.CENTER); this.getContentPane().setLayout(new BorderLayout()); this.getContentPane().add(leftPanel, BorderLayout.WEST); JScrollPane sc = new JScrollPane(debugPane); sc.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(4, 0, 0, 2), sc.getBorder())); sc.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); this.getContentPane().add(sc, BorderLayout.CENTER); this.setTitle("MobileIMSDK v4演示工程 - (当前登陆:" +ClientCoreSDK.getInstance().getCurrentLoginUserId() +", 讨论区:52im.net, QQ群:101279154)"); this.setLocationRelativeTo(null); this.setSize(1000,700); // 显示当前账号信息 MainGUI.this.showIMInfo_green("当前账号:" +ClientCoreSDK.getInstance().getCurrentLoginUserId()); } private void initListeners() { btnLogout.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { // 退出登陆 doLogout(); // 退出程序 doExit(); } }); btnSend.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { doSendMessage(); } }); this.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ // 退出登陆 doLogout(); // 退出程序 doExit(); } }); } private void initOthers() { // Refresh userId to show refreshMyid(); // Set MainGUI instance refrence to listeners IMClientManager.getInstance().getTransDataListener().setMainGUI(this); IMClientManager.getInstance().getBaseEventListener().setMainGUI(this); IMClientManager.getInstance().getMessageQoSListener().setMainGUI(this); } public void refreshMyid() { boolean connectedToSer = ClientCoreSDK.getInstance().isConnectedToServer(); this.viewMyid.setText(connectedToSer ? "通信正常":"连接断开"); } private void doSendMessage() { final String msg = editContent.getText().toString().trim(); final String friendId = editId.getText().toString().trim(); if(msg.length() > 0 && friendId.length() > 0 ) { MainGUI.this.showIMInfo_black("我对"+friendId+"说:"+msg); // 发送消息(异步提升体验,你也可直接调用LocalUDPDataSender.send(..)方法发送) new LocalUDPDataSender.SendCommonDataAsync(msg, friendId)//, true) { @Override protected void onPostExecute(Integer code) { if(code == 0) Log.i(MainGUI.class.getSimpleName(), "2数据已成功发出!"); else showToast("数据发送失败。错误码是:"+code+"!"); } }.execute(); } else { String s = "接收者账号len="+friendId.length() +", 消息内容len="+msg.length()+", 发送没有继续!"; showIMInfo_red(s); Log.e(MainGUI.class.getSimpleName(), s); } } private void doLogout() { // 发出退出登陆请求包 int code = LocalUDPDataSender.getInstance().sendLoginout(); refreshMyid(); if(code == 0) System.out.println("注销登陆请求已完成!"); else System.out.println("注销登陆请求发送失败。错误码是:"+code+"!"); //## BUG FIX: 20170713 START by JackJiang // 退出登陆时记得一定要调用此行,不然不退出APP的情况下再登陆时会报 code=203错误哦! IMClientManager.getInstance().resetInitFlag(); //## BUG FIX: 20170713 END by JackJiang } public static void doExit() { // 释放IM占用资源 // ClientCoreSDK.getInstance().release(); IMClientManager.getInstance().release(); // JVM退出 System.exit(0); } //--------------------------------------------------------------- 控制台输出和Toast显示方法 START public void showIMInfo_black(String txt) { showIMInfo(new Color(0,0,0), txt); } public void showIMInfo_blue(String txt) { showIMInfo(new Color(0,0,255), txt); } public void showIMInfo_brightred(String txt) { showIMInfo(new Color(255,0,255), txt); } public void showIMInfo_red(String txt) { showIMInfo(new Color(255,0,0), txt); } public void showIMInfo_green(String txt) { showIMInfo(new Color(0,128,0), txt); } public void showIMInfo(Color c, String txt) { try{ Log.append(c, "["+hhmmDataFormat.format(new Date())+"]"+txt+"\r\n", this.imInfoPane); imInfoPane.setCaretPosition(imInfoPane.getDocument().getLength()); } catch(Exception e){ // e.printStackTrace(); } } public void showToast(String text) { Toast.showTost(3000, text, new Point((int)(this.getLocationOnScreen().getX())+50, (int)(this.getLocationOnScreen().getY())+400)); } //--------------------------------------------------------------- 控制台输出和Toast显示方法 END }
3e0b4c9776db69269705b412bd624959901c77a7
716
java
Java
twinkle-core/src/main/java/com/twinkle/framework/core/lang/util/ObjectArray.java
twinkle-cloud/twinkle-framework
89377246bb9f0dbd908a9592dc98fc45a75c247a
[ "Apache-2.0" ]
3
2020-05-10T04:04:09.000Z
2021-05-14T01:41:13.000Z
twinkle-core/src/main/java/com/twinkle/framework/core/lang/util/ObjectArray.java
twinkle-cloud/twinkle-framework
89377246bb9f0dbd908a9592dc98fc45a75c247a
[ "Apache-2.0" ]
null
null
null
twinkle-core/src/main/java/com/twinkle/framework/core/lang/util/ObjectArray.java
twinkle-cloud/twinkle-framework
89377246bb9f0dbd908a9592dc98fc45a75c247a
[ "Apache-2.0" ]
4
2019-07-13T07:33:33.000Z
2021-05-15T05:20:57.000Z
23.096774
73
0.635475
4,787
package com.twinkle.framework.core.lang.util; /** * Function: TODO ADD FUNCTION. <br/> * Reason: TODO ADD REASON. <br/> * Date: 8/30/19 5:53 PM<br/> * * @author chenxj * @see * @since JDK 1.8 */ public interface ObjectArray<E> extends Array { /** * Get the array item with the given index. * * @param _index * @return * @throws ArrayIndexOutOfBoundsException */ E get(int _index) throws ArrayIndexOutOfBoundsException; /** * Update the index's item with the given attribute. * * @param _index * @param _value * @throws ArrayIndexOutOfBoundsException */ void put(int _index, E _value) throws ArrayIndexOutOfBoundsException; }
3e0b4d0122de8d3a0fcca5f45ef52b2ceb8dc80a
3,074
java
Java
openhealthcard.common/src/test/java/de/gematik/ti/openhealthcard/common/exceptions/runtime/NotInitilizedWithContextExceptionTest.java
gematik/ref-OpenHealthCard-Common-Android
1324039e57079fb608f4d8f883c1f6fb0ff1330d
[ "Apache-2.0" ]
null
null
null
openhealthcard.common/src/test/java/de/gematik/ti/openhealthcard/common/exceptions/runtime/NotInitilizedWithContextExceptionTest.java
gematik/ref-OpenHealthCard-Common-Android
1324039e57079fb608f4d8f883c1f6fb0ff1330d
[ "Apache-2.0" ]
null
null
null
openhealthcard.common/src/test/java/de/gematik/ti/openhealthcard/common/exceptions/runtime/NotInitilizedWithContextExceptionTest.java
gematik/ref-OpenHealthCard-Common-Android
1324039e57079fb608f4d8f883c1f6fb0ff1330d
[ "Apache-2.0" ]
1
2021-07-28T16:17:03.000Z
2021-07-28T16:17:03.000Z
42.694444
107
0.709499
4,788
/* * Copyright (c) 2020 gematik GmbH * * 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 de.gematik.ti.openhealthcard.common.exceptions.runtime; import org.junit.Assert; import org.junit.Test; public class NotInitilizedWithContextExceptionTest { public static final String MSG = "The class need the android application context but it was not set."; @Test public void testNotInitilizedWithContextException() { Exception exception = new NotInitilizedWithContextException(); Assert.assertNotNull(exception); Assert.assertEquals(MSG, exception.getMessage()); } @Test public void testNotInitilizedWithContextExceptionWithCause() { Exception cause = new RuntimeException("Mhfhzy"); Exception exception = new NotInitilizedWithContextException(cause); Assert.assertNotNull(exception); Assert.assertEquals(cause, exception.getCause()); Assert.assertEquals(MSG, exception.getMessage()); } @Test public void testNotInitilizedWithContextExceptionWithCauseSuppressionStackTrace() { Exception cause = new RuntimeException("Myss"); Exception cause2 = new RuntimeException("My22sdfsdf"); Exception exception = new NotInitilizedWithContextException(cause, true, true); exception.addSuppressed(cause2); Assert.assertNotNull(exception); Assert.assertEquals(cause, exception.getCause()); Assert.assertNotNull(exception.getStackTrace()); Assert.assertTrue(exception.getStackTrace().length > 0); Assert.assertNotNull(exception.getSuppressed()); Assert.assertTrue(exception.getSuppressed().length > 0); Assert.assertEquals(MSG, exception.getMessage()); } @Test public void testNotInitilizedWithContextExceptionWithCauseWithoutSuppressionStackTrace() { Exception cause = new RuntimeException("M2sfdy"); Exception cause2 = new RuntimeException("My2iu"); Exception exception = new NotInitilizedWithContextException(cause, false, false); exception.addSuppressed(cause2); Assert.assertNotNull(exception); Assert.assertEquals(cause, exception.getCause()); Assert.assertNotNull(exception.getStackTrace()); Assert.assertTrue(exception.getStackTrace().length == 0); Assert.assertNotNull(exception.getSuppressed()); Assert.assertTrue(exception.getSuppressed().length == 0); Assert.assertEquals(MSG, exception.getMessage()); } }
3e0b4d21c622fa8fb77779961ee006de7be77d69
313
java
Java
Variant Programs/4-5/29/ReinstatementProgramme.java
hjc851/Dataset2-HowToDetectAdvancedSourceCodePlagiarism
a42ced1d5a92963207e3565860cac0946312e1b3
[ "MIT" ]
null
null
null
Variant Programs/4-5/29/ReinstatementProgramme.java
hjc851/Dataset2-HowToDetectAdvancedSourceCodePlagiarism
a42ced1d5a92963207e3565860cac0946312e1b3
[ "MIT" ]
null
null
null
Variant Programs/4-5/29/ReinstatementProgramme.java
hjc851/Dataset2-HowToDetectAdvancedSourceCodePlagiarism
a42ced1d5a92963207e3565860cac0946312e1b3
[ "MIT" ]
null
null
null
31.3
87
0.824281
4,789
public abstract class ReinstatementProgramme { public static final double symbolic = 0.07444801517042654; protected abstract void lendHomepage(Layout postscript, Methodology latestOperation); protected abstract boolean crackPlea(Methodology prevalentMethod); protected abstract boolean isComplete(); }
3e0b4ddd45bc94dc4a6eb2b680afc8fcedd32396
1,938
java
Java
starbound-text/src/main/gen/com/windea/plugin/idea/sbtext/psi/SbTextTypes.java
Fonata/Idea-Plugins
edf37fb29407701d65749e76a70f73ff55614461
[ "MIT" ]
3
2020-07-28T03:26:09.000Z
2021-01-18T20:37:21.000Z
starbound-text/src/main/gen/com/windea/plugin/idea/sbtext/psi/SbTextTypes.java
Fonata/Idea-Plugins
edf37fb29407701d65749e76a70f73ff55614461
[ "MIT" ]
1
2020-12-11T08:58:58.000Z
2020-12-11T09:13:26.000Z
starbound-text/src/main/gen/com/windea/plugin/idea/sbtext/psi/SbTextTypes.java
Fonata/Idea-Plugins
edf37fb29407701d65749e76a70f73ff55614461
[ "MIT" ]
2
2020-11-01T03:52:37.000Z
2020-12-11T08:34:09.000Z
38
82
0.723426
4,790
// This is a generated file. Not intended for manual editing. package com.windea.plugin.idea.sbtext.psi; import com.intellij.psi.tree.IElementType; import com.intellij.psi.PsiElement; import com.intellij.lang.ASTNode; import com.windea.plugin.idea.sbtext.psi.impl.*; public interface SbTextTypes { IElementType COLORFUL_TEXT = new SbTextElementType("COLORFUL_TEXT"); IElementType COLOR_MARKER = new SbTextElementType("COLOR_MARKER"); IElementType COLOR_RESET_MARKER = new SbTextElementType("COLOR_RESET_MARKER"); IElementType ESCAPE = new SbTextElementType("ESCAPE"); IElementType RICH_TEXT = new SbTextElementType("RICH_TEXT"); IElementType STRING = new SbTextElementType("STRING"); IElementType COLOR_CODE = new SbTextTokenType("COLOR_CODE"); IElementType COLOR_MARKER_END = new SbTextTokenType(";"); IElementType COLOR_MARKER_START = new SbTextTokenType("^"); IElementType COLOR_RESET_MARKER_TOKEN = new SbTextTokenType("^reset;"); IElementType INVALID_ESCAPE_TOKEN = new SbTextTokenType("INVALID_ESCAPE_TOKEN"); IElementType TEXT_TOKEN = new SbTextTokenType("TEXT_TOKEN"); IElementType VALID_ESCAPE_TOKEN = new SbTextTokenType("VALID_ESCAPE_TOKEN"); class Factory { public static PsiElement createElement(ASTNode node) { IElementType type = node.getElementType(); if (type == COLORFUL_TEXT) { return new SbTextColorfulTextImpl(node); } else if (type == COLOR_MARKER) { return new SbTextColorMarkerImpl(node); } else if (type == COLOR_RESET_MARKER) { return new SbTextColorResetMarkerImpl(node); } else if (type == ESCAPE) { return new SbTextEscapeImpl(node); } else if (type == RICH_TEXT) { return new SbTextRichTextImpl(node); } else if (type == STRING) { return new SbTextStringImpl(node); } throw new AssertionError("Unknown element type: " + type); } } }
3e0b4de861bc03148bc4702a62e9e4fe70ef49fb
1,793
java
Java
src/main/java/com/hbm/render/tileentity/RenderTesla.java
Syncinus/Hbm-s-Nuclear-Tech-GIT
3ccc662ea0ca016d0d0a507864e2c0ec950c2807
[ "Unlicense" ]
null
null
null
src/main/java/com/hbm/render/tileentity/RenderTesla.java
Syncinus/Hbm-s-Nuclear-Tech-GIT
3ccc662ea0ca016d0d0a507864e2c0ec950c2807
[ "Unlicense" ]
null
null
null
src/main/java/com/hbm/render/tileentity/RenderTesla.java
Syncinus/Hbm-s-Nuclear-Tech-GIT
3ccc662ea0ca016d0d0a507864e2c0ec950c2807
[ "Unlicense" ]
null
null
null
35.86
262
0.696598
4,791
package com.hbm.render.tileentity; import org.lwjgl.opengl.GL11; import com.hbm.main.ResourceManager; import com.hbm.render.amlfrom1710.Vec3; import com.hbm.render.misc.BeamPronter; import com.hbm.render.misc.BeamPronter.EnumBeamType; import com.hbm.render.misc.BeamPronter.EnumWaveType; import com.hbm.tileentity.machine.TileEntityTesla; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; public class RenderTesla extends TileEntitySpecialRenderer<TileEntityTesla> { @Override public boolean isGlobalRenderer(TileEntityTesla te) { return true; } @Override public void render(TileEntityTesla tesla, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y, z + 0.5D); GlStateManager.enableLighting(); GL11.glRotatef(180, 0F, 1F, 0F); bindTexture(ResourceManager.tesla_tex); ResourceManager.tesla.renderAll(); GlStateManager.enableCull(); double sx = tesla.getPos().getX() + 0.5D; double sy = tesla.getPos().getY() + TileEntityTesla.offset; double sz = tesla.getPos().getZ() + 0.5D; GL11.glTranslated(0.0D, TileEntityTesla.offset, 0.0D); for(double[] target : tesla.targets) { double length = Math.sqrt(Math.pow(target[0] - sx, 2) + Math.pow(target[1] - sy, 2) + Math.pow(target[2] - sz, 2)); BeamPronter.prontBeam(Vec3.createVectorHelper(-target[0] + sx, target[1] - sy, -target[2] + sz), EnumWaveType.RANDOM, EnumBeamType.SOLID, 0x404040, 0x404040, (int)tesla.getWorld().getTotalWorldTime() % 1000 + 1, (int) (length * 5), 0.125F, 2, 0.03125F); } GL11.glPopMatrix(); } }
3e0b50a47f014e5eaf340163c37d3a47848bafec
3,403
java
Java
jdial-core/src/test/java/al/jdi/core/devolveregistro/ModificadorResultadoInexistenteFakeTest.java
juradoz/jdial
d5c6cc586e4ae70fa8761dc3df3f212a503ed5a5
[ "MIT" ]
2
2018-12-11T12:47:29.000Z
2022-03-08T02:26:39.000Z
jdial-core/src/test/java/al/jdi/core/devolveregistro/ModificadorResultadoInexistenteFakeTest.java
juradoz/jdial
d5c6cc586e4ae70fa8761dc3df3f212a503ed5a5
[ "MIT" ]
null
null
null
jdial-core/src/test/java/al/jdi/core/devolveregistro/ModificadorResultadoInexistenteFakeTest.java
juradoz/jdial
d5c6cc586e4ae70fa8761dc3df3f212a503ed5a5
[ "MIT" ]
6
2016-03-09T15:39:50.000Z
2018-06-12T21:41:44.000Z
34.373737
134
0.794887
4,792
package al.jdi.core.devolveregistro; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.sameInstance; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import al.jdi.core.configuracoes.Configuracoes; import al.jdi.core.devolveregistro.ModificadorResultado.ResultadosConhecidos; import al.jdi.core.modelo.Discavel; import al.jdi.core.modelo.Ligacao; import al.jdi.core.tenant.Tenant; import al.jdi.dao.beans.DaoFactory; import al.jdi.dao.beans.ResultadoLigacaoDao; import al.jdi.dao.model.Campanha; import al.jdi.dao.model.Cliente; import al.jdi.dao.model.MotivoSistema; import al.jdi.dao.model.ResultadoLigacao; public class ModificadorResultadoInexistenteFakeTest { private ModificadorResultadoInexistenteFake modificadorResultadoInexistenteFake; @Mock private DaoFactory daoFactory; @Mock private ResultadoLigacao resultadoLigacao; @Mock private Ligacao ligacao; @Mock private Cliente cliente; @Mock private Campanha campanha; @Mock private ResultadoLigacaoDao resultadoLigacaoDao; @Mock private ResultadoLigacao resultadoLigacaoAtendida; @Mock private ResultadoLigacao resultadoLigacaoInexistente; @Mock private Configuracoes configuracoes; @Mock private Tenant tenant; @Mock private Discavel discavel; @Before public void setUp() throws Exception { initMocks(this); when(daoFactory.getResultadoLigacaoDao()).thenReturn(resultadoLigacaoDao); when(resultadoLigacaoDao.procura(MotivoSistema.ATENDIDA.getCodigo(), campanha)).thenReturn(resultadoLigacaoAtendida); when(resultadoLigacaoDao.procura(ResultadosConhecidos.INEXISTENTE.getCodigo(), campanha)).thenReturn(resultadoLigacaoInexistente); when(tenant.getConfiguracoes()).thenReturn(configuracoes); when(tenant.getCampanha()).thenReturn(campanha); when(ligacao.getDiscavel()).thenReturn(discavel); when(discavel.getCliente()).thenReturn(cliente); modificadorResultadoInexistenteFake = new ModificadorResultadoInexistenteFake(); } @Test public void acceptDeveriaRetornarTrue() throws Exception { assertThat(modificadorResultadoInexistenteFake.accept(tenant, daoFactory, ligacao, resultadoLigacaoAtendida), is(true)); } @Test public void acceptDeveriaRetornarFalseUraReversa() throws Exception { when(configuracoes.isUraReversa()).thenReturn(true); assertThat(modificadorResultadoInexistenteFake.accept(tenant, daoFactory, ligacao, resultadoLigacaoAtendida), is(false)); } @Test public void acceptDeveriaRetornarFalseResultado() throws Exception { assertThat(modificadorResultadoInexistenteFake.accept(tenant, daoFactory, ligacao, resultadoLigacaoInexistente), is(false)); } @Test public void acceptDeveriaRetornarFalseAtendida() throws Exception { when(ligacao.isAtendida()).thenReturn(true); assertThat(modificadorResultadoInexistenteFake.accept(tenant, daoFactory, ligacao, resultadoLigacaoAtendida), is(false)); } @Test public void modificaDeveriaRetornarInexistente() throws Exception { assertThat( modificadorResultadoInexistenteFake.modifica(tenant, daoFactory, ligacao, resultadoLigacao), is(sameInstance(resultadoLigacaoInexistente))); } }
3e0b516f1e88832c28b481a39d495dd53903e2e8
3,266
java
Java
app/src/main/java/com/iguerra94/weathernow/utils/db/DatabaseUtils.java
iguerra94/WeatherNow
79796a76294838afb5e869c70f45611be179733e
[ "Apache-2.0" ]
null
null
null
app/src/main/java/com/iguerra94/weathernow/utils/db/DatabaseUtils.java
iguerra94/WeatherNow
79796a76294838afb5e869c70f45611be179733e
[ "Apache-2.0" ]
null
null
null
app/src/main/java/com/iguerra94/weathernow/utils/db/DatabaseUtils.java
iguerra94/WeatherNow
79796a76294838afb5e869c70f45611be179733e
[ "Apache-2.0" ]
null
null
null
44.135135
205
0.733007
4,793
package com.iguerra94.weathernow.utils.db; import com.iguerra94.weathernow.db.entities.CurrentWeatherDB; import com.iguerra94.weathernow.db.entities.DailyForecastDB; import com.iguerra94.weathernow.utils.StringUtils; import com.iguerra94.weathernow.utils.api.ApiUtils; import com.iguerra94.weathernow.utils.api.retrofit.model.CurrentWeather; import com.iguerra94.weathernow.utils.api.retrofit.model.DailyForecast; import com.iguerra94.weathernow.utils.api.retrofit.model.DayForecast; import java.util.ArrayList; import java.util.List; public class DatabaseUtils { public static CurrentWeatherDB initCurrentWeatherDBObject(CurrentWeather currentWeather) { CurrentWeatherDB currentWeatherDB = new CurrentWeatherDB(); currentWeatherDB.setCityName(currentWeather.getName()); currentWeatherDB.setCountry(currentWeather.getSys().getCountry()); String currentWeatherDescription = currentWeather.getWeather().get(0).getDescription().substring(0,1).toUpperCase() + currentWeather.getWeather().get(0).getDescription().substring(1).toLowerCase(); currentWeatherDB.setDescription(currentWeatherDescription); String iconIdColoured = StringUtils.getIconIdColoured(currentWeather.getWeather().get(0).getIcon()); String iconUri = ApiUtils.WEATHER_ICONS_BASE_URL + iconIdColoured + "@2x.png"; currentWeatherDB.setIconUri(iconUri); currentWeatherDB.setCurrentTemp(Math.round(currentWeather.getMain().getTemp())); currentWeatherDB.setCurrentTempMax(Math.round(currentWeather.getMain().getTempMax())); currentWeatherDB.setCurrentTempMin(Math.round(currentWeather.getMain().getTempMin())); return currentWeatherDB; } public static List<DailyForecastDB> initDailyForecastDBListObject(DailyForecast dailyForecast) { List<DayForecast> dailyForecastShortened = new ArrayList<>(); int initialOffset = 8; int currentOffset; int resultsDistance = 8; int resultSize = 4; for (int i = 0; i < resultSize; i++) { currentOffset = initialOffset + i * resultsDistance; dailyForecastShortened.add(dailyForecast.getDailyForecast().get(currentOffset)); } List<DailyForecastDB> dailyForecastDBList = new ArrayList<>(); for (DayForecast dayForecast : dailyForecastShortened) { DailyForecastDB dailyForecastDB = new DailyForecastDB(); dailyForecastDB.setDt(dayForecast.getDt()); String description = dayForecast.getWeather().get(0).getDescription().substring(0,1).toUpperCase() + dayForecast.getWeather().get(0).getDescription().substring(1).toLowerCase(); dailyForecastDB.setDescription(description); String iconIdColoured = StringUtils.getIconIdColoured(dayForecast.getWeather().get(0).getIcon()); String iconUri = ApiUtils.WEATHER_ICONS_BASE_URL + iconIdColoured + ".png"; dailyForecastDB.setIconUri(iconUri); dailyForecastDB.setTempMax(Math.round(dayForecast.getMain().getTempMax())); dailyForecastDB.setTempMin(Math.round(dayForecast.getMain().getTempMin())); dailyForecastDBList.add(dailyForecastDB); } return dailyForecastDBList; } }
3e0b52379058433aab9c59d4b545a432ec2a37fb
2,261
java
Java
src/main/java/fr/dawoox/akasuki/commands/utils/WeatherCmd.java
Akasuki-bot/Akasuki
3ea425b42ac5204982b1c09ef4b3168b053ab8ce
[ "MIT" ]
2
2021-06-23T08:02:36.000Z
2021-06-26T06:25:18.000Z
src/main/java/fr/dawoox/akasuki/commands/utils/WeatherCmd.java
Akasuki-bot/Akasuki
3ea425b42ac5204982b1c09ef4b3168b053ab8ce
[ "MIT" ]
1
2021-09-03T11:37:22.000Z
2021-09-03T19:57:47.000Z
src/main/java/fr/dawoox/akasuki/commands/utils/WeatherCmd.java
Akasuki-bot/Akasuki
3ea425b42ac5204982b1c09ef4b3168b053ab8ce
[ "MIT" ]
null
null
null
43.480769
125
0.581601
4,794
package fr.dawoox.akasuki.commands.utils; import com.sun.tools.javac.util.List; import discord4j.rest.util.Color; import fr.dawoox.akasuki.core.command.BaseCmd; import fr.dawoox.akasuki.core.command.CommandCategory; import fr.dawoox.akasuki.core.command.CommandPermission; import fr.dawoox.akasuki.core.command.Context; import fr.dawoox.akasuki.utils.API.WeatherAPI; import fr.dawoox.akasuki.utils.json.WeatherBody; import java.time.Instant; public class WeatherCmd extends BaseCmd { public WeatherCmd() { super(CommandCategory.UTILS, CommandPermission.USER, List.of("weather", "w", "meteo")); } @Override public void execute(Context context) { final String city = context.requireArg(); WeatherBody weather = WeatherAPI.requestWeather(city); if (weather == null) { context.getChannel().createEmbed(embedCreateSpec -> { embedCreateSpec.setColor(Color.DEEP_LILAC) .setDescription("Nah, this city does not seems to exist") .setFooter("Akasuki", null) .setTimestamp(Instant.now()); }).block(); } else { try { context.getChannel().createEmbed(embedCreateSpec -> { embedCreateSpec.setColor(Color.DEEP_LILAC) .setAuthor("Météo : " + city, null, "https:"+weather.current.condition.icon) .setDescription(weather.current.condition.text) .addField("Température", ":thermometer: " + String.valueOf(weather.current.temp_c) + "°C" +"\n :small_orange_diamond: " + String.valueOf(weather.current.feelslike_c) + "°C", true) .addField("Informations", ":cloud_tornado: " + String.valueOf(weather.current.wind_kph) + " km/h" +"\n :droplet: " + String.valueOf(weather.current.humidity) + " %", true) .setFooter("Akasuki / Powered by WeatherAPI.com", null) .setTimestamp(Instant.now()); }).block(); } catch (Exception e) { e.printStackTrace(); } } } }
3e0b5303ad3f4ba87f59b75a7dee8d25e37d8d9a
118
java
Java
jingcai-service/src/main/java/gyqw/jingcai/dao/UsersMapper.java
FredGoo/1kejingcai
318a2e5bf9becfafaa6183c9bf8f703e94149bf3
[ "Apache-2.0" ]
null
null
null
jingcai-service/src/main/java/gyqw/jingcai/dao/UsersMapper.java
FredGoo/1kejingcai
318a2e5bf9becfafaa6183c9bf8f703e94149bf3
[ "Apache-2.0" ]
null
null
null
jingcai-service/src/main/java/gyqw/jingcai/dao/UsersMapper.java
FredGoo/1kejingcai
318a2e5bf9becfafaa6183c9bf8f703e94149bf3
[ "Apache-2.0" ]
null
null
null
19.666667
55
0.805085
4,795
package gyqw.jingcai.dao; import gyqw.jingcai.domain.User; public interface UsersMapper extends BaseMapper<User> { }
3e0b534d323cf9c7ef1832a2d2ddcefbddfb882a
785
java
Java
src/main/java/com/ruoyi/framework/web/page/TableSupport.java
OneSeriousBody/RuoYi
65e3ff53de80ad0ae89e25b2af1e89075a906857
[ "MIT" ]
161
2018-06-20T08:18:25.000Z
2022-03-18T07:38:03.000Z
src/main/java/com/ruoyi/framework/web/page/TableSupport.java
zm79287/RuoYi
1a94531053d27c2a820f8a08e363453cdb1024a9
[ "MIT" ]
3
2019-01-25T05:59:24.000Z
2019-10-24T07:56:36.000Z
src/main/java/com/ruoyi/framework/web/page/TableSupport.java
zm79287/RuoYi
1a94531053d27c2a820f8a08e363453cdb1024a9
[ "MIT" ]
80
2018-06-20T08:18:31.000Z
2022-03-23T07:03:37.000Z
24.53125
91
0.705732
4,796
package com.ruoyi.framework.web.page; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.constant.Constants; /** * 表格数据处理 * * @author ruoyi */ public class TableSupport { /** * 封装分页对象 */ public static PageDomain getPageDomain() { PageDomain pageDomain = new PageDomain(); pageDomain.setPageNum(ServletUtils.getIntParameter(Constants.PAGENUM)); pageDomain.setPageSize(ServletUtils.getIntParameter(Constants.PAGESIZE)); pageDomain.setOrderByColumn(ServletUtils.getStrParameter(Constants.ORDERBYCOLUMN)); pageDomain.setIsAsc(ServletUtils.getStrParameter(Constants.ISASC)); return pageDomain; } public static PageDomain buildPageRequest() { return getPageDomain(); } }
3e0b53d7c8a373d7b9bcfe3b4693885160a3a884
2,076
java
Java
IntelliJ/Contacts/Contacts/task/src/contacts/object/Organization.java
hpereirahp/Hyperskill-code-repo
a9aeab9b67ce484ab30bd0facea45c2100586c09
[ "MIT" ]
null
null
null
IntelliJ/Contacts/Contacts/task/src/contacts/object/Organization.java
hpereirahp/Hyperskill-code-repo
a9aeab9b67ce484ab30bd0facea45c2100586c09
[ "MIT" ]
null
null
null
IntelliJ/Contacts/Contacts/task/src/contacts/object/Organization.java
hpereirahp/Hyperskill-code-repo
a9aeab9b67ce484ab30bd0facea45c2100586c09
[ "MIT" ]
null
null
null
24.139535
108
0.522158
4,797
package contacts.object; public class Organization extends Contact { private static long serialVersionUID = 1L; protected String address; public Organization() { super(); } protected String getAddress() { return address; } protected void setAddress(String address) { this.address = address; } @Override public Field[] getPossibleFields() { return new Field[] {Field.NAME.setFullName("organization name"), Field.ADDRESS, Field.PHONE_NUMBER}; } @Override public void setField(Field field, String value) { super.setField(field, value); switch (field) { case NAME: setName(value); break; case ADDRESS: setAddress(value); break; case PHONE_NUMBER: setPhoneNumber(value); break; default: // TODO error break; } } @Override public String getField(Field field) { switch (field) { case NAME: return getName(); case ADDRESS: return getAddress(); case PHONE_NUMBER: return getPhoneNumber(); default: // TODO error return null; } } @Override public String getSearchString() { return new StringBuilder() .append(name).append(address).append(phoneNumber) .toString(); } @Override public String getInfo() { return name; } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Organization name: ").append(name) .append("\nAddress: ").append(address) .append("\nNumber: ").append(phoneNumber) .append("\nTime created: ").append(createdAt) .append("\nTime last edit: ").append(updatedAt).append("\n"); return sb.toString(); } }
3e0b55b003df527528a94ec427536f0c70d534bd
7,179
java
Java
app/src/main/java/com/github/android_login/manager/notification/NotificationManager.java
310ken1/android-login
017fbc77a50bc4258774c46a19326855110194b0
[ "Apache-2.0" ]
null
null
null
app/src/main/java/com/github/android_login/manager/notification/NotificationManager.java
310ken1/android-login
017fbc77a50bc4258774c46a19326855110194b0
[ "Apache-2.0" ]
null
null
null
app/src/main/java/com/github/android_login/manager/notification/NotificationManager.java
310ken1/android-login
017fbc77a50bc4258774c46a19326855110194b0
[ "Apache-2.0" ]
null
null
null
35.019512
85
0.56331
4,798
package com.github.android_login.manager.notification; import android.bluetooth.BluetoothAdapter; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.wifi.WifiManager; import android.os.BatteryManager; import android.os.StatFs; import android.util.Log; import com.github.android_login.common.Notifier; import java.util.Iterator; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; public class NotificationManager extends Notifier<NotificationListener> { private static final String TAG = NotificationManager.class.getSimpleName(); private static final boolean DEBUG = true; private final Context context; private final int batteryStep = 5; private int batteryThresholdMax = 50; private int batteryThreshold = batteryThresholdMax; private final int storageStep = 5; private final String storagePath = "/sdcard"; private int storageThresholdMax = 50; private int storageThreshold = storageThresholdMax; private Timer timer; private final int interval = 10000; private final NotificationState state = new NotificationState(); private final BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (null == intent) return; switch (intent.getAction()) { case Intent.ACTION_BATTERY_CHANGED: checkBattery(intent); break; case WifiManager.WIFI_STATE_CHANGED_ACTION: checkWifi(intent); break; case BluetoothAdapter.ACTION_STATE_CHANGED: checkBluetooth(intent); default: break; } } }; int count = 10; int life = 10 * 1000; public NotificationManager(Context context) { this.context = context; IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_BATTERY_CHANGED); filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); context.registerReceiver(receiver, filter); ConcurrentHashMap<Integer, State> map = new ConcurrentHashMap<>(); timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { checkStorage(); // if (0 < count) { // map.put(count, new State(true)); // count--; // } else { // long current = System.currentTimeMillis(); // for(Iterator<State> i = map.values().iterator(); i.hasNext();){ // State s = i.next(); // if((s.timestamp + life) < current){ // i.remove(); // } // } // } // Log.d(TAG, "size=" + map.size()); } }, 0, interval); } public void close() { if (null != timer) { timer.cancel(); timer = null; } context.unregisterReceiver(receiver); } public NotificationState getState() { return this.state; } private void checkBattery(Intent intent) { int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1); boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL; int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); if (DEBUG) Log.d(TAG, "isCharging=" + isCharging + " level=" + level + " batteryThreshold=" + batteryThreshold); if (batteryThreshold < level) { int value = threshold(level, batteryStep); batteryThreshold = Math.min(value, batteryThresholdMax); } else { int value = threshold(level, batteryStep); batteryThreshold = Math.max(value, 0); notify(new NotificationBattery(level)); } if (DEBUG) Log.d(TAG, "batteryThreshold=" + batteryThreshold); } private void checkStorage() { StatFs statFs = new StatFs(storagePath); double total = statFs.getBlockCountLong() * statFs.getBlockSizeLong(); double free = statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong(); int rate = (int) (free / total * 100.0); if (DEBUG) Log.d(TAG, "total=" + total + " free=" + free + " rate=" + rate + " storageThreshold=" + storageThreshold); if (storageThreshold < rate) { int value = threshold(rate, storageStep); storageThreshold = Math.min(value, batteryThresholdMax); } else { int value = threshold(rate, storageStep); storageThreshold = Math.max(value, 0); notify(new NotificationBattery(rate)); } if (DEBUG) Log.d(TAG, "storageThreshold=" + storageThreshold); } private void checkWifi(Intent intent) { final int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED); boolean change = false; switch (state) { case WifiManager.WIFI_STATE_DISABLED: if (DEBUG) Log.d(TAG, "WiFi:OFF"); this.state.wifi = new State(false); change = true; break; case WifiManager.WIFI_STATE_ENABLED: if (DEBUG) Log.d(TAG, "WiFi:ON"); this.state.wifi = new State(true); change = true; break; default: break; } if (change) { notify(this.state); } } private void checkBluetooth(Intent intent) { final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR); boolean change = false; switch (state) { case BluetoothAdapter.STATE_OFF: if (DEBUG) Log.d(TAG, "Bluetooth:OFF"); this.state.bluetooth = new State(false); change = true; break; case BluetoothAdapter.STATE_ON: if (DEBUG) Log.d(TAG, "Bluetooth:ON"); this.state.bluetooth = new State(true); change = true; break; default: break; } if (change) { notify(this.state); } } private void notify(Notification notification) { notify(listener -> { listener.onNotify(notification); }); } private int threshold(int value, int step) { int base = (0 == (value % step)) ? value - 1 : value; return (base / step) * step; } }
3e0b567ee01c369b8caaa114477fe8bc58fcc99e
8,910
java
Java
src/main/java/net/openhft/chronicle/queue/impl/AbstractChronicleQueueBuilder.java
kavukcutolga/Chronicle-Queue
2d871b6774e696d898cebc5aa6bd9500c012a603
[ "Apache-2.0" ]
null
null
null
src/main/java/net/openhft/chronicle/queue/impl/AbstractChronicleQueueBuilder.java
kavukcutolga/Chronicle-Queue
2d871b6774e696d898cebc5aa6bd9500c012a603
[ "Apache-2.0" ]
null
null
null
src/main/java/net/openhft/chronicle/queue/impl/AbstractChronicleQueueBuilder.java
kavukcutolga/Chronicle-Queue
2d871b6774e696d898cebc5aa6bd9500c012a603
[ "Apache-2.0" ]
null
null
null
27
116
0.658923
4,799
/* * Copyright 2016 higherfrequencytrading.com * * 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 net.openhft.chronicle.queue.impl; import net.openhft.chronicle.bytes.BytesRingBufferStats; import net.openhft.chronicle.core.Maths; import net.openhft.chronicle.core.threads.EventLoop; import net.openhft.chronicle.core.time.SystemTimeProvider; import net.openhft.chronicle.core.time.TimeProvider; import net.openhft.chronicle.queue.ChronicleQueue; import net.openhft.chronicle.queue.ChronicleQueueBuilder; import net.openhft.chronicle.queue.RollCycle; import net.openhft.chronicle.queue.RollCycles; import net.openhft.chronicle.threads.Pauser; import net.openhft.chronicle.threads.TimeoutPauser; import net.openhft.chronicle.wire.Wire; import net.openhft.chronicle.wire.WireType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Supplier; /** * Created by peter on 05/03/2016. */ public abstract class AbstractChronicleQueueBuilder<B extends ChronicleQueueBuilder<B, Q>, Q extends ChronicleQueue> implements ChronicleQueueBuilder<B, Q> { protected final File path; protected long blockSize; @NotNull protected WireType wireType; @NotNull protected RollCycle rollCycle; protected long epoch; // default is 1970-01-01 00:00:00.000 UTC protected boolean isBuffered; protected Consumer<Throwable> onThrowable = Throwable::printStackTrace; @Nullable protected EventLoop eventLoop; private long bufferCapacity; private int indexSpacing; private int indexCount; /** * by default logs the performance stats of the ring buffer */ private Consumer<BytesRingBufferStats> onRingBufferStats = NoBytesRingBufferStats.NONE; private TimeProvider timeProvider = SystemTimeProvider.INSTANCE; private Supplier<Pauser> pauserSupplier = () -> new TimeoutPauser(500_000); private long timeoutMS = 10_000; // 10 seconds. private BiFunction<RollingChronicleQueue, Wire, WireStore> storeFactory; private int sourceId = 0; public AbstractChronicleQueueBuilder(File path) { this.rollCycle = RollCycles.DAILY; this.blockSize = 64L << 20; this.path = path; this.wireType = WireType.BINARY; this.epoch = 0; bufferCapacity = 2 << 20; indexSpacing = -1; indexCount = -1; } protected Logger getLogger() { return LoggerFactory.getLogger(getClass().getName()); } /** * consumer will be called every second, also as there is data to report * * @param onRingBufferStats a consumer of the BytesRingBufferStats * @return this */ @Override @NotNull public B onRingBufferStats(@NotNull Consumer<BytesRingBufferStats> onRingBufferStats) { this.onRingBufferStats = onRingBufferStats; return (B) this; } @Override public Consumer<BytesRingBufferStats> onRingBufferStats() { return this.onRingBufferStats; } @Override @NotNull public File path() { return this.path; } @Override @NotNull public B blockSize(int blockSize) { this.blockSize = blockSize; return (B) this; } @Override public long blockSize() { return this.blockSize; } @Override @NotNull public B wireType(@NotNull WireType wireType) { this.wireType = wireType; return (B) this; } @Override @NotNull public WireType wireType() { return this.wireType; } @Override @NotNull public B rollCycle(@NotNull RollCycle rollCycle) { this.rollCycle = rollCycle; return (B) this; } /** * @return ringBufferCapacity in bytes */ @Override public long bufferCapacity() { return bufferCapacity; } /** * @param ringBufferSize sets the ring buffer capacity in bytes * @return this */ @Override @NotNull public B bufferCapacity(long ringBufferSize) { this.bufferCapacity = ringBufferSize; return (B) this; } /** * sets epoch offset in milliseconds * * @param epoch sets an epoch offset as the number of number of milliseconds since January 1, * 1970, 00:00:00 GMT * @return {@code this} */ @Override @NotNull public B epoch(long epoch) { this.epoch = epoch; return (B) this; } /** * @return epoch offset as the number of number of milliseconds since January 1, 1970, 00:00:00 * GMT */ @Override public long epoch() { return epoch; } @Override @NotNull public RollCycle rollCycle() { return this.rollCycle; } /** * use this to trap exceptions that came from the other threads * * @param onThrowable your exception handler * @return this */ @Override @NotNull public B onThrowable(@NotNull Consumer<Throwable> onThrowable) { this.onThrowable = onThrowable; return (B) this; } /** * when set to {@code true}. uses a ring buffer to buffer appends, excerpts are written to the * Chronicle Queue using a background thread * * @param isBuffered {@code true} if the append is buffered * @return this */ @Override @NotNull public B buffered(boolean isBuffered) { this.isBuffered = isBuffered; return (B) this; } /** * @return if we uses a ring buffer to buffer the appends, the Excerts are written to the * Chronicle Queue using a background thread */ @Override public boolean buffered() { return this.isBuffered; } @Override @Nullable public EventLoop eventLoop() { return eventLoop; } @Override @NotNull public B eventLoop(EventLoop eventLoop) { this.eventLoop = eventLoop; return (B) this; } /** * setting the {@code bufferCapacity} also sets {@code buffered} to {@code true} * * @param bufferCapacity the capacity of the ring buffer * @return this */ @Override @NotNull public B bufferCapacity(int bufferCapacity) { this.bufferCapacity = bufferCapacity; this.isBuffered = true; return (B) this; } @Override public B indexCount(int indexCount) { this.indexCount = Maths.nextPower2(indexCount, 8); return (B) this; } @Override public int indexCount() { return indexCount <= 0 ? rollCycle.defaultIndexCount() : indexCount; } @Override public B indexSpacing(int indexSpacing) { this.indexSpacing = Maths.nextPower2(indexSpacing, 1); return (B) this; } @Override public int indexSpacing() { return indexSpacing <= 0 ? rollCycle.defaultIndexSpacing() : indexSpacing; } public TimeProvider timeProvider() { return timeProvider; } public B timeProvider(TimeProvider timeProvider) { this.timeProvider = timeProvider; return (B) this; } public Supplier<Pauser> pauserSupplier() { return pauserSupplier; } public B pauserSupplier(Supplier<Pauser> pauser) { this.pauserSupplier = pauser; return (B) this; } public B timeoutMS(long timeoutMS) { this.timeoutMS = timeoutMS; return (B) this; } public long timeoutMS() { return timeoutMS; } public void storeFactory(BiFunction<RollingChronicleQueue, Wire, WireStore> storeFactory) { this.storeFactory = storeFactory; } @Override public BiFunction<RollingChronicleQueue, Wire, WireStore> storeFactory() { return storeFactory; } public B sourceId(int sourceId) { if (sourceId < 0) throw new IllegalArgumentException("Invalid source Id, must be positive"); this.sourceId = sourceId; return (B) this; } public int sourceId() { return sourceId; } enum NoBytesRingBufferStats implements Consumer<BytesRingBufferStats> { NONE; @Override public void accept(BytesRingBufferStats bytesRingBufferStats) { } } }
3e0b56877311a94ee100c703ce1bae71176bc236
390
java
Java
JavaExperiment/src/com/myproject/mytest/MainTest1.java
ashish246/java-labs
106dee4689f7fb42537e87e8b3c6a6aad0856dde
[ "MIT" ]
null
null
null
JavaExperiment/src/com/myproject/mytest/MainTest1.java
ashish246/java-labs
106dee4689f7fb42537e87e8b3c6a6aad0856dde
[ "MIT" ]
null
null
null
JavaExperiment/src/com/myproject/mytest/MainTest1.java
ashish246/java-labs
106dee4689f7fb42537e87e8b3c6a6aad0856dde
[ "MIT" ]
null
null
null
15
60
0.674359
4,800
package com.myproject.mytest; public class MainTest1 { public String test1; public String test2; public MainTest1(final String pTest1){ this(pTest1, null); } public MainTest1(final String pTest1, final String pTest2){ test1= pTest1; test2 = pTest2; } public void print(){ System.out.println("test1---->"+test1); System.out.println("test2---->"+test2); } }
3e0b578913841d72324fae2a93c00ae71062d36b
9,639
java
Java
x-pack/qa/sql/security/src/test/java/org/elasticsearch/xpack/qa/sql/security/CliSecurityIT.java
GaiserChan/elasticsearch
dcd4667e955666837e2cd9b6177ffb9ebfdcc249
[ "Apache-2.0" ]
49
2017-05-19T04:43:12.000Z
2021-07-03T05:59:26.000Z
x-pack/qa/sql/security/src/test/java/org/elasticsearch/xpack/qa/sql/security/CliSecurityIT.java
GaiserChan/elasticsearch
dcd4667e955666837e2cd9b6177ffb9ebfdcc249
[ "Apache-2.0" ]
3
2018-06-07T06:52:21.000Z
2020-11-29T02:42:44.000Z
x-pack/qa/sql/security/src/test/java/org/elasticsearch/xpack/qa/sql/security/CliSecurityIT.java
GaiserChan/elasticsearch
dcd4667e955666837e2cd9b6177ffb9ebfdcc249
[ "Apache-2.0" ]
39
2017-04-02T16:15:51.000Z
2020-02-03T14:37:28.000Z
45.9
132
0.574333
4,801
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ package org.elasticsearch.xpack.qa.sql.security; import org.elasticsearch.common.CheckedConsumer; import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.xpack.qa.sql.cli.EmbeddedCli; import org.elasticsearch.xpack.qa.sql.cli.EmbeddedCli.SecurityConfig; import org.elasticsearch.xpack.qa.sql.cli.ErrorsTestCase; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import static org.elasticsearch.xpack.qa.sql.cli.CliIntegrationTestCase.elasticsearchAddress; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.startsWith; public class CliSecurityIT extends SqlSecurityTestCase { static SecurityConfig adminSecurityConfig() { String keystoreLocation; String keystorePassword; if (RestSqlIT.SSL_ENABLED) { Path keyStore; try { keyStore = PathUtils.get(RestSqlIT.class.getResource("/test-node.jks").toURI()); } catch (URISyntaxException e) { throw new RuntimeException("exception while reading the store", e); } if (!Files.exists(keyStore)) { throw new IllegalStateException("Keystore file [" + keyStore + "] does not exist."); } keystoreLocation = keyStore.toAbsolutePath().toString(); keystorePassword = "keypass"; } else { keystoreLocation = null; keystorePassword = null; } return new SecurityConfig(RestSqlIT.SSL_ENABLED, "test_admin", "x-pack-test-password", keystoreLocation, keystorePassword); } /** * Perform security test actions using the CLI. */ private static class CliActions implements Actions { @Override public String minimalPermissionsForAllActions() { return "cli_or_drivers_minimal"; } private SecurityConfig userSecurity(String user) { SecurityConfig admin = adminSecurityConfig(); if (user == null) { return admin; } return new SecurityConfig(RestSqlIT.SSL_ENABLED, user, "testpass", admin.keystoreLocation(), admin.keystorePassword()); } @Override public void queryWorksAsAdmin() throws Exception { try (EmbeddedCli cli = new EmbeddedCli(elasticsearchAddress(), true, adminSecurityConfig())) { assertThat(cli.command("SELECT * FROM test ORDER BY a"), containsString("a | b | c")); assertEquals("---------------+---------------+---------------", cli.readLine()); assertThat(cli.readLine(), containsString("1 |2 |3")); assertThat(cli.readLine(), containsString("4 |5 |6")); assertEquals("", cli.readLine()); } } @Override public void expectMatchesAdmin(String adminSql, String user, String userSql) throws Exception { expectMatchesAdmin(adminSql, user, userSql, cli -> {}); } @Override public void expectScrollMatchesAdmin(String adminSql, String user, String userSql) throws Exception { expectMatchesAdmin(adminSql, user, userSql, cli -> { assertEquals("[?1l>[?1000l[?2004lfetch size set to [90m1[0m", cli.command("fetch size = 1")); assertEquals("[?1l>[?1000l[?2004lfetch separator set to \"[90m -- fetch sep -- [0m\"", cli.command("fetch separator = \" -- fetch sep -- \"")); }); } public void expectMatchesAdmin(String adminSql, String user, String userSql, CheckedConsumer<EmbeddedCli, Exception> customizer) throws Exception { List<String> adminResult = new ArrayList<>(); try (EmbeddedCli cli = new EmbeddedCli(elasticsearchAddress(), true, adminSecurityConfig())) { customizer.accept(cli); adminResult.add(cli.command(adminSql)); String line; do { line = cli.readLine(); adminResult.add(line); } while (false == (line.equals("[0m") || line.equals(""))); adminResult.add(line); } Iterator<String> expected = adminResult.iterator(); try (EmbeddedCli cli = new EmbeddedCli(elasticsearchAddress(), true, userSecurity(user))) { customizer.accept(cli); assertTrue(expected.hasNext()); assertEquals(expected.next(), cli.command(userSql)); String line; do { line = cli.readLine(); assertTrue(expected.hasNext()); assertEquals(expected.next(), line); } while (false == (line.equals("[0m") || line.equals(""))); assertTrue(expected.hasNext()); assertEquals(expected.next(), line); assertFalse(expected.hasNext()); } } @Override public void expectDescribe(Map<String, List<String>> columns, String user) throws Exception { try (EmbeddedCli cli = new EmbeddedCli(elasticsearchAddress(), true, userSecurity(user))) { String output = cli.command("DESCRIBE test"); assertThat(output, containsString("column")); assertThat(output, containsString("type")); assertThat(output, containsString("mapping")); assertThat(cli.readLine(), containsString("-+---------------+---------------")); for (Map.Entry<String, List<String>> column : columns.entrySet()) { String line = cli.readLine(); assertThat(line, startsWith(column.getKey())); for (String value : column.getValue()) { assertThat(line, containsString(value)); } } assertEquals("", cli.readLine()); } } @Override public void expectShowTables(List<String> tables, String user) throws Exception { try (EmbeddedCli cli = new EmbeddedCli(elasticsearchAddress(), true, userSecurity(user))) { String tablesOutput = cli.command("SHOW TABLES"); assertThat(tablesOutput, containsString("name")); assertThat(tablesOutput, containsString("type")); assertEquals("---------------+---------------", cli.readLine()); for (String table : tables) { String line = null; /* * Security automatically creates either a `.security` or a * `.security6` index but it might not have created the index * by the time the test runs. */ while (line == null || line.startsWith(".security")) { line = cli.readLine(); } assertThat(line, containsString(table)); } assertEquals("", cli.readLine()); } } @Override public void expectUnknownIndex(String user, String sql) throws Exception { try (EmbeddedCli cli = new EmbeddedCli(elasticsearchAddress(), true, userSecurity(user))) { ErrorsTestCase.assertFoundOneProblem(cli.command(sql)); assertThat(cli.readLine(), containsString("Unknown index")); } } @Override public void expectForbidden(String user, String sql) throws Exception { /* * Cause the CLI to skip its connection test on startup so we * can get a forbidden exception when we run the query. */ try (EmbeddedCli cli = new EmbeddedCli(elasticsearchAddress(), false, userSecurity(user))) { assertThat(cli.command(sql), containsString("is unauthorized for user [" + user + "]")); } } @Override public void expectUnknownColumn(String user, String sql, String column) throws Exception { try (EmbeddedCli cli = new EmbeddedCli(elasticsearchAddress(), true, userSecurity(user))) { ErrorsTestCase.assertFoundOneProblem(cli.command(sql)); assertThat(cli.readLine(), containsString("Unknown column [" + column + "]" + ErrorsTestCase.END)); } } @Override public void checkNoMonitorMain(String user) throws Exception { // Building the cli will attempt the connection and run the assertion @SuppressWarnings("resource") // forceClose will close it EmbeddedCli cli = new EmbeddedCli(elasticsearchAddress(), true, userSecurity(user)) { @Override protected void assertConnectionTest() throws IOException { assertThat(readLine(), containsString("action [cluster:monitor/main] is unauthorized for user [" + user + "]")); } }; cli.forceClose(); } } public CliSecurityIT() { super(new CliActions()); } }
3e0b58c1d1a544cc0431075acfd8f178b384e5b2
228
java
Java
src/main/java/cs/ubc/ca/errors/CompileError.java
marquesarthur/tiny-dot
48621a97c11cc46d96be9e96d65a921db7c1fd7e
[ "MIT" ]
1
2019-07-30T08:47:07.000Z
2019-07-30T08:47:07.000Z
src/main/java/cs/ubc/ca/errors/CompileError.java
marquesarthur/tiny-dot
48621a97c11cc46d96be9e96d65a921db7c1fd7e
[ "MIT" ]
null
null
null
src/main/java/cs/ubc/ca/errors/CompileError.java
marquesarthur/tiny-dot
48621a97c11cc46d96be9e96d65a921db7c1fd7e
[ "MIT" ]
1
2018-10-03T22:18:37.000Z
2018-10-03T22:18:37.000Z
17.538462
52
0.644737
4,802
package cs.ubc.ca.errors; public class CompileError extends RuntimeException { public CompileError(String msg) { super(msg); } public CompileError(String msg, Exception e) { super(msg, e); } }
3e0b5a9f19228f1f01a3e64ab7a2c948f11e9161
4,777
java
Java
Object Oriented Programming Methodology/Exp06.java
jimit105/Computer-Engineering-Programs
695eff84e9a6e004f92d8378b2f6aea28ae1b6c5
[ "MIT" ]
5
2018-10-16T15:01:14.000Z
2022-03-15T06:09:29.000Z
Object Oriented Programming Methodology/Exp06.java
jimit105/Computer-Engineering-Programs
695eff84e9a6e004f92d8378b2f6aea28ae1b6c5
[ "MIT" ]
null
null
null
Object Oriented Programming Methodology/Exp06.java
jimit105/Computer-Engineering-Programs
695eff84e9a6e004f92d8378b2f6aea28ae1b6c5
[ "MIT" ]
2
2018-10-09T17:48:59.000Z
2020-09-12T15:07:40.000Z
17.370909
107
0.604982
4,803
import java.util.*; class Student { int rollno; String name; double g_t; Student (int r, String name1, double total) { rollno=r; name=name1; g_t=total; } public String toString() { return("Roll No.: "+rollno+"\t\tName: "+name+"\t\tTotal Marks: "+g_t); } } class Vector1 { Vector<Student> v=new Vector<Student>(); void Create() { System.out.println("\nEnter the total number of students "); Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for (int i=0;i<n;i++) { System.out.println("\nEnter the roll number of student "+(i+1)); int r=sc.nextInt(); System.out.println("\nEnter the name of student "+(i+1)); String name=sc.next(); System.out.println("\nEnter the total marks of student "+(i+1)); double total=sc.nextDouble(); Student s=new Student (r, name, total); if(v.size()==0) v.add(s); else { int j; for(j=0;j<v.size();j++) { if(((Student)v.elementAt(j)).g_t < total) break; } v.insertElementAt(s,j); } } } void Display() { for(int i=0;i<v.size();i++) { System.out.println("\nDetails of student "+(i+1)+":"); String s1=v.elementAt(i).toString(); System.out.println("\n"+s1); } } void Insert() { int j; Scanner sc=new Scanner(System.in); System.out.println("\nEnter the roll number "); int r=sc.nextInt(); System.out.println("\nEnter the name "); String name=sc.next(); System.out.println("\nEnter the total marks "); double total=sc.nextDouble(); Student s=new Student (r, name, total); for(j=0;j<v.size();j++) { if(((Student)v.elementAt(j)).g_t < total) break; } v.insertElementAt(s,j); } void deleteByName() { Scanner sc=new Scanner(System.in); System.out.println("\nEnter the name of the student "); String name1=sc.next(); for(int i=0;i<v.size();i++) { if(((Student)v.elementAt(i)).name.equals(name1)) { v.removeElementAt(i); break; } } } void deleteByRollNo() { Scanner sc=new Scanner(System.in); System.out.println("\nEnter the roll number of the student "); int rn=sc.nextInt(); for(int i=0;i<v.size();i++) { if(((Student)v.elementAt(i)).rollno==rn) { v.removeElementAt(i); break; } } } } class Exp06 { public static void main(String args[]) { int ch; Vector1 obj=new Vector1(); Scanner sc=new Scanner(System.in); System.out.println("\nEnter the details "); obj.Create(); obj.Display(); do { System.out.println("\nEnter your choice\n1.Insert\n2.Delete By Name\n3.Delete By Roll Number\n4.Exit"); ch=sc.nextInt(); if(ch==1) { obj.Insert(); obj.Display(); } else if(ch==2) { obj.deleteByName(); obj.Display(); } else if(ch==3) { obj.deleteByRollNo(); obj.Display(); } }while(ch!=4); } } /* OUTPUT * *Enter the details Enter the total number of students 3 Enter the roll number of student 1 1 Enter the name of student 1 abc Enter the total marks of student 1 40 Enter the roll number of student 2 2 Enter the name of student 2 pqr Enter the total marks of student 2 35 Enter the roll number of student 3 3 Enter the name of student 3 xyz Enter the total marks of student 3 45 Details of student 1: Roll No.: 3 Name: xyz Total Marks: 45.0 Details of student 2: Roll No.: 1 Name: abc Total Marks: 40.0 Details of student 3: Roll No.: 2 Name: pqr Total Marks: 35.0 Enter your choice 1.Insert 2.Delete By Name 3.Delete By Roll Number 4.Exit 1 Enter the roll number 4 Enter the name lmn Enter the total marks 55 Details of student 1: Roll No.: 4 Name: lmn Total Marks: 55.0 Details of student 2: Roll No.: 3 Name: xyz Total Marks: 45.0 Details of student 3: Roll No.: 1 Name: abc Total Marks: 40.0 Details of student 4: Roll No.: 2 Name: pqr Total Marks: 35.0 Enter your choice 1.Insert 2.Delete By Name 3.Delete By Roll Number 4.Exit 2 Enter the name of the student abc Details of student 1: Roll No.: 4 Name: lmn Total Marks: 55.0 Details of student 2: Roll No.: 3 Name: xyz Total Marks: 45.0 Details of student 3: Roll No.: 2 Name: pqr Total Marks: 35.0 Enter your choice 1.Insert 2.Delete By Name 3.Delete By Roll Number 4.Exit 3 Enter the roll number of the student 3 Details of student 1: Roll No.: 4 Name: lmn Total Marks: 55.0 Details of student 2: Roll No.: 2 Name: pqr Total Marks: 35.0 Enter your choice 1.Insert 2.Delete By Name 3.Delete By Roll Number 4.Exit 4 Process completed. */
3e0b5b39c96b8b7f3b459a47b979580f5f0b09d7
18,246
java
Java
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorHandlerObjectDelete.java
opct/dbeaver
434253ee861c1a577318ae3cd3a4a2512c51dd21
[ "Apache-2.0" ]
null
null
null
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorHandlerObjectDelete.java
opct/dbeaver
434253ee861c1a577318ae3cd3a4a2512c51dd21
[ "Apache-2.0" ]
null
null
null
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/navigator/actions/NavigatorHandlerObjectDelete.java
opct/dbeaver
434253ee861c1a577318ae3cd3a4a2512c51dd21
[ "Apache-2.0" ]
null
null
null
49.989041
226
0.626219
4,804
/* * DBeaver - Universal Database Manager * Copyright (C) 2010-2021 DBeaver Corp and others * * 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.jkiss.dbeaver.ui.navigator.actions; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.*; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.commands.IElementUpdater; import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.menus.UIElement; import org.jkiss.code.NotNull; import org.jkiss.dbeaver.DBException; import org.jkiss.dbeaver.Log; import org.jkiss.dbeaver.model.DBUtils; import org.jkiss.dbeaver.model.edit.DBEObjectManager; import org.jkiss.dbeaver.model.edit.DBEObjectWithDependencies; import org.jkiss.dbeaver.model.navigator.*; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; import org.jkiss.dbeaver.model.struct.*; import org.jkiss.dbeaver.model.struct.rdb.DBSTableConstraint; import org.jkiss.dbeaver.model.struct.rdb.DBSTableIndex; import org.jkiss.dbeaver.runtime.DBWorkbench; import org.jkiss.dbeaver.ui.DBeaverIcons; import org.jkiss.dbeaver.ui.UIIcon; import org.jkiss.dbeaver.ui.UIUtils; import org.jkiss.dbeaver.ui.internal.UINavigatorMessages; import org.jkiss.utils.CommonUtils; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; public class NavigatorHandlerObjectDelete extends NavigatorHandlerObjectBase implements IElementUpdater { private static final Log log = Log.getLog(NavigatorHandlerObjectDelete.class); @Override public Object execute(final ExecutionEvent event) throws ExecutionException { final ISelection selection = HandlerUtil.getCurrentSelection(event); if (!(selection instanceof IStructuredSelection)) { return null; } final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); tryDeleteObjects(window, (IStructuredSelection) selection); return null; } public static boolean tryDeleteObjects(IWorkbenchWindow window, IStructuredSelection selection) { @SuppressWarnings("unchecked") final List<DBNNode> selectedObjects = selection.toList(); final NavigatorObjectsDeleter deleter = NavigatorObjectsDeleter.of(selectedObjects, window); return makeDeletionAttempt(window, selectedObjects, deleter); } private static boolean makeDeletionAttempt(final IWorkbenchWindow window, final List<?> selectedObjects, final NavigatorObjectsDeleter deleter) { if (deleter.hasNodesFromDifferentDataSources()) { // attempt to delete database nodes from different databases DBWorkbench.getPlatformUI(). showError( UINavigatorMessages.error_deleting_multiple_objects_from_different_datasources_title, UINavigatorMessages.error_deleting_multiple_objects_from_different_datasources_message ); return false; } final ConfirmationDialog dialog = ConfirmationDialog.of( window.getShell(), selectedObjects, deleter); final int result = dialog.open(); if (result == IDialogConstants.YES_ID) { return deleteObjects(window, deleter, selectedObjects); } else if (result == IDialogConstants.DETAILS_ID) { final boolean persistCheck = deleter.showScriptWindow(); if (persistCheck) { return deleteObjects(window, deleter, selectedObjects); } else { return makeDeletionAttempt(window, selectedObjects, deleter); } } else { return false; } } private static boolean deleteObjects(final IWorkbenchWindow window, NavigatorObjectsDeleter deleter, final List<?> selectedObjects) { if (confirmDependenciesDelete(window, selectedObjects)) { deleter.delete(); return true; } return false; } private static boolean confirmDependenciesDelete(final IWorkbenchWindow window, final List<?> selectedObjects) { List<DBNNode> dependentObjectsListNodes = new ArrayList<>(); try { UIUtils.runInProgressService(monitor -> { for (Object obj : selectedObjects) { if (obj instanceof DBNDatabaseItem) { DBSObject dbsObject = ((DBNDatabaseItem) obj).getObject(); if (dbsObject instanceof DBSEntityAttribute) { DBSEntityAttribute attribute = (DBSEntityAttribute) dbsObject; DBEObjectManager<?> objectManager = attribute.getDataSource().getContainer().getPlatform().getEditorsRegistry().getObjectManager(attribute.getClass()); if (objectManager instanceof DBEObjectWithDependencies) { try { List<? extends DBSObject> dependentObjectsList = ((DBEObjectWithDependencies) objectManager).getDependentObjectsList(monitor, attribute); changeDependentObjectsList(monitor, dependentObjectsList); if (!CommonUtils.isEmpty(dependentObjectsList)) { for (Object object : dependentObjectsList) { if (object instanceof DBSObject) { DBNDatabaseNode node = DBNUtils.getNodeByObject(monitor, (DBSObject) object, false); dependentObjectsListNodes.add(node); } } } } catch (DBException e) { log.debug("Can't get object dependent list", e); } } } } } }); } catch (InvocationTargetException e) { DBWorkbench.getPlatformUI().showError( UINavigatorMessages.search_dependencies_error_title, UINavigatorMessages.search_dependencies_error_message, e.getTargetException()); } catch (InterruptedException ignored) { } if (!CommonUtils.isEmpty(dependentObjectsListNodes)) { NavigatorObjectsDeleter dependentObjectsDeleter = NavigatorObjectsDeleter.of(dependentObjectsListNodes, window); String confirmMessage; if (dependentObjectsListNodes.size() == 1) { DBNDatabaseNode node = (DBNDatabaseNode) dependentObjectsListNodes.get(0); confirmMessage = NLS.bind(UINavigatorMessages.confirm_deleting_dependent_one_object, node.getNodeType(), node.getNodeName()); } else { confirmMessage = NLS.bind(UINavigatorMessages.confirm_deleting_dependent_objects, dependentObjectsListNodes.size()); } final ConfirmationDialog dialog = new ConfirmationDialog( window.getShell(), UINavigatorMessages.confirm_deleting_dependent_objects_title, confirmMessage, dependentObjectsListNodes, dependentObjectsDeleter); final int result = dialog.open(); if (result == IDialogConstants.YES_ID) { dependentObjectsDeleter.delete(); return true; } else { return false; } } else { return true; } } private static void changeDependentObjectsList(@NotNull DBRProgressMonitor monitor, List<? extends DBSObject> dependentObjectsList) throws DBException { // Some indexes in some databases in fact duplicate existing keys, and therefore deleting keys will automatically delete indexes on the database side // Let's find this indexes and remove from dependent list if (!CommonUtils.isEmpty(dependentObjectsList)) { List<? extends DBSObject> indexList = dependentObjectsList.stream().filter(o -> o instanceof DBSTableIndex).collect(Collectors.toList()); List<? extends DBSObject> constrList = dependentObjectsList.stream().filter(o -> o instanceof DBSTableConstraint).collect(Collectors.toList()); for (DBSObject constraint : constrList) { for (DBSObject index : indexList) { if (constraint instanceof DBSEntityReferrer && index instanceof DBSEntityReferrer) { if (DBUtils.referrerMatches(monitor, (DBSEntityReferrer) constraint, DBUtils.getEntityAttributes(monitor, (DBSEntityReferrer) index))) { dependentObjectsList.remove(index); } } } } } } private static class ConfirmationDialog extends MessageDialog { private final List<?> selectedObjects; private final NavigatorObjectsDeleter deleter; private ConfirmationDialog(final Shell shell, final String title, final String message, final List<?> selectedObjects, final NavigatorObjectsDeleter deleter) { super( shell, title, DBeaverIcons.getImage(UIIcon.REJECT), message, MessageDialog.WARNING, null, 0 ); this.selectedObjects = selectedObjects; this.deleter = deleter; } static ConfirmationDialog of(final Shell shell, final List<?> selectedObjects, final NavigatorObjectsDeleter deleter) { if (selectedObjects.size() > 1) { return new ConfirmationDialog( shell, UINavigatorMessages.confirm_deleting_multiple_objects_title, NLS.bind(UINavigatorMessages.confirm_deleting_multiple_objects_message, selectedObjects.size()), selectedObjects, deleter); } final DBNNode node = (DBNNode) selectedObjects.get(0); final String title = NLS.bind(node instanceof DBNLocalFolder ? UINavigatorMessages.confirm_local_folder_delete_title : UINavigatorMessages.confirm_entity_delete_title, node.getNodeType(), node.getNodeName()); final String message = NLS.bind(node instanceof DBNLocalFolder ? UINavigatorMessages.confirm_local_folder_delete_message : UINavigatorMessages.confirm_entity_delete_message, node.getNodeType(), node.getNodeName()); return new ConfirmationDialog(shell, title, message, selectedObjects, deleter); } @Override protected Control createCustomArea(final Composite parent) { if (selectedObjects.size() > 1) { createObjectsTable(parent); } createDeleteContents(parent); createCascadeButton(parent); return super.createCustomArea(parent); } private void createObjectsTable(final Composite parent) { final Composite placeholder = UIUtils.createComposite(parent, 1); placeholder.setLayoutData(new GridData(GridData.FILL_BOTH)); final Group tableGroup = UIUtils.createControlGroup(placeholder, UINavigatorMessages.confirm_deleting_multiple_objects_table_group_name, 1, GridData.FILL_BOTH, 0); tableGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); final Table objectsTable = new Table(tableGroup, SWT.BORDER | SWT.FULL_SELECTION); objectsTable.setHeaderVisible(false); objectsTable.setLinesVisible(true); GridData gd = new GridData(GridData.FILL_BOTH); int fontHeight = UIUtils.getFontHeight(objectsTable); int rowCount = selectedObjects.size(); gd.widthHint = fontHeight * 7; gd.heightHint = rowCount < 6 ? fontHeight * 2 * rowCount : fontHeight * 10; objectsTable.setLayoutData(gd); UIUtils.createTableColumn(objectsTable, SWT.LEFT, UINavigatorMessages.confirm_deleting_multiple_objects_column_name); UIUtils.createTableColumn(objectsTable, SWT.LEFT, UINavigatorMessages.confirm_deleting_multiple_objects_column_description); for (Object obj: selectedObjects) { if (!(obj instanceof DBNNode)) { continue; } final DBNNode node = (DBNNode) obj; final TableItem item = new TableItem(objectsTable, SWT.NONE); item.setImage(DBeaverIcons.getImage(node.getNodeIcon())); if (node instanceof DBNResource && ((DBNResource) node).getResource() != null) { item.setText(0, node.getName()); IPath resLocation = ((DBNResource) node).getResource().getLocation(); item.setText(1, resLocation == null ? "" : resLocation.toFile().getAbsolutePath()); } else { item.setText(0, node.getNodeFullName()); item.setText(1, CommonUtils.toString(node.getNodeDescription())); } } UIUtils.packColumns(objectsTable, true); } private void createDeleteContents(final Composite parent) { if (!deleter.isShowDeleteContents()) { return; } IProject project = deleter.getProjectToDelete(); if (project == null) { return; } final Composite ph = UIUtils.createPlaceholder(parent, 2, 5); final Button keepContentsCheck = UIUtils.createCheckbox( ph, UINavigatorMessages.confirm_deleting_delete_contents_checkbox, UINavigatorMessages.confirm_deleting_delete_contents_checkbox_tooltip, false, 2 ); keepContentsCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { deleter.setDeleteContents(keepContentsCheck.getSelection()); } }); UIUtils.createLabelText(ph, UINavigatorMessages.confirm_deleting_project_location_label, project.getLocation().toFile().getAbsolutePath(), SWT.READ_ONLY); } private void createCascadeButton(final Composite parent) { if (!deleter.isShowCascade()) { return; } final Composite ph = UIUtils.createPlaceholder(parent, 1, 5); final Button cascadeCheckButton = UIUtils.createCheckbox( ph, UINavigatorMessages.confirm_deleting_multiple_objects_cascade_checkbox, UINavigatorMessages.confirm_deleting_multiple_objects_cascade_checkbox_tooltip, false, 0 ); cascadeCheckButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { deleter.setDeleteCascade(cascadeCheckButton.getSelection()); } }); } @Override protected void createButtonsForButtonBar(final Composite parent) { createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); if (deleter.isShowViewScript()) { createButton(parent, IDialogConstants.DETAILS_ID, UINavigatorMessages.actions_navigator_view_script_button, false); } } @Override protected boolean isResizable() { return true; } } @Override public void updateElement(UIElement element, Map parameters) { // if (!updateUI) { // return; // } // final ISelectionProvider selectionProvider = UIUtils.getSelectionProvider(element.getServiceLocator()); // if (selectionProvider != null) { // ISelection selection = selectionProvider.getSelection(); // // if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() > 1) { // element.setText(UINavigatorMessages.actions_navigator_delete_objects); // } else { // DBNNode node = NavigatorUtils.getSelectedNode(selection); // if (node != null) { // element.setText(UINavigatorMessages.actions_navigator_delete_ + " " + node.getNodeTypeLabel() + " '" + node.getNodeName() + "'"); // } // } // } } }
3e0b5b5ed6c7f1668aee4eb8df501d795aef074f
2,838
java
Java
platforms/android/farwolf.weex/src/main/java/com/farwolf/weex/activity/ActivityManager.java
qq476743842/weex-saoa
27d2347e865cf35e7c9bfb6180ba7b5106875296
[ "MIT" ]
13
2018-04-14T09:38:13.000Z
2021-09-03T17:07:04.000Z
platforms/android/farwolf.weex/src/main/java/com/farwolf/weex/activity/ActivityManager.java
qq476743842/weex-oa
27d2347e865cf35e7c9bfb6180ba7b5106875296
[ "MIT" ]
1
2019-09-05T02:17:42.000Z
2019-09-05T02:17:42.000Z
platforms/android/farwolf.weex/src/main/java/com/farwolf/weex/activity/ActivityManager.java
qq476743842/weex-oa
27d2347e865cf35e7c9bfb6180ba7b5106875296
[ "MIT" ]
5
2019-08-13T08:36:46.000Z
2021-09-03T05:20:21.000Z
35.475
97
0.647287
4,805
package com.farwolf.weex.activity; import android.app.Activity; import android.app.Application; import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Created by zhengjiangrong on 2017/12/23. */ public class ActivityManager { private static ActivityManager sInstance = new ActivityManager(); // 采用弱引用持有 Activity ,避免造成 内存泄露 private WeakReference<Activity> sCurrentActivityWeakRef; private ActivityManager() { } public static ActivityManager getInstance() { return sInstance; } public Activity getCurrentActivity() { Activity currentActivity = null; if (sCurrentActivityWeakRef != null) { currentActivity = sCurrentActivityWeakRef.get(); } return currentActivity; } public void setCurrentActivity(Activity activity) { sCurrentActivityWeakRef = new WeakReference<Activity>(activity); } public static List<Activity> getActivitiesByApplication(Application application) { List<Activity> list = new ArrayList<>(); try { Class<Application> applicationClass = Application.class; Field mLoadedApkField = applicationClass.getDeclaredField("mLoadedApk"); mLoadedApkField.setAccessible(true); Object mLoadedApk = mLoadedApkField.get(application); Class<?> mLoadedApkClass = mLoadedApk.getClass(); Field mActivityThreadField = mLoadedApkClass.getDeclaredField("mActivityThread"); mActivityThreadField.setAccessible(true); Object mActivityThread = mActivityThreadField.get(mLoadedApk); Class<?> mActivityThreadClass = mActivityThread.getClass(); Field mActivitiesField = mActivityThreadClass.getDeclaredField("mActivities"); mActivitiesField.setAccessible(true); Object mActivities = mActivitiesField.get(mActivityThread); // 注意这里一定写成Map,低版本这里用的是HashMap,高版本用的是ArrayMap if (mActivities instanceof Map) { @SuppressWarnings("unchecked") Map<Object, Object> arrayMap = (Map<Object, Object>) mActivities; for (Map.Entry<Object, Object> entry : arrayMap.entrySet()) { Object value = entry.getValue(); Class<?> activityClientRecordClass = value.getClass(); Field activityField = activityClientRecordClass.getDeclaredField("activity"); activityField.setAccessible(true); Object o = activityField.get(value); list.add((Activity) o); } } } catch (Exception e) { e.printStackTrace(); list = null; } return list; } }
3e0b5b707ed4664bcad0d9bde0d44361250d3dad
3,225
java
Java
src/test/java/space/hideaway/util/ServicesTests/UserModelTest.java
MTUHIDE/CocoTemp
3e78b8884b9710eb9ba50603557fda6b6da1b555
[ "MIT" ]
7
2016-10-20T01:58:40.000Z
2019-10-01T16:32:27.000Z
src/test/java/space/hideaway/util/ServicesTests/UserModelTest.java
MTUHIDE/CoCoTemp
3e78b8884b9710eb9ba50603557fda6b6da1b555
[ "MIT" ]
142
2016-10-05T21:44:26.000Z
2022-01-21T23:21:43.000Z
src/test/java/space/hideaway/util/ServicesTests/UserModelTest.java
MTUHIDE/CocoTemp
3e78b8884b9710eb9ba50603557fda6b6da1b555
[ "MIT" ]
2
2017-10-08T17:49:03.000Z
2019-10-15T07:21:51.000Z
21.938776
75
0.651783
4,806
package space.hideaway.util.ServicesTests; import org.junit.*; import space.hideaway.model.Device; import space.hideaway.model.Role; import space.hideaway.model.User; import space.hideaway.model.site.Site; import space.hideaway.model.upload.UploadHistory; import java.util.HashSet; import java.util.Set; import static org.mockito.Mockito.mock; public class UserModelTest { User user; @Before public void setUp(){ user = new User(); } @Test public void TestGetAndSetId(){ Long expectedId = (long)345; user.setId(expectedId); Assert.assertEquals(expectedId,user.getId()); } @Test public void TestGetAndSetEmail(){ String email = "email"; user.setEmail(email); Assert.assertEquals(email,user.getEmail()); } @Test public void TestGetAndSetUsername(){ String username = "username"; user.setUsername(username); Assert.assertEquals(username,user.getUsername()); } @Test public void TestGetAndSetPassword(){ String password = "Password123!"; user.setPassword(password); Assert.assertEquals(password,user.getPassword()); } @Test public void TestGetAndSetConfirmationPassword(){ String password = "confirm"; user.setConfirmationPassword(password); Assert.assertEquals(password,user.getConfirmationPassword()); } @Test public void TestGetAndSetFirstName(){ String FName = "name"; user.setFirstName(FName); Assert.assertEquals(FName,user.getFirstName()); } @Test public void TestGetAndSetMiddleInitial(){ String Initial = "K"; user.setMiddleInitial(Initial); Assert.assertEquals(Initial,user.getMiddleInitial()); } @Test public void TestGetAndSetLastName(){ String LName = "Name"; user.setLastName(LName); Assert.assertEquals(LName,user.getLastName()); } @Test public void TestGetAndSetRoleSet(){ Set<Role> roleSet= new HashSet<Role>(); Role MockRole = mock(Role.class); roleSet.add(MockRole); user.setRoleSet(roleSet); Assert.assertEquals(roleSet,user.getRoleSet()); } @Test public void TestGetAndSetSiteSet(){ Set<Site> SiteSet= new HashSet<Site>(); Site MockSite = mock(Site.class); SiteSet.add(MockSite); user.setSiteSet(SiteSet); Assert.assertEquals(SiteSet,user.getSiteSet()); } @Test public void TestGetAndSetUploadHistorySet(){ Set<UploadHistory> uploadHistorySet= new HashSet<UploadHistory>(); UploadHistory MockUploadHistory = mock(UploadHistory.class); uploadHistorySet.add(MockUploadHistory); user.setUploadHistorySet(uploadHistorySet); Assert.assertEquals(uploadHistorySet,user.getUploadHistorySet()); } @Test public void TestGetAndSetDeviceSet(){ Set<Device> deviceSet= new HashSet<Device>(); Device MockDevice = mock(Device.class); deviceSet.add(MockDevice); user.setDeviceSet(deviceSet); Assert.assertEquals(deviceSet,user.getDeviceSet()); } }
3e0b5c1fefefe21b5031496bc54564b97c9ffb12
7,350
java
Java
entity-view/testsuite/src/test/java/com/blazebit/persistence/view/testsuite/inheritance/constructor/ConstructorInheritanceTest.java
sullrich84/blaze-persistence
f5a374fedf8cb1a24c769e37de56bd44e91afcf3
[ "ECL-2.0", "Apache-2.0" ]
884
2015-02-17T16:29:05.000Z
2022-03-31T05:01:09.000Z
entity-view/testsuite/src/test/java/com/blazebit/persistence/view/testsuite/inheritance/constructor/ConstructorInheritanceTest.java
sullrich84/blaze-persistence
f5a374fedf8cb1a24c769e37de56bd44e91afcf3
[ "ECL-2.0", "Apache-2.0" ]
1,105
2015-01-07T08:49:17.000Z
2022-03-31T09:40:50.000Z
entity-view/testsuite/src/test/java/com/blazebit/persistence/view/testsuite/inheritance/constructor/ConstructorInheritanceTest.java
sullrich84/blaze-persistence
f5a374fedf8cb1a24c769e37de56bd44e91afcf3
[ "ECL-2.0", "Apache-2.0" ]
66
2015-03-12T16:43:39.000Z
2022-03-22T06:55:15.000Z
39.72973
160
0.662993
4,807
/* * Copyright 2014 - 2021 Blazebit. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.blazebit.persistence.view.testsuite.inheritance.constructor; import com.blazebit.persistence.CriteriaBuilder; import com.blazebit.persistence.testsuite.entity.Document; import com.blazebit.persistence.testsuite.entity.Person; import com.blazebit.persistence.testsuite.tx.TxVoidWork; import com.blazebit.persistence.view.EntityViewManager; import com.blazebit.persistence.view.EntityViewSetting; import com.blazebit.persistence.view.EntityViews; import com.blazebit.persistence.view.spi.EntityViewConfiguration; import com.blazebit.persistence.view.testsuite.AbstractEntityViewTest; import com.blazebit.persistence.view.testsuite.inheritance.constructor.model.DocumentBaseView; import com.blazebit.persistence.view.testsuite.inheritance.constructor.model.NewDocumentView; import com.blazebit.persistence.view.testsuite.inheritance.constructor.model.OldDocumentView; import com.blazebit.persistence.view.testsuite.inheritance.constructor.model.ParameterNewDocumentView; import com.blazebit.persistence.view.testsuite.inheritance.constructor.model.ParameterOldDocumentView; import com.blazebit.persistence.view.testsuite.inheritance.constructor.model.SimplePersonSubView; import com.blazebit.persistence.view.testsuite.inheritance.constructor.model.SuperTypeParameterDocumentBaseView; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import javax.persistence.EntityManager; import java.util.Collection; import java.util.Collections; import java.util.List; import static org.junit.Assert.*; /** * * @author Christian Beikov * @since 1.2.0 */ public class ConstructorInheritanceTest extends AbstractEntityViewTest { private Document doc1; private Document doc2; private Document doc3; private EntityViewManager evm; @Override public void setUpOnce() { cleanDatabase(); transactional(new TxVoidWork() { @Override public void work(EntityManager em) { doc1 = new Document("doc1", new Person("owner1")); doc2 = new Document("doc2", new Person("owner2")); doc3 = new Document("doc3", new Person("owner3")); Person o1 = new Person("pers1"); Person o2 = new Person("pers2"); Person o3 = new Person("pers3"); Person o4 = new Person("pers4"); // New doc1.setAge(1); doc1.getContacts().put(1, o1); doc1.getContacts().put(1, o2); // Base doc2.setAge(15); // Old doc3.setAge(16); em.persist(o1); em.persist(o2); em.persist(o3); em.persist(o4); o3.setPartnerDocument(doc3); o4.setPartnerDocument(doc3); em.persist(doc1); em.persist(doc2); em.persist(doc3); } }); } @Test public void inheritanceQuery() { doc1 = cbf.create(em, Document.class).where("name").eq("doc1").getSingleResult(); doc2 = cbf.create(em, Document.class).where("name").eq("doc2").getSingleResult(); doc3 = cbf.create(em, Document.class).where("name").eq("doc3").getSingleResult(); this.evm = build( SimplePersonSubView.class, DocumentBaseView.class, NewDocumentView.class, OldDocumentView.class ); CriteriaBuilder<Document> criteria = cbf.create(em, Document.class, "d") .orderByAsc("name"); CriteriaBuilder<DocumentBaseView> cb = evm.applySetting(EntityViewSetting.create(DocumentBaseView.class), criteria); List<DocumentBaseView> results = cb.getResultList(); assertEquals(3, results.size()); NewDocumentView docView1 = (NewDocumentView) results.get(0); DocumentBaseView docView2 = (DocumentBaseView) results.get(1); OldDocumentView docView3 = (OldDocumentView) results.get(2); assertDocumentEquals(doc1, docView1); assertDocumentEquals(doc2, docView2); assertDocumentEquals(doc3, docView3); assertSubviewEquals(doc1.getContacts().values(), docView1.getPeople()); assertSubviewEquals(Collections.singleton(doc2.getOwner()), docView2.getPeople()); assertSubviewEquals(doc3.getPartners(), docView3.getPeople()); } @Test public void inheritanceQuerySuperTypeParameter() { doc1 = cbf.create(em, Document.class).where("name").eq("doc1").getSingleResult(); doc2 = cbf.create(em, Document.class).where("name").eq("doc2").getSingleResult(); doc3 = cbf.create(em, Document.class).where("name").eq("doc3").getSingleResult(); this.evm = build( SuperTypeParameterDocumentBaseView.class, ParameterNewDocumentView.class, ParameterOldDocumentView.class ); CriteriaBuilder<Document> criteria = cbf.create(em, Document.class, "d") .orderByAsc("name"); CriteriaBuilder<SuperTypeParameterDocumentBaseView> cb = evm.applySetting(EntityViewSetting.create(SuperTypeParameterDocumentBaseView.class), criteria); List<SuperTypeParameterDocumentBaseView> results = cb.getResultList(); assertEquals(3, results.size()); ParameterNewDocumentView docView1 = (ParameterNewDocumentView) results.get(0); SuperTypeParameterDocumentBaseView docView2 = (SuperTypeParameterDocumentBaseView) results.get(1); ParameterOldDocumentView docView3 = (ParameterOldDocumentView) results.get(2); assertEquals("New", docView1.getName()); assertEquals("doc2", docView2.getName()); assertEquals("Old", docView3.getName()); } public static void assertDocumentEquals(Document doc, DocumentBaseView view) { assertEquals(doc.getId(), view.getId()); assertEquals(doc.getName(), view.getName()); } public static void assertSubviewEquals(Collection<Person> persons, Collection<SimplePersonSubView> personSubviews) { if (persons == null) { assertNull(personSubviews); return; } assertNotNull(personSubviews); assertEquals(persons.size(), personSubviews.size()); for (Person p : persons) { boolean found = false; for (SimplePersonSubView pSub : personSubviews) { if (p.getName().equals(pSub.getName())) { found = true; break; } } if (!found) { Assert.fail("Could not find a SimplePersonSubView with the name: " + p.getName()); } } } }
3e0b5c3f06d46da4383f248c5d78e91cc4f257a3
5,022
java
Java
src/main/java/com/emmanuelmess/schoolwebproject/web/rest/ThreadResource.java
EmmanuelMess/School-Web-Project-2
7969622e0ef551fe45b3d33f310f9a9550c243d6
[ "MIT" ]
2
2019-01-06T04:55:26.000Z
2020-04-21T10:24:02.000Z
src/main/java/com/emmanuelmess/schoolwebproject/web/rest/ThreadResource.java
EmmanuelMess/School-Web-Project-2
7969622e0ef551fe45b3d33f310f9a9550c243d6
[ "MIT" ]
null
null
null
src/main/java/com/emmanuelmess/schoolwebproject/web/rest/ThreadResource.java
EmmanuelMess/School-Web-Project-2
7969622e0ef551fe45b3d33f310f9a9550c243d6
[ "MIT" ]
1
2019-09-10T12:44:09.000Z
2019-09-10T12:44:09.000Z
39.234375
154
0.699522
4,808
package com.emmanuelmess.schoolwebproject.web.rest; import com.codahale.metrics.annotation.Timed; import com.emmanuelmess.schoolwebproject.domain.Thread; import com.emmanuelmess.schoolwebproject.repository.ThreadRepository; import com.emmanuelmess.schoolwebproject.web.rest.errors.BadRequestAlertException; import com.emmanuelmess.schoolwebproject.web.rest.util.HeaderUtil; import com.emmanuelmess.schoolwebproject.web.rest.util.PaginationUtil; import io.github.jhipster.web.util.ResponseUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.net.URI; import java.net.URISyntaxException; import java.util.List; import java.util.Optional; /** * REST controller for managing Thread. */ @RestController @RequestMapping("/api") public class ThreadResource { private final Logger log = LoggerFactory.getLogger(ThreadResource.class); private static final String ENTITY_NAME = "thread"; private final ThreadRepository threadRepository; public ThreadResource(ThreadRepository threadRepository) { this.threadRepository = threadRepository; } /** * POST /threads : Create a new thread. * * @param thread the thread to create * @return the ResponseEntity with status 201 (Created) and with body the new thread, or with status 400 (Bad Request) if the thread has already an ID * @throws URISyntaxException if the Location URI syntax is incorrect */ @PostMapping("/threads") @Timed public ResponseEntity<Thread> createThread(@RequestBody Thread thread) throws URISyntaxException { log.debug("REST request to save Thread : {}", thread); if (thread.getId() != null) { throw new BadRequestAlertException("A new thread cannot already have an ID", ENTITY_NAME, "idexists"); } Thread result = threadRepository.save(thread); return ResponseEntity.created(new URI("/api/threads/" + result.getId())) .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) .body(result); } /** * PUT /threads : Updates an existing thread. * * @param thread the thread to update * @return the ResponseEntity with status 200 (OK) and with body the updated thread, * or with status 400 (Bad Request) if the thread is not valid, * or with status 500 (Internal Server Error) if the thread couldn't be updated * @throws URISyntaxException if the Location URI syntax is incorrect */ @PutMapping("/threads") @Timed public ResponseEntity<Thread> updateThread(@RequestBody Thread thread) throws URISyntaxException { log.debug("REST request to update Thread : {}", thread); if (thread.getId() == null) { throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); } Thread result = threadRepository.save(thread); return ResponseEntity.ok() .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, thread.getId().toString())) .body(result); } /** * GET /threads : get all the threads. * * @param pageable the pagination information * @return the ResponseEntity with status 200 (OK) and the list of threads in body */ @GetMapping("/threads") @Timed public ResponseEntity<List<Thread>> getAllThreads(Pageable pageable) { log.debug("REST request to get a page of Threads"); Page<Thread> page = threadRepository.findAll(pageable); HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/threads"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); } /** * GET /threads/:id : get the "id" thread. * * @param id the id of the thread to retrieve * @return the ResponseEntity with status 200 (OK) and with body the thread, or with status 404 (Not Found) */ @GetMapping("/threads/{id}") @Timed public ResponseEntity<Thread> getThread(@PathVariable Long id) { log.debug("REST request to get Thread : {}", id); Optional<Thread> thread = threadRepository.findById(id); return ResponseUtil.wrapOrNotFound(thread); } /** * DELETE /threads/:id : delete the "id" thread. * * @param id the id of the thread to delete * @return the ResponseEntity with status 200 (OK) */ @DeleteMapping("/threads/{id}") @Timed public ResponseEntity<Void> deleteThread(@PathVariable Long id) { log.debug("REST request to delete Thread : {}", id); threadRepository.deleteById(id); return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); } }
3e0b5ca035e0d246ad113bd2134609bc0c357c6d
2,644
java
Java
src/test/java/de/perdian/flightlog/modules/overview/services/contributors/DifferentsContributorTest.java
perdian/flightlog
f5e334fbe66ba2a93dc541254ac074ec0e5da32f
[ "Apache-2.0" ]
2
2019-02-01T14:21:14.000Z
2020-04-05T21:06:54.000Z
src/test/java/de/perdian/flightlog/modules/overview/services/contributors/DifferentsContributorTest.java
perdian/flightlog
f5e334fbe66ba2a93dc541254ac074ec0e5da32f
[ "Apache-2.0" ]
1
2021-10-16T18:18:37.000Z
2021-10-16T18:18:37.000Z
src/test/java/de/perdian/flightlog/modules/overview/services/contributors/DifferentsContributorTest.java
perdian/flightlog
f5e334fbe66ba2a93dc541254ac074ec0e5da32f
[ "Apache-2.0" ]
null
null
null
57.478261
134
0.752648
4,809
package de.perdian.flightlog.modules.overview.services.contributors; import java.util.Arrays; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import de.perdian.flightlog.FlightlogTestHelper; import de.perdian.flightlog.modules.flights.model.FlightBean; import de.perdian.flightlog.modules.overview.model.OverviewBean; public class DifferentsContributorTest { @Test public void contributeTo() { OverviewBean overviewBean = new OverviewBean(); FlightBean flight1 = new FlightBean(); flight1.setAircraft(FlightlogTestHelper.createAircraftBean("A380", null, null)); flight1.setDepartureContact(FlightlogTestHelper.createAirportContactBean("CGN", "DE", null, null)); flight1.setArrivalContact(FlightlogTestHelper.createAirportContactBean("MCO", "US", null, null)); flight1.setAirline(FlightlogTestHelper.createAirlineBean("LH", "DE", "Lufthansa")); FlightBean flight2 = new FlightBean(); flight2.setAircraft(FlightlogTestHelper.createAircraftBean("A380", null, null)); flight2.setDepartureContact(FlightlogTestHelper.createAirportContactBean("CGN", "DE", null, null)); flight2.setArrivalContact(FlightlogTestHelper.createAirportContactBean("JFK", "US", null, null)); flight2.setAirline(FlightlogTestHelper.createAirlineBean("LH", "DE", "Lufthansa")); FlightBean flight3 = new FlightBean(); flight3.setAircraft(FlightlogTestHelper.createAircraftBean("B747", null, null)); flight3.setDepartureContact(FlightlogTestHelper.createAirportContactBean("CGN", "DE", null, null)); flight3.setArrivalContact(FlightlogTestHelper.createAirportContactBean("MCO", "US", null, null)); flight3.setAirline(FlightlogTestHelper.createAirlineBean("UA", "US", "United")); DifferentsContributor contributor = new DifferentsContributor(); contributor.contributeTo(overviewBean, Arrays.asList(flight1, flight2, flight3)); Assertions.assertEquals(Integer.valueOf(2), overviewBean.getDifferents().get(0).getValue()); // numberOfDifferentAircraftTypes Assertions.assertEquals(Integer.valueOf(3), overviewBean.getDifferents().get(1).getValue()); // numberOfDifferentAirports Assertions.assertEquals(Integer.valueOf(2), overviewBean.getDifferents().get(2).getValue()); // numberOfDifferentCountries Assertions.assertEquals(Integer.valueOf(2), overviewBean.getDifferents().get(3).getValue()); // numberOfDifferentRoutes Assertions.assertEquals(Integer.valueOf(2), overviewBean.getDifferents().get(4).getValue()); // numberOfDifferentAirlines } }
3e0b5cc79994d19c98d6f60ffd0af6a107426dd7
1,736
java
Java
anyway-web/anyway-web-thymeleaf/src/main/java/ink/anyway/component/web/filter/SessionStatusFilter.java
lhbzjd/spring-anyway
2624384ab17c781d4be26021289e05d57ba31d54
[ "Apache-2.0" ]
null
null
null
anyway-web/anyway-web-thymeleaf/src/main/java/ink/anyway/component/web/filter/SessionStatusFilter.java
lhbzjd/spring-anyway
2624384ab17c781d4be26021289e05d57ba31d54
[ "Apache-2.0" ]
null
null
null
anyway-web/anyway-web-thymeleaf/src/main/java/ink/anyway/component/web/filter/SessionStatusFilter.java
lhbzjd/spring-anyway
2624384ab17c781d4be26021289e05d57ba31d54
[ "Apache-2.0" ]
null
null
null
35.489796
198
0.702128
4,810
package ink.anyway.component.web.filter; import ink.anyway.component.web.pojo.LoginUser; import org.springframework.security.core.context.SecurityContext; import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; /** * [添加说明] * <br>@author : 李海博(hzdkv@example.com) * <br>@date : 2018/1/11 10:44 * <br>@version : 1.0 */ public class SessionStatusFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { // TODO Auto-generated method stub } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { LoginUser ou = null; SecurityContext securityContext = (SecurityContext) ((HttpServletRequest) servletRequest).getSession().getAttribute("SPRING_SECURITY_CONTEXT"); if(securityContext!=null&&securityContext.getAuthentication()!=null){ ou = (LoginUser) securityContext.getAuthentication().getPrincipal(); } if (ou == null)//判断session里是否有用户信息 { if (((HttpServletRequest) servletRequest).getHeader("x-requested-with") != null && ((HttpServletRequest) servletRequest).getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest")) //如果是ajax请求响应头会有,x-requested-with; { ((HttpServletResponse) servletResponse).setHeader("sessionstatus", "timeout");//在响应头设置session状态 } } filterChain.doFilter(servletRequest,servletResponse); } @Override public void destroy() { // TODO Auto-generated method stub } }
3e0b5d0b5ad40ed6a043f927319becceca5fa754
14,892
java
Java
Braintree/src/androidTest/java/com/braintreepayments/api/AndroidPayTest.java
nopexinc/braintree_android
aae6ca1d73f49cefca4b9533824f147288336949
[ "MIT" ]
1
2018-02-22T23:29:04.000Z
2018-02-22T23:29:04.000Z
Braintree/src/androidTest/java/com/braintreepayments/api/AndroidPayTest.java
nopexinc/braintree_android
aae6ca1d73f49cefca4b9533824f147288336949
[ "MIT" ]
null
null
null
Braintree/src/androidTest/java/com/braintreepayments/api/AndroidPayTest.java
nopexinc/braintree_android
aae6ca1d73f49cefca4b9533824f147288336949
[ "MIT" ]
null
null
null
49.973154
151
0.743889
4,811
package com.braintreepayments.api; import android.app.Activity; import android.content.Intent; import android.support.test.runner.AndroidJUnit4; import com.braintreepayments.api.exceptions.InvalidArgumentException; import com.braintreepayments.api.interfaces.BraintreeResponseListener; import com.braintreepayments.api.interfaces.TokenizationParametersListener; import com.braintreepayments.api.internal.BraintreeHttpClient; import com.braintreepayments.api.models.AndroidPayCardNonce; import com.braintreepayments.api.models.BraintreeRequestCodes; import com.braintreepayments.api.models.Configuration; import com.braintreepayments.api.test.BraintreeActivityTestRule; import com.braintreepayments.api.test.TestActivity; import com.braintreepayments.testutils.TestConfigurationBuilder; import com.braintreepayments.testutils.TestConfigurationBuilder.TestAndroidPayConfigurationBuilder; import com.google.android.gms.identity.intents.model.CountrySpecification; import com.google.android.gms.identity.intents.model.UserAddress; import com.google.android.gms.wallet.Cart; import com.google.android.gms.wallet.FullWallet; import com.google.android.gms.wallet.InstrumentInfo; import com.google.android.gms.wallet.PaymentMethodToken; import com.google.android.gms.wallet.PaymentMethodTokenizationParameters; import com.google.android.gms.wallet.ProxyCard; import com.google.android.gms.wallet.WalletConstants; import com.google.android.gms.wallet.WalletConstants.CardNetwork; import org.json.JSONException; import org.json.JSONObject; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Collection; import java.util.concurrent.CountDownLatch; import static com.braintreepayments.api.AndroidPayActivity.AUTHORIZE; import static com.braintreepayments.api.AndroidPayActivity.CHANGE_PAYMENT_METHOD; import static com.braintreepayments.api.AndroidPayActivity.EXTRA_ALLOWED_CARD_NETWORKS; import static com.braintreepayments.api.AndroidPayActivity.EXTRA_ALLOWED_COUNTRIES; import static com.braintreepayments.api.AndroidPayActivity.EXTRA_CART; import static com.braintreepayments.api.AndroidPayActivity.EXTRA_ENVIRONMENT; import static com.braintreepayments.api.AndroidPayActivity.EXTRA_GOOGLE_TRANSACTION_ID; import static com.braintreepayments.api.AndroidPayActivity.EXTRA_MERCHANT_NAME; import static com.braintreepayments.api.AndroidPayActivity.EXTRA_PHONE_NUMBER_REQUIRED; import static com.braintreepayments.api.AndroidPayActivity.EXTRA_REQUEST_TYPE; import static com.braintreepayments.api.AndroidPayActivity.EXTRA_SHIPPING_ADDRESS_REQUIRED; import static com.braintreepayments.api.AndroidPayActivity.EXTRA_TOKENIZATION_PARAMETERS; import static com.braintreepayments.api.BraintreeFragmentTestUtils.getFragment; import static com.braintreepayments.api.BraintreeFragmentTestUtils.getMockFragmentWithConfiguration; import static com.braintreepayments.testutils.FixturesHelper.stringFromFixture; import static com.braintreepayments.testutils.TestTokenizationKey.TOKENIZATION_KEY; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @RunWith(AndroidJUnit4.class) public class AndroidPayTest { @Rule public final BraintreeActivityTestRule<TestActivity> mActivityTestRule = new BraintreeActivityTestRule<>(TestActivity.class); private CountDownLatch mLatch; private TestConfigurationBuilder mBaseConfiguration; @Before public void setup() { mLatch = new CountDownLatch(1); mBaseConfiguration = new TestConfigurationBuilder() .androidPay(new TestAndroidPayConfigurationBuilder() .googleAuthorizationFingerprint("google-auth-fingerprint")) .merchantId("android-pay-merchant-id"); } @Test(timeout = 5000) public void isReadyToPay_returnsFalseWhenAndroidPayIsNotEnabled() throws Exception { String configuration = new TestConfigurationBuilder() .androidPay(new TestAndroidPayConfigurationBuilder().enabled(false)) .build(); BraintreeFragment fragment = getFragment(mActivityTestRule.getActivity(), TOKENIZATION_KEY, configuration); AndroidPay.isReadyToPay(fragment, new BraintreeResponseListener<Boolean>() { @Override public void onResponse(Boolean isReadyToPay) { assertFalse(isReadyToPay); mLatch.countDown(); } }); mLatch.await(); } @Test(timeout = 5000) public void getTokenizationParameters_returnsCorrectParametersInCallback() throws Exception { String config = mBaseConfiguration.androidPay(mBaseConfiguration.androidPay() .supportedNetworks(new String[]{"visa", "mastercard", "amex", "discover"})) .build(); final Configuration configuration = Configuration.fromJson(config); BraintreeFragment fragment = getFragment(mActivityTestRule.getActivity(), TOKENIZATION_KEY, config); AndroidPay.getTokenizationParameters(fragment, new TokenizationParametersListener() { @Override public void onResult(PaymentMethodTokenizationParameters parameters, Collection<Integer> allowedCardNetworks) { assertEquals("braintree", parameters.getParameters().getString("gateway")); assertEquals(configuration.getMerchantId(), parameters.getParameters().getString("braintree:merchantId")); assertEquals(configuration.getAndroidPay().getGoogleAuthorizationFingerprint(), parameters.getParameters().getString("braintree:authorizationFingerprint")); assertEquals("v1", parameters.getParameters().getString("braintree:apiVersion")); assertEquals(BuildConfig.VERSION_NAME, parameters.getParameters().getString("braintree:sdkVersion")); try { JSONObject metadata = new JSONObject(parameters.getParameters().getString("braintree:metadata")); assertNotNull(metadata); assertEquals(BuildConfig.VERSION_NAME, metadata.getString("version")); assertNotNull(metadata.getString("sessionId")); assertEquals("custom", metadata.getString("integration")); assertEquals("android", metadata.get("platform")); } catch (JSONException e) { fail("Failed to unpack json from tokenization parameters: " + e.getMessage()); } assertEquals(4, allowedCardNetworks.size()); assertTrue(allowedCardNetworks.contains(CardNetwork.VISA)); assertTrue(allowedCardNetworks.contains(CardNetwork.MASTERCARD)); assertTrue(allowedCardNetworks.contains(CardNetwork.AMEX)); assertTrue(allowedCardNetworks.contains(CardNetwork.DISCOVER)); mLatch.countDown(); } }); mLatch.await(); } @Test public void requestAndroidPay_startsActivity() { BraintreeFragment fragment = getSetupFragment(); doNothing().when(fragment).startActivityForResult(any(Intent.class), anyInt()); Cart cart = Cart.newBuilder().build(); ArrayList<CountrySpecification> allowedCountries = new ArrayList<>(); AndroidPay.requestAndroidPay(fragment, cart, true, true, allowedCountries); ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class); verify(fragment).startActivityForResult(captor.capture(), eq(BraintreeRequestCodes.ANDROID_PAY)); Intent intent = captor.getValue(); assertEquals(AndroidPayActivity.class.getName(), intent.getComponent().getClassName()); assertEquals(AUTHORIZE, intent.getIntExtra(EXTRA_REQUEST_TYPE, -1)); assertEquals(WalletConstants.ENVIRONMENT_TEST, intent.getIntExtra(EXTRA_ENVIRONMENT, -1)); assertEquals("", intent.getStringExtra(EXTRA_MERCHANT_NAME)); assertEquals(cart, intent.getParcelableExtra(EXTRA_CART)); assertTrue(intent.getBooleanExtra(EXTRA_SHIPPING_ADDRESS_REQUIRED, false)); assertTrue(intent.getBooleanExtra(EXTRA_PHONE_NUMBER_REQUIRED, false)); assertEquals(allowedCountries, intent.getParcelableArrayListExtra(EXTRA_ALLOWED_COUNTRIES)); assertNotNull(intent.getParcelableExtra(EXTRA_TOKENIZATION_PARAMETERS)); assertNotNull(intent.getIntegerArrayListExtra(EXTRA_ALLOWED_CARD_NETWORKS)); } @Test public void requestAndroidPay_sendsAnalyticsEvent() throws InterruptedException, InvalidArgumentException { BraintreeFragment fragment = getSetupFragment(); doNothing().when(fragment).startActivityForResult(any(Intent.class), anyInt()); AndroidPay.requestAndroidPay(fragment, Cart.newBuilder().build(), false, false, new ArrayList<CountrySpecification>()); InOrder order = inOrder(fragment); order.verify(fragment).sendAnalyticsEvent("android-pay.selected"); order.verify(fragment).sendAnalyticsEvent("android-pay.started"); } @Test public void requestAndroidPay_postsExceptionWhenCartIsNull() throws InterruptedException, InvalidArgumentException { BraintreeFragment fragment = getSetupFragment(); AndroidPay.requestAndroidPay(fragment, null, false, false, new ArrayList<CountrySpecification>()); InOrder order = inOrder(fragment); order.verify(fragment).sendAnalyticsEvent("android-pay.selected"); order.verify(fragment).sendAnalyticsEvent("android-pay.failed"); } @Test public void changePaymentMethod_startsActivity() { BraintreeFragment fragment = getSetupFragment(); doNothing().when(fragment).startActivityForResult(any(Intent.class), anyInt()); AndroidPayCardNonce androidPayCardNonce = mock(AndroidPayCardNonce.class); when(androidPayCardNonce.getGoogleTransactionId()).thenReturn("google-transaction-id"); Cart cart = Cart.newBuilder().build(); when(androidPayCardNonce.getCart()).thenReturn(cart); AndroidPay.changePaymentMethod(fragment, androidPayCardNonce); ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class); verify(fragment).startActivityForResult(captor.capture(), eq(BraintreeRequestCodes.ANDROID_PAY)); Intent intent = captor.getValue(); assertEquals(AndroidPayActivity.class.getName(), intent.getComponent().getClassName()); assertEquals(CHANGE_PAYMENT_METHOD, intent.getIntExtra(EXTRA_REQUEST_TYPE, -1)); assertEquals(WalletConstants.ENVIRONMENT_TEST, intent.getIntExtra(EXTRA_ENVIRONMENT, -1)); assertEquals("google-transaction-id", intent.getStringExtra(EXTRA_GOOGLE_TRANSACTION_ID)); assertEquals(cart, intent.getParcelableExtra(EXTRA_CART)); } @Test public void changePaymentMethod_sendsAnalyticsEvent() { BraintreeFragment fragment = getSetupFragment(); doNothing().when(fragment).startActivityForResult(any(Intent.class), anyInt()); AndroidPayCardNonce androidPayCardNonce = mock(AndroidPayCardNonce.class); when(androidPayCardNonce.getGoogleTransactionId()).thenReturn("google-transaction-id"); AndroidPay.changePaymentMethod(fragment, androidPayCardNonce); verify(fragment).sendAnalyticsEvent("android-pay.change-masked-wallet"); } @Test public void onActivityResult_sendsAnalyticsEventOnCancel() { BraintreeFragment fragment = getSetupFragment(); AndroidPay.onActivityResult(fragment, Activity.RESULT_CANCELED, new Intent()); verify(fragment).sendAnalyticsEvent("android-pay.canceled"); } @Test public void onActivityResult_sendsAnalyticsEventOnNonOkOrCanceledResult() { BraintreeFragment fragment = getSetupFragment(); AndroidPay.onActivityResult(fragment, Activity.RESULT_FIRST_USER, new Intent()); verify(fragment).sendAnalyticsEvent("android-pay.failed"); } @Test public void onActivityResult_sendsAnalyticsEventOnFullWalletResponse() throws Exception { BraintreeFragment fragment = getSetupFragment(); FullWallet wallet = createFullWallet(); Intent intent = new Intent() .putExtra(WalletConstants.EXTRA_FULL_WALLET, wallet); AndroidPay.onActivityResult(fragment, Activity.RESULT_OK, intent); verify(fragment).sendAnalyticsEvent("android-pay.authorized"); } private BraintreeFragment getSetupFragment() { String configuration = mBaseConfiguration.androidPay(mBaseConfiguration.androidPay() .supportedNetworks(new String[]{"visa", "mastercard", "amex", "discover"})) .withAnalytics() .build(); BraintreeFragment fragment = getMockFragmentWithConfiguration(mActivityTestRule.getActivity(), configuration); when(fragment.getHttpClient()).thenReturn(mock(BraintreeHttpClient.class)); return fragment; } private FullWallet createFullWallet() throws Exception { Class paymentMethodTokenClass = PaymentMethodToken.class; Class[] tokenParams = new Class[] { int.class, String.class }; Constructor<PaymentMethodToken> tokenConstructor = paymentMethodTokenClass.getDeclaredConstructor(tokenParams); tokenConstructor.setAccessible(true); PaymentMethodToken token = tokenConstructor.newInstance(0, stringFromFixture("payment_methods/android_pay_card.json")); Class fullWalletClass = FullWallet.class; Class[] walletParams = new Class[] { String.class, String.class, ProxyCard.class, String.class, com.google.android.gms.wallet.zza.class, com.google.android.gms.wallet.zza.class, String[].class, UserAddress.class, UserAddress.class, InstrumentInfo[].class, PaymentMethodToken.class }; Constructor<FullWallet> walletConstructor = fullWalletClass.getDeclaredConstructor(walletParams); walletConstructor.setAccessible(true); return walletConstructor.newInstance(null, null, null, null, null, null, null, null, null, null, token); } }
3e0b5db891311f310b77082bab7137cacb53919c
1,131
java
Java
Data/Juliet-Java/Juliet-Java-v103/000/142/803/CWE789_Uncontrolled_Mem_Alloc__Environment_ArrayList_52b.java
b19e93n/PLC-Pyramid
6d5b57be6995a94ef7402144cee965862713b031
[ "MIT" ]
null
null
null
Data/Juliet-Java/Juliet-Java-v103/000/142/803/CWE789_Uncontrolled_Mem_Alloc__Environment_ArrayList_52b.java
b19e93n/PLC-Pyramid
6d5b57be6995a94ef7402144cee965862713b031
[ "MIT" ]
null
null
null
Data/Juliet-Java/Juliet-Java-v103/000/142/803/CWE789_Uncontrolled_Mem_Alloc__Environment_ArrayList_52b.java
b19e93n/PLC-Pyramid
6d5b57be6995a94ef7402144cee965862713b031
[ "MIT" ]
null
null
null
32.314286
143
0.739169
4,812
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE789_Uncontrolled_Mem_Alloc__Environment_ArrayList_52b.java Label Definition File: CWE789_Uncontrolled_Mem_Alloc.int.label.xml Template File: sources-sink-52b.tmpl.java */ /* * @description * CWE: 789 Uncontrolled Memory Allocation * BadSource: Environment Read data from an environment variable * GoodSource: A hardcoded non-zero, non-min, non-max, even number * Sinks: ArrayList * BadSink : Create an ArrayList using data as the initial size * Flow Variant: 52 Data flow: data passed as an argument from one method to another to another in three different classes in the same package * * */ public class CWE789_Uncontrolled_Mem_Alloc__Environment_ArrayList_52b { public void badSink(int data ) throws Throwable { (new CWE789_Uncontrolled_Mem_Alloc__Environment_ArrayList_52c()).badSink(data ); } /* goodG2B() - use goodsource and badsink */ public void goodG2BSink(int data ) throws Throwable { (new CWE789_Uncontrolled_Mem_Alloc__Environment_ArrayList_52c()).goodG2BSink(data ); } }
3e0b5dbc66d5e2d82f42814c5186f35293d7c2df
261
java
Java
src/main/java/it/unisa/petra/core/exceptions/ADBNotFoundException.java
s141015/PETrA
04da01428e3a077217aa8d06799e631ea33c5604
[ "MIT" ]
2
2021-01-04T09:02:27.000Z
2021-08-09T08:25:53.000Z
src/main/java/it/unisa/petra/core/exceptions/ADBNotFoundException.java
s141015/PETrA
04da01428e3a077217aa8d06799e631ea33c5604
[ "MIT" ]
1
2021-12-03T17:07:05.000Z
2022-01-31T10:01:07.000Z
src/main/java/it/unisa/petra/core/exceptions/ADBNotFoundException.java
s141015/PETrA
04da01428e3a077217aa8d06799e631ea33c5604
[ "MIT" ]
3
2020-09-08T07:43:30.000Z
2021-10-01T07:45:16.000Z
20.076923
53
0.662835
4,813
package it.unisa.petra.core.exceptions; /** * @author dardin88 */ public class ADBNotFoundException extends Exception { public ADBNotFoundException() { super("error: adb not found!"); System.out.println("error: adb not found!"); } }
3e0b5f16c44b8e585aedd4004e6cf068f618e259
137,292
java
Java
webwozwizard/src/com/webwoz/wizard/client/wizardlayouts/DefaultWizardScreen.java
SouvickG/WebWOZ
cb8632ca9aaf1c7f4081dc8457415293ea25f23b
[ "Apache-2.0" ]
5
2016-06-10T09:34:28.000Z
2020-07-21T07:43:19.000Z
webwozwizard/src/com/webwoz/wizard/client/wizardlayouts/DefaultWizardScreen.java
SouvickG/WebWOZ
cb8632ca9aaf1c7f4081dc8457415293ea25f23b
[ "Apache-2.0" ]
null
null
null
webwozwizard/src/com/webwoz/wizard/client/wizardlayouts/DefaultWizardScreen.java
SouvickG/WebWOZ
cb8632ca9aaf1c7f4081dc8457415293ea25f23b
[ "Apache-2.0" ]
2
2019-08-15T01:49:34.000Z
2020-09-30T17:07:28.000Z
31.352364
270
0.706538
4,814
package com.webwoz.wizard.client.wizardlayouts; /* * 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. */ import java.util.Date; import java.util.Vector; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.TabPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.ComponentFactory; import com.webwoz.wizard.client.ComponentFactoryAsync; import com.webwoz.wizard.client.DatabaseAccess; import com.webwoz.wizard.client.DatabaseAccessAsync; import com.webwoz.wizard.client.Screen; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; public class DefaultWizardScreen implements Screen { // Panels private VerticalPanel layoutPanel; private HorizontalPanel horLayoutPanel; private VerticalPanel historyPanel; private VerticalPanel historyUtterancesPanel; private ScrollPanel historyUtterancesScrollPanel; private VerticalPanel leftPanel; private VerticalPanel rightPanel; private VerticalPanel recoveryPanel; private HorizontalPanel experimentNotesPanel; private VerticalPanel domainDataResponsePanel; private VerticalPanel freeTextElementsCollectionPanel; private ScrollPanel domainDataResponseScrollPanel; private VerticalPanel[] domainDataSlotPanel; private HorizontalPanel[] domainDataSlotPanelHeading; private HorizontalPanel userPanel; private HorizontalPanel editHeadingButtonsPanel; private static VerticalPanel editPanel; private static VerticalPanel editTabsPanel; private static VerticalPanel editFreeTextPanel; private VerticalPanel preparedFreeTextPanel; private TabPanel dialogueStructurePanel; private TabPanel domainDataTabPanel; private VerticalPanel newTabPanel; private HorizontalPanel addTabPanel; private HorizontalPanel[] uttPanel; private HorizontalPanel[] editTabs; private HorizontalPanel signalPanel; private HorizontalPanel[] domainUttPanel; private HorizontalPanel[] slots; private VerticalPanel[] tabNotesPanel; private VerticalPanel[] dialogueTabPanel; private HorizontalPanel domainDataSlotCollectionPanel; private ScrollPanel domainDataSlotScrollPanel; private ScrollPanel domainDataFreeTextScrollPanel; private ScrollPanel wizardCorrectionScrollPanel; private ScrollPanel nBestListScrollPanel; private VerticalPanel wizardCorrectionPanel; private VerticalPanel nBestListPanel; private VerticalPanel freeTextPanel; private ScrollPanel[] dialogueTabScrollPanel; private ScrollPanel[] notesTabScrollanel; private VerticalPanel[] dialogueUtterancesPanel; private VerticalPanel[] utterancesPanel; private VerticalPanel recoveryUtterancePanel; private ScrollPanel recoveryScrollPanel; private HorizontalPanel editButtonsPanel; private HorizontalPanel editDomainButtonsPanel; private static VerticalPanel reportPanel; private ScrollPanel reportContentScrollPanel; private HorizontalPanel reportButtonsPanel; private HorizontalPanel reportContentHeadingPanel; private ScrollPanel editTabsScrollPanel; private VerticalPanel editTabsTabsPanel; private static VerticalPanel editDomainDataPanel; private static VerticalPanel editSlotPopUpPanel; private static VerticalPanel addSlotPopUpPanel; private VerticalPanel editDomainFilterPanel; private HorizontalPanel editFilterPanel; private HorizontalPanel editFilterAddSlotPanel; private HorizontalPanel[] editFilterSlotsPanel; private VerticalPanel editFilterSlotCollectionPanel; private HorizontalPanel addFilterPanel; private HorizontalPanel addFilterButtons; private VerticalPanel addFilterSlotCollection; private HorizontalPanel addFiltersStandardSlotPanel; private HorizontalPanel addFilterValuePanel; private HorizontalPanel shoutPanel; private VerticalPanel[] editTabsContainer; private ScrollPanel experimentNotesContainer; private VerticalPanel experimentNotesCollection; private HorizontalPanel notesHeadingPanel; private HorizontalPanel preparedFreeTextButtonsPanel; private HorizontalPanel[] domainDataFreeTextPanels; // lists private ListBox userList; private ListBox editTabUttList; private ListBox[] filterList; // Labels private Label recoveryHeadingLabel; private Label semLabel; private Label textLabel; private Label audioLabel; private Label mmLabel; private Label translationLabel; private Label translationAudioLabel; private Label translationMMLabel; private Label tabLabel; private Label rankLabel; private Label[] uttLabels; private Label user; private Label[] domainUttLabels; private Label[] domainUttNoLabels; private Label[] slotHeadingLabel; private Label historyHeadingLabel; private Label[] tabNotes; private Label[] tabNotesHeading; private Label[] uttHeadings; private Label experimentNotesHeading; private Label editTabsErrorLabel; private Label semDomainLabel; private Label textDomainLabel; private Label audioDomainLabel; private Label mmDomainLabel; private Label translationDomainLabel; private Label translationDomainAudioLabel; private Label translationDomainMMLabel; private Label[] filterHeadingLabel; private Label editFilterSlotValues; private Label errorDeleteSlotValueLabel; private Label standardFilterValueLabel; private Label standardFilterValueExpLabel; private Label addFilterLabel; private Label tabNameLabel; private Label tabInstructionLabel; private Label preparedFreeTextSemKeyLabel; private Label preparedFreeTextLabel; private Label[] domainDataFreeTextLabels; // TextBoxes private TextBox semKeyTextBox; private TextBox audioFileTextBox; private TextBox mmFileTextBox; private TextBox translAudioFileTextBox; private TextBox translMMFileTextBox; private TextBox rankTextBox; private TextBox addTabTextBox; private TextBox[] tabText; private TextBox semKeyDomainTextBox; private TextBox audioFileDomainTextBox; private TextBox mmFileDomainTextBox; private TextBox translAudioFileDomainTextBox; private TextBox translMMFileDomainTextBox; private TextBox editFilterTextBox; private TextBox[] editFilterSlotValuesTextBox; private TextBox editFilterAddSlotTextBox; private TextBox addFilterTextBox; private TextBox standardFilterValueTextBox; private TextBox addFilterValueTextBox; private TextBox preparedFreeTextShortTextBox; // Text Areas private TextArea experimentNotesTextArea; private TextArea translTextArea; private TextArea textTextArea; private TextArea textDomainTextArea; private TextArea translDomainTextArea; private TextArea shoutBoxTexatArea; private TextArea intructionTextArea; private TextArea[] tabInstructions; private TextArea preparedFreeTextTextArea; // Buttons private Button startEditButton; private Button endEditButton; private Button changeUttEditButton; private Button deleteUttEditButton; private Button addUttEditButton; private Button cancelUttEditButton; private Button addUttButton; private Button editTabsButton; private Button addTabEditButton; private Button addPreparedFreeTextElementsButton; private Button cancelTabEditButton; private Button openReportButton; private Button endExperimentMarkerButton; private Button processingButton; private Button closeReportButton; private Button addDomainDataButton; private Button addFilterButton; private Button saveNotesButton; private Button editFilterSaveButton; private Button editFilterDeleteButton; private Button[] tabDelButton; private Button[] tabSaveButton; private Button[] uttButtons; private Button[] uttButtonsEdit; private Button[] uttButtonsToFreeText; private Button[] domainUttButtons; private Button[] domainUttButtonsEdit; private Button[] domainDataSlotEditButtons; private Button printReportButton; private Button exportReportButton; private Button exportNotesButton; private Button changeUttDomainEditButton; private Button addUttDomainEditButton; private Button cancelUttDomainEditButton; private Button deleteUttDomainEditButton; private Button cancelEditSlotPopUpButton; private Button[] editFilterDeletSlotButton; private Button[] editFilterChangeSlotButton; private Button editFilterAddSlotButton; private Button cancelAddSlotPopUpButton; private Button addFilterSaveButton; private Button addFilterValueButton; private Button sendFreeTextButton; private Button addFreeTextButton; private Button closeFreeTextButton; private Button editFreeTextButton; private Button deleteFreeTextButton; private Button[] domainDataFreeTextButtons; private Button[] domainDataFreeTextButtonsEdit; private Button[] uttButtonsRankUpButtons; private Button[] uttButtonsRankDownButtons; // Radio Buttons private RadioButton[][] slotRadioButton; // handler private ClickHandler[] addUtteranceClickHandler; private ClickHandler[] editUtteranceClickHandler; private ClickHandler[] addDomainUtteranceClickHandler; private ClickHandler[] editDomainUtteranceClickHandler; private ClickHandler[] saveTabClickHandler; private ClickHandler[] delTabClickHandler; private ClickHandler[] editSlotHandler; private ClickHandler[][] slotRadioButtonHandler; private ClickHandler[] changeSlotValueHandler; private ClickHandler[] deleteSlotValueHandler; private ClickHandler[] addFreeTextHandler; private ClickHandler[] editFreeTextHandler; private ClickHandler[] addToFreeTextHandler; private ClickHandler[] uttButtonRankUpHandler; private ClickHandler[] uttButtonRankDownHandler; // handler registration private HandlerRegistration[] addUtteranceClickHandlerRegistration; private HandlerRegistration[] editUtteranceClickHandlerRegistration; private HandlerRegistration[] addToFreeClickHandlerRegistration; private HandlerRegistration[] addDomainUtteranceClickHandlerRegistration; private HandlerRegistration[] editDomainUtteranceClickHandlerRegistration; private HandlerRegistration[] saveTabClickHandlerRegistration; private HandlerRegistration[] delTabClickHandlerRegistration; private HandlerRegistration[] editSlotHandlerRegistration; private HandlerRegistration[][] slotRadioButtonHandlerRegistration; private HandlerRegistration[] changeSlotValueHandlerRegistration; private HandlerRegistration[] deleteSlotValueHandlerRegistration; private HandlerRegistration[] addFreeTextHandlerRegistration; private HandlerRegistration[] editFreeTextHandlerRegistration; private HandlerRegistration[] uttButtUpClickHandlerRegistration; private HandlerRegistration[] uttButtDownClickHandlerRegistration; // Pop-ups private EditUtterancesPopup editUtterancesPopup; private EditDomainDataPopUp editDomainDataPopup; private EditTabsPopup editTabsPopup; private PrintReportPopup printReportPopup; private EditSlotPopUp editSlotPopUp; private AddSlotPopUp addSlotPopUp; private EditPreparedFreeTextPopup editFreeTextPopUp; // HTML private HTML reportTable; private HTML reportHeadingTable; private HTML statusHtml; private HTML loggedInHtml; // RPC private DatabaseAccessAsync databaseAccessSvc; private ComponentFactoryAsync componentFactorySvc; // Vectors private Vector<HorizontalPanel> inputElementVectorHorPanels; private Vector<Button> inputButtonVectorButtons; private Vector<TextArea> inputTextAreaVectorTextAreas; private Vector<String> inputTextVector; private Vector<VerticalPanel> inputNBestListVectorVerPanels; private Vector<HorizontalPanel> inputNBestListVectorHorPanels; private Vector<Button> inputNBestListVectorButtons; private Vector<Label> inputNBestListVectorLabels; private Vector<String> inputNBestListAlternatives; // Refresh interval private final int REFRESH_INTERVAL = 1000; private Timer refreshTimer; // Layout variables private int expId; private int userId; private int wizId; private String editUtt; private String editDomainUtt; private int countDomainUtt; private int countUtt; private int editId; private int countTab; private int editSlotRank; private int editSlotId; private String editSlot; private String reportHtml; private String reportHeadingHtml; private Integer[][] domainDataSort; private Integer[] selectedSlots; private Integer[][] possibleData; private int reloadMode; private Boolean reload; private Boolean statusUpdate; private int rankEstimation; private String defaultSlotValue; private int notesCount; private boolean slotsExist; private String semKey; private String rank; private String text; private String audio; private String mm; private String transtext; private String transaudio; private String transmm; private String note; private String tabName; private String tabInst; private String newFilter; private String newValue; private int selectedTab; private int selectedDomainTab; private String currentFreeTextElement; private int countFreeTextElements; private boolean reloadFreeText; private boolean nBestList; private boolean wizardCorrection; private boolean domainPanelVisible; private boolean freeText; private String recognized; private String alterantives; public DefaultWizardScreen(int exp, int wiz) { // set wizard and experiment wizId = wiz; expId = exp; // initialize variables initialize(); } private void initialize() { // Panels layoutPanel = new VerticalPanel(); horLayoutPanel = new HorizontalPanel(); historyPanel = new VerticalPanel(); historyUtterancesPanel = new VerticalPanel(); historyUtterancesScrollPanel = new ScrollPanel(historyUtterancesPanel); leftPanel = new VerticalPanel(); rightPanel = new VerticalPanel(); recoveryPanel = new VerticalPanel(); experimentNotesPanel = new HorizontalPanel(); domainDataResponsePanel = new VerticalPanel(); freeTextElementsCollectionPanel = new VerticalPanel(); domainDataResponseScrollPanel = new ScrollPanel(); userPanel = new HorizontalPanel(); editHeadingButtonsPanel = new HorizontalPanel(); editPanel = new VerticalPanel(); editTabsPanel = new VerticalPanel(); editFreeTextPanel = new VerticalPanel(); preparedFreeTextPanel = new VerticalPanel(); dialogueStructurePanel = new TabPanel(); domainDataTabPanel = new TabPanel(); newTabPanel = new VerticalPanel(); addTabPanel = new HorizontalPanel(); signalPanel = new HorizontalPanel(); domainDataSlotCollectionPanel = new HorizontalPanel(); domainDataSlotScrollPanel = new ScrollPanel(); domainDataFreeTextScrollPanel = new ScrollPanel(); wizardCorrectionScrollPanel = new ScrollPanel(); nBestListScrollPanel = new ScrollPanel(); wizardCorrectionPanel = new VerticalPanel(); nBestListPanel = new VerticalPanel(); freeTextPanel = new VerticalPanel(); recoveryUtterancePanel = new VerticalPanel(); recoveryScrollPanel = new ScrollPanel(); editButtonsPanel = new HorizontalPanel(); editDomainButtonsPanel = new HorizontalPanel(); reportPanel = new VerticalPanel(); reportContentScrollPanel = new ScrollPanel(); reportButtonsPanel = new HorizontalPanel(); reportContentHeadingPanel = new HorizontalPanel(); editTabsScrollPanel = new ScrollPanel(); editTabsTabsPanel = new VerticalPanel(); editDomainDataPanel = new VerticalPanel(); editSlotPopUpPanel = new VerticalPanel(); addSlotPopUpPanel = new VerticalPanel(); editDomainFilterPanel = new VerticalPanel(); editFilterPanel = new HorizontalPanel(); editFilterAddSlotPanel = new HorizontalPanel(); editFilterSlotCollectionPanel = new VerticalPanel(); addFilterPanel = new HorizontalPanel(); addFilterButtons = new HorizontalPanel(); addFilterSlotCollection = new VerticalPanel(); addFiltersStandardSlotPanel = new HorizontalPanel(); addFilterValuePanel = new HorizontalPanel(); shoutPanel = new HorizontalPanel(); experimentNotesContainer = new ScrollPanel(); experimentNotesCollection = new VerticalPanel(); notesHeadingPanel = new HorizontalPanel(); preparedFreeTextButtonsPanel = new HorizontalPanel(); // lists userList = new ListBox(); editTabUttList = new ListBox(); // Labels recoveryHeadingLabel = new Label(); semLabel = new Label("Short Name / Label: "); textLabel = new Label("Utterance: "); audioLabel = new Label("Link to Audio File: "); mmLabel = new Label("Link to Multi-Media File: "); translationLabel = new Label("Translated Utterance: "); translationAudioLabel = new Label("Link to Translated Audio File: "); translationMMLabel = new Label("Link to Translated Multi-Media File: "); tabLabel = new Label("Tab: "); rankLabel = new Label("Rank: "); user = new Label("User: "); historyHeadingLabel = new Label("Sent Utterances:"); experimentNotesHeading = new Label(); editTabsErrorLabel = new Label(); semDomainLabel = new Label("Short Name / Label: "); textDomainLabel = new Label("Utterance: "); audioDomainLabel = new Label("Link to Audio File: "); mmDomainLabel = new Label("Link to Multi-Media File: "); translationDomainLabel = new Label("Translated Utterance: "); translationDomainAudioLabel = new Label( "Link to Translated Audio File: "); translationDomainMMLabel = new Label( "Link to Translated Multi-Media File: "); editFilterSlotValues = new Label("Filter Values:"); errorDeleteSlotValueLabel = new Label(); standardFilterValueLabel = new Label("Default Value*"); standardFilterValueExpLabel = new Label( "*The default value is applied to all domain data utterances as soon as the filter is created! Values can be changed by separately editing the different utterances."); addFilterLabel = new Label("Filter Name"); tabNameLabel = new Label("Tab Name"); tabInstructionLabel = new Label("Tab Instructions"); preparedFreeTextSemKeyLabel = new Label("Short Name / Label: "); preparedFreeTextLabel = new Label("Text Element: "); // TextBoxes semKeyTextBox = new TextBox(); audioFileTextBox = new TextBox(); mmFileTextBox = new TextBox(); translAudioFileTextBox = new TextBox(); translMMFileTextBox = new TextBox(); rankTextBox = new TextBox(); addTabTextBox = new TextBox(); semKeyDomainTextBox = new TextBox(); audioFileDomainTextBox = new TextBox(); mmFileDomainTextBox = new TextBox(); translAudioFileDomainTextBox = new TextBox(); translMMFileDomainTextBox = new TextBox(); editFilterTextBox = new TextBox(); editFilterAddSlotTextBox = new TextBox(); addFilterTextBox = new TextBox(); standardFilterValueTextBox = new TextBox(); addFilterValueTextBox = new TextBox(); preparedFreeTextShortTextBox = new TextBox(); // Text Areas experimentNotesTextArea = new TextArea(); translTextArea = new TextArea(); textTextArea = new TextArea(); textDomainTextArea = new TextArea(); translDomainTextArea = new TextArea(); shoutBoxTexatArea = new TextArea(); intructionTextArea = new TextArea(); preparedFreeTextTextArea = new TextArea(); // Buttons startEditButton = new Button("Enter Edit Mode"); endEditButton = new Button("Stop Edit Mode"); changeUttEditButton = new Button("Save Changes"); deleteUttEditButton = new Button("Delete Utterance"); addUttEditButton = new Button("Add Utterance"); cancelUttEditButton = new Button("Close"); addUttButton = new Button("Add Utterance"); editTabsButton = new Button("Add/Edit Tabs"); addTabEditButton = new Button("Add Tab"); addPreparedFreeTextElementsButton = new Button( "Add Prepared Free Text Elements"); cancelTabEditButton = new Button("Close"); openReportButton = new Button("Show Report"); endExperimentMarkerButton = new Button("End Experiment"); processingButton = new Button("Processing..."); closeReportButton = new Button("Close"); addDomainDataButton = new Button("Add Domain Data"); addFilterButton = new Button("Add Filter"); saveNotesButton = new Button("Save"); editFilterSaveButton = new Button("Save Changes"); editFilterDeleteButton = new Button("Delete Filter"); printReportButton = new Button("Print Report"); exportReportButton = new Button("Export Report"); exportNotesButton = new Button("Export Notes"); changeUttDomainEditButton = new Button("Save Changes"); addUttDomainEditButton = new Button("Add Utterance"); cancelUttDomainEditButton = new Button("Close"); deleteUttDomainEditButton = new Button("Delete Utterance"); cancelEditSlotPopUpButton = new Button("Close"); editFilterAddSlotButton = new Button("Add Filter Value"); cancelAddSlotPopUpButton = new Button("Close"); addFilterSaveButton = new Button("Add Filter"); addFilterValueButton = new Button("Add Value"); sendFreeTextButton = new Button("Send"); addFreeTextButton = new Button("Add Free Text Element"); closeFreeTextButton = new Button("Close"); editFreeTextButton = new Button("Save Changes"); deleteFreeTextButton = new Button("Delete Element"); // HTML reportTable = new HTML(); reportHeadingTable = new HTML(); statusHtml = new HTML(); loggedInHtml = new HTML(); // RPC databaseAccessSvc = GWT.create(DatabaseAccess.class); componentFactorySvc = GWT.create(ComponentFactory.class); // Vectors inputElementVectorHorPanels = new Vector<HorizontalPanel>(); inputButtonVectorButtons = new Vector<Button>(); inputTextAreaVectorTextAreas = new Vector<TextArea>(); inputTextVector = new Vector<String>(); inputNBestListVectorVerPanels = new Vector<VerticalPanel>(); inputNBestListVectorHorPanels = new Vector<HorizontalPanel>(); inputNBestListVectorButtons = new Vector<Button>(); inputNBestListVectorLabels = new Vector<Label>(); inputNBestListAlternatives = new Vector<String>(); // reload variables (for editing) reloadMode = 0; reload = true; // start with no status queries => is turned on after all the data is // loaded! statusUpdate = false; // keep track of which tab is selected selectedTab = 0; // set it to 100 at the beginning to distinguish between load and reload selectedDomainTab = 100; recognized = ""; reloadFreeText = false; // Instantiate pop-ups editUtterancesPopup = new EditUtterancesPopup(); editDomainDataPopup = new EditDomainDataPopUp(); editTabsPopup = new EditTabsPopup(); printReportPopup = new PrintReportPopup(); editSlotPopUp = new EditSlotPopUp(); addSlotPopUp = new AddSlotPopUp(); editFreeTextPopUp = new EditPreparedFreeTextPopup(); buildLayout(); } private void buildLayout() { // hide popups editUtterancesPopup.hide(); editTabsPopup.hide(); printReportPopup.hide(); editDomainDataPopup.hide(); editSlotPopUp.hide(); addSlotPopUp.hide(); editFreeTextPopUp.hide(); // load user loadUser(); // status signalPanel.clear(); loggedInHtml.setHTML("<div><strong>Logged out</strong></div>"); statusHtml.setHTML(""); signalPanel.add(loggedInHtml); signalPanel.add(statusHtml); signalPanel.setWidth("220px"); // edit panel editPanel.clear(); editPanel.add(semLabel); semLabel.setStyleName("labelVertical"); semLabel.addStyleName("strong"); editPanel.add(semKeyTextBox); semKeyTextBox.setWidth("100px"); semKeyTextBox.setStyleName("text"); editPanel.add(textLabel); textLabel.setStyleName("labelVertical"); textLabel.addStyleName("strong"); editPanel.add(textTextArea); textTextArea.setCharacterWidth(110); textTextArea.setVisibleLines(3); textTextArea.setStyleName("text"); editPanel.add(audioLabel); audioLabel.setStyleName("labelVertical"); audioLabel.addStyleName("strong"); editPanel.add(audioFileTextBox); audioFileTextBox.setWidth("400px"); audioFileTextBox.setStyleName("text"); editPanel.add(mmLabel); mmLabel.setStyleName("labelVertical"); mmLabel.addStyleName("strong"); editPanel.add(mmFileTextBox); mmFileTextBox.setWidth("400px"); mmFileTextBox.setStyleName("text"); editPanel.add(translationLabel); translationLabel.setStyleName("labelVertical"); translationLabel.addStyleName("strong"); editPanel.add(translTextArea); translTextArea.setCharacterWidth(110); translTextArea.setVisibleLines(3); translTextArea.setStyleName("text"); editPanel.add(translationAudioLabel); translationAudioLabel.setStyleName("labelVertical"); translationAudioLabel.addStyleName("strong"); editPanel.add(translAudioFileTextBox); translAudioFileTextBox.setWidth("400px"); translAudioFileTextBox.setStyleName("text"); editPanel.add(translationMMLabel); translationMMLabel.setStyleName("labelVertical"); translationMMLabel.addStyleName("strong"); editPanel.add(translMMFileTextBox); translMMFileTextBox.setWidth("400px"); translMMFileTextBox.setStyleName("text"); editPanel.add(tabLabel); tabLabel.setStyleName("labelVertical"); tabLabel.addStyleName("strong"); editPanel.add(editTabUttList); editTabUttList.setStyleName("list"); editPanel.add(rankLabel); rankLabel.setStyleName("labelVertical"); editPanel.add(rankTextBox); rankTextBox.setWidth("30px"); rankTextBox.setStyleName("text"); // for the moment set invisible rankLabel.setVisible(false); rankTextBox.setVisible(false); changeUttEditButton.setStyleName("buttonHorizontal"); addUttEditButton.setStyleName("buttonHorizontal"); cancelUttEditButton.setStyleName("buttonHorizontal"); deleteUttEditButton.setStyleName("buttonHorizontal"); editButtonsPanel.clear(); editButtonsPanel.add(deleteUttEditButton); editButtonsPanel.add(changeUttEditButton); editButtonsPanel.add(addUttEditButton); editButtonsPanel.add(cancelUttEditButton); editPanel.add(editButtonsPanel); editPanel.setStyleName("editPanel"); editPanel.setHeight("500px"); editPanel.setWidth("810px"); // edit tabs panel error editTabsErrorLabel.setStyleName("error"); // edit domain data panel editDomainDataPanel.clear(); editDomainDataPanel.add(semDomainLabel); semDomainLabel.setStyleName("labelVertical"); semDomainLabel.addStyleName("strong"); editDomainDataPanel.add(semKeyDomainTextBox); semKeyDomainTextBox.setWidth("100px"); semKeyDomainTextBox.setStyleName("text"); editDomainDataPanel.add(textDomainLabel); textDomainLabel.setStyleName("labelVertical"); textDomainLabel.addStyleName("strong"); editDomainDataPanel.add(textDomainTextArea); textDomainTextArea.setCharacterWidth(110); textDomainTextArea.setVisibleLines(3); textDomainTextArea.setStyleName("text"); editDomainDataPanel.add(audioDomainLabel); audioDomainLabel.setStyleName("labelVertical"); audioDomainLabel.addStyleName("strong"); editDomainDataPanel.add(audioFileDomainTextBox); audioFileDomainTextBox.setWidth("400px"); audioFileDomainTextBox.setStyleName("text"); editDomainDataPanel.add(mmDomainLabel); mmDomainLabel.setStyleName("labelVertical"); mmDomainLabel.addStyleName("strong"); editDomainDataPanel.add(mmFileDomainTextBox); mmFileDomainTextBox.setWidth("400px"); mmFileDomainTextBox.setStyleName("text"); editDomainDataPanel.add(translationDomainLabel); translationDomainLabel.setStyleName("labelVertical"); translationDomainLabel.addStyleName("strong"); editDomainDataPanel.add(translDomainTextArea); translDomainTextArea.setCharacterWidth(110); translDomainTextArea.setVisibleLines(3); translDomainTextArea.setStyleName("text"); editDomainDataPanel.add(translationDomainAudioLabel); translationDomainAudioLabel.setStyleName("labelVertical"); translationDomainAudioLabel.addStyleName("strong"); editDomainDataPanel.add(translAudioFileDomainTextBox); translAudioFileDomainTextBox.setWidth("400px"); translAudioFileDomainTextBox.setStyleName("text"); editDomainDataPanel.add(translationDomainMMLabel); translationDomainMMLabel.setStyleName("labelVertical"); translationDomainMMLabel.addStyleName("strong"); editDomainDataPanel.add(translMMFileDomainTextBox); translMMFileDomainTextBox.setWidth("400px"); translMMFileDomainTextBox.setStyleName("text"); editDomainFilterPanel.setStyleName("editDomainFilterPanel"); editDomainFilterPanel.addStyleName("strong"); editDomainDataPanel.add(editDomainFilterPanel); changeUttDomainEditButton.setStyleName("buttonHorizontal"); addUttDomainEditButton.setStyleName("buttonHorizontal"); cancelUttDomainEditButton.setStyleName("buttonHorizontal"); deleteUttDomainEditButton.setStyleName("buttonHorizontal"); editDomainButtonsPanel.clear(); editDomainButtonsPanel.add(deleteUttDomainEditButton); editDomainButtonsPanel.add(changeUttDomainEditButton); editDomainButtonsPanel.add(addUttDomainEditButton); editDomainButtonsPanel.add(cancelUttDomainEditButton); editDomainDataPanel.add(editDomainButtonsPanel); editDomainDataPanel.setStyleName("editPanel"); editDomainDataPanel.setHeight("500px"); editDomainDataPanel.setWidth("810px"); // edit slots editFilterPanel.clear(); editFilterPanel.add(editFilterTextBox); editFilterSaveButton.setStyleName("button"); editFilterDeleteButton.setStyleName("button"); editFilterPanel.add(editFilterSaveButton); editFilterPanel.add(editFilterDeleteButton); cancelEditSlotPopUpButton.setStyleName("cancelEditSlotPopUpButton"); editFilterPanel.setStyleName("editFilterPanel"); editSlotPopUpPanel.clear(); editSlotPopUpPanel.add(editFilterPanel); editFilterSlotValues.setStyleName("editFilterSlotValues"); editSlotPopUpPanel.add(editFilterSlotValues); editSlotPopUpPanel.add(editFilterSlotCollectionPanel); editFilterAddSlotPanel.clear(); editFilterAddSlotPanel.add(editFilterAddSlotTextBox); editFilterAddSlotButton.setStyleName("button"); editFilterAddSlotPanel.add(editFilterAddSlotButton); editFilterAddSlotPanel.setStyleName("editFilterSlotValues"); errorDeleteSlotValueLabel.setStyleName("errorSlot"); editSlotPopUpPanel.add(errorDeleteSlotValueLabel); editSlotPopUpPanel.add(editFilterAddSlotPanel); editSlotPopUpPanel.add(cancelEditSlotPopUpButton); // add slots addFilterPanel.clear(); addFilterPanel.add(addFilterTextBox); addFilterPanel.add(addFilterLabel); addFilterLabel.setStyleName("labelLeft"); addFilterLabel.addStyleName("strong"); addFilterPanel.setStyleName("editFilterPanel"); addFilterSlotCollection.clear(); addFilterSlotCollection.setStyleName("addFilterSlotCollection"); addFilterSlotCollection.add(addFiltersStandardSlotPanel); addFiltersStandardSlotPanel.clear(); addFiltersStandardSlotPanel.add(standardFilterValueTextBox); standardFilterValueTextBox.setText("Default-"); standardFilterValueLabel.setStyleName("labelLeft"); standardFilterValueLabel.addStyleName("strong"); addFiltersStandardSlotPanel.add(standardFilterValueLabel); standardFilterValueExpLabel.setStyleName("standardFilterValueExpLabel"); addFilterSlotCollection.add(standardFilterValueExpLabel); addFilterValuePanel.clear(); addFilterValuePanel.setStyleName("addFilterSlotCollection"); addFilterValuePanel.add(addFilterValueTextBox); addFilterValuePanel.add(addFilterValueButton); addFilterValueButton.setStyleName("button"); addFilterButtons.clear(); addFilterButtons.setStyleName("addFilterButtons"); addFilterSaveButton.setStyleName("button"); addFilterButtons.add(addFilterSaveButton); cancelAddSlotPopUpButton.setStyleName("button"); addFilterButtons.add(cancelAddSlotPopUpButton); addSlotPopUpPanel.clear(); addSlotPopUpPanel.add(addFilterPanel); addSlotPopUpPanel.add(addFilterSlotCollection); addSlotPopUpPanel.add(addFilterValuePanel); // for now keep it invisible // addFilterValuePanel.setVisible(false); addSlotPopUpPanel.add(addFilterButtons); // define size recoveryPanel recoveryHeadingLabel.setText("Frequently Used Utterances:"); recoveryHeadingLabel.setStyleName("recoveryHeading"); recoveryPanel.setStyleName("recoveryPanel"); recoveryScrollPanel.clear(); recoveryScrollPanel.setWidth("310px"); recoveryScrollPanel.add(recoveryUtterancePanel); // experiment Notes experimentNotesPanel.clear(); experimentNotesContainer.clear(); experimentNotesContainer.setHeight("150px"); experimentNotesContainer.setWidth("250px"); experimentNotesContainer.setStyleName("experimentNotesContainer"); experimentNotesContainer.add(experimentNotesCollection); experimentNotesCollection.setStyleName("experimentNotesPanel"); experimentNotesPanel.add(experimentNotesContainer); experimentNotesPanel.add(saveNotesButton); saveNotesButton.setStyleName("saveNotesbutton"); experimentNotesPanel.setStyleName("experimentNotesPanel"); // domain Data domainDataResponseScrollPanel.clear(); domainDataResponseScrollPanel.add(domainDataResponsePanel); domainDataResponseScrollPanel.setStyleName("domainDataPanel"); domainDataResponseScrollPanel.setHeight("90px"); domainDataResponseScrollPanel.setWidth("800px"); domainDataSlotScrollPanel.clear(); domainDataSlotScrollPanel.add(domainDataSlotCollectionPanel); domainDataSlotCollectionPanel.setStyleName("domainDataSlotPanel"); domainDataSlotScrollPanel.setHeight("90px"); domainDataSlotScrollPanel.setWidth("800px"); domainDataFreeTextScrollPanel.clear(); domainDataFreeTextScrollPanel.add(freeTextElementsCollectionPanel); domainDataFreeTextScrollPanel.setStyleName("domainDataPanel"); domainDataFreeTextScrollPanel.setHeight("90px"); domainDataFreeTextScrollPanel.setWidth("800px"); // wizard correction wizardCorrectionScrollPanel.clear(); wizardCorrectionScrollPanel.add(wizardCorrectionPanel); wizardCorrectionScrollPanel.setStyleName("domainDataPanel"); wizardCorrectionScrollPanel.setHeight("357px"); wizardCorrectionScrollPanel.setWidth("806px"); // n-best list nBestListScrollPanel.clear(); nBestListScrollPanel.add(nBestListPanel); nBestListScrollPanel.setStyleName("domainDataPanel"); nBestListScrollPanel.setHeight("357px"); nBestListScrollPanel.setWidth("806px"); // free text field shoutBoxTexatArea.setCharacterWidth(100); shoutBoxTexatArea.setVisibleLines(5); shoutPanel.clear(); shoutPanel.add(shoutBoxTexatArea); shoutPanel.add(sendFreeTextButton); sendFreeTextButton.setStyleName("button"); shoutPanel.setStyleName("domainDataPanel"); shoutBoxTexatArea.setText(""); freeTextPanel.clear(); freeTextPanel.add(shoutPanel); freeTextPanel.setHeight("90px"); freeTextPanel.setWidth("806px"); domainDataTabPanel.setWidth("825px"); domainDataTabPanel.setHeight("140px"); domainDataTabPanel.setStyleName("domainData"); domainDataTabPanel.clear(); domainDataTabPanel.add(domainDataResponseScrollPanel, "Domain Data"); domainDataTabPanel.add(domainDataSlotScrollPanel, "Filter"); domainDataTabPanel.add(freeTextPanel, "Free Text"); domainDataTabPanel.selectTab(0); // turn off visibilty at the beginning domainDataTabPanel.setVisible(false); userPanel.clear(); userPanel.add(startEditButton); startEditButton.setStyleName("button"); userPanel.add(endEditButton); endEditButton.setStyleName("button"); endEditButton.setVisible(false); user.setStyleName("user"); userPanel.add(user); userPanel.add(userList); userList.setStyleName("list"); userPanel.add(signalPanel); userPanel.setStyleName("userPanel"); openReportButton.setStyleName("showReportButton"); endExperimentMarkerButton.setStyleName("showReportButton"); userPanel.add(openReportButton); userPanel.add(endExperimentMarkerButton); processingButton.setStyleName("processingButton"); editHeadingButtonsPanel.clear(); editHeadingButtonsPanel.add(addUttButton); addUttButton.setStyleName("button"); editHeadingButtonsPanel.add(editTabsButton); editTabsButton.setStyleName("button"); editHeadingButtonsPanel.add(addDomainDataButton); addDomainDataButton.setStyleName("button"); editHeadingButtonsPanel.add(addFilterButton); addFilterButton.setStyleName("button"); editHeadingButtonsPanel.setVisible(false); editHeadingButtonsPanel.setStyleName("editHeadingPanel"); // history historyPanel.clear(); historyPanel.setStyleName("historyPanel"); historyPanel.add(historyHeadingLabel); historyHeadingLabel.setStyleName("historyHeading"); historyPanel.add(historyUtterancesScrollPanel); historyUtterancesScrollPanel.setWidth("800px"); historyUtterancesScrollPanel.setHeight("65px"); historyUtterancesPanel.setWidth("750px"); historyUtterancesPanel.setStyleName("historyUtterancesPanel"); // report panel reportContentHeadingPanel.clear(); reportContentHeadingPanel.add(reportHeadingTable); reportContentHeadingPanel.setStyleName("reportContentScrollPanel"); reportContentHeadingPanel.setWidth("880px"); reportContentScrollPanel.add(reportTable); reportContentScrollPanel.setStyleName("reportContentScrollPanel"); reportContentScrollPanel.setWidth("880px"); reportContentScrollPanel.setHeight("450px"); reportPanel.clear(); reportPanel.add(reportContentHeadingPanel); reportPanel.add(reportContentScrollPanel); reportPanel.add(reportButtonsPanel); reportButtonsPanel.clear(); reportButtonsPanel.setStyleName("reportButtons"); printReportButton.setStyleName("button"); reportButtonsPanel.add(printReportButton); exportReportButton.setStyleName("button"); reportButtonsPanel.add(exportReportButton); closeReportButton.setStyleName("button"); reportButtonsPanel.add(closeReportButton); reportPanel.setWidth("900px"); reportPanel.setHeight("500px"); // free text panel preparedFreeTextPanel.clear(); preparedFreeTextPanel.add(preparedFreeTextSemKeyLabel); preparedFreeTextPanel.add(preparedFreeTextShortTextBox); preparedFreeTextPanel.add(preparedFreeTextLabel); preparedFreeTextPanel.add(preparedFreeTextTextArea); preparedFreeTextTextArea.setText(""); preparedFreeTextShortTextBox.setText(""); preparedFreeTextTextArea.setCharacterWidth(50); preparedFreeTextTextArea.setVisibleLines(5); preparedFreeTextButtonsPanel.clear(); preparedFreeTextButtonsPanel.add(addFreeTextButton); preparedFreeTextButtonsPanel.add(deleteFreeTextButton); preparedFreeTextButtonsPanel.add(editFreeTextButton); preparedFreeTextButtonsPanel.add(closeFreeTextButton); preparedFreeTextPanel.add(preparedFreeTextButtonsPanel); addFreeTextButton.setStyleName("button"); deleteFreeTextButton.setStyleName("button"); editFreeTextButton.setStyleName("button"); closeFreeTextButton.setStyleName("button"); preparedFreeTextSemKeyLabel.setStyleName("labelVertical"); preparedFreeTextSemKeyLabel.addStyleName("strong"); preparedFreeTextLabel.setStyleName("labelVertical"); preparedFreeTextLabel.addStyleName("strong"); preparedFreeTextPanel.setStyleName("preparedFreeTextPanel"); editFreeTextPanel.clear(); editFreeTextPanel.add(preparedFreeTextPanel); // add to Layout leftPanel.clear(); leftPanel.add(historyPanel); leftPanel.add(editHeadingButtonsPanel); leftPanel.add(domainDataTabPanel); leftPanel.add(dialogueStructurePanel); recoveryPanel.clear(); recoveryPanel.add(recoveryHeadingLabel); recoveryPanel.add(processingButton); recoveryPanel.add(recoveryScrollPanel); experimentNotesHeading.setStyleName("experimentNotesHeading"); experimentNotesHeading.setWidth("100px"); rightPanel.clear(); rightPanel.add(recoveryPanel); notesHeadingPanel.add(experimentNotesHeading); notesHeadingPanel.add(exportNotesButton); exportNotesButton.setStyleName("experimentNotesHeadingButton"); notesHeadingPanel.setStyleName("notesHeadingPanel"); rightPanel.add(notesHeadingPanel); rightPanel.add(experimentNotesPanel); horLayoutPanel.clear(); horLayoutPanel.add(leftPanel); horLayoutPanel.add(rightPanel); layoutPanel.clear(); layoutPanel.add(userPanel); layoutPanel.add(horLayoutPanel); // handler processingButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { statusUpdate = false; getTimeStamp(); } }); startEditButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // turn status update off statusUpdate = false; reloadFreeText = true; endEditButton.setVisible(true); startEditButton.setVisible(false); editHeadingButtonsPanel.setVisible(true); sendFreeTextButton.setVisible(false); // standard response utterances for (int i = 0; i < countUtt; i++) { uttPanel[i].setStyleName("utteranceEdit"); uttPanel[i].getWidget(0).setVisible(false); uttPanel[i].getWidget(1).setVisible(true); uttPanel[i].getWidget(2).setVisible(false); uttPanel[i].getWidget(4).setVisible(true); uttPanel[i].getWidget(5).setVisible(true); } // domain data for (int i = 0; i < countDomainUtt; i++) { domainUttPanel[i].setStyleName("utteranceEdit"); domainUttPanel[i].getWidget(1).setVisible(false); domainUttPanel[i].getWidget(2).setVisible(true); } // free text elements if (domainDataFreeTextPanels != null) { for (int i = 0; i < domainDataFreeTextPanels.length; i++) { domainDataFreeTextPanels[i] .setStyleName("utteranceEdit"); domainDataFreeTextPanels[i].getWidget(0).setVisible( false); domainDataFreeTextPanels[i].getWidget(1).setVisible( true); } } // slots if (domainDataSlotEditButtons != null) { for (int i = 0; i < domainDataSlotEditButtons.length; i++) { domainDataSlotEditButtons[i].setVisible(true); } } } }); endEditButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // turn on status information statusUpdate = true; reloadMode = 0; reload = true; reloadFreeText = false; endEditButton.setVisible(false); startEditButton.setVisible(true); editHeadingButtonsPanel.setVisible(false); sendFreeTextButton.setVisible(true); // standard response utterances for (int i = 0; i < countUtt; i++) { uttPanel[i].setStyleName("utterance"); uttPanel[i].getWidget(0).setVisible(true); uttPanel[i].getWidget(1).setVisible(false); uttPanel[i].getWidget(2).setVisible(true); uttPanel[i].getWidget(4).setVisible(false); uttPanel[i].getWidget(5).setVisible(false); } // domain data for (int i = 0; i < countDomainUtt; i++) { domainUttPanel[i].setStyleName("utterance"); domainUttPanel[i].getWidget(1).setVisible(true); domainUttPanel[i].getWidget(2).setVisible(false); } // free text if (domainDataFreeTextPanels != null) { for (int i = 0; i < domainDataFreeTextPanels.length; i++) { domainDataFreeTextPanels[i].setStyleName("utterance"); domainDataFreeTextPanels[i].getWidget(0).setVisible( true); domainDataFreeTextPanels[i].getWidget(1).setVisible( false); } } // slots if (domainDataSlotEditButtons != null) { for (int i = 0; i < domainDataSlotEditButtons.length; i++) { domainDataSlotEditButtons[i].setVisible(false); } } } }); cancelUttEditButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { editUtterancesPopup.hide(); } }); changeUttEditButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // clean from hivens semKey = clearHiven(semKeyTextBox.getText()); rank = clearHiven(rankTextBox.getText()); text = clearHiven(textTextArea.getText()); audio = clearHiven(audioFileTextBox.getText()); mm = clearHiven(mmFileTextBox.getText()); transtext = clearHiven(translTextArea.getText()); transaudio = clearHiven(translAudioFileTextBox.getText()); transmm = clearHiven(translMMFileTextBox.getText()); selectedTab = dialogueStructurePanel.getTabBar() .getSelectedTab(); String sql = "Update recording set semkey = '" + semKey + "', section = " + editTabUttList.getSelectedIndex() + ", rank = " + rank + ", origtext = '" + text + "', origaudiofile = '" + audio + "', origmmfile = '" + mm + "', transtext = '" + transtext + "', transaudiofile = '" + transaudio + "', transmmfile = '" + transmm + "' where id = " + editUtt; changeUtt(sql, 1); editUtterancesPopup.hide(); } }); changeUttDomainEditButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { semKey = clearHiven(semKeyDomainTextBox.getText()); text = clearHiven(textDomainTextArea.getText()); audio = clearHiven(audioFileDomainTextBox.getText()); mm = clearHiven(mmFileDomainTextBox.getText()); transtext = clearHiven(translDomainTextArea.getText()); transaudio = clearHiven(translAudioFileDomainTextBox.getText()); transmm = clearHiven(translMMFileDomainTextBox.getText()); selectedDomainTab = domainDataTabPanel.getTabBar() .getSelectedTab(); String sql1 = "Update domaindata set semkey = '" + semKey + "', origtext = '" + text + "', origaudiofile = '" + audio + "', origmmfile = '" + mm + "', transtext = '" + transtext + "', transaudiofile = '" + transaudio + "', transmmfile = '" + transmm + "' where id = " + editDomainUtt + "; "; // build sql to update the different filter String sql2 = ""; if (slotsExist) { for (int i = 0; i < filterHeadingLabel.length; i++) { sql2 = sql2 + "update domaindataslot inner join slot on domaindataslot.slotid = slot.id set slotid = " + filterList[i].getValue(filterList[i] .getSelectedIndex()) + " where name = '" + filterHeadingLabel[i].getText() + "' and dataid = " + editDomainUtt + "; "; } } // Merge the sql statements String sql = sql1 + sql2; changeUtt(sql, 1); editDomainDataPopup.hide(); } }); editFilterSaveButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { newFilter = clearHiven(editFilterTextBox.getText()); selectedDomainTab = domainDataTabPanel.getTabBar() .getSelectedTab(); String sql = "Update Slot set name = '" + newFilter + "' where name = '" + editSlot + "' and expid = " + expId + ";"; changeUtt(sql, 4); } }); editFilterDeleteButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { selectedDomainTab = domainDataTabPanel.getTabBar() .getSelectedTab(); String sql = "Delete domaindataslot from domaindataslot inner join slot where slot.id = domaindataslot.slotid and slot.name = '" + editSlot + "' and slot.expid = " + expId + "; "; sql = sql + "Delete from slot where name = '" + editSlot + "' and expid = " + expId + ";"; changeUtt(sql, 1); editSlotPopUp.hide(); } }); deleteUttEditButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { selectedTab = dialogueStructurePanel.getTabBar() .getSelectedTab(); String sql = "Delete from recording where id = " + editUtt; changeUtt(sql, 1); editUtterancesPopup.hide(); } }); deleteUttDomainEditButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { selectedDomainTab = domainDataTabPanel.getTabBar() .getSelectedTab(); String sql = "Delete from domaindata where id = " + editDomainUtt + "; "; sql = sql + "Delete from domaindataslot where dataid = " + editDomainUtt + ";"; changeUtt(sql, 1); editDomainDataPopup.hide(); } }); addFilterValueButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { selectedDomainTab = domainDataTabPanel.getTabBar() .getSelectedTab(); addFilterSlot(); addFilterValueTextBox.setText(""); } }); addUttEditButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { semKey = clearHiven(semKeyTextBox.getText()); rank = clearHiven(rankTextBox.getText()); text = clearHiven(textTextArea.getText()); audio = clearHiven(audioFileTextBox.getText()); mm = clearHiven(mmFileTextBox.getText()); transtext = clearHiven(translTextArea.getText()); transaudio = clearHiven(translAudioFileTextBox.getText()); transmm = clearHiven(translMMFileTextBox.getText()); selectedTab = dialogueStructurePanel.getTabBar() .getSelectedTab(); String sql = "Insert into recording (expid, semkey, section, rank, origtext, origaudiofile, origmmfile, transtext, transaudiofile, transmmfile) values (" + expId + ", '" + semKey + "', " + editTabUttList.getSelectedIndex() + ", " + rank + ", '" + text + "', '" + audio + "', '" + mm + "', '" + transtext + "', '" + transaudio + "', '" + transmm + "')"; editUtterancesPopup.hide(); changeUtt(sql, 1); } }); deleteFreeTextButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String sql = "Delete from freetext where id = " + currentFreeTextElement; selectedDomainTab = domainDataTabPanel.getTabBar() .getSelectedTab(); reloadMode = 1; changeFreeText(sql, 1); editFreeTextPopUp.hide(); } }); editFreeTextButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String sql = "Update freetext set text = '" + preparedFreeTextTextArea.getText() + "', semkey = '" + preparedFreeTextShortTextBox.getText() + "' where id =" + currentFreeTextElement; selectedDomainTab = domainDataTabPanel.getTabBar() .getSelectedTab(); reloadMode = 1; changeFreeText(sql, 1); } }); addUttDomainEditButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // clear hivens semKey = clearHiven(semKeyDomainTextBox.getText()); text = clearHiven(textDomainTextArea.getText()); audio = clearHiven(audioFileDomainTextBox.getText()); mm = clearHiven(mmFileDomainTextBox.getText()); transtext = clearHiven(translDomainTextArea.getText()); transaudio = clearHiven(translAudioFileDomainTextBox.getText()); transmm = clearHiven(translMMFileDomainTextBox.getText()); selectedDomainTab = domainDataTabPanel.getTabBar() .getSelectedTab(); String sql = "Insert into domaindata (expid, semkey, section, rank, origtext, origaudiofile, origmmfile, transtext, transaudiofile, transmmfile) values (" + expId + ", '" + semKey + "', " + 1 + ", " + 1 + ", '" + text + "', '" + audio + "', '" + mm + "', '" + transtext + "', '" + transaudio + "', '" + transmm + "')"; changeUtt(sql, 3); } }); editFilterAddSlotButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { getFilterRank(); } }); addUttButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { selectedTab = dialogueStructurePanel.getTabBar() .getSelectedTab(); editTabUttList.setSelectedIndex(selectedTab + 1); editButtonsPanel.setStyleName("addButtons"); addUttEditButton.setVisible(true); deleteUttEditButton.setVisible(false); changeUttEditButton.setVisible(false); semKeyTextBox.setText(""); textTextArea.setText(""); audioFileTextBox.setText(""); mmFileTextBox.setText(""); translTextArea.setText(""); translAudioFileTextBox.setText(""); translMMFileTextBox.setText(""); rankTextBox.setText("1"); editUtterancesPopup.show(); editUtterancesPopup.center(); } }); addDomainDataButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { editDomainButtonsPanel.setStyleName("addButtons"); addUttDomainEditButton.setVisible(true); deleteUttDomainEditButton.setVisible(false); changeUttDomainEditButton.setVisible(false); semKeyDomainTextBox.setText(""); textDomainTextArea.setText(""); audioFileDomainTextBox.setText(""); mmFileDomainTextBox.setText(""); translDomainTextArea.setText(""); translAudioFileDomainTextBox.setText(""); translMMFileDomainTextBox.setText(""); if (filterList != null) { for (int i = 0; i < filterList.length; i++) { filterList[i].setItemSelected(0, true); } } editDomainDataPopup.show(); editDomainDataPopup.center(); } }); editTabsButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { editTabsErrorLabel.setText(""); editTabsPopup.show(); editTabsPopup.center(); } }); addPreparedFreeTextElementsButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { preparedFreeTextTextArea.setText(""); preparedFreeTextShortTextBox.setText(""); addFreeTextButton.setVisible(true); editFreeTextButton.setVisible(false); deleteFreeTextButton.setVisible(false); editFreeTextPopUp.show(); editFreeTextPopUp.center(); preparedFreeTextButtonsPanel.setStyleName("addPreparedText"); selectedTab = 2; } }); closeFreeTextButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { editFreeTextPopUp.hide(); } }); addFreeTextButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String semkey = clearHiven(preparedFreeTextShortTextBox .getText()); String freeText = clearHiven(preparedFreeTextTextArea.getText()); String sql = "Insert into freetext (expid, semkey, text) values (" + expId + ", '" + semkey + "', '" + freeText + "');"; changeFreeText(sql, 1); editFreeTextPopUp.hide(); } }); addTabEditButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (!addTabTextBox.getText().equals("")) { tabName = clearHiven(addTabTextBox.getText()); tabInst = clearHiven(intructionTextArea.getText()); String sql = "Insert into tab (tabname, notes, exp, rank) values ('" + tabName + "', \"" + tabInst + "\", " + expId + "," + countTab + ")"; changeUtt(sql, 1); addTabTextBox.setText(""); intructionTextArea.setText(""); } } }); cancelTabEditButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { editTabsPopup.hide(); } }); cancelUttDomainEditButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { editDomainDataPopup.hide(); } }); cancelEditSlotPopUpButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { errorDeleteSlotValueLabel.setText(""); editFilterAddSlotTextBox.setText(""); editSlotPopUp.hide(); } }); cancelAddSlotPopUpButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { addSlotPopUp.hide(); addFilterValueTextBox.setText(""); } }); addFilterButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { addFilterTextBox.setText("Default Filter"); standardFilterValueTextBox.setText(defaultSlotValue); addFilterSlotCollection.clear(); addFilterSlotCollection.add(addFiltersStandardSlotPanel); addFilterSlotCollection.add(standardFilterValueExpLabel); addSlotPopUp.show(); addSlotPopUp.center(); } }); saveNotesButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { getNotesTime(); } }); experimentNotesTextArea.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { getNotesTime(); } } }); openReportButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { printReport(); } }); endExperimentMarkerButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { endExperiment(); } }); closeReportButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { reportTable.setHTML(""); printReportPopup.hide(); } }); printReportButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { openPrintView(); } }); exportReportButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { openExport(); } }); exportNotesButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { exportNotes(); } }); sendFreeTextButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { pushOutput(shoutBoxTexatArea.getText(), "3", 0); shoutBoxTexatArea.setText(""); } }); shoutBoxTexatArea.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { shoutBoxTexatArea.cancelKey(); pushOutput(shoutBoxTexatArea.getText(), "3", 0); shoutBoxTexatArea.setText(""); } } }); userList.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { changeUser(); } }); // Filter addFilterSaveButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String sql = ""; for (int i = 1; i < (addFilterSlotCollection.getWidgetCount() - 1); i++) { HorizontalPanel hp = (HorizontalPanel) addFilterSlotCollection .getWidget(i); Label lb = (Label) hp.getWidget(0); newFilter = clearHiven(addFilterTextBox.getText()); newValue = clearHiven(lb.getText()); sql = sql + "Insert into slot (expid, name, value, type, rank) values (" + expId + ", '" + newFilter + "', '" + newValue + "', " + 1 + ", " + rankEstimation + "); "; } newFilter = clearHiven(addFilterTextBox.getText()); newValue = clearHiven(standardFilterValueTextBox.getText()); sql = sql + "Insert into slot (expid, name, value, type, rank) values (" + expId + ", '" + newFilter + "', '" + newValue + "', " + 1 + ", " + rankEstimation + "); "; changeUtt(sql, 6); addSlotPopUp.hide(); } }); // Setup timer to refresh parts of the site automatically. setTimer(); } private void setTimer() { refreshTimer = new Timer() { @Override public void run() { if (statusUpdate) { getSignal(); } } }; // run refresh refreshTimer.scheduleRepeating(REFRESH_INTERVAL); } private void getSignal() { if (reload & userList.getItemCount() > 0) { // System.out.println("reload"); String sql = "Select * from output where experiment = " + expId + " and sender = " + userList.getValue(userList.getSelectedIndex()) + " and receiver = " + wizId + " and sign in (0, 1, 2, 3, 4) order by id desc limit 1"; // Initialize the service remote procedure call DatabaseAccessAsync databaseAccessSvc = GWT .create(DatabaseAccess.class); AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { if (result != null) { // get signal switch (Integer.parseInt(result[0][16])) { case 1: loggedInHtml .setHTML("<div style='color:red; margin-left:5px;'><strong>Logged in</strong></div>"); statusHtml.setHTML(""); break; case 2: loggedInHtml .setHTML("<div style='color:red; margin-left:5px;'><strong>Logged in | </strong></div>"); statusHtml .setHTML("<div style='color:green; margin-left:5px;'><strong>Session started</strong></div>"); break; case 3: loggedInHtml .setHTML("<div style='color:red; margin-left:5px;'><strong>Logged in | </strong></div>"); statusHtml .setHTML("<div style='color:green; margin-left:5px;'><strong>Session running</strong></div>"); break; case 4: loggedInHtml .setHTML("<div style='color:red; margin-left:5px;'><strong>Logged in | </strong></div>"); statusHtml .setHTML("<div style='color:navy; margin-left:5px;'><strong>Session stopped</strong></div>"); break; default: loggedInHtml .setHTML("<div style='margin-left:5px;'><strong>Logged out</strong></div>"); statusHtml.setHTML(""); break; } // check for user input if (Integer.parseInt(result[0][20]) == 1) { getInput(result[0][1], result[0][0], "1"); statusUpdate = false; } } else { } } }; databaseAccessSvc.retrieveData(sql, callback); AsyncCallback<Void> dbCloseCallBack = new AsyncCallback<Void>() { public void onFailure(Throwable caught) { } public void onSuccess(Void result) { } }; databaseAccessSvc.closeConnection(dbCloseCallBack); } } private void getInput(String text, String id, String mode) { // Initialize the service remote procedure call if (componentFactorySvc == null) { componentFactorySvc = GWT.create(ComponentFactory.class); } AsyncCallback<Vector<String>> callback = new AsyncCallback<Vector<String>>() { public void onFailure(Throwable caught) { } public void onSuccess(Vector<String> result) { String t = ""; if (result.size() == 1) { t = result.get(0); } else { t = result.get(0) + " ("; for (int i = 1; i < result.size() - 1; i++) { t = t + result.get(i) + ", "; } if (result.size() > 1) { t = t + result.get(result.size() - 1) + ")"; } else { t = t + ")"; } } historyUtterancesPanel.insert(new HTML("&rarr; " + t), 0); historyUtterancesPanel.getWidget(0).setStyleName("asrInput"); // Wizard Correction int i = inputElementVectorHorPanels.size(); inputTextVector.add(i, new String()); inputTextVector.set(i, result.get(0)); inputTextAreaVectorTextAreas.add(i, new TextArea()); inputTextAreaVectorTextAreas.get(i).setText(result.get(0)); inputTextAreaVectorTextAreas.get(i).setCharacterWidth(50); inputTextAreaVectorTextAreas.get(i).setVisibleLines(3); inputButtonVectorButtons.add(i, new Button("Send")); inputButtonVectorButtons.get(i).setStyleName("button"); inputElementVectorHorPanels.add(i, new HorizontalPanel()); inputElementVectorHorPanels.get(i).add( inputTextAreaVectorTextAreas.get(i)); inputElementVectorHorPanels.get(i).add( inputButtonVectorButtons.get(i)); wizardCorrectionPanel.add(inputElementVectorHorPanels.get(i)); addInputElementClickHandler(inputButtonVectorButtons.get(i), i, wizardCorrectionPanel.getWidgetCount() - 1); addInputElementKeyPressHandler( inputTextAreaVectorTextAreas.get(i), i, wizardCorrectionPanel.getWidgetCount() - 1); // N-Best list int j = inputNBestListVectorVerPanels.size(); int k = inputNBestListVectorHorPanels.size(); inputNBestListVectorVerPanels.add(j, new VerticalPanel()); String list = ""; for (int x = 0; x < result.size(); x++) { list = list + ";" + result.get(x); inputNBestListVectorLabels.add(k, new Label()); inputNBestListVectorLabels.get(k).setText(result.get(x)); inputNBestListVectorButtons.add(k, new Button("Send")); inputNBestListVectorButtons.get(k).setStyleName("button"); inputNBestListVectorHorPanels.add(k, new HorizontalPanel()); inputNBestListVectorHorPanels.get(k).add( inputNBestListVectorButtons.get(k)); inputNBestListVectorHorPanels.get(k).add( inputNBestListVectorLabels.get(k)); inputNBestListVectorVerPanels.get(j).add( inputNBestListVectorHorPanels.get(k)); addInputNBestListClickHandler( inputNBestListVectorButtons.get(k), k, nBestListPanel.getWidgetCount(), j); k++; } inputNBestListAlternatives.add(j, new String(list)); inputNBestListVectorVerPanels.get(j).add( new HTML("<div style=\"margin-left:15px;\">--</div>")); nBestListPanel.add(inputNBestListVectorVerPanels.get(j)); statusUpdate = true; } }; componentFactorySvc.getInput(text, id, mode, callback); } private void addInputElementClickHandler(Button b, final int id, final int panelId) { b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // Temporarily save the original text recognized = inputTextVector.get(id); pushOutput(inputTextAreaVectorTextAreas.get(id).getText(), "4", 0); while (inputElementVectorHorPanels.get(id).getWidgetCount() > 0) { inputElementVectorHorPanels.get(id).getWidget(0) .removeFromParent(); } inputElementVectorHorPanels.get(id).clear(); } }); } private void addInputNBestListClickHandler(Button b, final int id, final int panelId, final int listId) { b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String out = inputNBestListVectorLabels.get(id).getText(); alterantives = ""; String nlist = inputNBestListAlternatives.get(panelId); Vector<Integer> index = new Vector<Integer>(); Vector<String> list = new Vector<String>(); // find ; for (int i = 0; i < nlist.length(); i++) { if (nlist.substring(i, i + 1).equals(";")) { index.add(i); } } // check if there is at least one ; if (index.size() != 0) { list.add(nlist.substring(0, index.get(0))); for (int j = 0; j < index.size() - 1; j++) { list.add(nlist.substring(index.get(j) + 1, index.get(j + 1))); } // get the last one if (index.size() > 1) { list.add(nlist.substring( index.get(index.size() - 1) + 1, nlist.length())); } } else { // return the whole String - no n-Best list list.add(nlist); } // compare if it is the one that was send an add the rest to // alternatives for (int j = 0; j < list.size(); j++) { System.out.println(list.get(j)); if (!list.get(j).equals(out)) { alterantives = alterantives + list.get(j) + ", "; } } // trim the last and first comma as well as the last and first // white space alterantives = alterantives.substring(2, alterantives.length() - 2); pushOutput(out, "5", 0); // remove all elements while (inputNBestListVectorVerPanels.get(panelId) .getWidgetCount() > 0) { inputNBestListVectorVerPanels.get(panelId).getWidget(0) .removeFromParent(); } inputNBestListVectorVerPanels.get(panelId).clear(); } }); } private void addInputElementKeyPressHandler(TextArea t, final int id, final int panelId) { t.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { pushOutput(inputTextAreaVectorTextAreas.get(id).getText(), "4", 0); inputTextAreaVectorTextAreas.remove(id); inputButtonVectorButtons.remove(id); inputElementVectorHorPanels.remove(id); } } }); } private void loadUser() { String sql = "Select * from user inner join experimentuser where user.id = experimentuser.userid and experimentuser.expid = " + expId + " and user.role = 2 order by user.id asc"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { userList.clear(); if (result != null) { userId = Integer.parseInt(result[0][0]); for (int i = 0; i < result.length; i++) { userList.addItem(result[i][1] + " (" + result[i][0] + ")", result[i][0]); } } else { System.out.println("No users for this experiment"); } // turn reload on reload = true; // load experiment notes loadExperimentNotes(1); } }; databaseAccessSvc.retrieveData(sql, callback); } private void changeUser() { userId = Integer .parseInt(userList.getValue(userList.getSelectedIndex())); loadExperimentNotes(0); } public VerticalPanel getScreen() { return layoutPanel; } private void loadResponseUtterances() { String sql = "Select * from recording where expid = " + expId + " order by rank desc, id asc"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { if (result != null) { // remove click handler if (addUtteranceClickHandlerRegistration != null) { for (int i = 0; i < addUtteranceClickHandlerRegistration.length; i++) { addUtteranceClickHandlerRegistration[i] .removeHandler(); editUtteranceClickHandlerRegistration[i] .removeHandler(); addToFreeClickHandlerRegistration[i] .removeHandler(); uttButtUpClickHandlerRegistration[i] .removeHandler(); uttButtDownClickHandlerRegistration[i] .removeHandler(); } } addUtteranceClickHandler = new ClickHandler[result.length]; editUtteranceClickHandler = new ClickHandler[result.length]; addToFreeTextHandler = new ClickHandler[result.length]; uttButtonRankUpHandler = new ClickHandler[result.length]; uttButtonRankDownHandler = new ClickHandler[result.length]; addUtteranceClickHandlerRegistration = new HandlerRegistration[result.length]; editUtteranceClickHandlerRegistration = new HandlerRegistration[result.length]; addToFreeClickHandlerRegistration = new HandlerRegistration[result.length]; uttButtUpClickHandlerRegistration = new HandlerRegistration[result.length]; uttButtDownClickHandlerRegistration = new HandlerRegistration[result.length]; countUtt = result.length; uttPanel = new HorizontalPanel[result.length]; uttLabels = new Label[result.length]; uttButtons = new Button[result.length]; uttButtonsEdit = new Button[result.length]; uttButtonsToFreeText = new Button[result.length]; uttButtonsRankUpButtons = new Button[result.length]; uttButtonsRankDownButtons = new Button[result.length]; recoveryUtterancePanel.clear(); for (int i = 0; i < result.length; i++) { // create panel, label & button for utterance uttPanel[i] = new HorizontalPanel(); uttPanel[i].setHeight("20px"); uttLabels[i] = new Label(); uttLabels[i].setText(result[i][5]); uttLabels[i].setWidth("640px"); uttButtonsEdit[i] = new Button("Edit"); uttButtonsEdit[i].setStyleName("button"); uttButtons[i] = new Button("Send"); uttButtons[i].setStyleName("button"); uttButtonsToFreeText[i] = new Button("Free Text"); uttButtonsToFreeText[i].setStyleName("button"); uttButtonsRankUpButtons[i] = new Button("up"); uttButtonsRankUpButtons[i].setStyleName("button"); uttButtonsRankDownButtons[i] = new Button("down"); uttButtonsRankDownButtons[i].setStyleName("button"); // add handler to buttons using the id addUtteranceHandler(uttButtons[i], result[i][0], i); addEditHandler(uttButtonsEdit[i], result[i][0], i); addToFreeTextHandler(uttButtonsToFreeText[i], i); addUttUpHandler(uttButtonsRankUpButtons[i], result[i][0], i, result[i][4]); addUttDownHandler(uttButtonsRankDownButtons[i], result[i][0], i, result[i][4]); uttPanel[i].clear(); uttPanel[i].add(uttButtons[i]); uttPanel[i].add(uttButtonsEdit[i]); uttPanel[i].add(uttButtonsToFreeText[i]); uttPanel[i].add(uttLabels[i]); uttPanel[i].add(uttButtonsRankUpButtons[i]); uttPanel[i].add(uttButtonsRankDownButtons[i]); if (reloadMode < 1) { uttButtonsEdit[i].setVisible(false); uttButtonsRankUpButtons[i].setVisible(false); uttButtonsRankDownButtons[i].setVisible(false); uttButtonsToFreeText[i].setVisible(true); uttPanel[i].setStyleName("utterance"); } else { uttButtons[i].setVisible(false); uttButtonsToFreeText[i].setVisible(false); uttButtonsRankUpButtons[i].setVisible(true); uttButtonsRankDownButtons[i].setVisible(true); uttPanel[i].setStyleName("utteranceEdit"); } // check for frequently used utterances if (Integer.parseInt(result[i][3]) == 0) { uttLabels[i].setWidth("150px"); recoveryUtterancePanel.add(uttPanel[i]); } else { // add utterance int section = Integer.parseInt(result[i][3]); if (section <= countTab) { dialogueUtterancesPanel[Integer .parseInt(result[i][3]) - 1] .add(uttPanel[i]); } } } } else { } dialogueStructurePanel.selectTab(selectedTab); loadDomainData(); } }; databaseAccessSvc.retrieveData(sql, callback); } public void addUtteranceHandler(Button b, final String id, final int i) { addUtteranceClickHandler[i] = new ClickHandler() { public void onClick(ClickEvent event) { // stop reload to prevent disruption statusUpdate = false; uttPanel[i].setStyleName("utteranceSent"); pushOutput(id, "1", i); } }; addUtteranceClickHandlerRegistration[i] = b .addClickHandler(addUtteranceClickHandler[i]); } public void addUttUpHandler(Button b, final String id, final int i, final String rank) { int newRank = Integer.parseInt(rank); // increase newRank++; final String sql = "Update recording set rank = " + newRank + " where id = " + id; uttButtonRankUpHandler[i] = new ClickHandler() { public void onClick(ClickEvent event) { updateRank(sql); } }; uttButtUpClickHandlerRegistration[i] = b .addClickHandler(uttButtonRankUpHandler[i]); } public void addUttDownHandler(Button b, final String id, final int i, final String rank) { int newRank = Integer.parseInt(rank); final String sql = "Update recording set rank = " + newRank + " where id = " + id; ; // only reduce if more than 1 if (newRank > 1) { newRank--; } uttButtonRankDownHandler[i] = new ClickHandler() { public void onClick(ClickEvent event) { updateRank(sql); } }; uttButtDownClickHandlerRegistration[i] = b .addClickHandler(uttButtonRankDownHandler[i]); } public void addDomainUtteranceHandler(Button b, final String id, final int i) { addDomainUtteranceClickHandler[i] = new ClickHandler() { public void onClick(ClickEvent event) { // stop reload to prevent disruption statusUpdate = false; domainUttPanel[i].setStyleName("utteranceSent"); pushOutput(id, "2", i); } }; addDomainUtteranceClickHandlerRegistration[i] = b .addClickHandler(addDomainUtteranceClickHandler[i]); selectedDomainTab = domainDataTabPanel.getTabBar().getSelectedTab(); } public void addFreeTextAddHandler(Button b, final int i) { addFreeTextHandler[i] = new ClickHandler() { public void onClick(ClickEvent event) { // add free text to text field shoutBoxTexatArea.setText(shoutBoxTexatArea.getText() + " " + domainDataFreeTextLabels[i].getText()); } }; addFreeTextHandlerRegistration[i] = b .addClickHandler(addFreeTextHandler[i]); } public void addEditHandler(Button b, final String id, final int uttId) { editUtteranceClickHandler[uttId] = new ClickHandler() { public void onClick(ClickEvent event) { addUttEditButton.setVisible(false); deleteUttEditButton.setVisible(true); changeUttEditButton.setVisible(true); editUtt = id; setEditId(uttId); loadUtt(); editButtonsPanel.setStyleName("editButtons"); editUtterancesPopup.show(); editUtterancesPopup.center(); } }; editUtteranceClickHandlerRegistration[uttId] = b .addClickHandler(editUtteranceClickHandler[uttId]); } public void addToFreeTextHandler(Button b, final int uttId) { addToFreeTextHandler[uttId] = new ClickHandler() { public void onClick(ClickEvent event) { shoutBoxTexatArea.setText(shoutBoxTexatArea.getText() + " " + uttLabels[uttId].getText()); } }; addToFreeClickHandlerRegistration[uttId] = b .addClickHandler(addToFreeTextHandler[uttId]); } public void addDomainUtteranceEditHandler(Button b, final String id, final int uttId) { editDomainUtteranceClickHandler[uttId] = new ClickHandler() { public void onClick(ClickEvent event) { addUttDomainEditButton.setVisible(false); deleteUttDomainEditButton.setVisible(true); changeUttDomainEditButton.setVisible(true); editDomainUtt = id; if (slotsExist) { loadDomainUtt(); } else { loadDomainUttNormal(); } editDomainButtonsPanel.setStyleName("editButtons"); editDomainDataPopup.show(); editDomainDataPopup.center(); } }; editDomainUtteranceClickHandlerRegistration[uttId] = b .addClickHandler(editDomainUtteranceClickHandler[uttId]); selectedDomainTab = domainDataTabPanel.getTabBar().getSelectedTab(); } public void addFreeTextEditHandler(Button b, final String id, final String text, final String semk, final int uttId) { editFreeTextHandler[uttId] = new ClickHandler() { public void onClick(ClickEvent event) { preparedFreeTextTextArea.setText(text); preparedFreeTextShortTextBox.setText(semk); addFreeTextButton.setVisible(false); editFreeTextButton.setVisible(true); deleteFreeTextButton.setVisible(true); editFreeTextPopUp.show(); editFreeTextPopUp.center(); preparedFreeTextButtonsPanel.setStyleName("editPreparedText"); currentFreeTextElement = id; } }; editFreeTextHandlerRegistration[uttId] = b .addClickHandler(editFreeTextHandler[uttId]); } public void addChangeSlotValueHandler(Button b, final int itemId, final int listId) { changeSlotValueHandler[itemId] = new ClickHandler() { public void onClick(ClickEvent event) { newValue = clearHiven(editFilterSlotValuesTextBox[itemId] .getText()); String sql = "Update slot set value = '" + newValue + "' where value = '" + filterList[listId].getItemText(itemId) + "' and expid =" + expId; changeUtt(sql, 1); } }; changeSlotValueHandlerRegistration[itemId] = b .addClickHandler(changeSlotValueHandler[itemId]); selectedDomainTab = domainDataTabPanel.getTabBar().getSelectedTab(); } public void addDeleteSlotValueHandler(Button b, final int itemId, final int listId) { deleteSlotValueHandler[itemId] = new ClickHandler() { public void onClick(ClickEvent event) { String sql1 = "select count(*) from slot inner join domaindataslot where slot.id = domaindataslot.slotid and slot.value = '" + filterList[listId].getItemText(itemId) + "' and name = '" + filterHeadingLabel[listId].getText() + "' and expid =" + expId; String sql2 = "delete from slot where value = '" + filterList[listId].getItemText(itemId) + "' and name = '" + filterHeadingLabel[listId].getText() + "' and expid =" + expId; getSlotValueUseCount(sql1, sql2, itemId); } }; deleteSlotValueHandlerRegistration[itemId] = b .addClickHandler(deleteSlotValueHandler[itemId]); selectedDomainTab = domainDataTabPanel.getTabBar().getSelectedTab(); } public void addSlotEditHandler(Button b, final int id) { editSlotHandler[id] = new ClickHandler() { public void onClick(ClickEvent event) { editFilterTextBox.setText(filterHeadingLabel[id].getText()); editSlot = filterHeadingLabel[id].getText(); editSlotId = id; editSlotPopUp.show(); editSlotPopUp.center(); // remove handler if (changeSlotValueHandlerRegistration != null) { for (int i = 0; i < changeSlotValueHandlerRegistration.length; i++) { changeSlotValueHandlerRegistration[i].removeHandler(); deleteSlotValueHandlerRegistration[i].removeHandler(); } } changeSlotValueHandler = new ClickHandler[filterList[id] .getItemCount()]; deleteSlotValueHandler = new ClickHandler[filterList[id] .getItemCount()]; changeSlotValueHandlerRegistration = new HandlerRegistration[filterList[id] .getItemCount()]; deleteSlotValueHandlerRegistration = new HandlerRegistration[filterList[id] .getItemCount()]; editFilterSlotValuesTextBox = new TextBox[filterList[id] .getItemCount()]; editFilterDeletSlotButton = new Button[filterList[id] .getItemCount()]; editFilterChangeSlotButton = new Button[filterList[id] .getItemCount()]; editFilterSlotsPanel = new HorizontalPanel[filterList[id] .getItemCount()]; editFilterSlotCollectionPanel.clear(); for (int i = 0; i < filterList[id].getItemCount(); i++) { editFilterSlotValuesTextBox[i] = new TextBox(); editFilterSlotValuesTextBox[i].setText(filterList[id] .getItemText(i)); editFilterChangeSlotButton[i] = new Button("Save Changes "); editFilterChangeSlotButton[i].setStyleName("button"); addChangeSlotValueHandler(editFilterChangeSlotButton[i], i, id); editFilterDeletSlotButton[i] = new Button( "Delete Filter Value"); editFilterDeletSlotButton[i].setStyleName("button"); addDeleteSlotValueHandler(editFilterDeletSlotButton[i], i, id); editFilterSlotsPanel[i] = new HorizontalPanel(); editFilterSlotsPanel[i].add(editFilterSlotValuesTextBox[i]); editFilterSlotsPanel[i].add(editFilterChangeSlotButton[i]); editFilterSlotsPanel[i].add(editFilterDeletSlotButton[i]); editFilterSlotCollectionPanel.add(editFilterSlotsPanel[i]); editFilterSlotCollectionPanel .setStyleName("editFilterSlotsPanel"); } } }; editSlotHandlerRegistration[id] = b .addClickHandler(editSlotHandler[id]); } public void addDelHandler(Button b, final String id, final int uttId) { b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String sql = "Delete from recording where id = " + id; uttPanel[uttId].setVisible(false); startEditButton.setVisible(true); endEditButton.setVisible(false); addUttButton.setVisible(true); editTabsButton.setVisible(true); changeUtt(sql, 2); } }); } public void addDelTabHandler(Button b, final String id, final int tabId) { delTabClickHandler[tabId] = new ClickHandler() { public void onClick(ClickEvent event) { if (dialogueUtterancesPanel[tabId].getWidgetCount() == 0) { String sql = "Delete from tab where id = " + id; editTabs[tabId].setVisible(false); countTab--; changeUtt(sql, 1); } else { editTabsErrorLabel .setText("Error: It is impossible to delete a tab that holds utterances! Please delete the utterances first or move them to a different tab."); } } }; delTabClickHandlerRegistration[tabId] = b .addClickHandler(delTabClickHandler[tabId]); } public void addSaveTabHandler(Button b, final String id, final int tabId) { saveTabClickHandler[tabId] = new ClickHandler() { public void onClick(ClickEvent event) { tabName = clearHiven(tabText[tabId].getText()); tabInst = clearHiven(tabInstructions[tabId].getText()); String sql = "Update tab set tabname = '" + tabName + "', notes = \"" + tabInst + "\" where id = " + id; changeUtt(sql, 1); } }; saveTabClickHandlerRegistration[tabId] = b .addClickHandler(saveTabClickHandler[tabId]); } public void pushOutput(final String output, final String mode, final int i) { // Initialize the service remote procedure call if (componentFactorySvc == null) { componentFactorySvc = GWT.create(ComponentFactory.class); } AsyncCallback<String> callback = new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { // change the color of the old history elements if (historyUtterancesPanel.getWidgetCount() > 0) { for (int i = 0; i < historyUtterancesPanel.getWidgetCount(); i++) { historyUtterancesPanel.getWidget(i).setStyleName( "historyOld"); } } switch (Integer.parseInt(mode)) { case 1: // recorded utterance case 2: // domain utterance case 3: // free text historyUtterancesPanel.insert(new HTML("&larr; " + result), 0); break; case 4: // wizard correction historyUtterancesPanel.insert(new HTML("&larr; " + result + " (" + recognized + ")"), 0); break; case 5: // n-best list historyUtterancesPanel.insert(new HTML("&larr; " + result + " (" + alterantives + ")"), 0); break; } // turn reload back on statusUpdate = true; } }; componentFactorySvc.pushOutput(output, userId, mode, callback); } public void startProcessing(String time) { String sql = "Insert into output (textorig, audioorig, mmorig, texttrans, audiotrans, mmtrans, timestamp, experiment, user, sign, sender, receiver) values (\"" + "P R O C E S S I N G . . ." + "\", '" + "-" + "', '" + "-" + "', \"" + "-" + "\", '" + "-" + "', '" + "-" + "', \"" + time + "\", " + expId + ", " + userId + ", 6, " + wizId + ", " + userId + ")"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String> callback = new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { // change the color of the old history elements if (historyUtterancesPanel.getWidgetCount() > 0) { for (int i = 0; i < historyUtterancesPanel.getWidgetCount(); i++) { historyUtterancesPanel.getWidget(i).setStyleName( "historyOld"); } } historyUtterancesPanel.insert(new HTML( "< P R O C E S S I N G >"), 0); statusUpdate = true; } }; databaseAccessSvc.storeData(sql, callback); } public void changeUtt(String sql, final int reload) { // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String> callback = new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { if (reload == 4) { editSlot = editFilterTextBox.getText(); } if (reload == 5) { // reload filter values in pop-up reloadFilter(); } if (reload == 6) { getLastFilter(); } else { reloadLayout(reload); } } }; databaseAccessSvc.storeData(sql, callback); } private void changeFreeText(String sql, final int reload) { // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String> callback = new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { // reload loadFreeTextElements(); } }; databaseAccessSvc.storeData(sql, callback); } private void loadUtt() { String sql = "Select * from recording where id = " + editUtt; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { semKeyTextBox.setText(result[0][2]); textTextArea.setText(result[0][5]); audioFileTextBox.setText(result[0][6]); mmFileTextBox.setText(result[0][7]); translTextArea.setText(result[0][8]); translAudioFileTextBox.setText(result[0][9]); translMMFileTextBox.setText(result[0][10]); editTabUttList.setSelectedIndex(Integer.parseInt(result[0][3])); rankTextBox.setText(result[0][4]); } }; databaseAccessSvc.retrieveData(sql, callback); } public void getSlotValueUseCount(final String sql1, final String sql, final int id) { // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { if (Integer.parseInt(result[0][0]) == 0) { changeUtt(sql, 1); editFilterSlotCollectionPanel.remove(id); errorDeleteSlotValueLabel.setText(""); } else { errorDeleteSlotValueLabel .setText("Error: You cannot delete filter values that are still in use."); } } }; databaseAccessSvc.retrieveData(sql1, callback); } private void loadDomainUtt() { String sql = "Select * from domaindata inner join (select domaindataslot.dataid, domaindataslot.slotid, slot.name, slot.id, slot.rank from domaindataslot inner join slot where domaindataslot.slotid = slot.id) as q1 where domaindata.id = q1.dataid and domaindata.id = " + editDomainUtt + " order by q1.rank"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { semKeyDomainTextBox.setText(result[0][2]); textDomainTextArea.setText(result[0][5]); audioFileDomainTextBox.setText(result[0][6]); mmFileDomainTextBox.setText(result[0][7]); translDomainTextArea.setText(result[0][8]); translAudioFileDomainTextBox.setText(result[0][9]); translMMFileDomainTextBox.setText(result[0][10]); for (int i = 0; i < filterHeadingLabel.length; i++) { for (int j = 0; j < filterList[i].getItemCount(); j++) if (filterList[i].getValue(j).equals(result[i][14])) { filterList[i].setItemSelected(j, true); } } } }; databaseAccessSvc.retrieveData(sql, callback); } private void loadDomainUttNormal() { String sql = "Select * from domaindata where id = " + editDomainUtt; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { semKeyDomainTextBox.setText(result[0][2]); textDomainTextArea.setText(result[0][5]); audioFileDomainTextBox.setText(result[0][6]); mmFileDomainTextBox.setText(result[0][7]); translDomainTextArea.setText(result[0][8]); translAudioFileDomainTextBox.setText(result[0][9]); translMMFileDomainTextBox.setText(result[0][10]); editDomainFilterPanel.clear(); } }; databaseAccessSvc.retrieveData(sql, callback); } public void loadTabs() { String sql = "Select * from tab where exp = " + expId + " and visible = 1 order by rank asc"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { if (result != null) { // remove click handler if (saveTabClickHandlerRegistration != null) { for (int i = 0; i < saveTabClickHandlerRegistration.length; i++) { saveTabClickHandlerRegistration[i].removeHandler(); delTabClickHandlerRegistration[i].removeHandler(); } } saveTabClickHandler = new ClickHandler[result.length]; delTabClickHandler = new ClickHandler[result.length]; saveTabClickHandlerRegistration = new HandlerRegistration[result.length]; delTabClickHandlerRegistration = new HandlerRegistration[result.length]; // add heading for recovery panel countTab = result.length; uttHeadings = new Label[result.length]; utterancesPanel = new VerticalPanel[result.length]; tabText = new TextBox[result.length]; tabInstructions = new TextArea[result.length]; editTabsContainer = new VerticalPanel[result.length]; tabDelButton = new Button[result.length]; tabSaveButton = new Button[result.length]; tabNotesHeading = new Label[result.length]; tabNotesPanel = new VerticalPanel[result.length]; tabNotes = new Label[result.length]; dialogueTabPanel = new VerticalPanel[result.length]; dialogueTabScrollPanel = new ScrollPanel[result.length]; notesTabScrollanel = new ScrollPanel[result.length]; dialogueUtterancesPanel = new VerticalPanel[result.length]; editTabs = new HorizontalPanel[result.length]; editTabUttList.clear(); editTabUttList.addItem("Frequently Used Utterances"); // clear panel to prepare for reload editTabsTabsPanel.clear(); dialogueStructurePanel.clear(); for (int i = 0; i < result.length; i++) { // build tab layout dialogueTabPanel[i] = new VerticalPanel(); uttHeadings[i] = new Label(); uttHeadings[i].setText("Utterances:"); uttHeadings[i].setStyleName("utteranceHeading"); dialogueTabScrollPanel[i] = new ScrollPanel(); dialogueTabScrollPanel[i].setWidth("808px"); notesTabScrollanel[i] = new ScrollPanel(); notesTabScrollanel[i].setWidth("808px"); notesTabScrollanel[i].setHeight("80px"); tabNotesHeading[i] = new Label(); tabNotesHeading[i].setText("Instructions:"); tabNotesHeading[i].setStyleName("tabNotesHeading"); utterancesPanel[i] = new VerticalPanel(); utterancesPanel[i].clear(); utterancesPanel[i].add(uttHeadings[i]); utterancesPanel[i].add(dialogueTabScrollPanel[i]); tabNotesPanel[i] = new VerticalPanel(); tabNotesPanel[i].clear(); tabNotesPanel[i].add(tabNotesHeading[i]); tabNotesPanel[i].add(notesTabScrollanel[i]); dialogueUtterancesPanel[i] = new VerticalPanel(); dialogueTabPanel[i].clear(); dialogueTabPanel[i].add(utterancesPanel[i]); dialogueTabPanel[i].add(tabNotesPanel[i]); dialogueTabScrollPanel[i] .add(dialogueUtterancesPanel[i]); // tab notes tabNotes[i] = new Label(); tabNotes[i].setText(result[i][4]); tabNotes[i].setStyleName("experimentTabNotes"); notesTabScrollanel[i].add(tabNotes[i]); if (result[i][4].equals("")) { tabNotesPanel[i].setVisible(false); } else { tabNotesPanel[i].setVisible(true); } dialogueStructurePanel.add(dialogueTabPanel[i], result[i][1]); if (Integer.parseInt(result[i][5]) != 1) { editTabUttList.addItem(result[i][1]); } // build edit tab structure tabText[i] = new TextBox(); tabText[i].setWidth("250px"); tabText[i].setText(result[i][1]); tabInstructions[i] = new TextArea(); tabInstructions[i].setCharacterWidth(60); tabInstructions[i].setVisibleLines(5); tabInstructions[i].setText(result[i][4]); editTabs[i] = new HorizontalPanel(); editTabs[i].clear(); editTabs[i].add(tabText[i]); tabSaveButton[i] = new Button("Save Changes"); tabSaveButton[i].setStyleName("button"); addSaveTabHandler(tabSaveButton[i], result[i][0], i); editTabs[i].add(tabSaveButton[i]); tabDelButton[i] = new Button("Delete"); tabDelButton[i].setStyleName("button"); addDelTabHandler(tabDelButton[i], result[i][0], i); editTabs[i].add(tabDelButton[i]); if (i == 0) { tabDelButton[i].setVisible(false); } editTabs[i].setStyleName("editTabs"); editTabsContainer[i] = new VerticalPanel(); editTabsContainer[i].clear(); editTabsContainer[i].add(editTabs[i]); editTabsContainer[i].add(tabInstructions[i]); editTabsTabsPanel.add(editTabsContainer[i]); } editTabsPanel.setStyleName("editTabsPanel"); editTabsScrollPanel.setWidth("500px"); editTabsScrollPanel.setHeight("150px"); // clear panel before adding (implemented to allow reload) editTabsScrollPanel.clear(); editTabsScrollPanel.add(editTabsTabsPanel); addTabTextBox.setWidth("150px"); addTabEditButton.setStyleName("button"); addTabPanel.clear(); tabNameLabel.setStyleName("labelVertical"); tabNameLabel.addStyleName("strong"); tabInstructionLabel.setStyleName("labelVertical"); tabInstructionLabel.addStyleName("strong"); newTabPanel.add(tabNameLabel); addTabPanel.add(addTabTextBox); addTabPanel.add(addTabEditButton); newTabPanel.add(addTabPanel); newTabPanel.add(tabInstructionLabel); intructionTextArea.setCharacterWidth(70); intructionTextArea.setVisibleLines(8); newTabPanel.add(intructionTextArea); editTabsPanel.clear(); editTabsPanel.add(editTabsScrollPanel); editTabsPanel.add(editTabsErrorLabel); editTabsPanel.add(newTabPanel); editTabsPanel.add(cancelTabEditButton); cancelTabEditButton.setStyleName("cancleEditTabButton"); dialogueStructurePanel.add(wizardCorrectionScrollPanel, "Wizard Correction"); dialogueStructurePanel.add(nBestListScrollPanel, "N-best List"); } else { System.out.println("No tabs connected to this experiment!"); } dialogueStructurePanel.selectTab(0); // load utterances loadResponseUtterances(); } }; databaseAccessSvc.retrieveData(sql, callback); } private void reloadLayout(int mode) { reloadMode = mode; if (mode > 0) { // clear all variables tabText = null; tabDelButton = null; tabSaveButton = null; tabNotesHeading = null; editTabs = null; uttPanel = null; uttLabels = null; uttButtons = null; uttButtonsEdit = null; domainUttPanel = null; domainUttLabels = null; domainUttButtons = null; domainUttButtonsEdit = null; editTabUttList.clear(); dialogueStructurePanel.clear(); editTabsPanel.clear(); recoveryUtterancePanel.clear(); // reload tabs if (mode == 3) { getLastDomainDatatID(); } else { loadTabs(); } } } private void loadExperimentNotes(final int control) { String sql = "Select * from experimentnotes where expid = " + expId + " and userid = " + userId + " order by id"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { experimentNotesCollection.clear(); experimentNotesCollection.add(experimentNotesTextArea); if (result != null) { notesCount = result.length; if (result.length > 0) { for (int i = 0; i < result.length; i++) { if (experimentNotesCollection.getWidgetCount() > 1) { experimentNotesCollection.insert(new HTML( result[i][3].substring(11) + ": " + result[i][4]), 1); } else { experimentNotesCollection.add(new HTML( result[i][3].substring(11) + ": " + result[i][4])); } experimentNotesCollection.getWidget(1) .setStyleName("experimentNotesSaved"); } } } else { notesCount = 0; } experimentNotesHeading.setText("Notes (" + notesCount + ")"); experimentNotesTextArea.setStyleName("experimentNotes"); if (control == 1) { loadTabs(); } } }; databaseAccessSvc.retrieveData(sql, callback); } private void getNotesTime() { // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String> callback = new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { saveNotes(result); } }; databaseAccessSvc.getTimeStamp(callback); } private void saveNotes(final String time) { note = clearHiven(experimentNotesTextArea.getText()); String sql = "Insert into experimentnotes (expid, userid, timestamp, note) values (" + expId + ", " + userId + ", \"" + time + "\", \"" + note + "\");"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String> callback = new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { if (experimentNotesCollection.getWidgetCount() > 1) { experimentNotesCollection.insert( new HTML(time.substring(11) + ": " + experimentNotesTextArea.getText()), 1); } else { experimentNotesCollection.add(new HTML(time.substring(11) + ": " + experimentNotesTextArea.getText())); } experimentNotesCollection.getWidget(1).setStyleName( "experimentNotesSaved"); notesCount++; experimentNotesHeading.setText("Notes (" + notesCount + ")"); experimentNotesTextArea.setText(""); experimentNotesTextArea.setFocus(true); } }; databaseAccessSvc.storeData(sql, callback); } private void loadDomainData() { String sql = "Select * from domaindata where expid = " + expId + " order by id"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { if (result != null) { // remove handler if (addDomainUtteranceClickHandlerRegistration != null) { for (int i = 0; i < addDomainUtteranceClickHandlerRegistration.length; i++) { addDomainUtteranceClickHandlerRegistration[i] .removeHandler(); editDomainUtteranceClickHandlerRegistration[i] .removeHandler(); } } addDomainUtteranceClickHandler = new ClickHandler[result.length]; editDomainUtteranceClickHandler = new ClickHandler[result.length]; addDomainUtteranceClickHandlerRegistration = new HandlerRegistration[result.length]; editDomainUtteranceClickHandlerRegistration = new HandlerRegistration[result.length]; addFilterButton.setVisible(true); possibleData = new Integer[result.length][2]; setCountDomainUtt(result.length); domainDataTabPanel.getTabBar().setTabText(0, "Domain Data: (" + result.length + ")"); domainUttPanel = new HorizontalPanel[result.length]; domainUttNoLabels = new Label[result.length]; domainUttLabels = new Label[result.length]; domainUttButtons = new Button[result.length]; domainUttButtonsEdit = new Button[result.length]; domainDataResponsePanel.clear(); for (int i = 0; i < result.length; i++) { // set visibility of data possibleData[i][0] = Integer.parseInt(result[i][0]); possibleData[i][1] = 1; // create panel, label & button for utterance domainUttPanel[i] = new HorizontalPanel(); domainUttPanel[i].clear(); domainUttPanel[i].setHeight("30px"); domainUttLabels[i] = new Label(); domainUttLabels[i].setText(result[i][5]); domainUttLabels[i].setWidth("660px"); domainUttNoLabels[i] = new Label(); domainUttNoLabels[i].setText((i + 1) + ")"); domainUttNoLabels[i].setWidth("20px"); domainUttButtonsEdit[i] = new Button("Edit"); domainUttButtonsEdit[i].setStyleName("button"); addDomainUtteranceEditHandler(domainUttButtonsEdit[i], result[i][0], i); domainUttButtons[i] = new Button("Send"); domainUttButtons[i].setStyleName("button"); // add handler to buttons using the id addDomainUtteranceHandler(domainUttButtons[i], result[i][0], i); domainUttPanel[i].add(domainUttNoLabels[i]); domainUttPanel[i].add(domainUttButtons[i]); domainUttPanel[i].add(domainUttButtonsEdit[i]); domainUttPanel[i].add(domainUttLabels[i]); if (reloadMode < 1) { domainUttButtonsEdit[i].setVisible(false); domainUttPanel[i].setStyleName("utterance"); } else { domainUttButtons[i].setVisible(false); domainUttPanel[i].setStyleName("utteranceEdit"); } domainDataResponsePanel.add(domainUttPanel[i]); } domainDataTabPanel.selectTab(selectedDomainTab); loadSlots(); } else { countDomainUtt = 0; addFilterButton.setVisible(false); // turn on status update if (reloadMode < 1) { // start statusUpdate statusUpdate = true; } loadFreeTextElements(); } } }; databaseAccessSvc.retrieveData(sql, callback); } public void changeDomainUtt(String sql, final int reload) { // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String> callback = new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { reloadLayout(reload); } }; databaseAccessSvc.storeData(sql, callback); } public void setCountDomainUtt(int countDomainUtt) { this.countDomainUtt = countDomainUtt; } public int getCountDomainUtt() { return countDomainUtt; } private void loadSlots() { String sql = "Select id, name, count(value), rank from slot where expid = " + expId + " group by name order by rank, id asc"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } @SuppressWarnings("deprecation") public void onSuccess(String[][] result) { if (result != null) { // remove handler if (slotRadioButtonHandlerRegistration != null) { for (int i = 0; i < slotRadioButtonHandlerRegistration.length; i++) { for (int j = 0; j < slotRadioButtonHandlerRegistration[i].length; j++) { slotRadioButtonHandlerRegistration[i][j] .removeHandler(); } } } // clear handler if (editSlotHandlerRegistration != null) { for (int i = 0; i < editSlotHandlerRegistration.length; i++) { editSlotHandlerRegistration[i].removeHandler(); } } editSlotHandler = new ClickHandler[result.length]; editSlotHandlerRegistration = new HandlerRegistration[result.length]; slotRadioButtonHandler = new ClickHandler[result.length][]; slotRadioButtonHandlerRegistration = new HandlerRegistration[result.length][]; slotsExist = true; domainDataTabPanel.getTabBar().setTabEnabled(1, true); rankEstimation = (result.length) + 1; defaultSlotValue = "Default-" + rankEstimation; standardFilterValueTextBox.setText(defaultSlotValue); domainDataSlotPanel = new VerticalPanel[result.length]; domainDataSlotPanelHeading = new HorizontalPanel[result.length]; domainDataSlotEditButtons = new Button[result.length]; slotHeadingLabel = new Label[result.length]; filterList = new ListBox[result.length]; filterHeadingLabel = new Label[result.length]; slots = new HorizontalPanel[result.length]; slotRadioButton = new RadioButton[result.length][]; domainDataSlotCollectionPanel.clear(); editDomainFilterPanel.clear(); for (int i = 0; i < result.length; i++) { // filter filterHeadingLabel[i] = new Label(); filterHeadingLabel[i].setText(result[i][1]); filterList[i] = new ListBox(); editDomainFilterPanel.add(filterHeadingLabel[i]); editDomainFilterPanel.add(filterList[i]); domainDataSlotPanel[i] = new VerticalPanel(); domainDataSlotPanel[i].clear(); domainDataSlotCollectionPanel .add(domainDataSlotPanel[i]); slotHeadingLabel[i] = new Label(); slotHeadingLabel[i].setText(result[i][1]); domainDataSlotPanelHeading[i] = new HorizontalPanel(); domainDataSlotPanelHeading[i].clear(); domainDataSlotPanelHeading[i].add(slotHeadingLabel[i]); domainDataSlotEditButtons[i] = new Button("Edit"); domainDataSlotEditButtons[i] .setStyleName("buttonSlotEdit"); addSlotEditHandler(domainDataSlotEditButtons[i], i); domainDataSlotPanelHeading[i] .add(domainDataSlotEditButtons[i]); if (reloadMode < 1) { domainDataSlotEditButtons[i].setVisible(false); } else { domainDataSlotEditButtons[i].setVisible(true); } domainDataSlotPanel[i] .add(domainDataSlotPanelHeading[i]); domainDataSlotPanel[i] .setStyleName("domainDataSlotPanel"); slots[i] = new HorizontalPanel(); slots[i].clear(); // Amount of radio buttons + 1 for disabling the filter slotRadioButton[i] = new RadioButton[Integer .parseInt(result[i][2]) + 1]; // handler slotRadioButtonHandler[i] = new ClickHandler[Integer .parseInt(result[i][2]) + 1]; slotRadioButtonHandlerRegistration[i] = new HandlerRegistration[Integer .parseInt(result[i][2]) + 1]; // add the first radio button to disable filter slotRadioButton[i][0] = new RadioButton( slotHeadingLabel[i].getText()); slotRadioButton[i][0].setChecked(true); slots[i].add(slotRadioButton[i][0]); // add the rest of the radio buttons for this slot for (int j = 1; j < Integer.parseInt(result[i][2]) + 1; j++) { slotRadioButton[i][j] = new RadioButton( slotHeadingLabel[i].getText()); slots[i].add(slotRadioButton[i][j]); } domainDataSlotPanel[i].add(slots[i]); slotHeadingLabel[i].setStyleName("slotHeading"); slots[i].setStyleName("slot"); } loadSlotLabels(); } else { slotsExist = false; domainDataTabPanel.getTabBar().setTabEnabled(1, false); domainDataTabPanel.selectTab(0); loadFreeTextElements(); } } }; databaseAccessSvc.retrieveData(sql, callback); } private void reloadDomainData() { String s[] = new String[domainDataSort.length]; String c[] = new String[domainDataSort.length]; int countData = 0; // turn all records to visible before filtering them for (int k = 0; k < possibleData.length; k++) { possibleData[k][1] = 1; } for (int i = 0; i < domainDataSort.length; i++) { s[i] = ""; c[i] = ""; for (int j = 0; j < selectedSlots.length; j++) { if (selectedSlots[j] != 0) { s[i] = s[i] + selectedSlots[j]; c[i] = c[i] + domainDataSort[i][j + 1]; // Then String comparison to find which to turn on and which // to turn off System.out.print(s[i] + " | "); System.out.println(c[i]); if (s[i].equals(c[i])) { for (int k = 0; k < possibleData.length; k++) { if (possibleData[k][0].byteValue() == domainDataSort[i][0] .byteValue()) { possibleData[k][1] = 1; } } } else { for (int k = 0; k < possibleData.length; k++) { System.out.println(possibleData[k][0] + " | " + domainDataSort[i][0]); if (possibleData[k][0].byteValue() == domainDataSort[i][0] .byteValue()) { possibleData[k][1] = 0; } } } } } } // change data visibility int z = 1; for (int x = 0; x < possibleData.length; x++) { System.out.println(possibleData[x][0] + ": " + possibleData[x][1]); if (possibleData[x][1] == 0) { domainUttPanel[x].setVisible(false); } else { domainUttNoLabels[x].setText(z + ")"); domainUttPanel[x].setVisible(true); z++; } } // get amount of possible data for (int x = 0; x < possibleData.length; x++) { if (possibleData[x][1] == 1) { countData++; } } domainDataTabPanel.getTabBar().setTabText(0, "Domain Data: (" + countData + ")"); } private void loadSlotLabels() { String sql = "Select * from slot where expid = " + expId + " order by rank, id asc"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { if (result != null) { int k = 0; for (int i = 0; i < slotRadioButton.length; i++) { // add the heading for 'Filter off' slotRadioButton[i][0].setHTML("OFF"); addRadioButtonValueChangeHandler(slotRadioButton[i][0], 0, i, 0); // add the rest of the headings for (int j = 1; j < slotRadioButton[i].length; j++) { slotRadioButton[i][j].setHTML(result[k][3]); addRadioButtonValueChangeHandler( slotRadioButton[i][j], Integer.parseInt(result[k][0]), i, j); filterList[i].addItem(result[k][3], result[k][0]); k++; } } } getDomainDataSort(); } }; databaseAccessSvc.retrieveData(sql, callback); } private void addRadioButtonValueChangeHandler(RadioButton rb, final int id, final int i, final int j) { slotRadioButtonHandler[i][j] = new ClickHandler() { public void onClick(ClickEvent event) { selectedSlots[i] = id; reloadDomainData(); } }; slotRadioButtonHandlerRegistration[i][j] = rb .addClickHandler(slotRadioButtonHandler[i][j]); } private void getDomainDataSort() { String sql = " SELECT * FROM (domaindataslot INNER JOIN slot ON domaindataslot.slotid = slot.id) inner JOIN domaindata WHERE domaindataslot.dataid = domaindata.id AND domaindata.expid = " + expId + " order by domaindataslot.dataid, slot.rank, domaindataslot.id, domaindataslot.slotid asc"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { if (result != null) { // define slot tracking and set all values to 0 selectedSlots = new Integer[slots.length]; for (int i = 0; i < selectedSlots.length; i++) { selectedSlots[i] = 0; } domainDataSort = new Integer[result.length / slots.length][slots.length + 1]; int k = 0; for (int i = 0; i < domainDataSort.length; i++) { for (int j = 0; j < domainDataSort[i].length; j++) { if (j == 0) { domainDataSort[i][j] = Integer .parseInt(result[k][0]); } else { domainDataSort[i][j] = Integer .parseInt(result[k][1]); k++; } } } } loadFreeTextElements(); } }; databaseAccessSvc.retrieveData(sql, callback); } public void setEditId(int editId) { this.editId = editId; } public int getEditId() { return editId; } private static class EditUtterancesPopup extends PopupPanel { public EditUtterancesPopup() { // Set the dialog box's caption. setWidth("810px"); setHeight("500px"); // Enable animation. setAnimationEnabled(true); setGlassEnabled(true); setWidget(editPanel); } } private static class EditPreparedFreeTextPopup extends PopupPanel { public EditPreparedFreeTextPopup() { // Set the dialog box's caption. setWidth("400px"); setHeight("200px"); // Enable animation. setAnimationEnabled(true); setGlassEnabled(true); setWidget(editFreeTextPanel); } } private void printReport() { String sql = "select * from output where experiment = " + expId + " and user = " + userId + " and sign in (2, 3, 4) order by id"; // System.out.println(sql); // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(final String[][] result) { // heading reportHeadingHtml = "<table>"; reportHeadingHtml = reportHeadingHtml + "<tr>"; reportHeadingHtml = reportHeadingHtml + "<th width=\"80px\">Timestamp</th>"; reportHeadingHtml = reportHeadingHtml + "<th width=\"150px\">Sent</th>"; reportHeadingHtml = reportHeadingHtml + "<th width=\"150px\">Original</th>"; reportHeadingHtml = reportHeadingHtml + "<th width=\"80px\" align=\"center\">Translation Text Flag</th>"; reportHeadingHtml = reportHeadingHtml + "<th width=\"80px\" align=\"center\">Original Text Flag</th>"; reportHeadingHtml = reportHeadingHtml + "<th width=\"80px\" align=\"center\">Translation Audio Flag</th>"; reportHeadingHtml = reportHeadingHtml + "<th width=\"80px\" align=\"center\">Original Audio Flag</th>"; reportHeadingHtml = reportHeadingHtml + "<th width=\"80px\" align=\"center\">Translation MM Flag</th>"; reportHeadingHtml = reportHeadingHtml + "<th width=\"80px\" align=\"center\">Original MM Flag</th>"; reportHeadingHtml = reportHeadingHtml + "</tr>"; reportHeadingHtml = reportHeadingHtml + "</table>"; if (result != null) { // String record; reportHtml = "<table>"; for (int i = 0; i < result.length; i++) { // different color for every second record if (i % 2 == 0) { reportHtml = reportHtml + "<tr style=\"background-color:#ADD8E6\">"; } else { reportHtml = reportHtml + "<tr style=\"background-color:#C0C0C0\">"; } reportHtml = reportHtml + "<td width=\"80px\" align=\"left\">" + result[i][8] + "</td>"; reportHtml = reportHtml + "<td width=\"150px\">" + result[i][4] + "</td>"; reportHtml = reportHtml + "<td width=\"150px\">" + result[i][1] + "</td>"; reportHtml = reportHtml + "<td width=\"80px\" align=\"center\">" + result[i][10] + "</td>"; reportHtml = reportHtml + "<td width=\"80px\" align=\"center\">" + result[i][11] + "</td>"; reportHtml = reportHtml + "<td width=\"80px\" align=\"center\">" + result[i][12] + "</td>"; reportHtml = reportHtml + "<td width=\"80px\" align=\"center\">" + result[i][13] + "</td>"; reportHtml = reportHtml + "<td width=\"80px\" align=\"center\">" + result[i][14] + "</td>"; reportHtml = reportHtml + "<td width=\"80px\" align=\"center\">" + result[i][15] + "</td>"; reportHtml = reportHtml + "</tr>"; } reportHtml = reportHtml + "</table>"; } else { reportHtml = ""; } reportHeadingTable.setHTML(reportHeadingHtml); reportTable.setHTML(reportHtml); printReportPopup.show(); printReportPopup.center(); } }; databaseAccessSvc.retrieveData(sql, callback); } private static class EditTabsPopup extends PopupPanel { public EditTabsPopup() { // Set the dialog box's caption. setWidth("530px"); setHeight("400px"); // Enable animation. setAnimationEnabled(true); setGlassEnabled(true); setWidget(editTabsPanel); } } private static class PrintReportPopup extends PopupPanel { public PrintReportPopup() { // Set the dialog box's caption. setWidth("900px"); setHeight("500px"); // Enable animation. setAnimationEnabled(true); setGlassEnabled(true); setWidget(reportPanel); } } private static class EditDomainDataPopUp extends PopupPanel { public EditDomainDataPopUp() { // Set the dialog box's caption. setWidth("810px"); setHeight("500px"); // Enable animation. setAnimationEnabled(true); setGlassEnabled(true); setWidget(editDomainDataPanel); } } private static class EditSlotPopUp extends PopupPanel { public EditSlotPopUp() { // Set the dialog box's caption. setWidth("580px"); setHeight("200px"); // Enable animation. setAnimationEnabled(true); setGlassEnabled(true); setWidget(editSlotPopUpPanel); } } private static class AddSlotPopUp extends PopupPanel { public AddSlotPopUp() { // Set the dialog box's caption. setWidth("580px"); setHeight("200px"); // Enable animation. setAnimationEnabled(true); setGlassEnabled(true); setWidget(addSlotPopUpPanel); } } private void openPrintView() { Window.open("/webwozwizard/webwozwizard/experimentReport?p1=user&p2=" + expId + "&p3=" + userId, "", ""); } private void openExport() { Window.open("/webwozwizard/webwozwizard/excelExport?p1=user&p2=" + expId + "&p3=" + userId, "", ""); } private void exportNotes() { Window.open("/webwozwizard/webwozwizard/notesExport?p1=" + expId + "&p2=" + userId, "", ""); } private void getLastDomainDatatID() { String sql = "select id from domaindata where expid = " + expId + " order by id desc"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(final String[][] result) { if (filterList != null) { String sql = ""; for (int i = 0; i < filterList.length; i++) { sql = sql + "Insert into domaindataslot (dataid, slotid) values (" + result[0][0] + ", " + filterList[i].getValue(filterList[i] .getSelectedIndex()) + "); "; } insertFilterSettings(sql); } else { loadTabs(); editDomainDataPopup.hide(); } } }; databaseAccessSvc.retrieveData(sql, callback); } private void insertFilterSettings(String sql) { // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String> callback = new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { loadTabs(); editDomainDataPopup.hide(); } }; databaseAccessSvc.storeData(sql, callback); } private void getFilterRank() { String sql = "Select rank from slot where name = '" + editSlot + "' and expid = " + expId; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { editSlotRank = Integer.parseInt(result[0][0]); newValue = clearHiven(editFilterAddSlotTextBox.getText()); String sql = "insert into slot (expid, name, value, type, rank) values (" + expId + ", '" + editSlot + "', '" + newValue + "', " + 1 + ", " + editSlotRank + ")"; changeUtt(sql, 5); } }; databaseAccessSvc.retrieveData(sql, callback); } private void reloadFilter() { filterList[editSlotId].addItem(editFilterAddSlotTextBox.getText()); editFilterSlotsPanel = null; editFilterSlotsPanel = new HorizontalPanel[filterList[editSlotId] .getItemCount()]; editFilterSlotValuesTextBox = null; editFilterSlotValuesTextBox = new TextBox[filterList[editSlotId] .getItemCount()]; editFilterChangeSlotButton = null; editFilterChangeSlotButton = new Button[filterList[editSlotId] .getItemCount()]; editFilterDeletSlotButton = null; editFilterDeletSlotButton = new Button[filterList[editSlotId] .getItemCount()]; editFilterSlotCollectionPanel.clear(); for (int i = 0; i < filterList[editSlotId].getItemCount(); i++) { editFilterSlotValuesTextBox[i] = new TextBox(); editFilterSlotValuesTextBox[i].setText(filterList[editSlotId] .getItemText(i)); editFilterChangeSlotButton[i] = new Button("Save Changes "); editFilterChangeSlotButton[i].setStyleName("button"); addChangeSlotValueHandler(editFilterChangeSlotButton[i], i, editSlotId); editFilterDeletSlotButton[i] = new Button("Delete Filter Value"); editFilterDeletSlotButton[i].setStyleName("button"); addDeleteSlotValueHandler(editFilterDeletSlotButton[i], i, editSlotId); editFilterSlotsPanel[i] = new HorizontalPanel(); editFilterSlotsPanel[i].add(editFilterSlotValuesTextBox[i]); editFilterSlotsPanel[i].add(editFilterChangeSlotButton[i]); editFilterSlotsPanel[i].add(editFilterDeletSlotButton[i]); editFilterSlotCollectionPanel.add(editFilterSlotsPanel[i]); editFilterSlotCollectionPanel.setStyleName("editFilterSlotsPanel"); } editFilterAddSlotTextBox.setText(""); } private void getLastFilter() { String sql = "Select id from slot where expid = " + expId + " order by id desc"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { String sql2 = ""; for (int i = 0; i < possibleData.length; i++) { sql2 = sql2 + "Insert into domaindataslot (dataid, slotid) values (" + possibleData[i][0] + ", " + result[0][0] + "); "; } changeUtt(sql2, 7); } }; databaseAccessSvc.retrieveData(sql, callback); } private void addFilterSlot() { int id = addFilterSlotCollection.getWidgetCount(); addFilterSlotCollection.insert(new HorizontalPanel(), id - 1); getFilterSlotPanel((HorizontalPanel) addFilterSlotCollection .getWidget(id - 1)); } private void getFilterSlotPanel(HorizontalPanel p) { p.setStyleName("addFilterValue"); p.add(new Label(addFilterValueTextBox.getText())); p.getWidget(0).setWidth("90px"); p.add(new Button("Delete")); addButtonHandler((Button) p.getWidget(1)); } private void addButtonHandler(final Button b) { b.setStyleName("button"); b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { addFilterSlotCollection.remove((HorizontalPanel) b.getParent()); } }); } public void stopReload() { refreshTimer.cancel(); statusUpdate = false; // flush popups editUtterancesPopup = null; editDomainDataPopup = null; editTabsPopup = null; printReportPopup = null; editSlotPopUp = null; addSlotPopUp = null; editFreeTextPopUp = null; } public void turnOffComponent() { } private String clearHiven(String source) { source = source.replaceAll("\"", ""); return source.replaceAll("'", " "); } private void loadFreeTextElements() { String sql = "Select * from freetext where expid = " + expId + " order by id"; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { freeTextElementsCollectionPanel.clear(); if (result != null) { if (addFreeTextHandlerRegistration != null) { for (int i = 0; i < addFreeTextHandlerRegistration.length; i++) { addFreeTextHandlerRegistration[i].removeHandler(); editFreeTextHandlerRegistration[i].removeHandler(); } } setCountFreeTextElements(result.length); addFreeTextHandler = new ClickHandler[result.length]; editFreeTextHandler = new ClickHandler[result.length]; addFreeTextHandlerRegistration = new HandlerRegistration[result.length]; editFreeTextHandlerRegistration = new HandlerRegistration[result.length]; domainDataFreeTextPanels = new HorizontalPanel[result.length]; domainDataFreeTextLabels = new Label[result.length]; domainDataFreeTextButtons = new Button[result.length]; domainDataFreeTextButtonsEdit = new Button[result.length]; for (int i = 0; i < result.length; i++) { // create panel, label & button for free text domainDataFreeTextPanels[i] = new HorizontalPanel(); domainDataFreeTextPanels[i].clear(); domainDataFreeTextPanels[i].setHeight("30px"); domainDataFreeTextLabels[i] = new Label(); domainDataFreeTextLabels[i].setText(result[i][3]); domainDataFreeTextLabels[i].setWidth("600px"); domainDataFreeTextButtonsEdit[i] = new Button("Edit"); domainDataFreeTextButtonsEdit[i].setStyleName("button"); addFreeTextEditHandler( domainDataFreeTextButtonsEdit[i], result[i][0], result[i][3], result[i][2], i); domainDataFreeTextButtons[i] = new Button( "Add to Free Text"); domainDataFreeTextButtons[i].setStyleName("button"); addFreeTextAddHandler(domainDataFreeTextButtons[i], i); domainDataFreeTextPanels[i] .add(domainDataFreeTextButtons[i]); domainDataFreeTextPanels[i] .add(domainDataFreeTextButtonsEdit[i]); domainDataFreeTextPanels[i] .add(domainDataFreeTextLabels[i]); if (reloadMode < 1) { domainDataFreeTextButtonsEdit[i].setVisible(false); domainDataFreeTextPanels[i] .setStyleName("utterance"); } else { domainDataFreeTextButtons[i].setVisible(false); domainDataFreeTextPanels[i] .setStyleName("utteranceEdit"); } freeTextElementsCollectionPanel .add(domainDataFreeTextPanels[i]); } // turn freeText to editMode if (reloadFreeText) { for (int i = 0; i < domainDataFreeTextPanels.length; i++) { domainDataFreeTextPanels[i] .setStyleName("utteranceEdit"); domainDataFreeTextPanels[i].getWidget(0) .setVisible(false); domainDataFreeTextPanels[i].getWidget(1) .setVisible(true); } } } else { setCountFreeTextElements(0); } changeVisibility(); } }; databaseAccessSvc.retrieveData(sql, callback); } private void getTimeStamp() { // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String> callback = new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { startProcessing(result); } }; databaseAccessSvc.getTimeStamp(callback); } public void setCountFreeTextElements(int countFreeTextElements) { this.countFreeTextElements = countFreeTextElements; } public int getCountFreeTextElements() { return countFreeTextElements; } public void changeVisibility() { String sql = "Select nbestlist, wizardcorrection, freetext from experiment where id = " + expId; // clear content of n-Best list and wizard correction wizardCorrectionPanel.clear(); nBestListPanel.clear(); inputElementVectorHorPanels.clear(); inputButtonVectorButtons.clear(); inputTextAreaVectorTextAreas.clear(); inputNBestListVectorVerPanels.clear(); inputNBestListVectorHorPanels.clear(); inputNBestListVectorButtons.clear(); inputNBestListVectorLabels.clear(); statusUpdate = false; // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String[][]> callback = new AsyncCallback<String[][]>() { public void onFailure(Throwable caught) { } public void onSuccess(String[][] result) { if (Integer.parseInt(result[0][0]) == 1) { nBestList = true; } else { nBestList = false; } if (Integer.parseInt(result[0][1]) == 1) { wizardCorrection = true; } else { wizardCorrection = false; } if (Integer.parseInt(result[0][2]) == 1) { freeText = true; } else { freeText = false; } if (reloadMode < 1) { // start statusUpdate statusUpdate = true; } checkTabVisibility(); } }; databaseAccessSvc.retrieveData(sql, callback); } private void checkTabVisibility() { // start with domainDataPanel visible false domainPanelVisible = false; // domain data if (countDomainUtt > 0) { domainDataTabPanel.getTabBar().setTabEnabled(0, true); domainPanelVisible = true; domainDataTabPanel.selectTab(0); } else { domainDataTabPanel.getTabBar().setTabEnabled(0, false); domainDataTabPanel.getTabBar().setTabEnabled(1, false); domainDataTabPanel.getTabBar().setTabText(0, "Domain Data"); } if (slotsExist) { domainDataTabPanel.getTabBar().setTabEnabled(1, true); domainPanelVisible = true; } else { domainDataTabPanel.getTabBar().setTabEnabled(1, false); } // free text if (freeText) { domainDataTabPanel.getTabBar().setTabEnabled(2, true); domainPanelVisible = true; domainDataTabPanel.selectTab(2); // turn on to free text buttons for (int i = 0; i < countUtt; i++) { uttPanel[i].getWidget(2).setVisible(true); } } else { domainDataTabPanel.getTabBar().setTabEnabled(2, false); // turn off to free text buttons for (int i = 0; i < countUtt; i++) { uttPanel[i].getWidget(2).setVisible(false); } } // domainDataPanel Visibility if (domainPanelVisible) { domainDataTabPanel.setVisible(true); } else { domainDataTabPanel.setVisible(false); } // wizard Correction if (wizardCorrection) { dialogueStructurePanel.getTabBar().setTabEnabled(countTab, true); } else { dialogueStructurePanel.getTabBar().setTabEnabled(countTab, false); } // n-best List if (nBestList) { dialogueStructurePanel.getTabBar() .setTabEnabled(countTab + 1, true); } else { dialogueStructurePanel.getTabBar().setTabEnabled(countTab + 1, false); } // change the selected tab if reload if (selectedDomainTab != 100) { domainDataTabPanel.selectTab(selectedDomainTab); } if (selectedTab != 0) { dialogueStructurePanel.selectTab(selectedTab); } } private void endExperiment() { // time stamp @SuppressWarnings("deprecation") String time = DateTimeFormat.getMediumDateTimeFormat().format( new Date()); String sql = "Insert into output (textorig, audioorig, mmorig, texttrans, audiotrans, mmtrans, experiment, timestamp, played, sign, user, sender, receiver) values ('Stop Session (Wizard)', '-', '-', 'Stop Session (Wizard)', '-', '-', " + expId + ", '" + time + "', 1, 0, " + userId + " , " + userId + ", " + wizId + ")"; System.out.println(sql); // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String> callback = new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { } }; databaseAccessSvc.storeData(sql, callback); } private void updateRank(String sql) { // Initialize the service remote procedure call if (databaseAccessSvc == null) { databaseAccessSvc = GWT.create(DatabaseAccess.class); } AsyncCallback<String> callback = new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { reloadLayout(1); } }; databaseAccessSvc.storeData(sql, callback); } }
3e0b5f2a72c8fce2775bfa595c64bbb3934f9506
4,682
java
Java
aliyun-java-sdk-drds/src/main/java/com/aliyuncs/drds/model/v20190123/DescribeTableShardingInfoResponse.java
cctvzd7/aliyun-openapi-java-sdk
b8e4dce2a61ca968615c9b910bedebaea71781ae
[ "Apache-2.0" ]
3
2020-04-26T09:15:45.000Z
2020-05-09T03:10:26.000Z
aliyun-java-sdk-drds/src/main/java/com/aliyuncs/drds/model/v20190123/DescribeTableShardingInfoResponse.java
cctvzd7/aliyun-openapi-java-sdk
b8e4dce2a61ca968615c9b910bedebaea71781ae
[ "Apache-2.0" ]
null
null
null
aliyun-java-sdk-drds/src/main/java/com/aliyuncs/drds/model/v20190123/DescribeTableShardingInfoResponse.java
cctvzd7/aliyun-openapi-java-sdk
b8e4dce2a61ca968615c9b910bedebaea71781ae
[ "Apache-2.0" ]
null
null
null
22.95098
91
0.722982
4,815
/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.aliyuncs.drds.model.v20190123; import java.util.List; import com.aliyuncs.AcsResponse; import com.aliyuncs.drds.transform.v20190123.DescribeTableShardingInfoResponseUnmarshaller; import com.aliyuncs.transform.UnmarshallerContext; /** * @author auto create * @version */ public class DescribeTableShardingInfoResponse extends AcsResponse { private String requestId; private Boolean success; private Data data; public String getRequestId() { return this.requestId; } public void setRequestId(String requestId) { this.requestId = requestId; } public Boolean getSuccess() { return this.success; } public void setSuccess(Boolean success) { this.success = success; } public Data getData() { return this.data; } public void setData(Data data) { this.data = data; } public static class Data { private String dbShardingFunction; private Integer dbRightShiftOffset; private String tbShardingFunction; private Integer tbRightShiftOffset; private Integer tbPartitions; private Boolean isShard; private Integer tbComputeLength; private Integer dbComputeLength; private List<Column> columnList; private List<String> dbShardingColumnList; private List<String> tbShardingColumnList; public String getDbShardingFunction() { return this.dbShardingFunction; } public void setDbShardingFunction(String dbShardingFunction) { this.dbShardingFunction = dbShardingFunction; } public Integer getDbRightShiftOffset() { return this.dbRightShiftOffset; } public void setDbRightShiftOffset(Integer dbRightShiftOffset) { this.dbRightShiftOffset = dbRightShiftOffset; } public String getTbShardingFunction() { return this.tbShardingFunction; } public void setTbShardingFunction(String tbShardingFunction) { this.tbShardingFunction = tbShardingFunction; } public Integer getTbRightShiftOffset() { return this.tbRightShiftOffset; } public void setTbRightShiftOffset(Integer tbRightShiftOffset) { this.tbRightShiftOffset = tbRightShiftOffset; } public Integer getTbPartitions() { return this.tbPartitions; } public void setTbPartitions(Integer tbPartitions) { this.tbPartitions = tbPartitions; } public Boolean getIsShard() { return this.isShard; } public void setIsShard(Boolean isShard) { this.isShard = isShard; } public Integer getTbComputeLength() { return this.tbComputeLength; } public void setTbComputeLength(Integer tbComputeLength) { this.tbComputeLength = tbComputeLength; } public Integer getDbComputeLength() { return this.dbComputeLength; } public void setDbComputeLength(Integer dbComputeLength) { this.dbComputeLength = dbComputeLength; } public List<Column> getColumnList() { return this.columnList; } public void setColumnList(List<Column> columnList) { this.columnList = columnList; } public List<String> getDbShardingColumnList() { return this.dbShardingColumnList; } public void setDbShardingColumnList(List<String> dbShardingColumnList) { this.dbShardingColumnList = dbShardingColumnList; } public List<String> getTbShardingColumnList() { return this.tbShardingColumnList; } public void setTbShardingColumnList(List<String> tbShardingColumnList) { this.tbShardingColumnList = tbShardingColumnList; } public static class Column { private String name; private String type; public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getType() { return this.type; } public void setType(String type) { this.type = type; } } } @Override public DescribeTableShardingInfoResponse getInstance(UnmarshallerContext context) { return DescribeTableShardingInfoResponseUnmarshaller.unmarshall(this, context); } @Override public boolean checkShowJsonItemName() { return false; } }
3e0b5f986a69e9056fa7942111d712745dde1450
1,952
java
Java
app/src/main/java/com/example/android/sunshine/app/MainActivity.java
alenteria/Android-Test1
b0008727d40355346cc4e8b776f3d8a9d98faeb7
[ "Apache-2.0" ]
null
null
null
app/src/main/java/com/example/android/sunshine/app/MainActivity.java
alenteria/Android-Test1
b0008727d40355346cc4e8b776f3d8a9d98faeb7
[ "Apache-2.0" ]
null
null
null
app/src/main/java/com/example/android/sunshine/app/MainActivity.java
alenteria/Android-Test1
b0008727d40355346cc4e8b776f3d8a9d98faeb7
[ "Apache-2.0" ]
null
null
null
33.655172
80
0.682889
4,816
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.android.sunshine.app; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.container, new ForecastFragment()) .commit(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }
3e0b6067af281527378dbcbfdb986c1aee6e1f2c
2,219
java
Java
ayo-db/src/main/java/org/xutils/db/x.java
cowthan/AyoDB
370c7bdaf75f7082ce5f905fa5c566e024bd93c9
[ "Apache-2.0" ]
1
2016-08-29T11:17:53.000Z
2016-08-29T11:17:53.000Z
ayo-db/src/main/java/org/xutils/db/x.java
cowthan/AyoDB
370c7bdaf75f7082ce5f905fa5c566e024bd93c9
[ "Apache-2.0" ]
null
null
null
ayo-db/src/main/java/org/xutils/db/x.java
cowthan/AyoDB
370c7bdaf75f7082ce5f905fa5c566e024bd93c9
[ "Apache-2.0" ]
null
null
null
25.802326
109
0.584948
4,817
package org.xutils.db; import android.app.Application; import android.content.Context; import java.lang.reflect.Method; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSession; /** * Created by wyouflf on 15/6/10. * 任务控制中心, http, image, db, view注入等接口的入口. * 需要在在application的onCreate中初始化: x.Ext.init(this); */ public final class x { private x() { } public static boolean isDebug() { return Ext.debug; } public static Application app() { if (Ext.app == null) { try { // 在IDE进行布局预览时使用 Class<?> renderActionClass = Class.forName("com.android.layoutlib.bridge.impl.RenderAction"); Method method = renderActionClass.getDeclaredMethod("getCurrentContext"); Context context = (Context) method.invoke(null); Ext.app = new MockApplication(context); } catch (Throwable ignored) { throw new RuntimeException("please invoke x.Ext.init(app) on Application#onCreate()" + " and register your Application in manifest."); } } return Ext.app; } public static DbManager getDb(DbManager.DaoConfig daoConfig) { return DbManagerImpl.getInstance(daoConfig); } public static class Ext { private static boolean debug; private static Application app; private Ext() { } static { // 默认信任所有https域名 HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { return true; } }); } public static void init(Application app) { if (Ext.app == null) { Ext.app = app; } } public static void setDebug(boolean debug) { Ext.debug = debug; } } private static class MockApplication extends Application { public MockApplication(Context baseContext) { this.attachBaseContext(baseContext); } } }
3e0b6299df2e13ca5818c51752ee0f5e2a5bd2ee
848
java
Java
gen/org/jetbrains/r/psi/impl/RMuldivOperatorImpl.java
CyberFlameGO/Rplugin
e66ddceb2fe712f6b4c2e282c4c502afae1e097c
[ "Apache-2.0" ]
52
2019-10-24T17:16:53.000Z
2022-02-09T22:19:02.000Z
gen/org/jetbrains/r/psi/impl/RMuldivOperatorImpl.java
CyberFlameGO/Rplugin
e66ddceb2fe712f6b4c2e282c4c502afae1e097c
[ "Apache-2.0" ]
3
2019-10-24T17:26:36.000Z
2021-06-28T12:25:20.000Z
gen/org/jetbrains/r/psi/impl/RMuldivOperatorImpl.java
CyberFlameGO/Rplugin
e66ddceb2fe712f6b4c2e282c4c502afae1e097c
[ "Apache-2.0" ]
13
2020-02-16T00:07:56.000Z
2022-03-21T10:49:52.000Z
27.354839
83
0.772406
4,818
// This is a generated file. Not intended for manual editing. package org.jetbrains.r.psi.impl; import java.util.List; import org.jetbrains.annotations.*; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import static org.jetbrains.r.parsing.RElementTypes.*; import org.jetbrains.r.psi.api.*; public class RMuldivOperatorImpl extends ROperatorImpl implements RMuldivOperator { public RMuldivOperatorImpl(@NotNull ASTNode astNode) { super(astNode); } @Override public void accept(@NotNull RVisitor visitor) { visitor.visitMuldivOperator(this); } @Override public void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof RVisitor) accept((RVisitor)visitor); else super.accept(visitor); } }
3e0b629c867bb64d50b54e79dff72a3a81f50a0f
360
java
Java
back-end/src/main/java/softuni/angular/services/NInsTypeService.java
GKirilov98/Softuni-Angular-2021
5ba49fd0cde55273f357dbb34b0a1e06df448d55
[ "Apache-2.0" ]
1
2021-11-30T16:02:59.000Z
2021-11-30T16:02:59.000Z
back-end/src/main/java/softuni/angular/services/NInsTypeService.java
GKirilov98/Softuni-Java-Angular-2021
5ba49fd0cde55273f357dbb34b0a1e06df448d55
[ "Apache-2.0" ]
null
null
null
back-end/src/main/java/softuni/angular/services/NInsTypeService.java
GKirilov98/Softuni-Java-Angular-2021
5ba49fd0cde55273f357dbb34b0a1e06df448d55
[ "Apache-2.0" ]
null
null
null
22.5
69
0.788889
4,819
package softuni.angular.services; import softuni.angular.exception.GlobalServiceException; import softuni.angular.data.views.nomenclature.NomenclatureOutView; import java.util.List; /** * Project: backend * Created by: GKirilov * On: 8/4/2021 */ public interface NInsTypeService { List<NomenclatureOutView> getAll() throws GlobalServiceException; }
3e0b631fed34a7f6ac229af868c3138574d72067
4,527
java
Java
quickfixj-spring-boot-starter/src/main/java/ch/voulgarakis/spring/boot/starter/quickfixj/autoconfigure/QuickFixJConnectionAutoConfiguration.java
gevoulga/spring-boot-quickfixj
fa8b135bd32a1bc88e440ba6b170254bd07d8147
[ "Apache-2.0" ]
7
2020-09-02T08:29:36.000Z
2021-11-25T09:45:18.000Z
quickfixj-spring-boot-starter/src/main/java/ch/voulgarakis/spring/boot/starter/quickfixj/autoconfigure/QuickFixJConnectionAutoConfiguration.java
gevoulga/spring-boot-quickfixj
fa8b135bd32a1bc88e440ba6b170254bd07d8147
[ "Apache-2.0" ]
9
2020-04-03T12:11:53.000Z
2021-09-24T14:38:06.000Z
quickfixj-spring-boot-starter/src/main/java/ch/voulgarakis/spring/boot/starter/quickfixj/autoconfigure/QuickFixJConnectionAutoConfiguration.java
gevoulga/spring-boot-quickfixj
fa8b135bd32a1bc88e440ba6b170254bd07d8147
[ "Apache-2.0" ]
1
2020-04-03T12:22:00.000Z
2020-04-03T12:22:00.000Z
44.84466
114
0.731544
4,820
/* * Copyright (c) 2020 Georgios Voulgarakis * * 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 ch.voulgarakis.spring.boot.starter.quickfixj.autoconfigure; import ch.voulgarakis.spring.boot.starter.quickfixj.EnableQuickFixJ; import ch.voulgarakis.spring.boot.starter.quickfixj.authentication.AuthenticationService; import ch.voulgarakis.spring.boot.starter.quickfixj.connection.FixConnection; import ch.voulgarakis.spring.boot.starter.quickfixj.exception.QuickFixJConfigurationException; import ch.voulgarakis.spring.boot.starter.quickfixj.session.AbstractFixSession; import ch.voulgarakis.spring.boot.starter.quickfixj.session.FixConnectionType; import ch.voulgarakis.spring.boot.starter.quickfixj.session.FixSessionManager; import ch.voulgarakis.spring.boot.starter.quickfixj.session.InternalFixSessions; import ch.voulgarakis.spring.boot.starter.quickfixj.session.logging.LoggingId; import ch.voulgarakis.spring.boot.starter.quickfixj.session.utils.StartupLatch; import org.quickfixj.jmx.JmxExporter; import org.springframework.boot.autoconfigure.condition.*; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import quickfix.*; import javax.management.JMException; import javax.management.ObjectName; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; @Configuration @ConditionalOnBean(annotation = EnableQuickFixJ.class) upchh@example.com) dycjh@example.com) hzdkv@example.com) public class QuickFixJConnectionAutoConfiguration { @Bean @ConditionalOnMissingBean public Connector connector(Application application, FixConnectionType fixConnectionType, SessionSettings sessionSettings, MessageStoreFactory messageStoreFactory, MessageFactory messageFactory, Optional<LogFactory> logFactory) throws ConfigError { return fixConnectionType .createConnector(application, messageStoreFactory, sessionSettings, logFactory.orElse(null), messageFactory); } @Bean @ConditionalOnMissingBean public FixConnection fixConnection(Connector connector, StartupLatch startupLatch) { return new FixConnection(connector, startupLatch); } @Bean @ConditionalOnMissingBean public Application application(List<InternalFixSessions<?>> fixSessions, FixConnectionType fixConnectionType, StartupLatch startupLatch, LoggingId loggingId, AuthenticationService authenticationService) { //Extract the fix sessions Map<SessionID, AbstractFixSession> sessions = fixSessions.stream() .flatMap(internalFixSessions -> { Map<SessionID, ?> fixSessions1 = internalFixSessions.getFixSessions(); return fixSessions1.entrySet().stream(); }) .collect(Collectors.toMap(Map.Entry::getKey, e -> { Object session = e.getValue(); if (session instanceof AbstractFixSession) { return (AbstractFixSession) e.getValue(); } else { throw new QuickFixJConfigurationException( "Session object not of expected AbstractFixSession type: " + session); } })); return new FixSessionManager(sessions, fixConnectionType, startupLatch, loggingId, authenticationService); } @Bean @ConditionalOnProperty(prefix = "quickfixj", name = "jmx-enabled", havingValue = "true") @ConditionalOnClass(JmxExporter.class) @ConditionalOnSingleCandidate(Connector.class) @ConditionalOnMissingBean public ObjectName connectorMBean(Connector connector) { try { JmxExporter exporter = new JmxExporter(); return exporter.register(connector); } catch (JMException e) { throw new QuickFixJConfigurationException(e.getMessage(), e); } } }
3e0b638f55f4fded2c58e5c186e42342eb38b642
888
java
Java
core/src/main/java/org/openstack4j/model/common/resolvers/StableServiceVersionResolver.java
octetnest/openstack4j
9bd9f66d61f17662d70fd22deb65ebd03cf4b353
[ "Apache-2.0" ]
204
2016-05-14T12:06:15.000Z
2022-03-07T09:45:52.000Z
core/src/main/java/org/openstack4j/model/common/resolvers/StableServiceVersionResolver.java
octetnest/openstack4j
9bd9f66d61f17662d70fd22deb65ebd03cf4b353
[ "Apache-2.0" ]
721
2016-05-13T06:51:32.000Z
2022-01-13T17:44:40.000Z
core/src/main/java/org/openstack4j/model/common/resolvers/StableServiceVersionResolver.java
octetnest/openstack4j
9bd9f66d61f17662d70fd22deb65ebd03cf4b353
[ "Apache-2.0" ]
291
2016-05-13T05:58:13.000Z
2022-03-07T09:43:36.000Z
26.909091
101
0.755631
4,821
package org.openstack4j.model.common.resolvers; import java.util.SortedSet; import org.openstack4j.api.types.ServiceType; import org.openstack4j.model.identity.v3.Service; import org.openstack4j.model.identity.v2.Access; /** * Resolves each service to the lowest version which we consider most stable and * tested * * @author Jeremy Unruh */ public final class StableServiceVersionResolver implements ServiceVersionResolver { public static final StableServiceVersionResolver INSTANCE = new StableServiceVersionResolver(); private StableServiceVersionResolver() { } @Override public Service resolveV3(ServiceType type, SortedSet<? extends Service> services) { return services.first(); } @Override public Access.Service resolveV2(ServiceType type, SortedSet<? extends Access.Service> services) { return services.first(); } }
3e0b639dd609c7471cbcf6aa06f15ea52824de27
35,379
java
Java
core/src/test/java/cucumber/runtime/formatter/JUnitFormatterTest.java
anthonypdawson/cucumber-jvm
48b567294a8d119902a258368c01d2245e0450c6
[ "MIT" ]
1
2019-08-14T11:20:32.000Z
2019-08-14T11:20:32.000Z
core/src/test/java/cucumber/runtime/formatter/JUnitFormatterTest.java
anthonypdawson/cucumber-jvm
48b567294a8d119902a258368c01d2245e0450c6
[ "MIT" ]
null
null
null
core/src/test/java/cucumber/runtime/formatter/JUnitFormatterTest.java
anthonypdawson/cucumber-jvm
48b567294a8d119902a258368c01d2245e0450c6
[ "MIT" ]
1
2016-01-21T19:42:53.000Z
2016-01-21T19:42:53.000Z
53.849315
149
0.524944
4,822
package cucumber.runtime.formatter; import cucumber.runtime.Backend; import cucumber.runtime.Runtime; import cucumber.runtime.RuntimeOptions; import cucumber.runtime.TestHelper; import cucumber.runtime.Utils; import cucumber.runtime.io.ClasspathResourceLoader; import cucumber.runtime.model.CucumberFeature; import cucumber.runtime.snippets.FunctionNameGenerator; import gherkin.formatter.model.Feature; import gherkin.formatter.model.Match; import gherkin.formatter.model.Result; import gherkin.formatter.model.Scenario; import gherkin.formatter.model.Step; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.XMLUnit; import org.junit.Test; import org.xml.sax.SAXException; import javax.xml.parsers.ParserConfigurationException; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Scanner; import static cucumber.runtime.TestHelper.result; import static java.util.Arrays.asList; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class JUnitFormatterTest { @Test public void featureSimpleTest() throws Exception { File report = runFeaturesWithJunitFormatter(asList("cucumber/runtime/formatter/JUnitFormatterTest_1.feature")); assertXmlEqual("cucumber/runtime/formatter/JUnitFormatterTest_1.report.xml", report); } @Test public void featureWithBackgroundTest() throws Exception { File report = runFeaturesWithJunitFormatter(asList("cucumber/runtime/formatter/JUnitFormatterTest_2.feature")); assertXmlEqual("cucumber/runtime/formatter/JUnitFormatterTest_2.report.xml", report); } @Test public void featureWithOutlineTest() throws Exception { File report = runFeaturesWithJunitFormatter(asList("cucumber/runtime/formatter/JUnitFormatterTest_3.feature")); assertXmlEqual("cucumber/runtime/formatter/JUnitFormatterTest_3.report.xml", report); } @Test public void featureSimpleStrictTest() throws Exception { boolean strict = true; File report = runFeaturesWithJunitFormatter(asList("cucumber/runtime/formatter/JUnitFormatterTest_1.feature"), strict); assertXmlEqual("cucumber/runtime/formatter/JUnitFormatterTest_1_strict.report.xml", report); } @Test public void should_format_passed_scenario() throws Throwable { CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n" + " When second step\n" + " Then third step\n"); Map<String, Result> stepsToResult = new HashMap<String, Result>(); stepsToResult.put("first step", result("passed")); stepsToResult.put("second step", result("passed")); stepsToResult.put("third step", result("passed")); long stepDuration = milliSeconds(1); String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, stepDuration); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"1\" time=\"0.003\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step............................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, formatterOutput); } @Test public void should_format_pending_scenario() throws Throwable { CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n" + " When second step\n" + " Then third step\n"); Map<String, Result> stepsToResult = new HashMap<String, Result>(); stepsToResult.put("first step", result("pending")); stepsToResult.put("second step", result("skipped")); stepsToResult.put("third step", result("undefined")); long stepDuration = milliSeconds(1); String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, stepDuration); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"1\" tests=\"1\" time=\"0.001\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.001\">\n" + " <skipped><![CDATA[" + "Given first step............................................................pending\n" + "When second step............................................................skipped\n" + "Then third step.............................................................undefined\n" + "]]></skipped>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, formatterOutput); } @Test public void should_format_failed_scenario() throws Throwable { CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n" + " When second step\n" + " Then third step\n"); Map<String, Result> stepsToResult = new HashMap<String, Result>(); stepsToResult.put("first step", result("passed")); stepsToResult.put("second step", result("passed")); stepsToResult.put("third step", result("failed")); long stepDuration = milliSeconds(1); String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, stepDuration); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"1\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"1\" time=\"0.003\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.003\">\n" + " <failure message=\"the stack trace\"><![CDATA[" + "Given first step............................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................failed\n" + "\n" + "StackTrace:\n" + "the stack trace" + "]]></failure>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, formatterOutput); } @Test public void should_handle_failure_in_before_hook() throws Throwable { CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n" + " When second step\n" + " Then third step\n"); Map<String, Result> stepsToResult = new HashMap<String, Result>(); stepsToResult.put("first step", result("passed")); stepsToResult.put("second step", result("passed")); stepsToResult.put("third step", result("passed")); List<SimpleEntry<String, Result>> hooks = new ArrayList<SimpleEntry<String, Result>>(); hooks.add(TestHelper.hookEntry("before", result("failed"))); long stepHookDuration = milliSeconds(1); String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, hooks, stepHookDuration); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"1\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"1\" time=\"0.001\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.001\">\n" + " <failure message=\"the stack trace\"><![CDATA[" + "Given first step............................................................skipped\n" + "When second step............................................................skipped\n" + "Then third step.............................................................skipped\n" + "\n" + "StackTrace:\n" + "the stack trace" + "]]></failure>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, formatterOutput); } @Test public void should_handle_failure_in_before_hook_with_background() throws Throwable { CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Background: background name\n" + " Given first step\n" + " Scenario: scenario name\n" + " When second step\n" + " Then third step\n"); Map<String, Result> stepsToResult = new HashMap<String, Result>(); stepsToResult.put("first step", result("passed")); stepsToResult.put("second step", result("passed")); stepsToResult.put("third step", result("passed")); List<SimpleEntry<String, Result>> hooks = new ArrayList<SimpleEntry<String, Result>>(); hooks.add(TestHelper.hookEntry("before", result("failed"))); long stepHookDuration = milliSeconds(1); String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, hooks, stepHookDuration); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"1\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"1\" time=\"0.001\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.001\">\n" + " <failure message=\"the stack trace\"><![CDATA[" + "Given first step............................................................skipped\n" + "When second step............................................................skipped\n" + "Then third step.............................................................skipped\n" + "\n" + "StackTrace:\n" + "the stack trace" + "]]></failure>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, formatterOutput); } @Test public void should_handle_failure_in_after_hook() throws Throwable { CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n" + " When second step\n" + " Then third step\n"); Map<String, Result> stepsToResult = new HashMap<String, Result>(); stepsToResult.put("first step", result("passed")); stepsToResult.put("second step", result("passed")); stepsToResult.put("third step", result("passed")); List<SimpleEntry<String, Result>> hooks = new ArrayList<SimpleEntry<String, Result>>(); hooks.add(TestHelper.hookEntry("after", result("failed"))); long stepHookDuration = milliSeconds(1); String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, hooks, stepHookDuration); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"1\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"1\" time=\"0.004\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.004\">\n" + " <failure message=\"the stack trace\"><![CDATA[" + "Given first step............................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "\n" + "StackTrace:\n" + "the stack trace" + "]]></failure>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, formatterOutput); } @Test public void should_accumulate_time_from_steps_and_hooks() throws Throwable { CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario: scenario name\n" + " * first step\n" + " * second step\n"); Map<String, Result> stepsToResult = new HashMap<String, Result>(); stepsToResult.put("first step", result("passed")); stepsToResult.put("second step", result("passed")); List<SimpleEntry<String, Result>> hooks = new ArrayList<SimpleEntry<String, Result>>(); hooks.add(TestHelper.hookEntry("before", result("passed"))); hooks.add(TestHelper.hookEntry("after", result("passed"))); long stepHookDuration = milliSeconds(1); String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, hooks, stepHookDuration); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"1\" time=\"0.004\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.004\">\n" + " <system-out><![CDATA[" + "* first step................................................................passed\n" + "* second step...............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, formatterOutput); } @Test public void should_format_scenario_outlines() throws Throwable { CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario Outline: outline_name\n" + " Given first step \"<arg>\"\n" + " When second step\n" + " Then third step\n\n" + " Examples: examples\n" + " | arg |\n" + " | a |\n" + " | b |\n"); Map<String, Result> stepsToResult = new HashMap<String, Result>(); stepsToResult.put("first step", result("passed")); stepsToResult.put("second step", result("passed")); stepsToResult.put("third step", result("passed")); long stepDuration = milliSeconds(1); String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, stepDuration); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"2\" time=\"0.006\">\n" + " <testcase classname=\"feature name\" name=\"outline_name\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"a\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + " <testcase classname=\"feature name\" name=\"outline_name_2\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"b\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, formatterOutput); } @Test public void should_format_scenario_outlines_with_multiple_examples() throws Throwable { CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario Outline: outline name\n" + " Given first step \"<arg>\"\n" + " When second step\n" + " Then third step\n\n" + " Examples: examples 1\n" + " | arg |\n" + " | a |\n" + " | b |\n\n" + " Examples: examples 2\n" + " | arg |\n" + " | c |\n" + " | d |\n"); Map<String, Result> stepsToResult = new HashMap<String, Result>(); stepsToResult.put("first step", result("passed")); stepsToResult.put("second step", result("passed")); stepsToResult.put("third step", result("passed")); long stepDuration = milliSeconds(1); String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, stepDuration); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"4\" time=\"0.012\">\n" + " <testcase classname=\"feature name\" name=\"outline name\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"a\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + " <testcase classname=\"feature name\" name=\"outline name 2\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"b\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + " <testcase classname=\"feature name\" name=\"outline name 3\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"c\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + " <testcase classname=\"feature name\" name=\"outline name 4\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"d\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, formatterOutput); } @Test public void should_format_scenario_outlines_with_arguments_in_name() throws Throwable { CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario Outline: outline name <arg>\n" + " Given first step \"<arg>\"\n" + " When second step\n" + " Then third step\n\n" + " Examples: examples 1\n" + " | arg |\n" + " | a |\n" + " | b |\n"); Map<String, Result> stepsToResult = new HashMap<String, Result>(); stepsToResult.put("first step", result("passed")); stepsToResult.put("second step", result("passed")); stepsToResult.put("third step", result("passed")); long stepDuration = milliSeconds(1); String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, stepDuration); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"2\" time=\"0.006\">\n" + " <testcase classname=\"feature name\" name=\"outline name a\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"a\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + " <testcase classname=\"feature name\" name=\"outline name b\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"b\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, formatterOutput); } @Test public void should_format_scenario_outlines_with_the_junit_runner() throws Exception { final File report = File.createTempFile("cucumber-jvm-junit", ".xml"); final JUnitFormatter junitFormatter = createJUnitFormatter(report); // The JUnit runner will not call scenarioOutline() and examples() before executing the examples scenarios junitFormatter.uri(uri()); junitFormatter.feature(feature("feature name")); junitFormatter.scenario(scenario("Scenario Outline", "outline name")); junitFormatter.step(step("keyword ", "step name \"arg1\"")); junitFormatter.match(match()); junitFormatter.result(result("passed")); junitFormatter.scenario(scenario("Scenario Outline", "outline name")); junitFormatter.step(step("keyword ", "step name \"arg2\"")); junitFormatter.match(match()); junitFormatter.result(result("passed")); junitFormatter.eof(); junitFormatter.done(); junitFormatter.close(); String actual = new Scanner(new FileInputStream(report), "UTF-8").useDelimiter("\\A").next(); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" tests=\"2\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" time=\"0\">\n" + " <testcase classname=\"feature name\" name=\"outline name\" time=\"0\">\n" + " <system-out><![CDATA[" + "keyword step name \"arg1\"....................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + " <testcase classname=\"feature name\" name=\"outline name 2\" time=\"0\">\n" + " <system-out><![CDATA[" + "keyword step name \"arg2\"....................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, actual); } @Test public void should_handle_all_step_calls_first_execution() throws Exception { final File report = File.createTempFile("cucumber-jvm-junit", ".xml"); final JUnitFormatter junitFormatter = createJUnitFormatter(report); junitFormatter.uri(uri()); junitFormatter.feature(feature("feature name")); junitFormatter.scenario(scenario("scenario name")); junitFormatter.step(step("keyword ", "step name")); junitFormatter.step(step("keyword ", "step name")); junitFormatter.match(match()); junitFormatter.result(result("passed")); junitFormatter.match(match()); junitFormatter.result(result("passed")); junitFormatter.eof(); junitFormatter.done(); junitFormatter.close(); String actual = new Scanner(new FileInputStream(report), "UTF-8").useDelimiter("\\A").next(); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" tests=\"1\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" time=\"0\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0\">\n" + " <system-out><![CDATA[" + "keyword step name...........................................................passed\n" + "keyword step name...........................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, actual); } @Test public void should_handle_one_step_at_the_time_execution() throws Exception { final File report = File.createTempFile("cucumber-jvm-junit", ".xml"); final JUnitFormatter junitFormatter = createJUnitFormatter(report); junitFormatter.uri(uri()); junitFormatter.feature(feature("feature name")); junitFormatter.scenario(scenario("scenario name")); junitFormatter.step(step("keyword ", "step name")); junitFormatter.match(match()); junitFormatter.result(result("passed")); junitFormatter.step(step("keyword ", "step name")); junitFormatter.match(match()); junitFormatter.result(result("passed")); junitFormatter.eof(); junitFormatter.done(); junitFormatter.close(); String actual = new Scanner(new FileInputStream(report), "UTF-8").useDelimiter("\\A").next(); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"1\" time=\"0\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0\">\n" + " <system-out><![CDATA[" + "keyword step name...........................................................passed\n" + "keyword step name...........................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, actual); } @Test public void should_handle_empty_scenarios() throws Throwable { CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario: scenario name\n"); String formatterOutput = runFeatureWithJUnitFormatter(feature); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"1\" tests=\"1\" time=\"0\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0\">\n" + " <skipped message=\"The scenario has no steps\" />\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, formatterOutput); } @Test public void should_add_dummy_testcase_if_no_scenarios_are_run_to_aviod_failed_jenkins_jobs() throws Throwable { CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n"); String formatterOutput = runFeatureWithJUnitFormatter(feature); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" time=\"0\">\n" + " <testcase classname=\"dummy\" name=\"dummy\">\n" + " <skipped message=\"No features found\" />\n" + " </testcase>\n" + "</testsuite>\n"; assertXmlEqual(expected, formatterOutput); } private File runFeaturesWithJunitFormatter(final List<String> featurePaths) throws IOException { return runFeaturesWithJunitFormatter(featurePaths, false); } private File runFeaturesWithJunitFormatter(final List<String> featurePaths, boolean strict) throws IOException { File report = File.createTempFile("cucumber-jvm-junit", "xml"); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); final ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader(classLoader); List<String> args = new ArrayList<String>(); if (strict) { args.add("--strict"); } args.add("--plugin"); args.add("junit:" + report.getAbsolutePath()); args.addAll(featurePaths); RuntimeOptions runtimeOptions = new RuntimeOptions(args); Backend backend = mock(Backend.class); when(backend.getSnippet(any(Step.class), any(FunctionNameGenerator.class))).thenReturn("TEST SNIPPET"); final cucumber.runtime.Runtime runtime = new Runtime(resourceLoader, classLoader, asList(backend), runtimeOptions); runtime.run(); return report; } private String runFeatureWithJUnitFormatter(final CucumberFeature feature) throws Throwable { return runFeatureWithJUnitFormatter(feature, new HashMap<String, Result>(), 0L); } private String runFeatureWithJUnitFormatter(final CucumberFeature feature, final Map<String, Result> stepsToResult, final long stepHookDuration) throws Throwable { return runFeatureWithJUnitFormatter(feature, stepsToResult, Collections.<SimpleEntry<String, Result>>emptyList(), stepHookDuration); } private String runFeatureWithJUnitFormatter(final CucumberFeature feature, final Map<String, Result> stepsToResult, final List<SimpleEntry<String, Result>> hooks, final long stepHookDuration) throws Throwable { final File report = File.createTempFile("cucumber-jvm-junit", ".xml"); final JUnitFormatter junitFormatter = createJUnitFormatter(report); TestHelper.runFeatureWithFormatter(feature, stepsToResult, hooks, stepHookDuration, junitFormatter, junitFormatter); return new Scanner(new FileInputStream(report), "UTF-8").useDelimiter("\\A").next(); } private void assertXmlEqual(String expectedPath, File actual) throws IOException, ParserConfigurationException, SAXException { XMLUnit.setIgnoreWhitespace(true); InputStreamReader control = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(expectedPath), "UTF-8"); Diff diff = new Diff(control, new FileReader(actual)); assertTrue("XML files are similar " + diff, diff.identical()); } private void assertXmlEqual(String expected, String actual) throws SAXException, IOException { XMLUnit.setIgnoreWhitespace(true); Diff diff = new Diff(expected, actual); assertTrue("XML files are similar " + diff + "\nFormatterOutput = " + actual, diff.identical()); } private JUnitFormatter createJUnitFormatter(final File report) throws IOException { return new JUnitFormatter(Utils.toURL(report.getAbsolutePath())); } private String uri() { return "uri"; } private Feature feature(String featureName) { Feature feature = mock(Feature.class); when(feature.getName()).thenReturn(featureName); return feature; } private Scenario scenario(String scenarioName) { return scenario("Scenario", scenarioName); } private Scenario scenario(String keyword, String scenarioName) { Scenario scenario = mock(Scenario.class); when(scenario.getName()).thenReturn(scenarioName); when(scenario.getKeyword()).thenReturn(keyword); return scenario; } private Step step(String keyword, String stepName) { Step step = mock(Step.class); when(step.getKeyword()).thenReturn(keyword); when(step.getName()).thenReturn(stepName); return step; } private Match match() { return mock(Match.class); } private Long milliSeconds(int milliSeconds) { return milliSeconds * 1000000L; } }