blob_id
stringlengths
40
40
__id__
int64
225
39,780B
directory_id
stringlengths
40
40
path
stringlengths
6
313
content_id
stringlengths
40
40
detected_licenses
list
license_type
stringclasses
2 values
repo_name
stringlengths
6
132
repo_url
stringlengths
25
151
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
70
visit_date
timestamp[ns]
revision_date
timestamp[ns]
committer_date
timestamp[ns]
github_id
int64
7.28k
689M
star_events_count
int64
0
131k
fork_events_count
int64
0
48k
gha_license_id
stringclasses
23 values
gha_fork
bool
2 classes
gha_event_created_at
timestamp[ns]
gha_created_at
timestamp[ns]
gha_updated_at
timestamp[ns]
gha_pushed_at
timestamp[ns]
gha_size
int64
0
40.4M
gha_stargazers_count
int32
0
112k
gha_forks_count
int32
0
39.4k
gha_open_issues_count
int32
0
11k
gha_language
stringlengths
1
21
gha_archived
bool
2 classes
gha_disabled
bool
1 class
content
stringlengths
7
4.37M
src_encoding
stringlengths
3
16
language
stringclasses
1 value
length_bytes
int64
7
4.37M
extension
stringclasses
24 values
filename
stringlengths
4
174
language_id
stringclasses
1 value
entities
list
contaminating_dataset
stringclasses
0 values
malware_signatures
list
redacted_content
stringlengths
7
4.37M
redacted_length_bytes
int64
7
4.37M
alphanum_fraction
float32
0.25
0.94
alpha_fraction
float32
0.25
0.94
num_lines
int32
1
84k
avg_line_length
float32
0.76
99.9
std_line_length
float32
0
220
max_line_length
int32
5
998
is_vendor
bool
2 classes
is_generated
bool
1 class
max_hex_length
int32
0
319
hex_fraction
float32
0
0.38
max_unicode_length
int32
0
408
unicode_fraction
float32
0
0.36
max_base64_length
int32
0
506
base64_fraction
float32
0
0.5
avg_csv_sep_count
float32
0
4
is_autogen_header
bool
1 class
is_empty_html
bool
1 class
shard
stringclasses
16 values
e8eb7afa7580bb1641562b760cebcf78853d23b1
13,065,290,581,242
5c0295c6aef7196e1e03a3684757529cf3f95e02
/src/main/java/view/SmallContactListItem.java
d360ea7e42326382e49da537b276da0e7735d401
[]
no_license
JonathanKore/Basta_gruppen_LTD
https://github.com/JonathanKore/Basta_gruppen_LTD
137f19061fd33f0311225c6bc52d353e456b1204
0207d78b9d7ad73475bec455c4be05a707d64293
refs/heads/master
2020-03-28T09:07:55.025000
2018-10-28T22:39:45
2018-10-28T22:39:45
148,016,110
0
1
null
false
2018-10-28T13:01:58
2018-09-09T10:47:50
2018-10-28T12:35:13
2018-10-28T13:01:58
5,021
0
1
1
Java
false
null
package view; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.control.Label; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; import model.User; import java.io.IOException; public class SmallContactListItem extends AnchorPane { @FXML private Label newConvoContactNameLabel; @FXML private ImageView newConvoContactProfileImageView; private boolean isClicked; private User user; SmallContactListItem(User user) { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/NewConvoContactListItemView.fxml")); fxmlLoader.setRoot(this); fxmlLoader.setController(this); try { fxmlLoader.load(); } catch (IOException exception) { throw new RuntimeException(exception); } isClicked = false; this.user = user; this.newConvoContactNameLabel.setText(user.getFullName()); Image profileImage = new Image(user.getProfileImagePath()); this.newConvoContactProfileImageView.setImage(profileImage); } @FXML public void newConvoContactClicked() { if (this.isClicked) { this.isClicked = false; this.setStyle("-fx-background-color: #f7efef"); } else { this.isClicked = true; this.setStyle("-fx-background-color: #ada9a9"); } } public User getUser() { return user; } boolean isClicked() { return isClicked; } void setClicked(boolean clicked) { isClicked = clicked; } }
UTF-8
Java
1,641
java
SmallContactListItem.java
Java
[]
null
[]
package view; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.control.Label; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; import model.User; import java.io.IOException; public class SmallContactListItem extends AnchorPane { @FXML private Label newConvoContactNameLabel; @FXML private ImageView newConvoContactProfileImageView; private boolean isClicked; private User user; SmallContactListItem(User user) { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/NewConvoContactListItemView.fxml")); fxmlLoader.setRoot(this); fxmlLoader.setController(this); try { fxmlLoader.load(); } catch (IOException exception) { throw new RuntimeException(exception); } isClicked = false; this.user = user; this.newConvoContactNameLabel.setText(user.getFullName()); Image profileImage = new Image(user.getProfileImagePath()); this.newConvoContactProfileImageView.setImage(profileImage); } @FXML public void newConvoContactClicked() { if (this.isClicked) { this.isClicked = false; this.setStyle("-fx-background-color: #f7efef"); } else { this.isClicked = true; this.setStyle("-fx-background-color: #ada9a9"); } } public User getUser() { return user; } boolean isClicked() { return isClicked; } void setClicked(boolean clicked) { isClicked = clicked; } }
1,641
0.652651
0.650823
70
22.442858
22.531017
113
false
false
0
0
0
0
0
0
0.428571
false
false
1
8b4cc4fb9ad04e729854bb08cf992d809a56b1e9
11,974,368,833,057
31a344e28069ef96cfffce3422bff995edb3e844
/question16/DeadlockConditionExample.java
e1e92dd8d0a5cb0ba6062ef966ca23854576b324
[]
no_license
shivam87430/MultiThreading
https://github.com/shivam87430/MultiThreading
5ebe69d8f9682f9fb592fbc330f7c5a729c4afc3
0e20bd21abe21c4290afb8aba4eda1737369b235
refs/heads/master
2020-04-25T03:41:51.384000
2019-02-25T10:51:32
2019-02-25T10:51:32
172,485,709
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package Question.question16; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class DeadlockConditionExample { Lock lock1=new ReentrantLock(true); Lock lock2=new ReentrantLock(true); public void worker1(){ lock1.lock(); System.out.println("lock1 on worker1"); lock2.lock(); System.out.println("lock2 on worker1"); lock2.unlock(); lock1.unlock(); } public void worker2(){ lock2.lock(); System.out.println("lock2 on worker2"); lock1.lock(); System.out.println("lock1 on worker2"); lock1.unlock(); lock2.unlock(); } public static void main(String[] args) throws InterruptedException { DeadlockConditionExample solvingDeadlockConditionBytryLockExample=new DeadlockConditionExample(); Thread thread=new Thread(new Runnable() { @Override public void run() { solvingDeadlockConditionBytryLockExample.worker1(); } }); Thread thread1=new Thread(new Runnable() { @Override public void run() { solvingDeadlockConditionBytryLockExample.worker2(); } }); thread.start(); thread1.start(); thread.join(); thread1.join(); } }
UTF-8
Java
1,366
java
DeadlockConditionExample.java
Java
[]
null
[]
package Question.question16; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class DeadlockConditionExample { Lock lock1=new ReentrantLock(true); Lock lock2=new ReentrantLock(true); public void worker1(){ lock1.lock(); System.out.println("lock1 on worker1"); lock2.lock(); System.out.println("lock2 on worker1"); lock2.unlock(); lock1.unlock(); } public void worker2(){ lock2.lock(); System.out.println("lock2 on worker2"); lock1.lock(); System.out.println("lock1 on worker2"); lock1.unlock(); lock2.unlock(); } public static void main(String[] args) throws InterruptedException { DeadlockConditionExample solvingDeadlockConditionBytryLockExample=new DeadlockConditionExample(); Thread thread=new Thread(new Runnable() { @Override public void run() { solvingDeadlockConditionBytryLockExample.worker1(); } }); Thread thread1=new Thread(new Runnable() { @Override public void run() { solvingDeadlockConditionBytryLockExample.worker2(); } }); thread.start(); thread1.start(); thread.join(); thread1.join(); } }
1,366
0.599561
0.579795
48
27.458334
21.754271
105
false
false
0
0
0
0
0
0
0.541667
false
false
1
a8d0207fa7589c0a33776c507e1cac567e856461
11,974,368,833,603
b2817c2c75c7bb6691ef963b4b02fcdb9f8a2fdc
/app/src/androidTest/java/com/solutio/app/reference/payrate/type/PayRateTypesViewTest.java
3b93cc04ceab5f8f2d50f5b3e81d40ee1faa12a1
[]
no_license
jcigmenupraxis/solutio-mobile
https://github.com/jcigmenupraxis/solutio-mobile
fe2b02a17ac80714e99ca8c6a40f788ceddd888e
96b55ffa5b5e652459a5597fe2711b85088b1f06
refs/heads/master
2016-09-27T07:01:38.745000
2016-09-09T05:19:01
2016-09-09T05:19:01
48,011,384
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.solutio.app.reference.payrate.type; import android.support.test.rule.ActivityTestRule; import com.solutio.app.R; import com.solutio.app.TestActivity; import com.solutio.app.api.reference.ReferencesService; import com.solutio.app.framework.DaggerSolutioComponent; import com.solutio.app.framework.DataManagersModule; import com.solutio.app.framework.SolutioApplication; import com.solutio.app.framework.SolutioModule; import com.solutio.app.framework.bus.EventBusHelper; import com.solutio.app.models.KeyValue; import com.solutio.app.reference.ReferencesManager; import com.solutio.app.user.UserModule; import com.solutio.app.util.RxHelper; import com.solutio.app.util.SharedPreferencesHelper; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import java.util.Arrays; import rx.Observable; import rx.android.schedulers.AndroidSchedulers; import static android.os.SystemClock.sleep; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withText; import static com.solutio.app.util.AndroidTestUtils.clickCloseOnToolbar; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /** * @author Julious Igmen */ public class PayRateTypesViewTest { @Rule public ActivityTestRule<TestActivity> activityTestRule = new ActivityTestRule<>(TestActivity.class); EventBusHelper eventBusHelper; ReferencesManager referencesManager; RxHelper rxHelper; @Before public void setUp() throws Exception { initialiseMocks(); makeSynchronousRequestsEndOnUiThread(); mockComponents(); } void initialiseMocks() { eventBusHelper = mock(EventBusHelper.class); referencesManager = mock(ReferencesManager.class); rxHelper = mock(RxHelper.class); } void makeSynchronousRequestsEndOnUiThread() { when(rxHelper.getAndroidSchedulers()) .thenReturn(objectObservable -> objectObservable.observeOn(AndroidSchedulers.mainThread())); } void mockComponents() { SolutioApplication solutioApplication = (SolutioApplication) activityTestRule.getActivity().getApplication(); solutioApplication.setSolutioComponent( DaggerSolutioComponent.builder() .solutioModule(new SolutioModule(activityTestRule.getActivity()) { @Override public RxHelper provideRxHelper() { return rxHelper; } @Override public EventBusHelper provideEventBusHelper() { return eventBusHelper; } }) .userModule(new UserModule()) .dataManagersModule(new DataManagersModule() { @Override public ReferencesManager provideReferencesManager( ReferencesService referencesService, SharedPreferencesHelper sharedPreferencesHelper) { return referencesManager; } }) .build() ); } @Test public void dismissScreen() { makeTypesLoadingFail(); showScreen(); clickCloseOnToolbar(); assertFalse(activityTestRule.getActivity().getScreenController().hasScreen(PayRateTypesView.TAG)); } void makeTypesLoadingFail() { when(referencesManager.loadPayRateTypes()) .thenReturn(Observable.create(subscriber -> subscriber.onError(new Throwable()))); } @Test public void hasCorrectTitle() { makeTypesLoadingFail(); showScreen(); onView(withText(R.string.choose_payrate_type)).check(matches(isDisplayed())); } @Test public void selectType() { KeyValue type = new KeyValue("", "Hourly"); makeTypesLoadingReturn(type); showScreen(); onView(withText(type.toString())).perform(click()); verify(eventBusHelper).post(any(SelectPayRateTypeEvent.class)); } void makeTypesLoadingReturn(KeyValue... types) { when(referencesManager.loadPayRateTypes()) .thenReturn(Observable.create(subscriber -> { subscriber.onNext(Arrays.asList(types)); subscriber.onCompleted(); })); } @Test public void showFailurePrompt() { makeTypesLoadingFail(); showScreen(); onView(withText(R.string.failed_loading_payrate_types)).check(matches(isDisplayed())); } @Test public void showLoadedTypes() { KeyValue[] types = { new KeyValue("", "Hourly"), new KeyValue("", "Daily"), new KeyValue("", "Weekly"), new KeyValue("", "Bi-Weekly") }; makeTypesLoadingReturn(types); showScreen(); for (KeyValue type : types) { onView(withText(type.toString())).check(matches(isDisplayed())); } } void showScreen() { activityTestRule.getActivity().getScreenController().addScreen(new PayRateTypesView(), PayRateTypesView.TAG); sleep(500); assertTrue(activityTestRule.getActivity().getScreenController().hasScreen(PayRateTypesView.TAG)); } }
UTF-8
Java
5,052
java
PayRateTypesViewTest.java
Java
[ { "context": "t static org.mockito.Mockito.when;\n\n/**\n * @author Julious Igmen\n */\npublic class PayRateTypesViewTest {\n\n\t@Rule\n\t", "end": 1647, "score": 0.9998771548271179, "start": 1634, "tag": "NAME", "value": "Julious Igmen" } ]
null
[]
package com.solutio.app.reference.payrate.type; import android.support.test.rule.ActivityTestRule; import com.solutio.app.R; import com.solutio.app.TestActivity; import com.solutio.app.api.reference.ReferencesService; import com.solutio.app.framework.DaggerSolutioComponent; import com.solutio.app.framework.DataManagersModule; import com.solutio.app.framework.SolutioApplication; import com.solutio.app.framework.SolutioModule; import com.solutio.app.framework.bus.EventBusHelper; import com.solutio.app.models.KeyValue; import com.solutio.app.reference.ReferencesManager; import com.solutio.app.user.UserModule; import com.solutio.app.util.RxHelper; import com.solutio.app.util.SharedPreferencesHelper; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import java.util.Arrays; import rx.Observable; import rx.android.schedulers.AndroidSchedulers; import static android.os.SystemClock.sleep; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withText; import static com.solutio.app.util.AndroidTestUtils.clickCloseOnToolbar; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /** * @author <NAME> */ public class PayRateTypesViewTest { @Rule public ActivityTestRule<TestActivity> activityTestRule = new ActivityTestRule<>(TestActivity.class); EventBusHelper eventBusHelper; ReferencesManager referencesManager; RxHelper rxHelper; @Before public void setUp() throws Exception { initialiseMocks(); makeSynchronousRequestsEndOnUiThread(); mockComponents(); } void initialiseMocks() { eventBusHelper = mock(EventBusHelper.class); referencesManager = mock(ReferencesManager.class); rxHelper = mock(RxHelper.class); } void makeSynchronousRequestsEndOnUiThread() { when(rxHelper.getAndroidSchedulers()) .thenReturn(objectObservable -> objectObservable.observeOn(AndroidSchedulers.mainThread())); } void mockComponents() { SolutioApplication solutioApplication = (SolutioApplication) activityTestRule.getActivity().getApplication(); solutioApplication.setSolutioComponent( DaggerSolutioComponent.builder() .solutioModule(new SolutioModule(activityTestRule.getActivity()) { @Override public RxHelper provideRxHelper() { return rxHelper; } @Override public EventBusHelper provideEventBusHelper() { return eventBusHelper; } }) .userModule(new UserModule()) .dataManagersModule(new DataManagersModule() { @Override public ReferencesManager provideReferencesManager( ReferencesService referencesService, SharedPreferencesHelper sharedPreferencesHelper) { return referencesManager; } }) .build() ); } @Test public void dismissScreen() { makeTypesLoadingFail(); showScreen(); clickCloseOnToolbar(); assertFalse(activityTestRule.getActivity().getScreenController().hasScreen(PayRateTypesView.TAG)); } void makeTypesLoadingFail() { when(referencesManager.loadPayRateTypes()) .thenReturn(Observable.create(subscriber -> subscriber.onError(new Throwable()))); } @Test public void hasCorrectTitle() { makeTypesLoadingFail(); showScreen(); onView(withText(R.string.choose_payrate_type)).check(matches(isDisplayed())); } @Test public void selectType() { KeyValue type = new KeyValue("", "Hourly"); makeTypesLoadingReturn(type); showScreen(); onView(withText(type.toString())).perform(click()); verify(eventBusHelper).post(any(SelectPayRateTypeEvent.class)); } void makeTypesLoadingReturn(KeyValue... types) { when(referencesManager.loadPayRateTypes()) .thenReturn(Observable.create(subscriber -> { subscriber.onNext(Arrays.asList(types)); subscriber.onCompleted(); })); } @Test public void showFailurePrompt() { makeTypesLoadingFail(); showScreen(); onView(withText(R.string.failed_loading_payrate_types)).check(matches(isDisplayed())); } @Test public void showLoadedTypes() { KeyValue[] types = { new KeyValue("", "Hourly"), new KeyValue("", "Daily"), new KeyValue("", "Weekly"), new KeyValue("", "Bi-Weekly") }; makeTypesLoadingReturn(types); showScreen(); for (KeyValue type : types) { onView(withText(type.toString())).check(matches(isDisplayed())); } } void showScreen() { activityTestRule.getActivity().getScreenController().addScreen(new PayRateTypesView(), PayRateTypesView.TAG); sleep(500); assertTrue(activityTestRule.getActivity().getScreenController().hasScreen(PayRateTypesView.TAG)); } }
5,045
0.760095
0.759501
174
28.04023
26.388861
111
false
false
0
0
0
0
0
0
2.201149
false
false
1
41e0c6ec3e20bdefff68882a5ba10336a9967868
7,181,185,357,903
9d1794266863a8f63ca27ff6e0d8f93499f614f4
/recture/day18_class_recture/inheritance/inherit07/Inherit07Main.java
b754c625cbaf4024e548dd1a75dba0d385bbd7fc
[]
no_license
jd6186/java1
https://github.com/jd6186/java1
27ef91c362e70af0620d346ac595780a7048d281
f51e48baaa1ea396e98090594843b3dc0d13e25e
refs/heads/master
2020-09-13T17:18:45.414000
2020-01-08T11:16:01
2020-01-08T11:16:01
222,851,476
1
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.lec.java.inherit07; // 너무 중요해서 할 말이 없어 //면접에서 빠지지 않고 등장하는 질문이 메소드 오버라이딩과 메소드 오버로딩의 차이점에 대해 설명하시오다. /* ★★★★★★★★★★★★★★★★★★메소드 재정의(Overriding) ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ * ★★★★★'상속'★★★★★관계에서 ★★★★★'부모 클래스에 있던 메소드'★★★★★★★를 ★★★★★'재정의'★★★★★★하는 것. * 부모 클래스에 있는 메소드와 매개변수 리스트가 동일해야 함 * 부모 클래스에 있는 메소드와 접근권한 수식어가 동일할 필요는 없지만, * 접근권한의 범위가 축소될 수는 없다. * 즉, 접근권한은 같거나 더 넓은 수식어를 사용해야 함. * * ! 메소드 오버로딩(Overloading)과 혼돈하지 말자! * * final 메소드 : 더이상 오버라이딩 불가 * final 클래스 : 더이상 상속 불가 */ public class Inherit07Main { public static void main(String[] args) { System.out.println("상속: Method Overriding(재정의)"); System.out.println(); // Person 클래스의 인스턴스 생성 // TODO Persons p1 = new Persons(); p1.setName("abc"); p1.showInfo(); System.out.println(); // BusinessPerson 클래스의 인스턴스를 생성 // TODO BusinessPerson p2 = new BusinessPerson(); p2.setName("춘향이"); p2.setCompany("(주)조선"); p2.showInfo(); // 비지니스 펄슨이다. > 이건 오버라이딩을 출력하는 것 System.out.println(); p2.showInfo(10); // 이건 오버로딩을 출력한 것. System.out.println(p2); System.out.println(p2.toString()); // 위에는 밑에꺼를 축약시켜서 표현한 것일 뿐 값은 같다. System.out.println("\n프로그램 종료"); } // end main() } // end class
UTF-8
Java
2,088
java
Inherit07Main.java
Java
[ { "context": "\t\t\n\t\t\n\t\tPersons p1 = new Persons();\n\t\tp1.setName(\"abc\");\n\t\tp1.showInfo();\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t", "end": 759, "score": 0.9991255402565002, "start": 756, "tag": "NAME", "value": "abc" }, { "context": "ssPerson p2 = new BusinessPerson();\n\t\tp2.setName(\"춘향이\");\n\t\tp2.setCompany(\"(주)조선\");\n\t\tp2.showInfo(); // ", "end": 946, "score": 0.9998182654380798, "start": 943, "tag": "NAME", "value": "춘향이" } ]
null
[]
package com.lec.java.inherit07; // 너무 중요해서 할 말이 없어 //면접에서 빠지지 않고 등장하는 질문이 메소드 오버라이딩과 메소드 오버로딩의 차이점에 대해 설명하시오다. /* ★★★★★★★★★★★★★★★★★★메소드 재정의(Overriding) ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ * ★★★★★'상속'★★★★★관계에서 ★★★★★'부모 클래스에 있던 메소드'★★★★★★★를 ★★★★★'재정의'★★★★★★하는 것. * 부모 클래스에 있는 메소드와 매개변수 리스트가 동일해야 함 * 부모 클래스에 있는 메소드와 접근권한 수식어가 동일할 필요는 없지만, * 접근권한의 범위가 축소될 수는 없다. * 즉, 접근권한은 같거나 더 넓은 수식어를 사용해야 함. * * ! 메소드 오버로딩(Overloading)과 혼돈하지 말자! * * final 메소드 : 더이상 오버라이딩 불가 * final 클래스 : 더이상 상속 불가 */ public class Inherit07Main { public static void main(String[] args) { System.out.println("상속: Method Overriding(재정의)"); System.out.println(); // Person 클래스의 인스턴스 생성 // TODO Persons p1 = new Persons(); p1.setName("abc"); p1.showInfo(); System.out.println(); // BusinessPerson 클래스의 인스턴스를 생성 // TODO BusinessPerson p2 = new BusinessPerson(); p2.setName("춘향이"); p2.setCompany("(주)조선"); p2.showInfo(); // 비지니스 펄슨이다. > 이건 오버라이딩을 출력하는 것 System.out.println(); p2.showInfo(10); // 이건 오버로딩을 출력한 것. System.out.println(p2); System.out.println(p2.toString()); // 위에는 밑에꺼를 축약시켜서 표현한 것일 뿐 값은 같다. System.out.println("\n프로그램 종료"); } // end main() } // end class
2,088
0.553241
0.540895
65
18.63077
19.876982
81
false
false
0
0
0
0
0
0
1.6
false
false
1
66aa242900fb073669ee4ae4dac071da18cc220a
10,831,907,531,608
f1a5c8574fefd28c86f355b556c338b773f1ed90
/src/EX_BaekPKG/ex_for01.java
49b847b0475b1601e521505704402662a0a75dff
[]
no_license
J-ChanGI/Number2
https://github.com/J-ChanGI/Number2
6f560ee509a2f128d58f3175a52c9a60bf8a0ea4
cce8d83220c0517eb2ea4927d754978346544c10
refs/heads/master
2023-04-18T01:38:48.373000
2021-05-04T08:45:11
2021-05-04T08:45:11
357,724,819
1
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package EX_BaekPKG; import java.util.*; public class ex_for01 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int a = sc.nextInt(); for(int i=1; i<=a; i++) { for(int j=i; j<=i; j++) { int num1=sc.nextInt(); int num2=sc.nextInt(); int sum = num1+num2; System.out.println("Case #" + i + ":" + sum); } } } }
UTF-8
Java
446
java
ex_for01.java
Java
[]
null
[]
package EX_BaekPKG; import java.util.*; public class ex_for01 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int a = sc.nextInt(); for(int i=1; i<=a; i++) { for(int j=i; j<=i; j++) { int num1=sc.nextInt(); int num2=sc.nextInt(); int sum = num1+num2; System.out.println("Case #" + i + ":" + sum); } } } }
446
0.53139
0.515695
24
16.583334
15.146277
49
false
false
0
0
0
0
0
0
2.208333
false
false
1
a619c9468912d41b8b0d9d40e81c9402184f58d1
18,365,280,208,481
0d50d57140a6d5d8f6ace3361496f4f0b4e1d5bb
/src/com/example/demo/pass/test/sz/T1.java
e86c4193261ca46027ebcda063410d6a619bfc21
[]
no_license
My1deA/Algorithm-2006
https://github.com/My1deA/Algorithm-2006
3870bd01577d0c52664c328874d8cd9261f0be7f
85f628ba3494bcde33c3942f254454a7396e5133
refs/heads/master
2023-06-27T11:07:57.352000
2021-07-31T14:44:01
2021-07-31T14:44:01
269,584,997
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.example.demo.pass.test.sz; import java.util.Scanner; public class T1 { public static int getSqrt (int num) { // write code here String str=String.valueOf(Math.sqrt(num)); Integer t=str.charAt(0)-'0'; return t; } public static void main(String[] args) { Scanner scanner=new Scanner(System.in); Integer num=scanner.nextInt(); System.out.println(getSqrt(num)); } }
UTF-8
Java
450
java
T1.java
Java
[]
null
[]
package com.example.demo.pass.test.sz; import java.util.Scanner; public class T1 { public static int getSqrt (int num) { // write code here String str=String.valueOf(Math.sqrt(num)); Integer t=str.charAt(0)-'0'; return t; } public static void main(String[] args) { Scanner scanner=new Scanner(System.in); Integer num=scanner.nextInt(); System.out.println(getSqrt(num)); } }
450
0.615556
0.608889
19
22.68421
18.272938
50
false
false
0
0
0
0
0
0
0.421053
false
false
1
2e356dec12969166a36acbd4c3b14ef6ac61154c
5,102,421,157,100
8e56fe90e0cdb3b23afa82ea0895ea4bff917356
/src/main/java/com/pokemon/go/database/interfaces/IPokemonsController.java
65e7b8da406c8fd5d23c5eba2eb5bf02e9ac4576
[]
no_license
iskull/database-crawler
https://github.com/iskull/database-crawler
836eb396e2de7ba3e97cc8dabce2d8182536e253
4c3ec3f98c601c396b076bd7af70841f679ea811
refs/heads/master
2021-01-19T19:08:30.429000
2017-04-16T08:57:37
2017-04-16T08:57:37
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.pokemon.go.database.interfaces; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.pokemon.go.database.model.Pokemon; @Path("/pokemondb/pokemons") @Produces(MediaType.APPLICATION_JSON) public interface IPokemonsController { @GET @Path("/pokemon") Response get(@QueryParam("name") String name) throws WebApplicationException; @POST Response create(Pokemon pokemon) throws WebApplicationException; @PUT @Path("/pokemon") Response update(@QueryParam("id") String name, Pokemon pokemon) throws WebApplicationException; @DELETE @Path("/pokemon") Response delete(@QueryParam("id") String name) throws WebApplicationException; @GET Response getAll() throws WebApplicationException; }
UTF-8
Java
968
java
IPokemonsController.java
Java
[]
null
[]
package com.pokemon.go.database.interfaces; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.pokemon.go.database.model.Pokemon; @Path("/pokemondb/pokemons") @Produces(MediaType.APPLICATION_JSON) public interface IPokemonsController { @GET @Path("/pokemon") Response get(@QueryParam("name") String name) throws WebApplicationException; @POST Response create(Pokemon pokemon) throws WebApplicationException; @PUT @Path("/pokemon") Response update(@QueryParam("id") String name, Pokemon pokemon) throws WebApplicationException; @DELETE @Path("/pokemon") Response delete(@QueryParam("id") String name) throws WebApplicationException; @GET Response getAll() throws WebApplicationException; }
968
0.783058
0.783058
37
25.162163
24.452396
96
false
false
0
0
0
0
0
0
0.837838
false
false
1
589ce2ccc43375c88d0f847839078ffc8074273d
8,040,178,828,403
d2a30b09f4b563236831de505e4ed221230b141b
/src/test/java/com/spring/demo01/Test1.java
95b2094ca04d14912eef6a53065852db85fa7f3f
[]
no_license
GuntherLiu/JsonUtil
https://github.com/GuntherLiu/JsonUtil
ec020ffae05f85269ce1da93ae7420f26a8c2af0
c7d25a3352b2969c377396e6db7faa276bd30485
refs/heads/master
2020-04-09T07:41:02.965000
2018-12-13T08:49:03
2018-12-13T08:49:03
160,166,070
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.spring.demo01; import org.junit.Test; public class Test1 { @Test public void test1(){ Integer i = new Integer(1000); int i2 = 3; Object i2o = (Object)i2; boolean flag = i.getClass().equals(Integer.class); boolean flag2 = i2o.getClass().equals(Integer.class); System.out.println(flag2); } }
UTF-8
Java
386
java
Test1.java
Java
[]
null
[]
package com.spring.demo01; import org.junit.Test; public class Test1 { @Test public void test1(){ Integer i = new Integer(1000); int i2 = 3; Object i2o = (Object)i2; boolean flag = i.getClass().equals(Integer.class); boolean flag2 = i2o.getClass().equals(Integer.class); System.out.println(flag2); } }
386
0.569948
0.531088
18
19.444445
19.085255
61
false
false
0
0
0
0
0
0
0.444444
false
false
1
cbd00ffd8d11b72e2c056a066b1af1c3ee60c940
26,250,840,159,265
e426e92adfb1c29215bb991035ce360d93972eec
/app/src/room/java/com/example/stock/db/StockDatabase.java
a7aece3284093ecabc4ab1816aa8be6cc1945db0
[]
no_license
errorTime/stockWare
https://github.com/errorTime/stockWare
640f990d997f2ac04a5717f6e06f0ca8da3bb562
e67bd7f9971771ce0956ca5ef56ca4c4970e58a4
refs/heads/master
2021-05-09T02:06:44.400000
2018-02-09T16:45:25
2018-02-09T16:45:25
119,198,827
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.example.stock.db; import android.arch.persistence.db.SupportSQLiteDatabase; import android.arch.persistence.room.Database; import android.arch.persistence.room.Room; import android.arch.persistence.room.RoomDatabase; import android.arch.persistence.room.migration.Migration; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; @Database(entities = {Group.class}, version = 2) public abstract class StockDatabase extends RoomDatabase { private static StockDatabase INSTANCE; public abstract GroupDao groupDao(); private static final Object sLock = new Object(); @VisibleForTesting static final Migration MIGRATION_1_2 = new Migration(1, 2) { @Override public void migrate(@NonNull SupportSQLiteDatabase database) { } }; public static StockDatabase getInstance(Context ctx) { if (INSTANCE == null) { INSTANCE = Room.databaseBuilder(ctx.getApplicationContext(), StockDatabase.class, "stock.db") .addMigrations(MIGRATION_1_2) .build(); } return INSTANCE; } }
UTF-8
Java
1,201
java
StockDatabase.java
Java
[]
null
[]
package com.example.stock.db; import android.arch.persistence.db.SupportSQLiteDatabase; import android.arch.persistence.room.Database; import android.arch.persistence.room.Room; import android.arch.persistence.room.RoomDatabase; import android.arch.persistence.room.migration.Migration; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; @Database(entities = {Group.class}, version = 2) public abstract class StockDatabase extends RoomDatabase { private static StockDatabase INSTANCE; public abstract GroupDao groupDao(); private static final Object sLock = new Object(); @VisibleForTesting static final Migration MIGRATION_1_2 = new Migration(1, 2) { @Override public void migrate(@NonNull SupportSQLiteDatabase database) { } }; public static StockDatabase getInstance(Context ctx) { if (INSTANCE == null) { INSTANCE = Room.databaseBuilder(ctx.getApplicationContext(), StockDatabase.class, "stock.db") .addMigrations(MIGRATION_1_2) .build(); } return INSTANCE; } }
1,201
0.70358
0.697752
36
32.361111
23.161453
72
false
false
0
0
0
0
0
0
0.527778
false
false
1
ef006f5f0bc75cdd681431d81e27db98d8e78792
9,268,539,469,049
d036ded6c2f45b26752092dcada2e70a306db6f9
/src/main/java/com/capgemini/app/bean/Organization.java
f866816a3b94fda1508af99f26c22d9375458718
[]
no_license
jahnavialapati/firstspringapp
https://github.com/jahnavialapati/firstspringapp
40c928b1bd3d2bcb292af94d1b124b295930c8ea
8fea9c811f173011737e0c621875c4fe6af93c6f
refs/heads/master
2020-04-14T22:54:25.654000
2019-01-05T04:52:06
2019-01-05T04:52:06
164,182,880
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.capgemini.app.bean; import java.time.LocalDate; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; public class Organization { private int orgId; private String name; private Set<String> cities; private List<String> boardMembers; private Map<String, String> branchManagers; private LocalDate dateOfEstablishment; private double shareValue; private boolean listed; private Properties ipAddresses; public Organization() { super(); // TODO Auto-generated constructor stub } public Organization(int orgId, String name) { super(); this.orgId = orgId; this.name = name; } public int getOrgId() { return orgId; } public void setOrgId(int orgId) { this.orgId = orgId; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Set<String> getCities() { return cities; } public void setCities(Set<String> cities) { this.cities = cities; } public List<String> getBoardMembers() { return boardMembers; } public void setBoardMembers(List<String> boardMembers) { this.boardMembers = boardMembers; } public Map<String, String> getBranchManagers() { return branchManagers; } public void setBranchManagers(Map<String, String> branchManagers) { this.branchManagers = branchManagers; } public LocalDate getDateOfEstablishment() { return dateOfEstablishment; } public void setDateOfEstablishment(LocalDate dateOfEstablishment) { this.dateOfEstablishment = dateOfEstablishment; } public double getShareValue() { return shareValue; } public void setShareValue(double shareValue) { this.shareValue = shareValue; } public boolean isListed() { return listed; } public void setListed(boolean listed) { this.listed = listed; } public Properties getIpAddresses() { return ipAddresses; } public void setIpAddresses(Properties ipAddresses) { this.ipAddresses = ipAddresses; } @Override public String toString() { return "Organization [orgId=" + orgId + ", name=" + name + ", cities=" + cities + ", boardMembers=" + boardMembers + ", branchManagers=" + branchManagers + ", dateOfEstablishment=" + dateOfEstablishment + ", shareValue=" + shareValue + ", listed=" + listed + ", ipAddresses=" + ipAddresses + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((boardMembers == null) ? 0 : boardMembers.hashCode()); result = prime * result + ((branchManagers == null) ? 0 : branchManagers.hashCode()); result = prime * result + ((cities == null) ? 0 : cities.hashCode()); result = prime * result + ((dateOfEstablishment == null) ? 0 : dateOfEstablishment.hashCode()); result = prime * result + ((ipAddresses == null) ? 0 : ipAddresses.hashCode()); result = prime * result + (listed ? 1231 : 1237); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + orgId; long temp; temp = Double.doubleToLongBits(shareValue); result = prime * result + (int) (temp ^ (temp >>> 32)); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Organization other = (Organization) obj; if (boardMembers == null) { if (other.boardMembers != null) return false; } else if (!boardMembers.equals(other.boardMembers)) return false; if (branchManagers == null) { if (other.branchManagers != null) return false; } else if (!branchManagers.equals(other.branchManagers)) return false; if (cities == null) { if (other.cities != null) return false; } else if (!cities.equals(other.cities)) return false; if (dateOfEstablishment == null) { if (other.dateOfEstablishment != null) return false; } else if (!dateOfEstablishment.equals(other.dateOfEstablishment)) return false; if (ipAddresses == null) { if (other.ipAddresses != null) return false; } else if (!ipAddresses.equals(other.ipAddresses)) return false; if (listed != other.listed) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (orgId != other.orgId) return false; if (Double.doubleToLongBits(shareValue) != Double.doubleToLongBits(other.shareValue)) return false; return true; } }
UTF-8
Java
4,429
java
Organization.java
Java
[ { "context": "eturn \"Organization [orgId=\" + orgId + \", name=\" + name + \", cities=\" + cities + \", boardMembers=\"\n\t\t\t\t+ ", "end": 2044, "score": 0.811367928981781, "start": 2040, "tag": "NAME", "value": "name" } ]
null
[]
package com.capgemini.app.bean; import java.time.LocalDate; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; public class Organization { private int orgId; private String name; private Set<String> cities; private List<String> boardMembers; private Map<String, String> branchManagers; private LocalDate dateOfEstablishment; private double shareValue; private boolean listed; private Properties ipAddresses; public Organization() { super(); // TODO Auto-generated constructor stub } public Organization(int orgId, String name) { super(); this.orgId = orgId; this.name = name; } public int getOrgId() { return orgId; } public void setOrgId(int orgId) { this.orgId = orgId; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Set<String> getCities() { return cities; } public void setCities(Set<String> cities) { this.cities = cities; } public List<String> getBoardMembers() { return boardMembers; } public void setBoardMembers(List<String> boardMembers) { this.boardMembers = boardMembers; } public Map<String, String> getBranchManagers() { return branchManagers; } public void setBranchManagers(Map<String, String> branchManagers) { this.branchManagers = branchManagers; } public LocalDate getDateOfEstablishment() { return dateOfEstablishment; } public void setDateOfEstablishment(LocalDate dateOfEstablishment) { this.dateOfEstablishment = dateOfEstablishment; } public double getShareValue() { return shareValue; } public void setShareValue(double shareValue) { this.shareValue = shareValue; } public boolean isListed() { return listed; } public void setListed(boolean listed) { this.listed = listed; } public Properties getIpAddresses() { return ipAddresses; } public void setIpAddresses(Properties ipAddresses) { this.ipAddresses = ipAddresses; } @Override public String toString() { return "Organization [orgId=" + orgId + ", name=" + name + ", cities=" + cities + ", boardMembers=" + boardMembers + ", branchManagers=" + branchManagers + ", dateOfEstablishment=" + dateOfEstablishment + ", shareValue=" + shareValue + ", listed=" + listed + ", ipAddresses=" + ipAddresses + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((boardMembers == null) ? 0 : boardMembers.hashCode()); result = prime * result + ((branchManagers == null) ? 0 : branchManagers.hashCode()); result = prime * result + ((cities == null) ? 0 : cities.hashCode()); result = prime * result + ((dateOfEstablishment == null) ? 0 : dateOfEstablishment.hashCode()); result = prime * result + ((ipAddresses == null) ? 0 : ipAddresses.hashCode()); result = prime * result + (listed ? 1231 : 1237); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + orgId; long temp; temp = Double.doubleToLongBits(shareValue); result = prime * result + (int) (temp ^ (temp >>> 32)); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Organization other = (Organization) obj; if (boardMembers == null) { if (other.boardMembers != null) return false; } else if (!boardMembers.equals(other.boardMembers)) return false; if (branchManagers == null) { if (other.branchManagers != null) return false; } else if (!branchManagers.equals(other.branchManagers)) return false; if (cities == null) { if (other.cities != null) return false; } else if (!cities.equals(other.cities)) return false; if (dateOfEstablishment == null) { if (other.dateOfEstablishment != null) return false; } else if (!dateOfEstablishment.equals(other.dateOfEstablishment)) return false; if (ipAddresses == null) { if (other.ipAddresses != null) return false; } else if (!ipAddresses.equals(other.ipAddresses)) return false; if (listed != other.listed) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (orgId != other.orgId) return false; if (Double.doubleToLongBits(shareValue) != Double.doubleToLongBits(other.shareValue)) return false; return true; } }
4,429
0.691804
0.687514
153
27.954248
22.39641
106
false
false
0
0
0
0
0
0
2.254902
false
false
1
7f20d1f922af1c308c1ff3f87bb570a375506710
3,770,981,287,900
b5effab7cf302cd321a1eb2584c2101f035aac73
/SampleProject/src/com/ArmstrongNumber.java
b8bb2d798574cef07889549a0ab08abb30c4638a
[]
no_license
sridhar6/javaquestions
https://github.com/sridhar6/javaquestions
1ae4c7f36899ec825a6937c62cdb4567997a7b62
6f3c4296c2dc2c9a1392a815bc72a0f389fe87bf
refs/heads/master
2021-01-10T03:26:34.948000
2015-10-28T04:45:50
2015-10-28T04:45:50
45,088,571
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com; public class ArmstrongNumber { public boolean isArmstrongNumber(int number){ int temp=number; int numberofdigits=String.valueOf(number).length(); int sum=0; int div=0; while(temp>0){ div=temp%10; int j=1; for(int i=0;i<numberofdigits;i++){ j=j*div; }sum=sum+j; temp=temp/10; } if(number==sum){ return true; }else{ return false; } } public static void main(String[] args){ ArmstrongNumber testObj=new ArmstrongNumber(); boolean result=testObj.isArmstrongNumber(371); System.out.println("isArmstromgnumber "+ result); } }
UTF-8
Java
564
java
ArmstrongNumber.java
Java
[]
null
[]
package com; public class ArmstrongNumber { public boolean isArmstrongNumber(int number){ int temp=number; int numberofdigits=String.valueOf(number).length(); int sum=0; int div=0; while(temp>0){ div=temp%10; int j=1; for(int i=0;i<numberofdigits;i++){ j=j*div; }sum=sum+j; temp=temp/10; } if(number==sum){ return true; }else{ return false; } } public static void main(String[] args){ ArmstrongNumber testObj=new ArmstrongNumber(); boolean result=testObj.isArmstrongNumber(371); System.out.println("isArmstromgnumber "+ result); } }
564
0.707447
0.68617
39
13.461538
16.361065
52
false
false
0
0
0
0
0
0
0.923077
false
false
1
39a93bcce064af07a1bbdc9f85c29b8c49487279
18,150,531,851,340
a48a8477a5c3a4265298a0e8edaf3db0c89a647d
/src/main/java/com/springapp/entity/Scenario.java
a66c05eb07c9936016c9473a6700263e792474f8
[]
no_license
mendor71/ScriptCreator
https://github.com/mendor71/ScriptCreator
73963989f21924c52aadc4a9aa17c7ed72a22764
90ec916f176db4b5428ee9697ee554c9fa76e66f
refs/heads/master
2021-09-15T04:15:07.369000
2018-05-25T16:14:30
2018-05-25T16:14:30
115,113,266
0
1
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.springapp.entity; import org.springframework.hateoas.ResourceSupport; import javax.persistence.*; import java.util.ArrayList; import java.util.List; @Entity @Table(name = "public.scenarios") public class Scenario extends ResourceSupport { @Id @Column(name = "sc_id") @GeneratedValue(strategy = GenerationType.IDENTITY) private Long scId; @JoinColumn(name = "sc_cat_id", referencedColumnName = "cat_id") @ManyToOne private Category scCatId; @Column(name = "sc_name") private String scName; @JoinColumn(name = "sc_state_id", referencedColumnName = "state_id") @ManyToOne private State scStateId; @JoinColumn(name = "sc_owner_user_id", referencedColumnName = "user_id") @ManyToOne private User scOwnerUserId; @JoinTable(name = "user_scenarios_access", joinColumns = {@JoinColumn(name = "usa_sc_id")}, inverseJoinColumns = {@JoinColumn(name = "usa_user_id")}) @ManyToMany private List<User> scAccessUsers = new ArrayList<>(); public Long getScId() { return scId; } public void setScId(Long scId) { this.scId = scId; } public Category getScCatId() { return scCatId; } public void setScCatId(Category scCatId) { this.scCatId = scCatId; } public State getScStateId() { return scStateId; } public void setScStateId(State scStateId) { this.scStateId = scStateId; } public String getScName() { return scName; } public void setScName(String scName) { this.scName = scName; } public User getScOwnerUserId() { return scOwnerUserId; } public void setScOwnerUserId(User scOwnerUserId) { this.scOwnerUserId = scOwnerUserId; } public List<User> getScAccessUsers() { return scAccessUsers; } public void setScAccessUsers(List<User> scAccessUsers) { this.scAccessUsers = scAccessUsers; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; Scenario scenario = (Scenario) o; return scId != null ? scId.equals(scenario.scId) : scenario.scId == null; } @Override public String toString() { return "Scenario{" + "scId=" + scId + ", scCatId=" + scCatId + ", scName='" + scName + '\'' + ", scStateId=" + scStateId + ", scOwnerUserId=" + scOwnerUserId + ", scAccessUsers=" + scAccessUsers + '}'; } }
UTF-8
Java
2,672
java
Scenario.java
Java
[]
null
[]
package com.springapp.entity; import org.springframework.hateoas.ResourceSupport; import javax.persistence.*; import java.util.ArrayList; import java.util.List; @Entity @Table(name = "public.scenarios") public class Scenario extends ResourceSupport { @Id @Column(name = "sc_id") @GeneratedValue(strategy = GenerationType.IDENTITY) private Long scId; @JoinColumn(name = "sc_cat_id", referencedColumnName = "cat_id") @ManyToOne private Category scCatId; @Column(name = "sc_name") private String scName; @JoinColumn(name = "sc_state_id", referencedColumnName = "state_id") @ManyToOne private State scStateId; @JoinColumn(name = "sc_owner_user_id", referencedColumnName = "user_id") @ManyToOne private User scOwnerUserId; @JoinTable(name = "user_scenarios_access", joinColumns = {@JoinColumn(name = "usa_sc_id")}, inverseJoinColumns = {@JoinColumn(name = "usa_user_id")}) @ManyToMany private List<User> scAccessUsers = new ArrayList<>(); public Long getScId() { return scId; } public void setScId(Long scId) { this.scId = scId; } public Category getScCatId() { return scCatId; } public void setScCatId(Category scCatId) { this.scCatId = scCatId; } public State getScStateId() { return scStateId; } public void setScStateId(State scStateId) { this.scStateId = scStateId; } public String getScName() { return scName; } public void setScName(String scName) { this.scName = scName; } public User getScOwnerUserId() { return scOwnerUserId; } public void setScOwnerUserId(User scOwnerUserId) { this.scOwnerUserId = scOwnerUserId; } public List<User> getScAccessUsers() { return scAccessUsers; } public void setScAccessUsers(List<User> scAccessUsers) { this.scAccessUsers = scAccessUsers; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; Scenario scenario = (Scenario) o; return scId != null ? scId.equals(scenario.scId) : scenario.scId == null; } @Override public String toString() { return "Scenario{" + "scId=" + scId + ", scCatId=" + scCatId + ", scName='" + scName + '\'' + ", scStateId=" + scStateId + ", scOwnerUserId=" + scOwnerUserId + ", scAccessUsers=" + scAccessUsers + '}'; } }
2,672
0.606662
0.606662
106
24.207546
24.169886
153
false
false
0
0
0
0
0
0
0.386792
false
false
1
86ccdab747077cd8c32a63d4121ece84dc6d3827
2,113,123,960,382
1eae2e8e0eadcfb5a9fa9547e39e269c60cf013f
/src/java/br/com/curso/urnaweb/dao/JPAUtil.java
1b91e8d360aea0ef779d64842e457b2cdc33292a
[]
no_license
mrsuzuki/urnaweb
https://github.com/mrsuzuki/urnaweb
79926df7adabab6f934416c6580acedba8b025be
d7271a0c426a6299366062bb01211e5ce0f91562
refs/heads/master
2015-08-10T10:06:55.842000
2014-03-21T22:59:43
2014-03-21T22:59:43
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package br.com.curso.urnaweb.dao; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; /** * Classe responsável por fazer a conexão com o Banco de Dados * */ public class JPAUtil { private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory("urnawebPU"); /** * Obtém uma conexão com o Banco de Dados * * @return * Um "entity manager" conectado ao Banco de Dados. */ public EntityManager getEntityManager() { return emf.createEntityManager(); } /** * Fecha a conexão com o Banco de Dados * * @param em * Um "entity manager" conectado ao Banco de Dados. */ public void close(EntityManager em) { em.close(); } }
UTF-8
Java
765
java
JPAUtil.java
Java
[]
null
[]
package br.com.curso.urnaweb.dao; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; /** * Classe responsável por fazer a conexão com o Banco de Dados * */ public class JPAUtil { private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory("urnawebPU"); /** * Obtém uma conexão com o Banco de Dados * * @return * Um "entity manager" conectado ao Banco de Dados. */ public EntityManager getEntityManager() { return emf.createEntityManager(); } /** * Fecha a conexão com o Banco de Dados * * @param em * Um "entity manager" conectado ao Banco de Dados. */ public void close(EntityManager em) { em.close(); } }
765
0.710526
0.710526
36
20.111111
23.739065
101
false
false
0
0
0
0
0
0
1
false
false
1
68b0155710975bd0490460de3e8263287f0ceaa6
13,477,607,437,493
259215065fcefda39b033829839ab7ed3bde09d2
/src/application/client/MessageEvent.java
fe183dffc865c07eafdbe4a7aab30a69534f68f4
[]
no_license
Marteeh/ChatSystem
https://github.com/Marteeh/ChatSystem
e305238ef1aa5d22f41bffba4dc91f15aed96e09
d44f4963e227db774846096ce45bcda11cbacca6
refs/heads/master
2020-09-14T11:53:14.305000
2020-02-03T17:54:47
2020-02-03T17:54:47
223,121,365
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package application.client; import application.User; public class MessageEvent extends GUIEvent { public final User userFrom; public final User userTo; public final String content; MessageEvent(User userFrom, User userTo, String content) { this.userFrom = userFrom; this.userTo = userTo; this.content = content; } }
UTF-8
Java
331
java
MessageEvent.java
Java
[]
null
[]
package application.client; import application.User; public class MessageEvent extends GUIEvent { public final User userFrom; public final User userTo; public final String content; MessageEvent(User userFrom, User userTo, String content) { this.userFrom = userFrom; this.userTo = userTo; this.content = content; } }
331
0.761329
0.761329
16
19.6875
17.156336
59
false
false
0
0
0
0
0
0
1.3125
false
false
1
6687992563fcc796f0375a174cd78db7e4d7e6fc
22,308,060,137,614
0dc7b5884df384709a2704a8bd7995058f039a4b
/tesuto-drools-services/tesuto-drools-common/src/main/java/org/ccctc/common/droolscommon/action/result/ActionResult.java
afcbe26681b29480c29c6afe7956b327ef6c4278
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "EPL-1.0" ]
permissive
apereo-tesuto/tesuto
https://github.com/apereo-tesuto/tesuto
b1672fc2ebbd4b5d4647ee15e3e4285c8e3dc0be
90ed26311b1baa15cd90d67bb55e7d4c613bdc53
refs/heads/master
2021-10-08T01:02:49.098000
2021-09-24T21:22:52
2021-09-24T21:22:52
218,090,150
4
3
Apache-2.0
false
2021-09-24T21:22:53
2019-10-28T16:08:04
2020-08-20T18:36:40
2021-09-24T21:22:52
34,927
4
1
0
null
false
false
/******************************************************************************* * Copyright © 2019 by California Community Colleges Chancellor's Office * * 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.ccctc.common.droolscommon.action.result; import java.io.Serializable; public class ActionResult implements Serializable { private static final long serialVersionUID = 1L; protected String actionName; protected String message; public ActionResult() { } public ActionResult(String name, String message) { this.actionName = name; this.message = message; } public String getActionName() { return actionName; } public String getMessage() { return message; } public void setActionName(String actionName) { this.actionName = actionName; } public void setMessage(String message) { this.message = message; } @Override public String toString() { return "Action taken: " + actionName + " - " + message; } }
UTF-8
Java
1,643
java
ActionResult.java
Java
[]
null
[]
/******************************************************************************* * Copyright © 2019 by California Community Colleges Chancellor's Office * * 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.ccctc.common.droolscommon.action.result; import java.io.Serializable; public class ActionResult implements Serializable { private static final long serialVersionUID = 1L; protected String actionName; protected String message; public ActionResult() { } public ActionResult(String name, String message) { this.actionName = name; this.message = message; } public String getActionName() { return actionName; } public String getMessage() { return message; } public void setActionName(String actionName) { this.actionName = actionName; } public void setMessage(String message) { this.message = message; } @Override public String toString() { return "Action taken: " + actionName + " - " + message; } }
1,643
0.623021
0.61754
54
29.407408
27.495804
80
false
false
0
0
0
0
0
0
0.333333
false
false
1
bd61a66c42b132c6eda1d16efd09aae93d8b18d1
24,807,731,161,051
609981dad82c7f59c595f31edf596116644891f9
/Learning33.java
7af518a6ca4a45231f63351c11d846ed17f21f94
[]
no_license
angelfly12138/Java-Programs
https://github.com/angelfly12138/Java-Programs
31a3a1a4ce4583064713ca285d0a7d5cab943eed
89854d1370dfc671f33c5cd600db5a8d200b9a58
refs/heads/master
2020-12-02T18:31:40.457000
2019-01-30T03:13:54
2019-01-30T03:13:54
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
import java.util.*; import java.util.Scanner; public class Learning33 { public static void main(String args[]) { Scanner input = new Scanner(System.in); System.out.println("Enter a phrase with three words in it repeated: "); String phrase = input.nextLine(); System.out.println("Enter the repeated word: "); String word = input.nextLine(); System.out.println("Enter a replacement: "); String newWord = input.nextLine(); System.out.println("Enter a replacement: "); String newWord2 = input.nextLine(); System.out.println("Enter a replacement: "); String newWord3 = input.nextLine(); String phrase1 = phrase.replaceFirst(word, newWord); String phrase2 = phrase1.replaceFirst(word, newWord2); String phrase3 = phrase2.replaceFirst(word, newWord3); System.out.println(phrase3); } }
UTF-8
Java
942
java
Learning33.java
Java
[]
null
[]
import java.util.*; import java.util.Scanner; public class Learning33 { public static void main(String args[]) { Scanner input = new Scanner(System.in); System.out.println("Enter a phrase with three words in it repeated: "); String phrase = input.nextLine(); System.out.println("Enter the repeated word: "); String word = input.nextLine(); System.out.println("Enter a replacement: "); String newWord = input.nextLine(); System.out.println("Enter a replacement: "); String newWord2 = input.nextLine(); System.out.println("Enter a replacement: "); String newWord3 = input.nextLine(); String phrase1 = phrase.replaceFirst(word, newWord); String phrase2 = phrase1.replaceFirst(word, newWord2); String phrase3 = phrase2.replaceFirst(word, newWord3); System.out.println(phrase3); } }
942
0.622081
0.609342
41
21.024391
21.578545
74
false
false
0
0
0
0
0
0
0.487805
false
false
1
e5c5f78ab7aac20b59c68140985da55b3cd9f344
25,074,019,084,900
30a84c1e0567405b0dbe950596187cb0c807e919
/app/src/main/java/ru/ifmo/md/exam2/provider/playlist/PlaylistSelection.java
1fd883388c17691bb6736ab5e7380bd67cca09d4
[]
no_license
zakharvoit/exam2
https://github.com/zakharvoit/exam2
b85df014d81683be0e8d05e045401932e364c0b5
aeaf88695cf3330c4f7a1c7dca4415c9348b179c
refs/heads/master
2020-12-31T03:42:13.181000
2015-01-23T10:57:52
2015-01-23T10:57:52
29,720,342
0
0
null
true
2015-01-23T06:42:30
2015-01-23T06:42:30
2015-01-23T06:28:51
2015-01-23T06:28:51
0
0
0
0
null
null
null
/* * This source file is generated with https://github.com/BoD/android-contentprovider-generator */ package ru.ifmo.md.exam2.provider.playlist; import java.util.Date; import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; import ru.ifmo.md.exam2.provider.base.AbstractSelection; /** * Selection for the {@code playlist} table. */ public class PlaylistSelection extends AbstractSelection<PlaylistSelection> { @Override public Uri uri() { return PlaylistColumns.CONTENT_URI; } /** * Query the given content resolver using this selection. * * @param contentResolver The content resolver to query. * @param projection A list of which columns to return. Passing null will return all columns, which is inefficient. * @param sortOrder How to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort * order, which may be unordered. * @return A {@code PlaylistCursor} object, which is positioned before the first entry, or null. */ public PlaylistCursor query(ContentResolver contentResolver, String[] projection, String sortOrder) { Cursor cursor = contentResolver.query(uri(), projection, sel(), args(), sortOrder); if (cursor == null) return null; return new PlaylistCursor(cursor); } /** * Equivalent of calling {@code query(contentResolver, projection, null}. */ public PlaylistCursor query(ContentResolver contentResolver, String[] projection) { return query(contentResolver, projection, null); } /** * Equivalent of calling {@code query(contentResolver, projection, null, null}. */ public PlaylistCursor query(ContentResolver contentResolver) { return query(contentResolver, null, null); } public PlaylistSelection id(long... value) { addEquals("playlist." + PlaylistColumns._ID, toObjectArray(value)); return this; } public PlaylistSelection name(String... value) { addEquals(PlaylistColumns.NAME, value); return this; } public PlaylistSelection nameNot(String... value) { addNotEquals(PlaylistColumns.NAME, value); return this; } public PlaylistSelection nameLike(String... value) { addLike(PlaylistColumns.NAME, value); return this; } }
UTF-8
Java
2,427
java
PlaylistSelection.java
Java
[ { "context": " source file is generated with https://github.com/BoD/android-contentprovider-generator\n */\npackage ru.", "end": 63, "score": 0.9994815587997437, "start": 60, "tag": "USERNAME", "value": "BoD" } ]
null
[]
/* * This source file is generated with https://github.com/BoD/android-contentprovider-generator */ package ru.ifmo.md.exam2.provider.playlist; import java.util.Date; import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; import ru.ifmo.md.exam2.provider.base.AbstractSelection; /** * Selection for the {@code playlist} table. */ public class PlaylistSelection extends AbstractSelection<PlaylistSelection> { @Override public Uri uri() { return PlaylistColumns.CONTENT_URI; } /** * Query the given content resolver using this selection. * * @param contentResolver The content resolver to query. * @param projection A list of which columns to return. Passing null will return all columns, which is inefficient. * @param sortOrder How to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort * order, which may be unordered. * @return A {@code PlaylistCursor} object, which is positioned before the first entry, or null. */ public PlaylistCursor query(ContentResolver contentResolver, String[] projection, String sortOrder) { Cursor cursor = contentResolver.query(uri(), projection, sel(), args(), sortOrder); if (cursor == null) return null; return new PlaylistCursor(cursor); } /** * Equivalent of calling {@code query(contentResolver, projection, null}. */ public PlaylistCursor query(ContentResolver contentResolver, String[] projection) { return query(contentResolver, projection, null); } /** * Equivalent of calling {@code query(contentResolver, projection, null, null}. */ public PlaylistCursor query(ContentResolver contentResolver) { return query(contentResolver, null, null); } public PlaylistSelection id(long... value) { addEquals("playlist." + PlaylistColumns._ID, toObjectArray(value)); return this; } public PlaylistSelection name(String... value) { addEquals(PlaylistColumns.NAME, value); return this; } public PlaylistSelection nameNot(String... value) { addNotEquals(PlaylistColumns.NAME, value); return this; } public PlaylistSelection nameLike(String... value) { addLike(PlaylistColumns.NAME, value); return this; } }
2,427
0.688504
0.68768
73
32.246574
34.723083
154
false
false
0
0
0
0
0
0
0.616438
false
false
1
e566a8542b47671037ffda394750df2f6c6b295e
17,592,186,045,767
6980fc504529832e46dfa54126eef8de0c838c1d
/src/ec/edu/ups/ejb/PedidoFacade.java
b81da610529f4abff12aa7b2ce3ce4ec703ce0d8
[]
no_license
JonathanAtancuri3218/Atancuri-Jonathan-Examen
https://github.com/JonathanAtancuri3218/Atancuri-Jonathan-Examen
7d449e4bbb6065914a630c0a71f23725b088d333
4527add2d2fc89b255969d4e7c09b04f87e30a9d
refs/heads/master
2023-05-29T08:01:36.882000
2021-06-11T16:36:15
2021-06-11T16:36:15
376,045,243
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package ec.edu.ups.ejb; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import ec.edu.ups.entidad.Pedido; public class PedidoFacade extends AbstractFacade<Pedido>{ @PersistenceContext(unitName = "Atancuri-Jonathan-Examen") private EntityManager em; public PedidoFacade() { super(Pedido.class); } @Override protected EntityManager getEntityManager() { return em; } public List<Pedido> findPedidosNombre() { String jpql = "FROM Usuario u WHERE u.rol = 'cliente' ORDER BY u.nombre DESC"; return (List<Pedido>)em.createQuery(jpql).getResultList(); } public List<Pedido> findPedidosTarjeta() { String jpql = "FROM Usuario u WHERE u.rol = 'cliente' ORDER BY u.nombre DESC"; return (List<Pedido>)em.createQuery(jpql).getResultList(); } public List<Pedido> findByName(String name) { //System.out.println("llego al metodo de buscar..............................."); //System.out.println("nombre....... " + name.toString()); String jpql = "FROM Pedido b WHERE b.numero LIKE '" + name + "%'"; //System.out.println("Lista================================== " + em.createQuery(jpql).getResultList()); return (List<Pedido>) em.createQuery(jpql).getResultList(); } }
UTF-8
Java
1,385
java
PedidoFacade.java
Java
[]
null
[]
package ec.edu.ups.ejb; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import ec.edu.ups.entidad.Pedido; public class PedidoFacade extends AbstractFacade<Pedido>{ @PersistenceContext(unitName = "Atancuri-Jonathan-Examen") private EntityManager em; public PedidoFacade() { super(Pedido.class); } @Override protected EntityManager getEntityManager() { return em; } public List<Pedido> findPedidosNombre() { String jpql = "FROM Usuario u WHERE u.rol = 'cliente' ORDER BY u.nombre DESC"; return (List<Pedido>)em.createQuery(jpql).getResultList(); } public List<Pedido> findPedidosTarjeta() { String jpql = "FROM Usuario u WHERE u.rol = 'cliente' ORDER BY u.nombre DESC"; return (List<Pedido>)em.createQuery(jpql).getResultList(); } public List<Pedido> findByName(String name) { //System.out.println("llego al metodo de buscar..............................."); //System.out.println("nombre....... " + name.toString()); String jpql = "FROM Pedido b WHERE b.numero LIKE '" + name + "%'"; //System.out.println("Lista================================== " + em.createQuery(jpql).getResultList()); return (List<Pedido>) em.createQuery(jpql).getResultList(); } }
1,385
0.622383
0.622383
45
29.777779
30.718716
113
false
false
0
0
0
0
0
0
0.444444
false
false
1
c9264643cd445f8069466ba55fc6ccff3f083c46
36,249,524,028,559
b2ff914fd4bade30fdc7d606bdc058520578fcad
/OSPIcecap-service/src/main/java/com/osp/icecap/service/persistence/impl/DataCollectionPersistenceImpl.java
14b8b8e8843d42812692e0e0f975204e2a634375
[]
no_license
jerryhseo/icecap
https://github.com/jerryhseo/icecap
7e9f49644569905a435a06f9f4c3575960e4fdcf
8a6079fc341a1a93829b52cfd7d3e9eed8e73d18
refs/heads/master
2022-12-24T15:36:46.268000
2020-10-07T10:39:33
2020-10-07T10:39:33
278,283,701
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.osp.icecap.service.persistence.impl; import com.liferay.petra.string.StringBundler; import com.liferay.portal.kernel.configuration.Configuration; import com.liferay.portal.kernel.dao.orm.EntityCache; import com.liferay.portal.kernel.dao.orm.FinderCache; import com.liferay.portal.kernel.dao.orm.FinderPath; import com.liferay.portal.kernel.dao.orm.Query; import com.liferay.portal.kernel.dao.orm.QueryPos; import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.dao.orm.SQLQuery; import com.liferay.portal.kernel.dao.orm.Session; import com.liferay.portal.kernel.dao.orm.SessionFactory; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.security.auth.CompanyThreadLocal; import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil; import com.liferay.portal.kernel.service.ServiceContext; import com.liferay.portal.kernel.service.ServiceContextThreadLocal; import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl; import com.liferay.portal.kernel.util.GetterUtil; import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.util.ProxyUtil; import com.liferay.portal.kernel.util.SetUtil; import com.liferay.portal.kernel.util.StringUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.uuid.PortalUUIDUtil; import com.osp.icecap.exception.NoSuchDataCollectionException; import com.osp.icecap.model.DataCollection; import com.osp.icecap.model.impl.DataCollectionImpl; import com.osp.icecap.model.impl.DataCollectionModelImpl; import com.osp.icecap.service.persistence.DataCollectionPersistence; import com.osp.icecap.service.persistence.impl.constants.ICECAPPersistenceConstants; import java.io.Serializable; import java.lang.reflect.InvocationHandler; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import javax.sql.DataSource; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.component.annotations.Reference; /** * The persistence implementation for the data collection service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author Jerry H. Seo * @generated */ @Component(service = DataCollectionPersistence.class) public class DataCollectionPersistenceImpl extends BasePersistenceImpl<DataCollection> implements DataCollectionPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use <code>DataCollectionUtil</code> to access the data collection persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = DataCollectionImpl.class.getName(); public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List1"; public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List2"; private FinderPath _finderPathWithPaginationFindAll; private FinderPath _finderPathWithoutPaginationFindAll; private FinderPath _finderPathCountAll; private FinderPath _finderPathWithPaginationFindByUuid; private FinderPath _finderPathWithoutPaginationFindByUuid; private FinderPath _finderPathCountByUuid; /** * Returns all the data collections where uuid = &#63;. * * @param uuid the uuid * @return the matching data collections */ @Override public List<DataCollection> findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where uuid = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param uuid the uuid * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByUuid(String uuid, int start, int end) { return findByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the data collections where uuid = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param uuid the uuid * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByUuid( String uuid, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByUuid(uuid, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where uuid = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param uuid the uuid * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByUuid( String uuid, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByUuid; finderArgs = new Object[] {uuid}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByUuid; finderArgs = new Object[] {uuid, start, end, orderByComparator}; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (!uuid.equals(dataCollection.getUuid())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where uuid = &#63;. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUuid_First( String uuid, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUuid_First( uuid, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where uuid = &#63;. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUuid_First( String uuid, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByUuid(uuid, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where uuid = &#63;. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUuid_Last( String uuid, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUuid_Last( uuid, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where uuid = &#63;. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUuid_Last( String uuid, OrderByComparator<DataCollection> orderByComparator) { int count = countByUuid(uuid); if (count == 0) { return null; } List<DataCollection> list = findByUuid( uuid, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where uuid = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByUuid_PrevAndNext( long dataCollectionId, String uuid, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { uuid = Objects.toString(uuid, ""); DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByUuid_PrevAndNext( session, dataCollection, uuid, orderByComparator, true); array[1] = dataCollection; array[2] = getByUuid_PrevAndNext( session, dataCollection, uuid, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByUuid_PrevAndNext( Session session, DataCollection dataCollection, String uuid, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where uuid = &#63; from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (DataCollection dataCollection : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where uuid = &#63;. * * @param uuid the uuid * @return the number of matching data collections */ @Override public int countByUuid(String uuid) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = _finderPathCountByUuid; Object[] finderArgs = new Object[] {uuid}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_UUID_2 = "dataCollection.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dataCollection.uuid IS NULL OR dataCollection.uuid = '')"; private FinderPath _finderPathFetchByUUID_G; private FinderPath _finderPathCountByUUID_G; /** * Returns the data collection where uuid = &#63; and groupId = &#63; or throws a <code>NoSuchDataCollectionException</code> if it could not be found. * * @param uuid the uuid * @param groupId the group ID * @return the matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUUID_G(String uuid, long groupId) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUUID_G(uuid, groupId); if (dataCollection == null) { StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append(", groupId="); sb.append(groupId); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchDataCollectionException(sb.toString()); } return dataCollection; } /** * Returns the data collection where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param uuid the uuid * @param groupId the group ID * @return the matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUUID_G(String uuid, long groupId) { return fetchByUUID_G(uuid, groupId, true); } /** * Returns the data collection where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param uuid the uuid * @param groupId the group ID * @param useFinderCache whether to use the finder cache * @return the matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUUID_G( String uuid, long groupId, boolean useFinderCache) { uuid = Objects.toString(uuid, ""); Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] {uuid, groupId}; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByUUID_G, finderArgs, this); } if (result instanceof DataCollection) { DataCollection dataCollection = (DataCollection)result; if (!Objects.equals(uuid, dataCollection.getUuid()) || (groupId != dataCollection.getGroupId())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_G_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_G_UUID_2); } sb.append(_FINDER_COLUMN_UUID_G_GROUPID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(groupId); List<DataCollection> list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByUUID_G, finderArgs, list); } } else { DataCollection dataCollection = list.get(0); result = dataCollection; cacheResult(dataCollection); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult( _finderPathFetchByUUID_G, finderArgs); } throw processException(exception); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (DataCollection)result; } } /** * Removes the data collection where uuid = &#63; and groupId = &#63; from the database. * * @param uuid the uuid * @param groupId the group ID * @return the data collection that was removed */ @Override public DataCollection removeByUUID_G(String uuid, long groupId) throws NoSuchDataCollectionException { DataCollection dataCollection = findByUUID_G(uuid, groupId); return remove(dataCollection); } /** * Returns the number of data collections where uuid = &#63; and groupId = &#63;. * * @param uuid the uuid * @param groupId the group ID * @return the number of matching data collections */ @Override public int countByUUID_G(String uuid, long groupId) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = _finderPathCountByUUID_G; Object[] finderArgs = new Object[] {uuid, groupId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_G_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_G_UUID_2); } sb.append(_FINDER_COLUMN_UUID_G_GROUPID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(groupId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dataCollection.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dataCollection.uuid IS NULL OR dataCollection.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dataCollection.groupId = ?"; private FinderPath _finderPathWithPaginationFindByUuid_C; private FinderPath _finderPathWithoutPaginationFindByUuid_C; private FinderPath _finderPathCountByUuid_C; /** * Returns all the data collections where uuid = &#63; and companyId = &#63;. * * @param uuid the uuid * @param companyId the company ID * @return the matching data collections */ @Override public List<DataCollection> findByUuid_C(String uuid, long companyId) { return findByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where uuid = &#63; and companyId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByUuid_C( String uuid, long companyId, int start, int end) { return findByUuid_C(uuid, companyId, start, end, null); } /** * Returns an ordered range of all the data collections where uuid = &#63; and companyId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByUuid_C( String uuid, long companyId, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByUuid_C( uuid, companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where uuid = &#63; and companyId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByUuid_C( String uuid, long companyId, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByUuid_C; finderArgs = new Object[] {uuid, companyId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByUuid_C; finderArgs = new Object[] { uuid, companyId, start, end, orderByComparator }; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (!uuid.equals(dataCollection.getUuid()) || (companyId != dataCollection.getCompanyId())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where uuid = &#63; and companyId = &#63;. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUuid_C_First( String uuid, long companyId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUuid_C_First( uuid, companyId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append(", companyId="); sb.append(companyId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where uuid = &#63; and companyId = &#63;. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUuid_C_First( String uuid, long companyId, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByUuid_C( uuid, companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where uuid = &#63; and companyId = &#63;. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUuid_C_Last( String uuid, long companyId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUuid_C_Last( uuid, companyId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append(", companyId="); sb.append(companyId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where uuid = &#63; and companyId = &#63;. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUuid_C_Last( String uuid, long companyId, OrderByComparator<DataCollection> orderByComparator) { int count = countByUuid_C(uuid, companyId); if (count == 0) { return null; } List<DataCollection> list = findByUuid_C( uuid, companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where uuid = &#63; and companyId = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByUuid_C_PrevAndNext( long dataCollectionId, String uuid, long companyId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { uuid = Objects.toString(uuid, ""); DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByUuid_C_PrevAndNext( session, dataCollection, uuid, companyId, orderByComparator, true); array[1] = dataCollection; array[2] = getByUuid_C_PrevAndNext( session, dataCollection, uuid, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByUuid_C_PrevAndNext( Session session, DataCollection dataCollection, String uuid, long companyId, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where uuid = &#63; and companyId = &#63; from the database. * * @param uuid the uuid * @param companyId the company ID */ @Override public void removeByUuid_C(String uuid, long companyId) { for (DataCollection dataCollection : findByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where uuid = &#63; and companyId = &#63;. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching data collections */ @Override public int countByUuid_C(String uuid, long companyId) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = _finderPathCountByUuid_C; Object[] finderArgs = new Object[] {uuid, companyId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "dataCollection.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(dataCollection.uuid IS NULL OR dataCollection.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "dataCollection.companyId = ?"; private FinderPath _finderPathWithPaginationFindByGroupId; private FinderPath _finderPathWithoutPaginationFindByGroupId; private FinderPath _finderPathCountByGroupId; /** * Returns all the data collections where groupId = &#63;. * * @param groupId the group ID * @return the matching data collections */ @Override public List<DataCollection> findByGroupId(long groupId) { return findByGroupId( groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where groupId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByGroupId( long groupId, int start, int end) { return findByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the data collections where groupId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByGroupId( long groupId, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByGroupId(groupId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where groupId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByGroupId( long groupId, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByGroupId; finderArgs = new Object[] {groupId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByGroupId; finderArgs = new Object[] {groupId, start, end, orderByComparator}; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (groupId != dataCollection.getGroupId()) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where groupId = &#63;. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByGroupId_First( long groupId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByGroupId_First( groupId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where groupId = &#63;. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByGroupId_First( long groupId, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByGroupId( groupId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where groupId = &#63;. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByGroupId_Last( long groupId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByGroupId_Last( groupId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where groupId = &#63;. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByGroupId_Last( long groupId, OrderByComparator<DataCollection> orderByComparator) { int count = countByGroupId(groupId); if (count == 0) { return null; } List<DataCollection> list = findByGroupId( groupId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where groupId = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByGroupId_PrevAndNext( long dataCollectionId, long groupId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByGroupId_PrevAndNext( session, dataCollection, groupId, orderByComparator, true); array[1] = dataCollection; array[2] = getByGroupId_PrevAndNext( session, dataCollection, groupId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByGroupId_PrevAndNext( Session session, DataCollection dataCollection, long groupId, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the data collections that the user has permission to view where groupId = &#63;. * * @param groupId the group ID * @return the matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByGroupId(long groupId) { return filterFindByGroupId( groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections that the user has permission to view where groupId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByGroupId( long groupId, int start, int end) { return filterFindByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the data collections that the user has permissions to view where groupId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByGroupId( long groupId, int start, int end, OrderByComparator<DataCollection> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId(groupId, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); return (List<DataCollection>)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the data collections before and after the current data collection in the ordered set of data collections that the user has permission to view where groupId = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] filterFindByGroupId_PrevAndNext( long dataCollectionId, long groupId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId_PrevAndNext( dataCollectionId, groupId, orderByComparator); } DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = filterGetByGroupId_PrevAndNext( session, dataCollection, groupId, orderByComparator, true); array[1] = dataCollection; array[2] = filterGetByGroupId_PrevAndNext( session, dataCollection, groupId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection filterGetByGroupId_PrevAndNext( Session session, DataCollection dataCollection, long groupId, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where groupId = &#63; from the database. * * @param groupId the group ID */ @Override public void removeByGroupId(long groupId) { for (DataCollection dataCollection : findByGroupId( groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where groupId = &#63;. * * @param groupId the group ID * @return the number of matching data collections */ @Override public int countByGroupId(long groupId) { FinderPath finderPath = _finderPathCountByGroupId; Object[] finderArgs = new Object[] {groupId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of data collections that the user has permission to view where groupId = &#63;. * * @param groupId the group ID * @return the number of matching data collections that the user has permission to view */ @Override public int filterCountByGroupId(long groupId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByGroupId(groupId); } StringBundler sb = new StringBundler(2); sb.append(_FILTER_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dataCollection.groupId = ?"; private FinderPath _finderPathWithPaginationFindByUserId; private FinderPath _finderPathWithoutPaginationFindByUserId; private FinderPath _finderPathCountByUserId; /** * Returns all the data collections where userId = &#63;. * * @param userId the user ID * @return the matching data collections */ @Override public List<DataCollection> findByUserId(long userId) { return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByUserId(long userId, int start, int end) { return findByUserId(userId, start, end, null); } /** * Returns an ordered range of all the data collections where userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByUserId( long userId, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByUserId(userId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByUserId( long userId, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByUserId; finderArgs = new Object[] {userId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByUserId; finderArgs = new Object[] {userId, start, end, orderByComparator}; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (userId != dataCollection.getUserId()) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_USERID_USERID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(userId); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where userId = &#63;. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUserId_First( long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUserId_First( userId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("userId="); sb.append(userId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where userId = &#63;. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUserId_First( long userId, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByUserId( userId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where userId = &#63;. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUserId_Last( long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUserId_Last( userId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("userId="); sb.append(userId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where userId = &#63;. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUserId_Last( long userId, OrderByComparator<DataCollection> orderByComparator) { int count = countByUserId(userId); if (count == 0) { return null; } List<DataCollection> list = findByUserId( userId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where userId = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByUserId_PrevAndNext( long dataCollectionId, long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByUserId_PrevAndNext( session, dataCollection, userId, orderByComparator, true); array[1] = dataCollection; array[2] = getByUserId_PrevAndNext( session, dataCollection, userId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByUserId_PrevAndNext( Session session, DataCollection dataCollection, long userId, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_USERID_USERID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(userId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where userId = &#63; from the database. * * @param userId the user ID */ @Override public void removeByUserId(long userId) { for (DataCollection dataCollection : findByUserId( userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where userId = &#63;. * * @param userId the user ID * @return the number of matching data collections */ @Override public int countByUserId(long userId) { FinderPath finderPath = _finderPathCountByUserId; Object[] finderArgs = new Object[] {userId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_USERID_USERID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(userId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_USERID_USERID_2 = "dataCollection.userId = ?"; private FinderPath _finderPathWithPaginationFindByStatus; private FinderPath _finderPathWithoutPaginationFindByStatus; private FinderPath _finderPathCountByStatus; /** * Returns all the data collections where status = &#63;. * * @param status the status * @return the matching data collections */ @Override public List<DataCollection> findByStatus(int status) { return findByStatus(status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByStatus(int status, int start, int end) { return findByStatus(status, start, end, null); } /** * Returns an ordered range of all the data collections where status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByStatus( int status, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByStatus(status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByStatus( int status, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByStatus; finderArgs = new Object[] {status}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByStatus; finderArgs = new Object[] {status, start, end, orderByComparator}; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (status != dataCollection.getStatus()) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_STATUS_STATUS_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(status); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where status = &#63;. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByStatus_First( int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByStatus_First( status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where status = &#63;. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByStatus_First( int status, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByStatus( status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where status = &#63;. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByStatus_Last( int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByStatus_Last( status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where status = &#63;. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByStatus_Last( int status, OrderByComparator<DataCollection> orderByComparator) { int count = countByStatus(status); if (count == 0) { return null; } List<DataCollection> list = findByStatus( status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where status = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByStatus_PrevAndNext( long dataCollectionId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByStatus_PrevAndNext( session, dataCollection, status, orderByComparator, true); array[1] = dataCollection; array[2] = getByStatus_PrevAndNext( session, dataCollection, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByStatus_PrevAndNext( Session session, DataCollection dataCollection, int status, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_STATUS_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where status = &#63; from the database. * * @param status the status */ @Override public void removeByStatus(int status) { for (DataCollection dataCollection : findByStatus( status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where status = &#63;. * * @param status the status * @return the number of matching data collections */ @Override public int countByStatus(int status) { FinderPath finderPath = _finderPathCountByStatus; Object[] finderArgs = new Object[] {status}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_STATUS_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(status); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_STATUS_STATUS_2 = "dataCollection.status = ?"; private FinderPath _finderPathWithPaginationFindByG_U; private FinderPath _finderPathWithoutPaginationFindByG_U; private FinderPath _finderPathCountByG_U; /** * Returns all the data collections where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @return the matching data collections */ @Override public List<DataCollection> findByG_U(long groupId, long userId) { return findByG_U( groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where groupId = &#63; and userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByG_U( long groupId, long userId, int start, int end) { return findByG_U(groupId, userId, start, end, null); } /** * Returns an ordered range of all the data collections where groupId = &#63; and userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByG_U( long groupId, long userId, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByG_U(groupId, userId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where groupId = &#63; and userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByG_U( long groupId, long userId, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByG_U; finderArgs = new Object[] {groupId, userId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByG_U; finderArgs = new Object[] { groupId, userId, start, end, orderByComparator }; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if ((groupId != dataCollection.getGroupId()) || (userId != dataCollection.getUserId())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_USERID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(userId); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByG_U_First( long groupId, long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByG_U_First( groupId, userId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", userId="); sb.append(userId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByG_U_First( long groupId, long userId, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByG_U( groupId, userId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByG_U_Last( long groupId, long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByG_U_Last( groupId, userId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", userId="); sb.append(userId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByG_U_Last( long groupId, long userId, OrderByComparator<DataCollection> orderByComparator) { int count = countByG_U(groupId, userId); if (count == 0) { return null; } List<DataCollection> list = findByG_U( groupId, userId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where groupId = &#63; and userId = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByG_U_PrevAndNext( long dataCollectionId, long groupId, long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByG_U_PrevAndNext( session, dataCollection, groupId, userId, orderByComparator, true); array[1] = dataCollection; array[2] = getByG_U_PrevAndNext( session, dataCollection, groupId, userId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByG_U_PrevAndNext( Session session, DataCollection dataCollection, long groupId, long userId, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_USERID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(userId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the data collections that the user has permission to view where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @return the matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_U(long groupId, long userId) { return filterFindByG_U( groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections that the user has permission to view where groupId = &#63; and userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_U( long groupId, long userId, int start, int end) { return filterFindByG_U(groupId, userId, start, end, null); } /** * Returns an ordered range of all the data collections that the user has permissions to view where groupId = &#63; and userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_U( long groupId, long userId, int start, int end, OrderByComparator<DataCollection> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U(groupId, userId, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_G_U_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_USERID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(userId); return (List<DataCollection>)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the data collections before and after the current data collection in the ordered set of data collections that the user has permission to view where groupId = &#63; and userId = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] filterFindByG_U_PrevAndNext( long dataCollectionId, long groupId, long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_PrevAndNext( dataCollectionId, groupId, userId, orderByComparator); } DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = filterGetByG_U_PrevAndNext( session, dataCollection, groupId, userId, orderByComparator, true); array[1] = dataCollection; array[2] = filterGetByG_U_PrevAndNext( session, dataCollection, groupId, userId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection filterGetByG_U_PrevAndNext( Session session, DataCollection dataCollection, long groupId, long userId, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_G_U_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_USERID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(userId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where groupId = &#63; and userId = &#63; from the database. * * @param groupId the group ID * @param userId the user ID */ @Override public void removeByG_U(long groupId, long userId) { for (DataCollection dataCollection : findByG_U( groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @return the number of matching data collections */ @Override public int countByG_U(long groupId, long userId) { FinderPath finderPath = _finderPathCountByG_U; Object[] finderArgs = new Object[] {groupId, userId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_USERID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(userId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of data collections that the user has permission to view where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @return the number of matching data collections that the user has permission to view */ @Override public int filterCountByG_U(long groupId, long userId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_U(groupId, userId); } StringBundler sb = new StringBundler(3); sb.append(_FILTER_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_USERID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(userId); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "dataCollection.groupId = ? AND "; private static final String _FINDER_COLUMN_G_U_USERID_2 = "dataCollection.userId = ?"; private FinderPath _finderPathWithPaginationFindByG_S; private FinderPath _finderPathWithoutPaginationFindByG_S; private FinderPath _finderPathCountByG_S; /** * Returns all the data collections where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @return the matching data collections */ @Override public List<DataCollection> findByG_S(long groupId, int status) { return findByG_S( groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where groupId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByG_S( long groupId, int status, int start, int end) { return findByG_S(groupId, status, start, end, null); } /** * Returns an ordered range of all the data collections where groupId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByG_S( long groupId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByG_S(groupId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where groupId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByG_S( long groupId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByG_S; finderArgs = new Object[] {groupId, status}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByG_S; finderArgs = new Object[] { groupId, status, start, end, orderByComparator }; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if ((groupId != dataCollection.getGroupId()) || (status != dataCollection.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(status); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByG_S_First( long groupId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByG_S_First( groupId, status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByG_S_First( long groupId, int status, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByG_S( groupId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByG_S_Last( long groupId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByG_S_Last( groupId, status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByG_S_Last( long groupId, int status, OrderByComparator<DataCollection> orderByComparator) { int count = countByG_S(groupId, status); if (count == 0) { return null; } List<DataCollection> list = findByG_S( groupId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where groupId = &#63; and status = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByG_S_PrevAndNext( long dataCollectionId, long groupId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByG_S_PrevAndNext( session, dataCollection, groupId, status, orderByComparator, true); array[1] = dataCollection; array[2] = getByG_S_PrevAndNext( session, dataCollection, groupId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByG_S_PrevAndNext( Session session, DataCollection dataCollection, long groupId, int status, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the data collections that the user has permission to view where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @return the matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_S(long groupId, int status) { return filterFindByG_S( groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections that the user has permission to view where groupId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_S( long groupId, int status, int start, int end) { return filterFindByG_S(groupId, status, start, end, null); } /** * Returns an ordered range of all the data collections that the user has permissions to view where groupId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_S( long groupId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_S(groupId, status, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_G_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(status); return (List<DataCollection>)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the data collections before and after the current data collection in the ordered set of data collections that the user has permission to view where groupId = &#63; and status = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] filterFindByG_S_PrevAndNext( long dataCollectionId, long groupId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_S_PrevAndNext( dataCollectionId, groupId, status, orderByComparator); } DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = filterGetByG_S_PrevAndNext( session, dataCollection, groupId, status, orderByComparator, true); array[1] = dataCollection; array[2] = filterGetByG_S_PrevAndNext( session, dataCollection, groupId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection filterGetByG_S_PrevAndNext( Session session, DataCollection dataCollection, long groupId, int status, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_G_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where groupId = &#63; and status = &#63; from the database. * * @param groupId the group ID * @param status the status */ @Override public void removeByG_S(long groupId, int status) { for (DataCollection dataCollection : findByG_S( groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @return the number of matching data collections */ @Override public int countByG_S(long groupId, int status) { FinderPath finderPath = _finderPathCountByG_S; Object[] finderArgs = new Object[] {groupId, status}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_S_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(status); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of data collections that the user has permission to view where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @return the number of matching data collections that the user has permission to view */ @Override public int filterCountByG_S(long groupId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_S(groupId, status); } StringBundler sb = new StringBundler(3); sb.append(_FILTER_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(status); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "dataCollection.groupId = ? AND "; private static final String _FINDER_COLUMN_G_S_STATUS_2 = "dataCollection.status = ?"; private FinderPath _finderPathWithPaginationFindByU_S; private FinderPath _finderPathWithoutPaginationFindByU_S; private FinderPath _finderPathCountByU_S; /** * Returns all the data collections where userId = &#63; and status = &#63;. * * @param userId the user ID * @param status the status * @return the matching data collections */ @Override public List<DataCollection> findByU_S(long userId, int status) { return findByU_S( userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByU_S( long userId, int status, int start, int end) { return findByU_S(userId, status, start, end, null); } /** * Returns an ordered range of all the data collections where userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByU_S( long userId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByU_S(userId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByU_S( long userId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByU_S; finderArgs = new Object[] {userId, status}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByU_S; finderArgs = new Object[] { userId, status, start, end, orderByComparator }; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if ((userId != dataCollection.getUserId()) || (status != dataCollection.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_U_S_USERID_2); sb.append(_FINDER_COLUMN_U_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(userId); queryPos.add(status); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where userId = &#63; and status = &#63;. * * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByU_S_First( long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByU_S_First( userId, status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("userId="); sb.append(userId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where userId = &#63; and status = &#63;. * * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByU_S_First( long userId, int status, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByU_S( userId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where userId = &#63; and status = &#63;. * * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByU_S_Last( long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByU_S_Last( userId, status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("userId="); sb.append(userId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where userId = &#63; and status = &#63;. * * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByU_S_Last( long userId, int status, OrderByComparator<DataCollection> orderByComparator) { int count = countByU_S(userId, status); if (count == 0) { return null; } List<DataCollection> list = findByU_S( userId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where userId = &#63; and status = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByU_S_PrevAndNext( long dataCollectionId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByU_S_PrevAndNext( session, dataCollection, userId, status, orderByComparator, true); array[1] = dataCollection; array[2] = getByU_S_PrevAndNext( session, dataCollection, userId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByU_S_PrevAndNext( Session session, DataCollection dataCollection, long userId, int status, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_U_S_USERID_2); sb.append(_FINDER_COLUMN_U_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(userId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where userId = &#63; and status = &#63; from the database. * * @param userId the user ID * @param status the status */ @Override public void removeByU_S(long userId, int status) { for (DataCollection dataCollection : findByU_S( userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where userId = &#63; and status = &#63;. * * @param userId the user ID * @param status the status * @return the number of matching data collections */ @Override public int countByU_S(long userId, int status) { FinderPath finderPath = _finderPathCountByU_S; Object[] finderArgs = new Object[] {userId, status}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_U_S_USERID_2); sb.append(_FINDER_COLUMN_U_S_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(userId); queryPos.add(status); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_U_S_USERID_2 = "dataCollection.userId = ? AND "; private static final String _FINDER_COLUMN_U_S_STATUS_2 = "dataCollection.status = ?"; private FinderPath _finderPathWithPaginationFindByG_U_S; private FinderPath _finderPathWithoutPaginationFindByG_U_S; private FinderPath _finderPathCountByG_U_S; /** * Returns all the data collections where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @return the matching data collections */ @Override public List<DataCollection> findByG_U_S( long groupId, long userId, int status) { return findByG_U_S( groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where groupId = &#63; and userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByG_U_S( long groupId, long userId, int status, int start, int end) { return findByG_U_S(groupId, userId, status, start, end, null); } /** * Returns an ordered range of all the data collections where groupId = &#63; and userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByG_U_S( long groupId, long userId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByG_U_S( groupId, userId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where groupId = &#63; and userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByG_U_S( long groupId, long userId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByG_U_S; finderArgs = new Object[] {groupId, userId, status}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByG_U_S; finderArgs = new Object[] { groupId, userId, status, start, end, orderByComparator }; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if ((groupId != dataCollection.getGroupId()) || (userId != dataCollection.getUserId()) || (status != dataCollection.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(5); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_S_USERID_2); sb.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(userId); queryPos.add(status); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByG_U_S_First( long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByG_U_S_First( groupId, userId, status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(8); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", userId="); sb.append(userId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByG_U_S_First( long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByG_U_S( groupId, userId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByG_U_S_Last( long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByG_U_S_Last( groupId, userId, status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(8); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", userId="); sb.append(userId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByG_U_S_Last( long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) { int count = countByG_U_S(groupId, userId, status); if (count == 0) { return null; } List<DataCollection> list = findByG_U_S( groupId, userId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByG_U_S_PrevAndNext( long dataCollectionId, long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByG_U_S_PrevAndNext( session, dataCollection, groupId, userId, status, orderByComparator, true); array[1] = dataCollection; array[2] = getByG_U_S_PrevAndNext( session, dataCollection, groupId, userId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByG_U_S_PrevAndNext( Session session, DataCollection dataCollection, long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(5); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_S_USERID_2); sb.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(userId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the data collections that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @return the matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_U_S( long groupId, long userId, int status) { return filterFindByG_U_S( groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_U_S( long groupId, long userId, int status, int start, int end) { return filterFindByG_U_S(groupId, userId, status, start, end, null); } /** * Returns an ordered range of all the data collections that the user has permissions to view where groupId = &#63; and userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_U_S( long groupId, long userId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_S( groupId, userId, status, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(6); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_S_USERID_2); sb.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(userId); queryPos.add(status); return (List<DataCollection>)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the data collections before and after the current data collection in the ordered set of data collections that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] filterFindByG_U_S_PrevAndNext( long dataCollectionId, long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_S_PrevAndNext( dataCollectionId, groupId, userId, status, orderByComparator); } DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = filterGetByG_U_S_PrevAndNext( session, dataCollection, groupId, userId, status, orderByComparator, true); array[1] = dataCollection; array[2] = filterGetByG_U_S_PrevAndNext( session, dataCollection, groupId, userId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection filterGetByG_U_S_PrevAndNext( Session session, DataCollection dataCollection, long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 7 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(6); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_S_USERID_2); sb.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(userId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where groupId = &#63; and userId = &#63; and status = &#63; from the database. * * @param groupId the group ID * @param userId the user ID * @param status the status */ @Override public void removeByG_U_S(long groupId, long userId, int status) { for (DataCollection dataCollection : findByG_U_S( groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @return the number of matching data collections */ @Override public int countByG_U_S(long groupId, long userId, int status) { FinderPath finderPath = _finderPathCountByG_U_S; Object[] finderArgs = new Object[] {groupId, userId, status}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_S_USERID_2); sb.append(_FINDER_COLUMN_G_U_S_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(userId); queryPos.add(status); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of data collections that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @return the number of matching data collections that the user has permission to view */ @Override public int filterCountByG_U_S(long groupId, long userId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_U_S(groupId, userId, status); } StringBundler sb = new StringBundler(4); sb.append(_FILTER_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_S_USERID_2); sb.append(_FINDER_COLUMN_G_U_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(userId); queryPos.add(status); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "dataCollection.groupId = ? AND "; private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "dataCollection.userId = ? AND "; private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "dataCollection.status = ?"; private FinderPath _finderPathWithPaginationFindByName; private FinderPath _finderPathWithoutPaginationFindByName; private FinderPath _finderPathCountByName; /** * Returns all the data collections where name = &#63;. * * @param name the name * @return the matching data collections */ @Override public List<DataCollection> findByName(String name) { return findByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where name = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param name the name * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByName(String name, int start, int end) { return findByName(name, start, end, null); } /** * Returns an ordered range of all the data collections where name = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param name the name * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByName( String name, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByName(name, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where name = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param name the name * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByName( String name, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { name = Objects.toString(name, ""); FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByName; finderArgs = new Object[] {name}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByName; finderArgs = new Object[] {name, start, end, orderByComparator}; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (!name.equals(dataCollection.getName())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindName = false; if (name.isEmpty()) { sb.append(_FINDER_COLUMN_NAME_NAME_3); } else { bindName = true; sb.append(_FINDER_COLUMN_NAME_NAME_2); } if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindName) { queryPos.add(name); } list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where name = &#63;. * * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByName_First( String name, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByName_First( name, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("name="); sb.append(name); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where name = &#63;. * * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByName_First( String name, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByName(name, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where name = &#63;. * * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByName_Last( String name, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByName_Last( name, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("name="); sb.append(name); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where name = &#63;. * * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByName_Last( String name, OrderByComparator<DataCollection> orderByComparator) { int count = countByName(name); if (count == 0) { return null; } List<DataCollection> list = findByName( name, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where name = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByName_PrevAndNext( long dataCollectionId, String name, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { name = Objects.toString(name, ""); DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByName_PrevAndNext( session, dataCollection, name, orderByComparator, true); array[1] = dataCollection; array[2] = getByName_PrevAndNext( session, dataCollection, name, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByName_PrevAndNext( Session session, DataCollection dataCollection, String name, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindName = false; if (name.isEmpty()) { sb.append(_FINDER_COLUMN_NAME_NAME_3); } else { bindName = true; sb.append(_FINDER_COLUMN_NAME_NAME_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); if (bindName) { queryPos.add(name); } if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where name = &#63; from the database. * * @param name the name */ @Override public void removeByName(String name) { for (DataCollection dataCollection : findByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where name = &#63;. * * @param name the name * @return the number of matching data collections */ @Override public int countByName(String name) { name = Objects.toString(name, ""); FinderPath finderPath = _finderPathCountByName; Object[] finderArgs = new Object[] {name}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); boolean bindName = false; if (name.isEmpty()) { sb.append(_FINDER_COLUMN_NAME_NAME_3); } else { bindName = true; sb.append(_FINDER_COLUMN_NAME_NAME_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindName) { queryPos.add(name); } count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_NAME_NAME_2 = "dataCollection.name = ?"; private static final String _FINDER_COLUMN_NAME_NAME_3 = "(dataCollection.name IS NULL OR dataCollection.name = '')"; private FinderPath _finderPathFetchByOrganizationId; private FinderPath _finderPathCountByOrganizationId; /** * Returns the data collection where organizationId = &#63; or throws a <code>NoSuchDataCollectionException</code> if it could not be found. * * @param organizationId the organization ID * @return the matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByOrganizationId(long organizationId) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByOrganizationId(organizationId); if (dataCollection == null) { StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("organizationId="); sb.append(organizationId); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchDataCollectionException(sb.toString()); } return dataCollection; } /** * Returns the data collection where organizationId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param organizationId the organization ID * @return the matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByOrganizationId(long organizationId) { return fetchByOrganizationId(organizationId, true); } /** * Returns the data collection where organizationId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param organizationId the organization ID * @param useFinderCache whether to use the finder cache * @return the matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByOrganizationId( long organizationId, boolean useFinderCache) { Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] {organizationId}; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByOrganizationId, finderArgs, this); } if (result instanceof DataCollection) { DataCollection dataCollection = (DataCollection)result; if (organizationId != dataCollection.getOrganizationId()) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(organizationId); List<DataCollection> list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByOrganizationId, finderArgs, list); } } else { if (list.size() > 1) { Collections.sort(list, Collections.reverseOrder()); if (_log.isWarnEnabled()) { if (!useFinderCache) { finderArgs = new Object[] {organizationId}; } _log.warn( "DataCollectionPersistenceImpl.fetchByOrganizationId(long, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } } DataCollection dataCollection = list.get(0); result = dataCollection; cacheResult(dataCollection); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult( _finderPathFetchByOrganizationId, finderArgs); } throw processException(exception); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (DataCollection)result; } } /** * Removes the data collection where organizationId = &#63; from the database. * * @param organizationId the organization ID * @return the data collection that was removed */ @Override public DataCollection removeByOrganizationId(long organizationId) throws NoSuchDataCollectionException { DataCollection dataCollection = findByOrganizationId(organizationId); return remove(dataCollection); } /** * Returns the number of data collections where organizationId = &#63;. * * @param organizationId the organization ID * @return the number of matching data collections */ @Override public int countByOrganizationId(long organizationId) { FinderPath finderPath = _finderPathCountByOrganizationId; Object[] finderArgs = new Object[] {organizationId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(organizationId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2 = "dataCollection.organizationId = ?"; private FinderPath _finderPathFetchByNameVersion; private FinderPath _finderPathCountByNameVersion; /** * Returns the data collection where name = &#63; and version = &#63; or throws a <code>NoSuchDataCollectionException</code> if it could not be found. * * @param name the name * @param version the version * @return the matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByNameVersion(String name, String version) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByNameVersion(name, version); if (dataCollection == null) { StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("name="); sb.append(name); sb.append(", version="); sb.append(version); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchDataCollectionException(sb.toString()); } return dataCollection; } /** * Returns the data collection where name = &#63; and version = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param name the name * @param version the version * @return the matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByNameVersion(String name, String version) { return fetchByNameVersion(name, version, true); } /** * Returns the data collection where name = &#63; and version = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param name the name * @param version the version * @param useFinderCache whether to use the finder cache * @return the matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByNameVersion( String name, String version, boolean useFinderCache) { name = Objects.toString(name, ""); version = Objects.toString(version, ""); Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] {name, version}; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByNameVersion, finderArgs, this); } if (result instanceof DataCollection) { DataCollection dataCollection = (DataCollection)result; if (!Objects.equals(name, dataCollection.getName()) || !Objects.equals(version, dataCollection.getVersion())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindName = false; if (name.isEmpty()) { sb.append(_FINDER_COLUMN_NAMEVERSION_NAME_3); } else { bindName = true; sb.append(_FINDER_COLUMN_NAMEVERSION_NAME_2); } boolean bindVersion = false; if (version.isEmpty()) { sb.append(_FINDER_COLUMN_NAMEVERSION_VERSION_3); } else { bindVersion = true; sb.append(_FINDER_COLUMN_NAMEVERSION_VERSION_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindName) { queryPos.add(name); } if (bindVersion) { queryPos.add(version); } List<DataCollection> list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByNameVersion, finderArgs, list); } } else { if (list.size() > 1) { Collections.sort(list, Collections.reverseOrder()); if (_log.isWarnEnabled()) { if (!useFinderCache) { finderArgs = new Object[] {name, version}; } _log.warn( "DataCollectionPersistenceImpl.fetchByNameVersion(String, String, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } } DataCollection dataCollection = list.get(0); result = dataCollection; cacheResult(dataCollection); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult( _finderPathFetchByNameVersion, finderArgs); } throw processException(exception); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (DataCollection)result; } } /** * Removes the data collection where name = &#63; and version = &#63; from the database. * * @param name the name * @param version the version * @return the data collection that was removed */ @Override public DataCollection removeByNameVersion(String name, String version) throws NoSuchDataCollectionException { DataCollection dataCollection = findByNameVersion(name, version); return remove(dataCollection); } /** * Returns the number of data collections where name = &#63; and version = &#63;. * * @param name the name * @param version the version * @return the number of matching data collections */ @Override public int countByNameVersion(String name, String version) { name = Objects.toString(name, ""); version = Objects.toString(version, ""); FinderPath finderPath = _finderPathCountByNameVersion; Object[] finderArgs = new Object[] {name, version}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); boolean bindName = false; if (name.isEmpty()) { sb.append(_FINDER_COLUMN_NAMEVERSION_NAME_3); } else { bindName = true; sb.append(_FINDER_COLUMN_NAMEVERSION_NAME_2); } boolean bindVersion = false; if (version.isEmpty()) { sb.append(_FINDER_COLUMN_NAMEVERSION_VERSION_3); } else { bindVersion = true; sb.append(_FINDER_COLUMN_NAMEVERSION_VERSION_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindName) { queryPos.add(name); } if (bindVersion) { queryPos.add(version); } count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_NAMEVERSION_NAME_2 = "dataCollection.name = ? AND "; private static final String _FINDER_COLUMN_NAMEVERSION_NAME_3 = "(dataCollection.name IS NULL OR dataCollection.name = '') AND "; private static final String _FINDER_COLUMN_NAMEVERSION_VERSION_2 = "dataCollection.version = ?"; private static final String _FINDER_COLUMN_NAMEVERSION_VERSION_3 = "(dataCollection.version IS NULL OR dataCollection.version = '')"; private FinderPath _finderPathWithPaginationFindByVariants; private FinderPath _finderPathWithoutPaginationFindByVariants; private FinderPath _finderPathCountByVariants; /** * Returns all the data collections where copiedFrom = &#63;. * * @param copiedFrom the copied from * @return the matching data collections */ @Override public List<DataCollection> findByVariants(long copiedFrom) { return findByVariants( copiedFrom, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where copiedFrom = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param copiedFrom the copied from * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByVariants( long copiedFrom, int start, int end) { return findByVariants(copiedFrom, start, end, null); } /** * Returns an ordered range of all the data collections where copiedFrom = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param copiedFrom the copied from * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByVariants( long copiedFrom, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByVariants(copiedFrom, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where copiedFrom = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param copiedFrom the copied from * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByVariants( long copiedFrom, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByVariants; finderArgs = new Object[] {copiedFrom}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByVariants; finderArgs = new Object[] { copiedFrom, start, end, orderByComparator }; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (copiedFrom != dataCollection.getCopiedFrom()) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_VARIANTS_COPIEDFROM_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(copiedFrom); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where copiedFrom = &#63;. * * @param copiedFrom the copied from * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByVariants_First( long copiedFrom, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByVariants_First( copiedFrom, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("copiedFrom="); sb.append(copiedFrom); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where copiedFrom = &#63;. * * @param copiedFrom the copied from * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByVariants_First( long copiedFrom, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByVariants( copiedFrom, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where copiedFrom = &#63;. * * @param copiedFrom the copied from * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByVariants_Last( long copiedFrom, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByVariants_Last( copiedFrom, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("copiedFrom="); sb.append(copiedFrom); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where copiedFrom = &#63;. * * @param copiedFrom the copied from * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByVariants_Last( long copiedFrom, OrderByComparator<DataCollection> orderByComparator) { int count = countByVariants(copiedFrom); if (count == 0) { return null; } List<DataCollection> list = findByVariants( copiedFrom, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where copiedFrom = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param copiedFrom the copied from * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByVariants_PrevAndNext( long dataCollectionId, long copiedFrom, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByVariants_PrevAndNext( session, dataCollection, copiedFrom, orderByComparator, true); array[1] = dataCollection; array[2] = getByVariants_PrevAndNext( session, dataCollection, copiedFrom, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByVariants_PrevAndNext( Session session, DataCollection dataCollection, long copiedFrom, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_VARIANTS_COPIEDFROM_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(copiedFrom); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where copiedFrom = &#63; from the database. * * @param copiedFrom the copied from */ @Override public void removeByVariants(long copiedFrom) { for (DataCollection dataCollection : findByVariants( copiedFrom, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where copiedFrom = &#63;. * * @param copiedFrom the copied from * @return the number of matching data collections */ @Override public int countByVariants(long copiedFrom) { FinderPath finderPath = _finderPathCountByVariants; Object[] finderArgs = new Object[] {copiedFrom}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_VARIANTS_COPIEDFROM_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(copiedFrom); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_VARIANTS_COPIEDFROM_2 = "dataCollection.copiedFrom = ?"; public DataCollectionPersistenceImpl() { setModelClass(DataCollection.class); setModelImplClass(DataCollectionImpl.class); setModelPKClass(long.class); Map<String, String> dbColumnNames = new HashMap<String, String>(); dbColumnNames.put("uuid", "uuid_"); setDBColumnNames(dbColumnNames); } /** * Caches the data collection in the entity cache if it is enabled. * * @param dataCollection the data collection */ @Override public void cacheResult(DataCollection dataCollection) { entityCache.putResult( entityCacheEnabled, DataCollectionImpl.class, dataCollection.getPrimaryKey(), dataCollection); finderCache.putResult( _finderPathFetchByUUID_G, new Object[] { dataCollection.getUuid(), dataCollection.getGroupId() }, dataCollection); finderCache.putResult( _finderPathFetchByOrganizationId, new Object[] {dataCollection.getOrganizationId()}, dataCollection); finderCache.putResult( _finderPathFetchByNameVersion, new Object[] { dataCollection.getName(), dataCollection.getVersion() }, dataCollection); dataCollection.resetOriginalValues(); } /** * Caches the data collections in the entity cache if it is enabled. * * @param dataCollections the data collections */ @Override public void cacheResult(List<DataCollection> dataCollections) { for (DataCollection dataCollection : dataCollections) { if (entityCache.getResult( entityCacheEnabled, DataCollectionImpl.class, dataCollection.getPrimaryKey()) == null) { cacheResult(dataCollection); } else { dataCollection.resetOriginalValues(); } } } /** * Clears the cache for all data collections. * * <p> * The <code>EntityCache</code> and <code>FinderCache</code> are both cleared by this method. * </p> */ @Override public void clearCache() { entityCache.clearCache(DataCollectionImpl.class); finderCache.clearCache(FINDER_CLASS_NAME_ENTITY); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the data collection. * * <p> * The <code>EntityCache</code> and <code>FinderCache</code> are both cleared by this method. * </p> */ @Override public void clearCache(DataCollection dataCollection) { entityCache.removeResult( entityCacheEnabled, DataCollectionImpl.class, dataCollection.getPrimaryKey()); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((DataCollectionModelImpl)dataCollection, true); } @Override public void clearCache(List<DataCollection> dataCollections) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (DataCollection dataCollection : dataCollections) { entityCache.removeResult( entityCacheEnabled, DataCollectionImpl.class, dataCollection.getPrimaryKey()); clearUniqueFindersCache( (DataCollectionModelImpl)dataCollection, true); } } public void clearCache(Set<Serializable> primaryKeys) { finderCache.clearCache(FINDER_CLASS_NAME_ENTITY); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (Serializable primaryKey : primaryKeys) { entityCache.removeResult( entityCacheEnabled, DataCollectionImpl.class, primaryKey); } } protected void cacheUniqueFindersCache( DataCollectionModelImpl dataCollectionModelImpl) { Object[] args = new Object[] { dataCollectionModelImpl.getUuid(), dataCollectionModelImpl.getGroupId() }; finderCache.putResult( _finderPathCountByUUID_G, args, Long.valueOf(1), false); finderCache.putResult( _finderPathFetchByUUID_G, args, dataCollectionModelImpl, false); args = new Object[] {dataCollectionModelImpl.getOrganizationId()}; finderCache.putResult( _finderPathCountByOrganizationId, args, Long.valueOf(1), false); finderCache.putResult( _finderPathFetchByOrganizationId, args, dataCollectionModelImpl, false); args = new Object[] { dataCollectionModelImpl.getName(), dataCollectionModelImpl.getVersion() }; finderCache.putResult( _finderPathCountByNameVersion, args, Long.valueOf(1), false); finderCache.putResult( _finderPathFetchByNameVersion, args, dataCollectionModelImpl, false); } protected void clearUniqueFindersCache( DataCollectionModelImpl dataCollectionModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { dataCollectionModelImpl.getUuid(), dataCollectionModelImpl.getGroupId() }; finderCache.removeResult(_finderPathCountByUUID_G, args); finderCache.removeResult(_finderPathFetchByUUID_G, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathFetchByUUID_G.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalUuid(), dataCollectionModelImpl.getOriginalGroupId() }; finderCache.removeResult(_finderPathCountByUUID_G, args); finderCache.removeResult(_finderPathFetchByUUID_G, args); } if (clearCurrent) { Object[] args = new Object[] { dataCollectionModelImpl.getOrganizationId() }; finderCache.removeResult(_finderPathCountByOrganizationId, args); finderCache.removeResult(_finderPathFetchByOrganizationId, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathFetchByOrganizationId.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalOrganizationId() }; finderCache.removeResult(_finderPathCountByOrganizationId, args); finderCache.removeResult(_finderPathFetchByOrganizationId, args); } if (clearCurrent) { Object[] args = new Object[] { dataCollectionModelImpl.getName(), dataCollectionModelImpl.getVersion() }; finderCache.removeResult(_finderPathCountByNameVersion, args); finderCache.removeResult(_finderPathFetchByNameVersion, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathFetchByNameVersion.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalName(), dataCollectionModelImpl.getOriginalVersion() }; finderCache.removeResult(_finderPathCountByNameVersion, args); finderCache.removeResult(_finderPathFetchByNameVersion, args); } } /** * Creates a new data collection with the primary key. Does not add the data collection to the database. * * @param dataCollectionId the primary key for the new data collection * @return the new data collection */ @Override public DataCollection create(long dataCollectionId) { DataCollection dataCollection = new DataCollectionImpl(); dataCollection.setNew(true); dataCollection.setPrimaryKey(dataCollectionId); String uuid = PortalUUIDUtil.generate(); dataCollection.setUuid(uuid); dataCollection.setCompanyId(CompanyThreadLocal.getCompanyId()); return dataCollection; } /** * Removes the data collection with the primary key from the database. Also notifies the appropriate model listeners. * * @param dataCollectionId the primary key of the data collection * @return the data collection that was removed * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection remove(long dataCollectionId) throws NoSuchDataCollectionException { return remove((Serializable)dataCollectionId); } /** * Removes the data collection with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the data collection * @return the data collection that was removed * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection remove(Serializable primaryKey) throws NoSuchDataCollectionException { Session session = null; try { session = openSession(); DataCollection dataCollection = (DataCollection)session.get( DataCollectionImpl.class, primaryKey); if (dataCollection == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchDataCollectionException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(dataCollection); } catch (NoSuchDataCollectionException noSuchEntityException) { throw noSuchEntityException; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } @Override protected DataCollection removeImpl(DataCollection dataCollection) { Session session = null; try { session = openSession(); if (!session.contains(dataCollection)) { dataCollection = (DataCollection)session.get( DataCollectionImpl.class, dataCollection.getPrimaryKeyObj()); } if (dataCollection != null) { session.delete(dataCollection); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } if (dataCollection != null) { clearCache(dataCollection); } return dataCollection; } @Override public DataCollection updateImpl(DataCollection dataCollection) { boolean isNew = dataCollection.isNew(); if (!(dataCollection instanceof DataCollectionModelImpl)) { InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(dataCollection.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler( dataCollection); throw new IllegalArgumentException( "Implement ModelWrapper in dataCollection proxy " + invocationHandler.getClass()); } throw new IllegalArgumentException( "Implement ModelWrapper in custom DataCollection implementation " + dataCollection.getClass()); } DataCollectionModelImpl dataCollectionModelImpl = (DataCollectionModelImpl)dataCollection; if (Validator.isNull(dataCollection.getUuid())) { String uuid = PortalUUIDUtil.generate(); dataCollection.setUuid(uuid); } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (dataCollection.getCreateDate() == null)) { if (serviceContext == null) { dataCollection.setCreateDate(now); } else { dataCollection.setCreateDate(serviceContext.getCreateDate(now)); } } if (!dataCollectionModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { dataCollection.setModifiedDate(now); } else { dataCollection.setModifiedDate( serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (dataCollection.isNew()) { session.save(dataCollection); dataCollection.setNew(false); } else { dataCollection = (DataCollection)session.merge(dataCollection); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!_columnBitmaskEnabled) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] {dataCollectionModelImpl.getUuid()}; finderCache.removeResult(_finderPathCountByUuid, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUuid, args); args = new Object[] { dataCollectionModelImpl.getUuid(), dataCollectionModelImpl.getCompanyId() }; finderCache.removeResult(_finderPathCountByUuid_C, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUuid_C, args); args = new Object[] {dataCollectionModelImpl.getGroupId()}; finderCache.removeResult(_finderPathCountByGroupId, args); finderCache.removeResult( _finderPathWithoutPaginationFindByGroupId, args); args = new Object[] {dataCollectionModelImpl.getUserId()}; finderCache.removeResult(_finderPathCountByUserId, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUserId, args); args = new Object[] {dataCollectionModelImpl.getStatus()}; finderCache.removeResult(_finderPathCountByStatus, args); finderCache.removeResult( _finderPathWithoutPaginationFindByStatus, args); args = new Object[] { dataCollectionModelImpl.getGroupId(), dataCollectionModelImpl.getUserId() }; finderCache.removeResult(_finderPathCountByG_U, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_U, args); args = new Object[] { dataCollectionModelImpl.getGroupId(), dataCollectionModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByG_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_S, args); args = new Object[] { dataCollectionModelImpl.getUserId(), dataCollectionModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByU_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByU_S, args); args = new Object[] { dataCollectionModelImpl.getGroupId(), dataCollectionModelImpl.getUserId(), dataCollectionModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByG_U_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_U_S, args); args = new Object[] {dataCollectionModelImpl.getName()}; finderCache.removeResult(_finderPathCountByName, args); finderCache.removeResult( _finderPathWithoutPaginationFindByName, args); args = new Object[] {dataCollectionModelImpl.getCopiedFrom()}; finderCache.removeResult(_finderPathCountByVariants, args); finderCache.removeResult( _finderPathWithoutPaginationFindByVariants, args); finderCache.removeResult(_finderPathCountAll, FINDER_ARGS_EMPTY); finderCache.removeResult( _finderPathWithoutPaginationFindAll, FINDER_ARGS_EMPTY); } else { if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByUuid.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalUuid() }; finderCache.removeResult(_finderPathCountByUuid, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUuid, args); args = new Object[] {dataCollectionModelImpl.getUuid()}; finderCache.removeResult(_finderPathCountByUuid, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUuid, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByUuid_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalUuid(), dataCollectionModelImpl.getOriginalCompanyId() }; finderCache.removeResult(_finderPathCountByUuid_C, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUuid_C, args); args = new Object[] { dataCollectionModelImpl.getUuid(), dataCollectionModelImpl.getCompanyId() }; finderCache.removeResult(_finderPathCountByUuid_C, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUuid_C, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByGroupId. getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalGroupId() }; finderCache.removeResult(_finderPathCountByGroupId, args); finderCache.removeResult( _finderPathWithoutPaginationFindByGroupId, args); args = new Object[] {dataCollectionModelImpl.getGroupId()}; finderCache.removeResult(_finderPathCountByGroupId, args); finderCache.removeResult( _finderPathWithoutPaginationFindByGroupId, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByUserId.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalUserId() }; finderCache.removeResult(_finderPathCountByUserId, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUserId, args); args = new Object[] {dataCollectionModelImpl.getUserId()}; finderCache.removeResult(_finderPathCountByUserId, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUserId, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByStatus.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalStatus() }; finderCache.removeResult(_finderPathCountByStatus, args); finderCache.removeResult( _finderPathWithoutPaginationFindByStatus, args); args = new Object[] {dataCollectionModelImpl.getStatus()}; finderCache.removeResult(_finderPathCountByStatus, args); finderCache.removeResult( _finderPathWithoutPaginationFindByStatus, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByG_U.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalGroupId(), dataCollectionModelImpl.getOriginalUserId() }; finderCache.removeResult(_finderPathCountByG_U, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_U, args); args = new Object[] { dataCollectionModelImpl.getGroupId(), dataCollectionModelImpl.getUserId() }; finderCache.removeResult(_finderPathCountByG_U, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_U, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByG_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalGroupId(), dataCollectionModelImpl.getOriginalStatus() }; finderCache.removeResult(_finderPathCountByG_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_S, args); args = new Object[] { dataCollectionModelImpl.getGroupId(), dataCollectionModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByG_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_S, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByU_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalUserId(), dataCollectionModelImpl.getOriginalStatus() }; finderCache.removeResult(_finderPathCountByU_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByU_S, args); args = new Object[] { dataCollectionModelImpl.getUserId(), dataCollectionModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByU_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByU_S, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByG_U_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalGroupId(), dataCollectionModelImpl.getOriginalUserId(), dataCollectionModelImpl.getOriginalStatus() }; finderCache.removeResult(_finderPathCountByG_U_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_U_S, args); args = new Object[] { dataCollectionModelImpl.getGroupId(), dataCollectionModelImpl.getUserId(), dataCollectionModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByG_U_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_U_S, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByName.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalName() }; finderCache.removeResult(_finderPathCountByName, args); finderCache.removeResult( _finderPathWithoutPaginationFindByName, args); args = new Object[] {dataCollectionModelImpl.getName()}; finderCache.removeResult(_finderPathCountByName, args); finderCache.removeResult( _finderPathWithoutPaginationFindByName, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByVariants. getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalCopiedFrom() }; finderCache.removeResult(_finderPathCountByVariants, args); finderCache.removeResult( _finderPathWithoutPaginationFindByVariants, args); args = new Object[] {dataCollectionModelImpl.getCopiedFrom()}; finderCache.removeResult(_finderPathCountByVariants, args); finderCache.removeResult( _finderPathWithoutPaginationFindByVariants, args); } } entityCache.putResult( entityCacheEnabled, DataCollectionImpl.class, dataCollection.getPrimaryKey(), dataCollection, false); clearUniqueFindersCache(dataCollectionModelImpl, false); cacheUniqueFindersCache(dataCollectionModelImpl); dataCollection.resetOriginalValues(); return dataCollection; } /** * Returns the data collection with the primary key or throws a <code>com.liferay.portal.kernel.exception.NoSuchModelException</code> if it could not be found. * * @param primaryKey the primary key of the data collection * @return the data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection findByPrimaryKey(Serializable primaryKey) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByPrimaryKey(primaryKey); if (dataCollection == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchDataCollectionException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return dataCollection; } /** * Returns the data collection with the primary key or throws a <code>NoSuchDataCollectionException</code> if it could not be found. * * @param dataCollectionId the primary key of the data collection * @return the data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection findByPrimaryKey(long dataCollectionId) throws NoSuchDataCollectionException { return findByPrimaryKey((Serializable)dataCollectionId); } /** * Returns the data collection with the primary key or returns <code>null</code> if it could not be found. * * @param dataCollectionId the primary key of the data collection * @return the data collection, or <code>null</code> if a data collection with the primary key could not be found */ @Override public DataCollection fetchByPrimaryKey(long dataCollectionId) { return fetchByPrimaryKey((Serializable)dataCollectionId); } /** * Returns all the data collections. * * @return the data collections */ @Override public List<DataCollection> findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of data collections */ @Override public List<DataCollection> findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the data collections. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of data collections */ @Override public List<DataCollection> findAll( int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of data collections */ @Override public List<DataCollection> findAll( int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindAll; finderArgs = FINDER_ARGS_EMPTY; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindAll; finderArgs = new Object[] {start, end, orderByComparator}; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); } if (list == null) { StringBundler sb = null; String sql = null; if (orderByComparator != null) { sb = new StringBundler( 2 + (orderByComparator.getOrderByFields().length * 2)); sb.append(_SQL_SELECT_DATACOLLECTION); appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = sb.toString(); } else { sql = _SQL_SELECT_DATACOLLECTION; sql = sql.concat(DataCollectionModelImpl.ORDER_BY_JPQL); } Session session = null; try { session = openSession(); Query query = session.createQuery(sql); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Removes all the data collections from the database. * */ @Override public void removeAll() { for (DataCollection dataCollection : findAll()) { remove(dataCollection); } } /** * Returns the number of data collections. * * @return the number of data collections */ @Override public int countAll() { Long count = (Long)finderCache.getResult( _finderPathCountAll, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query query = session.createQuery(_SQL_COUNT_DATACOLLECTION); count = (Long)query.uniqueResult(); finderCache.putResult( _finderPathCountAll, FINDER_ARGS_EMPTY, count); } catch (Exception exception) { finderCache.removeResult( _finderPathCountAll, FINDER_ARGS_EMPTY); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } @Override public Set<String> getBadColumnNames() { return _badColumnNames; } @Override protected EntityCache getEntityCache() { return entityCache; } @Override protected String getPKDBName() { return "dataCollectionId"; } @Override protected String getSelectSQL() { return _SQL_SELECT_DATACOLLECTION; } @Override protected Map<String, Integer> getTableColumnsMap() { return DataCollectionModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the data collection persistence. */ @Activate public void activate() { DataCollectionModelImpl.setEntityCacheEnabled(entityCacheEnabled); DataCollectionModelImpl.setFinderCacheEnabled(finderCacheEnabled); _finderPathWithPaginationFindAll = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); _finderPathWithoutPaginationFindAll = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); _finderPathCountAll = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); _finderPathWithPaginationFindByUuid = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByUuid = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid", new String[] {String.class.getName()}, DataCollectionModelImpl.UUID_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByUuid = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid", new String[] {String.class.getName()}); _finderPathFetchByUUID_G = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G", new String[] {String.class.getName(), Long.class.getName()}, DataCollectionModelImpl.UUID_COLUMN_BITMASK | DataCollectionModelImpl.GROUPID_COLUMN_BITMASK); _finderPathCountByUUID_G = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G", new String[] {String.class.getName(), Long.class.getName()}); _finderPathWithPaginationFindByUuid_C = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByUuid_C = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C", new String[] {String.class.getName(), Long.class.getName()}, DataCollectionModelImpl.UUID_COLUMN_BITMASK | DataCollectionModelImpl.COMPANYID_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByUuid_C = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C", new String[] {String.class.getName(), Long.class.getName()}); _finderPathWithPaginationFindByGroupId = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByGroupId = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId", new String[] {Long.class.getName()}, DataCollectionModelImpl.GROUPID_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByGroupId = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId", new String[] {Long.class.getName()}); _finderPathWithPaginationFindByUserId = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByUserId = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId", new String[] {Long.class.getName()}, DataCollectionModelImpl.USERID_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByUserId = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId", new String[] {Long.class.getName()}); _finderPathWithPaginationFindByStatus = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByStatus", new String[] { Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByStatus = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStatus", new String[] {Integer.class.getName()}, DataCollectionModelImpl.STATUS_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByStatus = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStatus", new String[] {Integer.class.getName()}); _finderPathWithPaginationFindByG_U = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByG_U = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U", new String[] {Long.class.getName(), Long.class.getName()}, DataCollectionModelImpl.GROUPID_COLUMN_BITMASK | DataCollectionModelImpl.USERID_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByG_U = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U", new String[] {Long.class.getName(), Long.class.getName()}); _finderPathWithPaginationFindByG_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByG_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S", new String[] {Long.class.getName(), Integer.class.getName()}, DataCollectionModelImpl.GROUPID_COLUMN_BITMASK | DataCollectionModelImpl.STATUS_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByG_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S", new String[] {Long.class.getName(), Integer.class.getName()}); _finderPathWithPaginationFindByU_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_S", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByU_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_S", new String[] {Long.class.getName(), Integer.class.getName()}, DataCollectionModelImpl.USERID_COLUMN_BITMASK | DataCollectionModelImpl.STATUS_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByU_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_S", new String[] {Long.class.getName(), Integer.class.getName()}); _finderPathWithPaginationFindByG_U_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByG_U_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, DataCollectionModelImpl.GROUPID_COLUMN_BITMASK | DataCollectionModelImpl.USERID_COLUMN_BITMASK | DataCollectionModelImpl.STATUS_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByG_U_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); _finderPathWithPaginationFindByName = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByName", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByName = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByName", new String[] {String.class.getName()}, DataCollectionModelImpl.NAME_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByName = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByName", new String[] {String.class.getName()}); _finderPathFetchByOrganizationId = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByOrganizationId", new String[] {Long.class.getName()}, DataCollectionModelImpl.ORGANIZATIONID_COLUMN_BITMASK); _finderPathCountByOrganizationId = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByOrganizationId", new String[] {Long.class.getName()}); _finderPathFetchByNameVersion = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByNameVersion", new String[] {String.class.getName(), String.class.getName()}, DataCollectionModelImpl.NAME_COLUMN_BITMASK | DataCollectionModelImpl.VERSION_COLUMN_BITMASK); _finderPathCountByNameVersion = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByNameVersion", new String[] {String.class.getName(), String.class.getName()}); _finderPathWithPaginationFindByVariants = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByVariants", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByVariants = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByVariants", new String[] {Long.class.getName()}, DataCollectionModelImpl.COPIEDFROM_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByVariants = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVariants", new String[] {Long.class.getName()}); } @Deactivate public void deactivate() { entityCache.removeCache(DataCollectionImpl.class.getName()); finderCache.removeCache(FINDER_CLASS_NAME_ENTITY); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @Override @Reference( target = ICECAPPersistenceConstants.SERVICE_CONFIGURATION_FILTER, unbind = "-" ) public void setConfiguration(Configuration configuration) { super.setConfiguration(configuration); _columnBitmaskEnabled = GetterUtil.getBoolean( configuration.get( "value.object.column.bitmask.enabled.com.osp.icecap.model.DataCollection"), true); } @Override @Reference( target = ICECAPPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setDataSource(DataSource dataSource) { super.setDataSource(dataSource); } @Override @Reference( target = ICECAPPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setSessionFactory(SessionFactory sessionFactory) { super.setSessionFactory(sessionFactory); } private boolean _columnBitmaskEnabled; @Reference protected EntityCache entityCache; @Reference protected FinderCache finderCache; private static final String _SQL_SELECT_DATACOLLECTION = "SELECT dataCollection FROM DataCollection dataCollection"; private static final String _SQL_SELECT_DATACOLLECTION_WHERE = "SELECT dataCollection FROM DataCollection dataCollection WHERE "; private static final String _SQL_COUNT_DATACOLLECTION = "SELECT COUNT(dataCollection) FROM DataCollection dataCollection"; private static final String _SQL_COUNT_DATACOLLECTION_WHERE = "SELECT COUNT(dataCollection) FROM DataCollection dataCollection WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dataCollection.dataCollectionId"; private static final String _FILTER_SQL_SELECT_DATACOLLECTION_WHERE = "SELECT DISTINCT {dataCollection.*} FROM ICECAP_DataCollection dataCollection WHERE "; private static final String _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {ICECAP_DataCollection.*} FROM (SELECT DISTINCT dataCollection.dataCollectionId FROM ICECAP_DataCollection dataCollection WHERE "; private static final String _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN ICECAP_DataCollection ON TEMP_TABLE.dataCollectionId = ICECAP_DataCollection.dataCollectionId"; private static final String _FILTER_SQL_COUNT_DATACOLLECTION_WHERE = "SELECT COUNT(DISTINCT dataCollection.dataCollectionId) AS COUNT_VALUE FROM ICECAP_DataCollection dataCollection WHERE "; private static final String _FILTER_ENTITY_ALIAS = "dataCollection"; private static final String _FILTER_ENTITY_TABLE = "ICECAP_DataCollection"; private static final String _ORDER_BY_ENTITY_ALIAS = "dataCollection."; private static final String _ORDER_BY_ENTITY_TABLE = "ICECAP_DataCollection."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DataCollection exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DataCollection exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( DataCollectionPersistenceImpl.class); private static final Set<String> _badColumnNames = SetUtil.fromArray( new String[] {"uuid"}); static { try { Class.forName(ICECAPPersistenceConstants.class.getName()); } catch (ClassNotFoundException classNotFoundException) { throw new ExceptionInInitializerError(classNotFoundException); } } }
UTF-8
Java
285,760
java
DataCollectionPersistenceImpl.java
Java
[ { "context": "ode>portal.properties</code>\n * </p>\n *\n * @author Jerry H. Seo\n * @generated\n */\n@Component(service = DataCollec", "end": 3097, "score": 0.9998796582221985, "start": 3085, "tag": "NAME", "value": "Jerry H. Seo" } ]
null
[]
/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.osp.icecap.service.persistence.impl; import com.liferay.petra.string.StringBundler; import com.liferay.portal.kernel.configuration.Configuration; import com.liferay.portal.kernel.dao.orm.EntityCache; import com.liferay.portal.kernel.dao.orm.FinderCache; import com.liferay.portal.kernel.dao.orm.FinderPath; import com.liferay.portal.kernel.dao.orm.Query; import com.liferay.portal.kernel.dao.orm.QueryPos; import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.dao.orm.SQLQuery; import com.liferay.portal.kernel.dao.orm.Session; import com.liferay.portal.kernel.dao.orm.SessionFactory; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.security.auth.CompanyThreadLocal; import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil; import com.liferay.portal.kernel.service.ServiceContext; import com.liferay.portal.kernel.service.ServiceContextThreadLocal; import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl; import com.liferay.portal.kernel.util.GetterUtil; import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.util.ProxyUtil; import com.liferay.portal.kernel.util.SetUtil; import com.liferay.portal.kernel.util.StringUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.uuid.PortalUUIDUtil; import com.osp.icecap.exception.NoSuchDataCollectionException; import com.osp.icecap.model.DataCollection; import com.osp.icecap.model.impl.DataCollectionImpl; import com.osp.icecap.model.impl.DataCollectionModelImpl; import com.osp.icecap.service.persistence.DataCollectionPersistence; import com.osp.icecap.service.persistence.impl.constants.ICECAPPersistenceConstants; import java.io.Serializable; import java.lang.reflect.InvocationHandler; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import javax.sql.DataSource; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.component.annotations.Reference; /** * The persistence implementation for the data collection service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author <NAME> * @generated */ @Component(service = DataCollectionPersistence.class) public class DataCollectionPersistenceImpl extends BasePersistenceImpl<DataCollection> implements DataCollectionPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use <code>DataCollectionUtil</code> to access the data collection persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = DataCollectionImpl.class.getName(); public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List1"; public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List2"; private FinderPath _finderPathWithPaginationFindAll; private FinderPath _finderPathWithoutPaginationFindAll; private FinderPath _finderPathCountAll; private FinderPath _finderPathWithPaginationFindByUuid; private FinderPath _finderPathWithoutPaginationFindByUuid; private FinderPath _finderPathCountByUuid; /** * Returns all the data collections where uuid = &#63;. * * @param uuid the uuid * @return the matching data collections */ @Override public List<DataCollection> findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where uuid = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param uuid the uuid * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByUuid(String uuid, int start, int end) { return findByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the data collections where uuid = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param uuid the uuid * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByUuid( String uuid, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByUuid(uuid, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where uuid = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param uuid the uuid * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByUuid( String uuid, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByUuid; finderArgs = new Object[] {uuid}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByUuid; finderArgs = new Object[] {uuid, start, end, orderByComparator}; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (!uuid.equals(dataCollection.getUuid())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where uuid = &#63;. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUuid_First( String uuid, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUuid_First( uuid, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where uuid = &#63;. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUuid_First( String uuid, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByUuid(uuid, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where uuid = &#63;. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUuid_Last( String uuid, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUuid_Last( uuid, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where uuid = &#63;. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUuid_Last( String uuid, OrderByComparator<DataCollection> orderByComparator) { int count = countByUuid(uuid); if (count == 0) { return null; } List<DataCollection> list = findByUuid( uuid, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where uuid = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByUuid_PrevAndNext( long dataCollectionId, String uuid, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { uuid = Objects.toString(uuid, ""); DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByUuid_PrevAndNext( session, dataCollection, uuid, orderByComparator, true); array[1] = dataCollection; array[2] = getByUuid_PrevAndNext( session, dataCollection, uuid, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByUuid_PrevAndNext( Session session, DataCollection dataCollection, String uuid, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where uuid = &#63; from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (DataCollection dataCollection : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where uuid = &#63;. * * @param uuid the uuid * @return the number of matching data collections */ @Override public int countByUuid(String uuid) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = _finderPathCountByUuid; Object[] finderArgs = new Object[] {uuid}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_UUID_2 = "dataCollection.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dataCollection.uuid IS NULL OR dataCollection.uuid = '')"; private FinderPath _finderPathFetchByUUID_G; private FinderPath _finderPathCountByUUID_G; /** * Returns the data collection where uuid = &#63; and groupId = &#63; or throws a <code>NoSuchDataCollectionException</code> if it could not be found. * * @param uuid the uuid * @param groupId the group ID * @return the matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUUID_G(String uuid, long groupId) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUUID_G(uuid, groupId); if (dataCollection == null) { StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append(", groupId="); sb.append(groupId); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchDataCollectionException(sb.toString()); } return dataCollection; } /** * Returns the data collection where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param uuid the uuid * @param groupId the group ID * @return the matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUUID_G(String uuid, long groupId) { return fetchByUUID_G(uuid, groupId, true); } /** * Returns the data collection where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param uuid the uuid * @param groupId the group ID * @param useFinderCache whether to use the finder cache * @return the matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUUID_G( String uuid, long groupId, boolean useFinderCache) { uuid = Objects.toString(uuid, ""); Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] {uuid, groupId}; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByUUID_G, finderArgs, this); } if (result instanceof DataCollection) { DataCollection dataCollection = (DataCollection)result; if (!Objects.equals(uuid, dataCollection.getUuid()) || (groupId != dataCollection.getGroupId())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_G_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_G_UUID_2); } sb.append(_FINDER_COLUMN_UUID_G_GROUPID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(groupId); List<DataCollection> list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByUUID_G, finderArgs, list); } } else { DataCollection dataCollection = list.get(0); result = dataCollection; cacheResult(dataCollection); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult( _finderPathFetchByUUID_G, finderArgs); } throw processException(exception); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (DataCollection)result; } } /** * Removes the data collection where uuid = &#63; and groupId = &#63; from the database. * * @param uuid the uuid * @param groupId the group ID * @return the data collection that was removed */ @Override public DataCollection removeByUUID_G(String uuid, long groupId) throws NoSuchDataCollectionException { DataCollection dataCollection = findByUUID_G(uuid, groupId); return remove(dataCollection); } /** * Returns the number of data collections where uuid = &#63; and groupId = &#63;. * * @param uuid the uuid * @param groupId the group ID * @return the number of matching data collections */ @Override public int countByUUID_G(String uuid, long groupId) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = _finderPathCountByUUID_G; Object[] finderArgs = new Object[] {uuid, groupId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_G_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_G_UUID_2); } sb.append(_FINDER_COLUMN_UUID_G_GROUPID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(groupId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dataCollection.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dataCollection.uuid IS NULL OR dataCollection.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dataCollection.groupId = ?"; private FinderPath _finderPathWithPaginationFindByUuid_C; private FinderPath _finderPathWithoutPaginationFindByUuid_C; private FinderPath _finderPathCountByUuid_C; /** * Returns all the data collections where uuid = &#63; and companyId = &#63;. * * @param uuid the uuid * @param companyId the company ID * @return the matching data collections */ @Override public List<DataCollection> findByUuid_C(String uuid, long companyId) { return findByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where uuid = &#63; and companyId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByUuid_C( String uuid, long companyId, int start, int end) { return findByUuid_C(uuid, companyId, start, end, null); } /** * Returns an ordered range of all the data collections where uuid = &#63; and companyId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByUuid_C( String uuid, long companyId, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByUuid_C( uuid, companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where uuid = &#63; and companyId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByUuid_C( String uuid, long companyId, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByUuid_C; finderArgs = new Object[] {uuid, companyId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByUuid_C; finderArgs = new Object[] { uuid, companyId, start, end, orderByComparator }; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (!uuid.equals(dataCollection.getUuid()) || (companyId != dataCollection.getCompanyId())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where uuid = &#63; and companyId = &#63;. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUuid_C_First( String uuid, long companyId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUuid_C_First( uuid, companyId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append(", companyId="); sb.append(companyId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where uuid = &#63; and companyId = &#63;. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUuid_C_First( String uuid, long companyId, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByUuid_C( uuid, companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where uuid = &#63; and companyId = &#63;. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUuid_C_Last( String uuid, long companyId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUuid_C_Last( uuid, companyId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append(", companyId="); sb.append(companyId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where uuid = &#63; and companyId = &#63;. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUuid_C_Last( String uuid, long companyId, OrderByComparator<DataCollection> orderByComparator) { int count = countByUuid_C(uuid, companyId); if (count == 0) { return null; } List<DataCollection> list = findByUuid_C( uuid, companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where uuid = &#63; and companyId = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByUuid_C_PrevAndNext( long dataCollectionId, String uuid, long companyId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { uuid = Objects.toString(uuid, ""); DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByUuid_C_PrevAndNext( session, dataCollection, uuid, companyId, orderByComparator, true); array[1] = dataCollection; array[2] = getByUuid_C_PrevAndNext( session, dataCollection, uuid, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByUuid_C_PrevAndNext( Session session, DataCollection dataCollection, String uuid, long companyId, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where uuid = &#63; and companyId = &#63; from the database. * * @param uuid the uuid * @param companyId the company ID */ @Override public void removeByUuid_C(String uuid, long companyId) { for (DataCollection dataCollection : findByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where uuid = &#63; and companyId = &#63;. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching data collections */ @Override public int countByUuid_C(String uuid, long companyId) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = _finderPathCountByUuid_C; Object[] finderArgs = new Object[] {uuid, companyId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "dataCollection.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(dataCollection.uuid IS NULL OR dataCollection.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "dataCollection.companyId = ?"; private FinderPath _finderPathWithPaginationFindByGroupId; private FinderPath _finderPathWithoutPaginationFindByGroupId; private FinderPath _finderPathCountByGroupId; /** * Returns all the data collections where groupId = &#63;. * * @param groupId the group ID * @return the matching data collections */ @Override public List<DataCollection> findByGroupId(long groupId) { return findByGroupId( groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where groupId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByGroupId( long groupId, int start, int end) { return findByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the data collections where groupId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByGroupId( long groupId, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByGroupId(groupId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where groupId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByGroupId( long groupId, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByGroupId; finderArgs = new Object[] {groupId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByGroupId; finderArgs = new Object[] {groupId, start, end, orderByComparator}; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (groupId != dataCollection.getGroupId()) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where groupId = &#63;. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByGroupId_First( long groupId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByGroupId_First( groupId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where groupId = &#63;. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByGroupId_First( long groupId, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByGroupId( groupId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where groupId = &#63;. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByGroupId_Last( long groupId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByGroupId_Last( groupId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where groupId = &#63;. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByGroupId_Last( long groupId, OrderByComparator<DataCollection> orderByComparator) { int count = countByGroupId(groupId); if (count == 0) { return null; } List<DataCollection> list = findByGroupId( groupId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where groupId = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByGroupId_PrevAndNext( long dataCollectionId, long groupId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByGroupId_PrevAndNext( session, dataCollection, groupId, orderByComparator, true); array[1] = dataCollection; array[2] = getByGroupId_PrevAndNext( session, dataCollection, groupId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByGroupId_PrevAndNext( Session session, DataCollection dataCollection, long groupId, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the data collections that the user has permission to view where groupId = &#63;. * * @param groupId the group ID * @return the matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByGroupId(long groupId) { return filterFindByGroupId( groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections that the user has permission to view where groupId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByGroupId( long groupId, int start, int end) { return filterFindByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the data collections that the user has permissions to view where groupId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByGroupId( long groupId, int start, int end, OrderByComparator<DataCollection> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId(groupId, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); return (List<DataCollection>)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the data collections before and after the current data collection in the ordered set of data collections that the user has permission to view where groupId = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] filterFindByGroupId_PrevAndNext( long dataCollectionId, long groupId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId_PrevAndNext( dataCollectionId, groupId, orderByComparator); } DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = filterGetByGroupId_PrevAndNext( session, dataCollection, groupId, orderByComparator, true); array[1] = dataCollection; array[2] = filterGetByGroupId_PrevAndNext( session, dataCollection, groupId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection filterGetByGroupId_PrevAndNext( Session session, DataCollection dataCollection, long groupId, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where groupId = &#63; from the database. * * @param groupId the group ID */ @Override public void removeByGroupId(long groupId) { for (DataCollection dataCollection : findByGroupId( groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where groupId = &#63;. * * @param groupId the group ID * @return the number of matching data collections */ @Override public int countByGroupId(long groupId) { FinderPath finderPath = _finderPathCountByGroupId; Object[] finderArgs = new Object[] {groupId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of data collections that the user has permission to view where groupId = &#63;. * * @param groupId the group ID * @return the number of matching data collections that the user has permission to view */ @Override public int filterCountByGroupId(long groupId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByGroupId(groupId); } StringBundler sb = new StringBundler(2); sb.append(_FILTER_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dataCollection.groupId = ?"; private FinderPath _finderPathWithPaginationFindByUserId; private FinderPath _finderPathWithoutPaginationFindByUserId; private FinderPath _finderPathCountByUserId; /** * Returns all the data collections where userId = &#63;. * * @param userId the user ID * @return the matching data collections */ @Override public List<DataCollection> findByUserId(long userId) { return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByUserId(long userId, int start, int end) { return findByUserId(userId, start, end, null); } /** * Returns an ordered range of all the data collections where userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByUserId( long userId, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByUserId(userId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByUserId( long userId, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByUserId; finderArgs = new Object[] {userId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByUserId; finderArgs = new Object[] {userId, start, end, orderByComparator}; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (userId != dataCollection.getUserId()) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_USERID_USERID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(userId); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where userId = &#63;. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUserId_First( long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUserId_First( userId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("userId="); sb.append(userId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where userId = &#63;. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUserId_First( long userId, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByUserId( userId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where userId = &#63;. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByUserId_Last( long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByUserId_Last( userId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("userId="); sb.append(userId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where userId = &#63;. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByUserId_Last( long userId, OrderByComparator<DataCollection> orderByComparator) { int count = countByUserId(userId); if (count == 0) { return null; } List<DataCollection> list = findByUserId( userId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where userId = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByUserId_PrevAndNext( long dataCollectionId, long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByUserId_PrevAndNext( session, dataCollection, userId, orderByComparator, true); array[1] = dataCollection; array[2] = getByUserId_PrevAndNext( session, dataCollection, userId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByUserId_PrevAndNext( Session session, DataCollection dataCollection, long userId, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_USERID_USERID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(userId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where userId = &#63; from the database. * * @param userId the user ID */ @Override public void removeByUserId(long userId) { for (DataCollection dataCollection : findByUserId( userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where userId = &#63;. * * @param userId the user ID * @return the number of matching data collections */ @Override public int countByUserId(long userId) { FinderPath finderPath = _finderPathCountByUserId; Object[] finderArgs = new Object[] {userId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_USERID_USERID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(userId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_USERID_USERID_2 = "dataCollection.userId = ?"; private FinderPath _finderPathWithPaginationFindByStatus; private FinderPath _finderPathWithoutPaginationFindByStatus; private FinderPath _finderPathCountByStatus; /** * Returns all the data collections where status = &#63;. * * @param status the status * @return the matching data collections */ @Override public List<DataCollection> findByStatus(int status) { return findByStatus(status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByStatus(int status, int start, int end) { return findByStatus(status, start, end, null); } /** * Returns an ordered range of all the data collections where status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByStatus( int status, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByStatus(status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByStatus( int status, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByStatus; finderArgs = new Object[] {status}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByStatus; finderArgs = new Object[] {status, start, end, orderByComparator}; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (status != dataCollection.getStatus()) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_STATUS_STATUS_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(status); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where status = &#63;. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByStatus_First( int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByStatus_First( status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where status = &#63;. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByStatus_First( int status, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByStatus( status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where status = &#63;. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByStatus_Last( int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByStatus_Last( status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where status = &#63;. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByStatus_Last( int status, OrderByComparator<DataCollection> orderByComparator) { int count = countByStatus(status); if (count == 0) { return null; } List<DataCollection> list = findByStatus( status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where status = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByStatus_PrevAndNext( long dataCollectionId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByStatus_PrevAndNext( session, dataCollection, status, orderByComparator, true); array[1] = dataCollection; array[2] = getByStatus_PrevAndNext( session, dataCollection, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByStatus_PrevAndNext( Session session, DataCollection dataCollection, int status, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_STATUS_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where status = &#63; from the database. * * @param status the status */ @Override public void removeByStatus(int status) { for (DataCollection dataCollection : findByStatus( status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where status = &#63;. * * @param status the status * @return the number of matching data collections */ @Override public int countByStatus(int status) { FinderPath finderPath = _finderPathCountByStatus; Object[] finderArgs = new Object[] {status}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_STATUS_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(status); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_STATUS_STATUS_2 = "dataCollection.status = ?"; private FinderPath _finderPathWithPaginationFindByG_U; private FinderPath _finderPathWithoutPaginationFindByG_U; private FinderPath _finderPathCountByG_U; /** * Returns all the data collections where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @return the matching data collections */ @Override public List<DataCollection> findByG_U(long groupId, long userId) { return findByG_U( groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where groupId = &#63; and userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByG_U( long groupId, long userId, int start, int end) { return findByG_U(groupId, userId, start, end, null); } /** * Returns an ordered range of all the data collections where groupId = &#63; and userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByG_U( long groupId, long userId, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByG_U(groupId, userId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where groupId = &#63; and userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByG_U( long groupId, long userId, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByG_U; finderArgs = new Object[] {groupId, userId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByG_U; finderArgs = new Object[] { groupId, userId, start, end, orderByComparator }; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if ((groupId != dataCollection.getGroupId()) || (userId != dataCollection.getUserId())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_USERID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(userId); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByG_U_First( long groupId, long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByG_U_First( groupId, userId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", userId="); sb.append(userId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByG_U_First( long groupId, long userId, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByG_U( groupId, userId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByG_U_Last( long groupId, long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByG_U_Last( groupId, userId, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", userId="); sb.append(userId); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByG_U_Last( long groupId, long userId, OrderByComparator<DataCollection> orderByComparator) { int count = countByG_U(groupId, userId); if (count == 0) { return null; } List<DataCollection> list = findByG_U( groupId, userId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where groupId = &#63; and userId = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByG_U_PrevAndNext( long dataCollectionId, long groupId, long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByG_U_PrevAndNext( session, dataCollection, groupId, userId, orderByComparator, true); array[1] = dataCollection; array[2] = getByG_U_PrevAndNext( session, dataCollection, groupId, userId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByG_U_PrevAndNext( Session session, DataCollection dataCollection, long groupId, long userId, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_USERID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(userId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the data collections that the user has permission to view where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @return the matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_U(long groupId, long userId) { return filterFindByG_U( groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections that the user has permission to view where groupId = &#63; and userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_U( long groupId, long userId, int start, int end) { return filterFindByG_U(groupId, userId, start, end, null); } /** * Returns an ordered range of all the data collections that the user has permissions to view where groupId = &#63; and userId = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_U( long groupId, long userId, int start, int end, OrderByComparator<DataCollection> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U(groupId, userId, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_G_U_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_USERID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(userId); return (List<DataCollection>)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the data collections before and after the current data collection in the ordered set of data collections that the user has permission to view where groupId = &#63; and userId = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] filterFindByG_U_PrevAndNext( long dataCollectionId, long groupId, long userId, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_PrevAndNext( dataCollectionId, groupId, userId, orderByComparator); } DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = filterGetByG_U_PrevAndNext( session, dataCollection, groupId, userId, orderByComparator, true); array[1] = dataCollection; array[2] = filterGetByG_U_PrevAndNext( session, dataCollection, groupId, userId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection filterGetByG_U_PrevAndNext( Session session, DataCollection dataCollection, long groupId, long userId, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_G_U_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_USERID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(userId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where groupId = &#63; and userId = &#63; from the database. * * @param groupId the group ID * @param userId the user ID */ @Override public void removeByG_U(long groupId, long userId) { for (DataCollection dataCollection : findByG_U( groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @return the number of matching data collections */ @Override public int countByG_U(long groupId, long userId) { FinderPath finderPath = _finderPathCountByG_U; Object[] finderArgs = new Object[] {groupId, userId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_USERID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(userId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of data collections that the user has permission to view where groupId = &#63; and userId = &#63;. * * @param groupId the group ID * @param userId the user ID * @return the number of matching data collections that the user has permission to view */ @Override public int filterCountByG_U(long groupId, long userId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_U(groupId, userId); } StringBundler sb = new StringBundler(3); sb.append(_FILTER_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_USERID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(userId); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "dataCollection.groupId = ? AND "; private static final String _FINDER_COLUMN_G_U_USERID_2 = "dataCollection.userId = ?"; private FinderPath _finderPathWithPaginationFindByG_S; private FinderPath _finderPathWithoutPaginationFindByG_S; private FinderPath _finderPathCountByG_S; /** * Returns all the data collections where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @return the matching data collections */ @Override public List<DataCollection> findByG_S(long groupId, int status) { return findByG_S( groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where groupId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByG_S( long groupId, int status, int start, int end) { return findByG_S(groupId, status, start, end, null); } /** * Returns an ordered range of all the data collections where groupId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByG_S( long groupId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByG_S(groupId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where groupId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByG_S( long groupId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByG_S; finderArgs = new Object[] {groupId, status}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByG_S; finderArgs = new Object[] { groupId, status, start, end, orderByComparator }; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if ((groupId != dataCollection.getGroupId()) || (status != dataCollection.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(status); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByG_S_First( long groupId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByG_S_First( groupId, status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByG_S_First( long groupId, int status, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByG_S( groupId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByG_S_Last( long groupId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByG_S_Last( groupId, status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByG_S_Last( long groupId, int status, OrderByComparator<DataCollection> orderByComparator) { int count = countByG_S(groupId, status); if (count == 0) { return null; } List<DataCollection> list = findByG_S( groupId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where groupId = &#63; and status = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByG_S_PrevAndNext( long dataCollectionId, long groupId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByG_S_PrevAndNext( session, dataCollection, groupId, status, orderByComparator, true); array[1] = dataCollection; array[2] = getByG_S_PrevAndNext( session, dataCollection, groupId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByG_S_PrevAndNext( Session session, DataCollection dataCollection, long groupId, int status, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the data collections that the user has permission to view where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @return the matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_S(long groupId, int status) { return filterFindByG_S( groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections that the user has permission to view where groupId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_S( long groupId, int status, int start, int end) { return filterFindByG_S(groupId, status, start, end, null); } /** * Returns an ordered range of all the data collections that the user has permissions to view where groupId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_S( long groupId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_S(groupId, status, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_G_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(status); return (List<DataCollection>)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the data collections before and after the current data collection in the ordered set of data collections that the user has permission to view where groupId = &#63; and status = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] filterFindByG_S_PrevAndNext( long dataCollectionId, long groupId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_S_PrevAndNext( dataCollectionId, groupId, status, orderByComparator); } DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = filterGetByG_S_PrevAndNext( session, dataCollection, groupId, status, orderByComparator, true); array[1] = dataCollection; array[2] = filterGetByG_S_PrevAndNext( session, dataCollection, groupId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection filterGetByG_S_PrevAndNext( Session session, DataCollection dataCollection, long groupId, int status, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_G_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where groupId = &#63; and status = &#63; from the database. * * @param groupId the group ID * @param status the status */ @Override public void removeByG_S(long groupId, int status) { for (DataCollection dataCollection : findByG_S( groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @return the number of matching data collections */ @Override public int countByG_S(long groupId, int status) { FinderPath finderPath = _finderPathCountByG_S; Object[] finderArgs = new Object[] {groupId, status}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_S_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(status); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of data collections that the user has permission to view where groupId = &#63; and status = &#63;. * * @param groupId the group ID * @param status the status * @return the number of matching data collections that the user has permission to view */ @Override public int filterCountByG_S(long groupId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_S(groupId, status); } StringBundler sb = new StringBundler(3); sb.append(_FILTER_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(status); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "dataCollection.groupId = ? AND "; private static final String _FINDER_COLUMN_G_S_STATUS_2 = "dataCollection.status = ?"; private FinderPath _finderPathWithPaginationFindByU_S; private FinderPath _finderPathWithoutPaginationFindByU_S; private FinderPath _finderPathCountByU_S; /** * Returns all the data collections where userId = &#63; and status = &#63;. * * @param userId the user ID * @param status the status * @return the matching data collections */ @Override public List<DataCollection> findByU_S(long userId, int status) { return findByU_S( userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByU_S( long userId, int status, int start, int end) { return findByU_S(userId, status, start, end, null); } /** * Returns an ordered range of all the data collections where userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByU_S( long userId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByU_S(userId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByU_S( long userId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByU_S; finderArgs = new Object[] {userId, status}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByU_S; finderArgs = new Object[] { userId, status, start, end, orderByComparator }; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if ((userId != dataCollection.getUserId()) || (status != dataCollection.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_U_S_USERID_2); sb.append(_FINDER_COLUMN_U_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(userId); queryPos.add(status); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where userId = &#63; and status = &#63;. * * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByU_S_First( long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByU_S_First( userId, status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("userId="); sb.append(userId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where userId = &#63; and status = &#63;. * * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByU_S_First( long userId, int status, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByU_S( userId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where userId = &#63; and status = &#63;. * * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByU_S_Last( long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByU_S_Last( userId, status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("userId="); sb.append(userId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where userId = &#63; and status = &#63;. * * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByU_S_Last( long userId, int status, OrderByComparator<DataCollection> orderByComparator) { int count = countByU_S(userId, status); if (count == 0) { return null; } List<DataCollection> list = findByU_S( userId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where userId = &#63; and status = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByU_S_PrevAndNext( long dataCollectionId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByU_S_PrevAndNext( session, dataCollection, userId, status, orderByComparator, true); array[1] = dataCollection; array[2] = getByU_S_PrevAndNext( session, dataCollection, userId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByU_S_PrevAndNext( Session session, DataCollection dataCollection, long userId, int status, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_U_S_USERID_2); sb.append(_FINDER_COLUMN_U_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(userId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where userId = &#63; and status = &#63; from the database. * * @param userId the user ID * @param status the status */ @Override public void removeByU_S(long userId, int status) { for (DataCollection dataCollection : findByU_S( userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where userId = &#63; and status = &#63;. * * @param userId the user ID * @param status the status * @return the number of matching data collections */ @Override public int countByU_S(long userId, int status) { FinderPath finderPath = _finderPathCountByU_S; Object[] finderArgs = new Object[] {userId, status}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_U_S_USERID_2); sb.append(_FINDER_COLUMN_U_S_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(userId); queryPos.add(status); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_U_S_USERID_2 = "dataCollection.userId = ? AND "; private static final String _FINDER_COLUMN_U_S_STATUS_2 = "dataCollection.status = ?"; private FinderPath _finderPathWithPaginationFindByG_U_S; private FinderPath _finderPathWithoutPaginationFindByG_U_S; private FinderPath _finderPathCountByG_U_S; /** * Returns all the data collections where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @return the matching data collections */ @Override public List<DataCollection> findByG_U_S( long groupId, long userId, int status) { return findByG_U_S( groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where groupId = &#63; and userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByG_U_S( long groupId, long userId, int status, int start, int end) { return findByG_U_S(groupId, userId, status, start, end, null); } /** * Returns an ordered range of all the data collections where groupId = &#63; and userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByG_U_S( long groupId, long userId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByG_U_S( groupId, userId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where groupId = &#63; and userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByG_U_S( long groupId, long userId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByG_U_S; finderArgs = new Object[] {groupId, userId, status}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByG_U_S; finderArgs = new Object[] { groupId, userId, status, start, end, orderByComparator }; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if ((groupId != dataCollection.getGroupId()) || (userId != dataCollection.getUserId()) || (status != dataCollection.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(5); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_S_USERID_2); sb.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(userId); queryPos.add(status); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByG_U_S_First( long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByG_U_S_First( groupId, userId, status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(8); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", userId="); sb.append(userId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByG_U_S_First( long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByG_U_S( groupId, userId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByG_U_S_Last( long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByG_U_S_Last( groupId, userId, status, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(8); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("groupId="); sb.append(groupId); sb.append(", userId="); sb.append(userId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByG_U_S_Last( long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) { int count = countByG_U_S(groupId, userId, status); if (count == 0) { return null; } List<DataCollection> list = findByG_U_S( groupId, userId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByG_U_S_PrevAndNext( long dataCollectionId, long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByG_U_S_PrevAndNext( session, dataCollection, groupId, userId, status, orderByComparator, true); array[1] = dataCollection; array[2] = getByG_U_S_PrevAndNext( session, dataCollection, groupId, userId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByG_U_S_PrevAndNext( Session session, DataCollection dataCollection, long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(5); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_S_USERID_2); sb.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(userId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the data collections that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @return the matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_U_S( long groupId, long userId, int status) { return filterFindByG_U_S( groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_U_S( long groupId, long userId, int status, int start, int end) { return filterFindByG_U_S(groupId, userId, status, start, end, null); } /** * Returns an ordered range of all the data collections that the user has permissions to view where groupId = &#63; and userId = &#63; and status = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param groupId the group ID * @param userId the user ID * @param status the status * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections that the user has permission to view */ @Override public List<DataCollection> filterFindByG_U_S( long groupId, long userId, int status, int start, int end, OrderByComparator<DataCollection> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_S( groupId, userId, status, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(6); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_S_USERID_2); sb.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(userId); queryPos.add(status); return (List<DataCollection>)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the data collections before and after the current data collection in the ordered set of data collections that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param groupId the group ID * @param userId the user ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] filterFindByG_U_S_PrevAndNext( long dataCollectionId, long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_S_PrevAndNext( dataCollectionId, groupId, userId, status, orderByComparator); } DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = filterGetByG_U_S_PrevAndNext( session, dataCollection, groupId, userId, status, orderByComparator, true); array[1] = dataCollection; array[2] = filterGetByG_U_S_PrevAndNext( session, dataCollection, groupId, userId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection filterGetByG_U_S_PrevAndNext( Session session, DataCollection dataCollection, long groupId, long userId, int status, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 7 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(6); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_DATACOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_S_USERID_2); sb.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(DataCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, DataCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, DataCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(userId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where groupId = &#63; and userId = &#63; and status = &#63; from the database. * * @param groupId the group ID * @param userId the user ID * @param status the status */ @Override public void removeByG_U_S(long groupId, long userId, int status) { for (DataCollection dataCollection : findByG_U_S( groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @return the number of matching data collections */ @Override public int countByG_U_S(long groupId, long userId, int status) { FinderPath finderPath = _finderPathCountByG_U_S; Object[] finderArgs = new Object[] {groupId, userId, status}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_S_USERID_2); sb.append(_FINDER_COLUMN_G_U_S_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(groupId); queryPos.add(userId); queryPos.add(status); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of data collections that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;. * * @param groupId the group ID * @param userId the user ID * @param status the status * @return the number of matching data collections that the user has permission to view */ @Override public int filterCountByG_U_S(long groupId, long userId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_U_S(groupId, userId, status); } StringBundler sb = new StringBundler(4); sb.append(_FILTER_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2); sb.append(_FINDER_COLUMN_G_U_S_USERID_2); sb.append(_FINDER_COLUMN_G_U_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), DataCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(groupId); queryPos.add(userId); queryPos.add(status); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "dataCollection.groupId = ? AND "; private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "dataCollection.userId = ? AND "; private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "dataCollection.status = ?"; private FinderPath _finderPathWithPaginationFindByName; private FinderPath _finderPathWithoutPaginationFindByName; private FinderPath _finderPathCountByName; /** * Returns all the data collections where name = &#63;. * * @param name the name * @return the matching data collections */ @Override public List<DataCollection> findByName(String name) { return findByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where name = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param name the name * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByName(String name, int start, int end) { return findByName(name, start, end, null); } /** * Returns an ordered range of all the data collections where name = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param name the name * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByName( String name, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByName(name, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where name = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param name the name * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByName( String name, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { name = Objects.toString(name, ""); FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByName; finderArgs = new Object[] {name}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByName; finderArgs = new Object[] {name, start, end, orderByComparator}; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (!name.equals(dataCollection.getName())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindName = false; if (name.isEmpty()) { sb.append(_FINDER_COLUMN_NAME_NAME_3); } else { bindName = true; sb.append(_FINDER_COLUMN_NAME_NAME_2); } if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindName) { queryPos.add(name); } list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where name = &#63;. * * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByName_First( String name, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByName_First( name, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("name="); sb.append(name); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where name = &#63;. * * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByName_First( String name, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByName(name, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where name = &#63;. * * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByName_Last( String name, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByName_Last( name, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("name="); sb.append(name); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where name = &#63;. * * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByName_Last( String name, OrderByComparator<DataCollection> orderByComparator) { int count = countByName(name); if (count == 0) { return null; } List<DataCollection> list = findByName( name, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where name = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByName_PrevAndNext( long dataCollectionId, String name, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { name = Objects.toString(name, ""); DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByName_PrevAndNext( session, dataCollection, name, orderByComparator, true); array[1] = dataCollection; array[2] = getByName_PrevAndNext( session, dataCollection, name, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByName_PrevAndNext( Session session, DataCollection dataCollection, String name, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindName = false; if (name.isEmpty()) { sb.append(_FINDER_COLUMN_NAME_NAME_3); } else { bindName = true; sb.append(_FINDER_COLUMN_NAME_NAME_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); if (bindName) { queryPos.add(name); } if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where name = &#63; from the database. * * @param name the name */ @Override public void removeByName(String name) { for (DataCollection dataCollection : findByName(name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where name = &#63;. * * @param name the name * @return the number of matching data collections */ @Override public int countByName(String name) { name = Objects.toString(name, ""); FinderPath finderPath = _finderPathCountByName; Object[] finderArgs = new Object[] {name}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); boolean bindName = false; if (name.isEmpty()) { sb.append(_FINDER_COLUMN_NAME_NAME_3); } else { bindName = true; sb.append(_FINDER_COLUMN_NAME_NAME_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindName) { queryPos.add(name); } count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_NAME_NAME_2 = "dataCollection.name = ?"; private static final String _FINDER_COLUMN_NAME_NAME_3 = "(dataCollection.name IS NULL OR dataCollection.name = '')"; private FinderPath _finderPathFetchByOrganizationId; private FinderPath _finderPathCountByOrganizationId; /** * Returns the data collection where organizationId = &#63; or throws a <code>NoSuchDataCollectionException</code> if it could not be found. * * @param organizationId the organization ID * @return the matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByOrganizationId(long organizationId) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByOrganizationId(organizationId); if (dataCollection == null) { StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("organizationId="); sb.append(organizationId); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchDataCollectionException(sb.toString()); } return dataCollection; } /** * Returns the data collection where organizationId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param organizationId the organization ID * @return the matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByOrganizationId(long organizationId) { return fetchByOrganizationId(organizationId, true); } /** * Returns the data collection where organizationId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param organizationId the organization ID * @param useFinderCache whether to use the finder cache * @return the matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByOrganizationId( long organizationId, boolean useFinderCache) { Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] {organizationId}; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByOrganizationId, finderArgs, this); } if (result instanceof DataCollection) { DataCollection dataCollection = (DataCollection)result; if (organizationId != dataCollection.getOrganizationId()) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(organizationId); List<DataCollection> list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByOrganizationId, finderArgs, list); } } else { if (list.size() > 1) { Collections.sort(list, Collections.reverseOrder()); if (_log.isWarnEnabled()) { if (!useFinderCache) { finderArgs = new Object[] {organizationId}; } _log.warn( "DataCollectionPersistenceImpl.fetchByOrganizationId(long, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } } DataCollection dataCollection = list.get(0); result = dataCollection; cacheResult(dataCollection); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult( _finderPathFetchByOrganizationId, finderArgs); } throw processException(exception); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (DataCollection)result; } } /** * Removes the data collection where organizationId = &#63; from the database. * * @param organizationId the organization ID * @return the data collection that was removed */ @Override public DataCollection removeByOrganizationId(long organizationId) throws NoSuchDataCollectionException { DataCollection dataCollection = findByOrganizationId(organizationId); return remove(dataCollection); } /** * Returns the number of data collections where organizationId = &#63;. * * @param organizationId the organization ID * @return the number of matching data collections */ @Override public int countByOrganizationId(long organizationId) { FinderPath finderPath = _finderPathCountByOrganizationId; Object[] finderArgs = new Object[] {organizationId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(organizationId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2 = "dataCollection.organizationId = ?"; private FinderPath _finderPathFetchByNameVersion; private FinderPath _finderPathCountByNameVersion; /** * Returns the data collection where name = &#63; and version = &#63; or throws a <code>NoSuchDataCollectionException</code> if it could not be found. * * @param name the name * @param version the version * @return the matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByNameVersion(String name, String version) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByNameVersion(name, version); if (dataCollection == null) { StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("name="); sb.append(name); sb.append(", version="); sb.append(version); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchDataCollectionException(sb.toString()); } return dataCollection; } /** * Returns the data collection where name = &#63; and version = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param name the name * @param version the version * @return the matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByNameVersion(String name, String version) { return fetchByNameVersion(name, version, true); } /** * Returns the data collection where name = &#63; and version = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param name the name * @param version the version * @param useFinderCache whether to use the finder cache * @return the matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByNameVersion( String name, String version, boolean useFinderCache) { name = Objects.toString(name, ""); version = Objects.toString(version, ""); Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] {name, version}; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByNameVersion, finderArgs, this); } if (result instanceof DataCollection) { DataCollection dataCollection = (DataCollection)result; if (!Objects.equals(name, dataCollection.getName()) || !Objects.equals(version, dataCollection.getVersion())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); boolean bindName = false; if (name.isEmpty()) { sb.append(_FINDER_COLUMN_NAMEVERSION_NAME_3); } else { bindName = true; sb.append(_FINDER_COLUMN_NAMEVERSION_NAME_2); } boolean bindVersion = false; if (version.isEmpty()) { sb.append(_FINDER_COLUMN_NAMEVERSION_VERSION_3); } else { bindVersion = true; sb.append(_FINDER_COLUMN_NAMEVERSION_VERSION_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindName) { queryPos.add(name); } if (bindVersion) { queryPos.add(version); } List<DataCollection> list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByNameVersion, finderArgs, list); } } else { if (list.size() > 1) { Collections.sort(list, Collections.reverseOrder()); if (_log.isWarnEnabled()) { if (!useFinderCache) { finderArgs = new Object[] {name, version}; } _log.warn( "DataCollectionPersistenceImpl.fetchByNameVersion(String, String, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } } DataCollection dataCollection = list.get(0); result = dataCollection; cacheResult(dataCollection); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult( _finderPathFetchByNameVersion, finderArgs); } throw processException(exception); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (DataCollection)result; } } /** * Removes the data collection where name = &#63; and version = &#63; from the database. * * @param name the name * @param version the version * @return the data collection that was removed */ @Override public DataCollection removeByNameVersion(String name, String version) throws NoSuchDataCollectionException { DataCollection dataCollection = findByNameVersion(name, version); return remove(dataCollection); } /** * Returns the number of data collections where name = &#63; and version = &#63;. * * @param name the name * @param version the version * @return the number of matching data collections */ @Override public int countByNameVersion(String name, String version) { name = Objects.toString(name, ""); version = Objects.toString(version, ""); FinderPath finderPath = _finderPathCountByNameVersion; Object[] finderArgs = new Object[] {name, version}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); boolean bindName = false; if (name.isEmpty()) { sb.append(_FINDER_COLUMN_NAMEVERSION_NAME_3); } else { bindName = true; sb.append(_FINDER_COLUMN_NAMEVERSION_NAME_2); } boolean bindVersion = false; if (version.isEmpty()) { sb.append(_FINDER_COLUMN_NAMEVERSION_VERSION_3); } else { bindVersion = true; sb.append(_FINDER_COLUMN_NAMEVERSION_VERSION_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindName) { queryPos.add(name); } if (bindVersion) { queryPos.add(version); } count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_NAMEVERSION_NAME_2 = "dataCollection.name = ? AND "; private static final String _FINDER_COLUMN_NAMEVERSION_NAME_3 = "(dataCollection.name IS NULL OR dataCollection.name = '') AND "; private static final String _FINDER_COLUMN_NAMEVERSION_VERSION_2 = "dataCollection.version = ?"; private static final String _FINDER_COLUMN_NAMEVERSION_VERSION_3 = "(dataCollection.version IS NULL OR dataCollection.version = '')"; private FinderPath _finderPathWithPaginationFindByVariants; private FinderPath _finderPathWithoutPaginationFindByVariants; private FinderPath _finderPathCountByVariants; /** * Returns all the data collections where copiedFrom = &#63;. * * @param copiedFrom the copied from * @return the matching data collections */ @Override public List<DataCollection> findByVariants(long copiedFrom) { return findByVariants( copiedFrom, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections where copiedFrom = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param copiedFrom the copied from * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of matching data collections */ @Override public List<DataCollection> findByVariants( long copiedFrom, int start, int end) { return findByVariants(copiedFrom, start, end, null); } /** * Returns an ordered range of all the data collections where copiedFrom = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param copiedFrom the copied from * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByVariants( long copiedFrom, int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findByVariants(copiedFrom, start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections where copiedFrom = &#63;. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param copiedFrom the copied from * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching data collections */ @Override public List<DataCollection> findByVariants( long copiedFrom, int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByVariants; finderArgs = new Object[] {copiedFrom}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByVariants; finderArgs = new Object[] { copiedFrom, start, end, orderByComparator }; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DataCollection dataCollection : list) { if (copiedFrom != dataCollection.getCopiedFrom()) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_VARIANTS_COPIEDFROM_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(copiedFrom); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first data collection in the ordered set where copiedFrom = &#63;. * * @param copiedFrom the copied from * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByVariants_First( long copiedFrom, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByVariants_First( copiedFrom, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("copiedFrom="); sb.append(copiedFrom); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the first data collection in the ordered set where copiedFrom = &#63;. * * @param copiedFrom the copied from * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByVariants_First( long copiedFrom, OrderByComparator<DataCollection> orderByComparator) { List<DataCollection> list = findByVariants( copiedFrom, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last data collection in the ordered set where copiedFrom = &#63;. * * @param copiedFrom the copied from * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection * @throws NoSuchDataCollectionException if a matching data collection could not be found */ @Override public DataCollection findByVariants_Last( long copiedFrom, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByVariants_Last( copiedFrom, orderByComparator); if (dataCollection != null) { return dataCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("copiedFrom="); sb.append(copiedFrom); sb.append("}"); throw new NoSuchDataCollectionException(sb.toString()); } /** * Returns the last data collection in the ordered set where copiedFrom = &#63;. * * @param copiedFrom the copied from * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching data collection, or <code>null</code> if a matching data collection could not be found */ @Override public DataCollection fetchByVariants_Last( long copiedFrom, OrderByComparator<DataCollection> orderByComparator) { int count = countByVariants(copiedFrom); if (count == 0) { return null; } List<DataCollection> list = findByVariants( copiedFrom, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the data collections before and after the current data collection in the ordered set where copiedFrom = &#63;. * * @param dataCollectionId the primary key of the current data collection * @param copiedFrom the copied from * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection[] findByVariants_PrevAndNext( long dataCollectionId, long copiedFrom, OrderByComparator<DataCollection> orderByComparator) throws NoSuchDataCollectionException { DataCollection dataCollection = findByPrimaryKey(dataCollectionId); Session session = null; try { session = openSession(); DataCollection[] array = new DataCollectionImpl[3]; array[0] = getByVariants_PrevAndNext( session, dataCollection, copiedFrom, orderByComparator, true); array[1] = dataCollection; array[2] = getByVariants_PrevAndNext( session, dataCollection, copiedFrom, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected DataCollection getByVariants_PrevAndNext( Session session, DataCollection dataCollection, long copiedFrom, OrderByComparator<DataCollection> orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_VARIANTS_COPIEDFROM_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(DataCollectionModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(copiedFrom); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( dataCollection)) { queryPos.add(orderByConditionValue); } } List<DataCollection> list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the data collections where copiedFrom = &#63; from the database. * * @param copiedFrom the copied from */ @Override public void removeByVariants(long copiedFrom) { for (DataCollection dataCollection : findByVariants( copiedFrom, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(dataCollection); } } /** * Returns the number of data collections where copiedFrom = &#63;. * * @param copiedFrom the copied from * @return the number of matching data collections */ @Override public int countByVariants(long copiedFrom) { FinderPath finderPath = _finderPathCountByVariants; Object[] finderArgs = new Object[] {copiedFrom}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_DATACOLLECTION_WHERE); sb.append(_FINDER_COLUMN_VARIANTS_COPIEDFROM_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(copiedFrom); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { finderCache.removeResult(finderPath, finderArgs); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_VARIANTS_COPIEDFROM_2 = "dataCollection.copiedFrom = ?"; public DataCollectionPersistenceImpl() { setModelClass(DataCollection.class); setModelImplClass(DataCollectionImpl.class); setModelPKClass(long.class); Map<String, String> dbColumnNames = new HashMap<String, String>(); dbColumnNames.put("uuid", "uuid_"); setDBColumnNames(dbColumnNames); } /** * Caches the data collection in the entity cache if it is enabled. * * @param dataCollection the data collection */ @Override public void cacheResult(DataCollection dataCollection) { entityCache.putResult( entityCacheEnabled, DataCollectionImpl.class, dataCollection.getPrimaryKey(), dataCollection); finderCache.putResult( _finderPathFetchByUUID_G, new Object[] { dataCollection.getUuid(), dataCollection.getGroupId() }, dataCollection); finderCache.putResult( _finderPathFetchByOrganizationId, new Object[] {dataCollection.getOrganizationId()}, dataCollection); finderCache.putResult( _finderPathFetchByNameVersion, new Object[] { dataCollection.getName(), dataCollection.getVersion() }, dataCollection); dataCollection.resetOriginalValues(); } /** * Caches the data collections in the entity cache if it is enabled. * * @param dataCollections the data collections */ @Override public void cacheResult(List<DataCollection> dataCollections) { for (DataCollection dataCollection : dataCollections) { if (entityCache.getResult( entityCacheEnabled, DataCollectionImpl.class, dataCollection.getPrimaryKey()) == null) { cacheResult(dataCollection); } else { dataCollection.resetOriginalValues(); } } } /** * Clears the cache for all data collections. * * <p> * The <code>EntityCache</code> and <code>FinderCache</code> are both cleared by this method. * </p> */ @Override public void clearCache() { entityCache.clearCache(DataCollectionImpl.class); finderCache.clearCache(FINDER_CLASS_NAME_ENTITY); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the data collection. * * <p> * The <code>EntityCache</code> and <code>FinderCache</code> are both cleared by this method. * </p> */ @Override public void clearCache(DataCollection dataCollection) { entityCache.removeResult( entityCacheEnabled, DataCollectionImpl.class, dataCollection.getPrimaryKey()); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((DataCollectionModelImpl)dataCollection, true); } @Override public void clearCache(List<DataCollection> dataCollections) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (DataCollection dataCollection : dataCollections) { entityCache.removeResult( entityCacheEnabled, DataCollectionImpl.class, dataCollection.getPrimaryKey()); clearUniqueFindersCache( (DataCollectionModelImpl)dataCollection, true); } } public void clearCache(Set<Serializable> primaryKeys) { finderCache.clearCache(FINDER_CLASS_NAME_ENTITY); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (Serializable primaryKey : primaryKeys) { entityCache.removeResult( entityCacheEnabled, DataCollectionImpl.class, primaryKey); } } protected void cacheUniqueFindersCache( DataCollectionModelImpl dataCollectionModelImpl) { Object[] args = new Object[] { dataCollectionModelImpl.getUuid(), dataCollectionModelImpl.getGroupId() }; finderCache.putResult( _finderPathCountByUUID_G, args, Long.valueOf(1), false); finderCache.putResult( _finderPathFetchByUUID_G, args, dataCollectionModelImpl, false); args = new Object[] {dataCollectionModelImpl.getOrganizationId()}; finderCache.putResult( _finderPathCountByOrganizationId, args, Long.valueOf(1), false); finderCache.putResult( _finderPathFetchByOrganizationId, args, dataCollectionModelImpl, false); args = new Object[] { dataCollectionModelImpl.getName(), dataCollectionModelImpl.getVersion() }; finderCache.putResult( _finderPathCountByNameVersion, args, Long.valueOf(1), false); finderCache.putResult( _finderPathFetchByNameVersion, args, dataCollectionModelImpl, false); } protected void clearUniqueFindersCache( DataCollectionModelImpl dataCollectionModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { dataCollectionModelImpl.getUuid(), dataCollectionModelImpl.getGroupId() }; finderCache.removeResult(_finderPathCountByUUID_G, args); finderCache.removeResult(_finderPathFetchByUUID_G, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathFetchByUUID_G.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalUuid(), dataCollectionModelImpl.getOriginalGroupId() }; finderCache.removeResult(_finderPathCountByUUID_G, args); finderCache.removeResult(_finderPathFetchByUUID_G, args); } if (clearCurrent) { Object[] args = new Object[] { dataCollectionModelImpl.getOrganizationId() }; finderCache.removeResult(_finderPathCountByOrganizationId, args); finderCache.removeResult(_finderPathFetchByOrganizationId, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathFetchByOrganizationId.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalOrganizationId() }; finderCache.removeResult(_finderPathCountByOrganizationId, args); finderCache.removeResult(_finderPathFetchByOrganizationId, args); } if (clearCurrent) { Object[] args = new Object[] { dataCollectionModelImpl.getName(), dataCollectionModelImpl.getVersion() }; finderCache.removeResult(_finderPathCountByNameVersion, args); finderCache.removeResult(_finderPathFetchByNameVersion, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathFetchByNameVersion.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalName(), dataCollectionModelImpl.getOriginalVersion() }; finderCache.removeResult(_finderPathCountByNameVersion, args); finderCache.removeResult(_finderPathFetchByNameVersion, args); } } /** * Creates a new data collection with the primary key. Does not add the data collection to the database. * * @param dataCollectionId the primary key for the new data collection * @return the new data collection */ @Override public DataCollection create(long dataCollectionId) { DataCollection dataCollection = new DataCollectionImpl(); dataCollection.setNew(true); dataCollection.setPrimaryKey(dataCollectionId); String uuid = PortalUUIDUtil.generate(); dataCollection.setUuid(uuid); dataCollection.setCompanyId(CompanyThreadLocal.getCompanyId()); return dataCollection; } /** * Removes the data collection with the primary key from the database. Also notifies the appropriate model listeners. * * @param dataCollectionId the primary key of the data collection * @return the data collection that was removed * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection remove(long dataCollectionId) throws NoSuchDataCollectionException { return remove((Serializable)dataCollectionId); } /** * Removes the data collection with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the data collection * @return the data collection that was removed * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection remove(Serializable primaryKey) throws NoSuchDataCollectionException { Session session = null; try { session = openSession(); DataCollection dataCollection = (DataCollection)session.get( DataCollectionImpl.class, primaryKey); if (dataCollection == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchDataCollectionException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(dataCollection); } catch (NoSuchDataCollectionException noSuchEntityException) { throw noSuchEntityException; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } @Override protected DataCollection removeImpl(DataCollection dataCollection) { Session session = null; try { session = openSession(); if (!session.contains(dataCollection)) { dataCollection = (DataCollection)session.get( DataCollectionImpl.class, dataCollection.getPrimaryKeyObj()); } if (dataCollection != null) { session.delete(dataCollection); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } if (dataCollection != null) { clearCache(dataCollection); } return dataCollection; } @Override public DataCollection updateImpl(DataCollection dataCollection) { boolean isNew = dataCollection.isNew(); if (!(dataCollection instanceof DataCollectionModelImpl)) { InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(dataCollection.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler( dataCollection); throw new IllegalArgumentException( "Implement ModelWrapper in dataCollection proxy " + invocationHandler.getClass()); } throw new IllegalArgumentException( "Implement ModelWrapper in custom DataCollection implementation " + dataCollection.getClass()); } DataCollectionModelImpl dataCollectionModelImpl = (DataCollectionModelImpl)dataCollection; if (Validator.isNull(dataCollection.getUuid())) { String uuid = PortalUUIDUtil.generate(); dataCollection.setUuid(uuid); } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (dataCollection.getCreateDate() == null)) { if (serviceContext == null) { dataCollection.setCreateDate(now); } else { dataCollection.setCreateDate(serviceContext.getCreateDate(now)); } } if (!dataCollectionModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { dataCollection.setModifiedDate(now); } else { dataCollection.setModifiedDate( serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (dataCollection.isNew()) { session.save(dataCollection); dataCollection.setNew(false); } else { dataCollection = (DataCollection)session.merge(dataCollection); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!_columnBitmaskEnabled) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] {dataCollectionModelImpl.getUuid()}; finderCache.removeResult(_finderPathCountByUuid, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUuid, args); args = new Object[] { dataCollectionModelImpl.getUuid(), dataCollectionModelImpl.getCompanyId() }; finderCache.removeResult(_finderPathCountByUuid_C, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUuid_C, args); args = new Object[] {dataCollectionModelImpl.getGroupId()}; finderCache.removeResult(_finderPathCountByGroupId, args); finderCache.removeResult( _finderPathWithoutPaginationFindByGroupId, args); args = new Object[] {dataCollectionModelImpl.getUserId()}; finderCache.removeResult(_finderPathCountByUserId, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUserId, args); args = new Object[] {dataCollectionModelImpl.getStatus()}; finderCache.removeResult(_finderPathCountByStatus, args); finderCache.removeResult( _finderPathWithoutPaginationFindByStatus, args); args = new Object[] { dataCollectionModelImpl.getGroupId(), dataCollectionModelImpl.getUserId() }; finderCache.removeResult(_finderPathCountByG_U, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_U, args); args = new Object[] { dataCollectionModelImpl.getGroupId(), dataCollectionModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByG_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_S, args); args = new Object[] { dataCollectionModelImpl.getUserId(), dataCollectionModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByU_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByU_S, args); args = new Object[] { dataCollectionModelImpl.getGroupId(), dataCollectionModelImpl.getUserId(), dataCollectionModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByG_U_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_U_S, args); args = new Object[] {dataCollectionModelImpl.getName()}; finderCache.removeResult(_finderPathCountByName, args); finderCache.removeResult( _finderPathWithoutPaginationFindByName, args); args = new Object[] {dataCollectionModelImpl.getCopiedFrom()}; finderCache.removeResult(_finderPathCountByVariants, args); finderCache.removeResult( _finderPathWithoutPaginationFindByVariants, args); finderCache.removeResult(_finderPathCountAll, FINDER_ARGS_EMPTY); finderCache.removeResult( _finderPathWithoutPaginationFindAll, FINDER_ARGS_EMPTY); } else { if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByUuid.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalUuid() }; finderCache.removeResult(_finderPathCountByUuid, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUuid, args); args = new Object[] {dataCollectionModelImpl.getUuid()}; finderCache.removeResult(_finderPathCountByUuid, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUuid, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByUuid_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalUuid(), dataCollectionModelImpl.getOriginalCompanyId() }; finderCache.removeResult(_finderPathCountByUuid_C, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUuid_C, args); args = new Object[] { dataCollectionModelImpl.getUuid(), dataCollectionModelImpl.getCompanyId() }; finderCache.removeResult(_finderPathCountByUuid_C, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUuid_C, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByGroupId. getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalGroupId() }; finderCache.removeResult(_finderPathCountByGroupId, args); finderCache.removeResult( _finderPathWithoutPaginationFindByGroupId, args); args = new Object[] {dataCollectionModelImpl.getGroupId()}; finderCache.removeResult(_finderPathCountByGroupId, args); finderCache.removeResult( _finderPathWithoutPaginationFindByGroupId, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByUserId.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalUserId() }; finderCache.removeResult(_finderPathCountByUserId, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUserId, args); args = new Object[] {dataCollectionModelImpl.getUserId()}; finderCache.removeResult(_finderPathCountByUserId, args); finderCache.removeResult( _finderPathWithoutPaginationFindByUserId, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByStatus.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalStatus() }; finderCache.removeResult(_finderPathCountByStatus, args); finderCache.removeResult( _finderPathWithoutPaginationFindByStatus, args); args = new Object[] {dataCollectionModelImpl.getStatus()}; finderCache.removeResult(_finderPathCountByStatus, args); finderCache.removeResult( _finderPathWithoutPaginationFindByStatus, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByG_U.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalGroupId(), dataCollectionModelImpl.getOriginalUserId() }; finderCache.removeResult(_finderPathCountByG_U, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_U, args); args = new Object[] { dataCollectionModelImpl.getGroupId(), dataCollectionModelImpl.getUserId() }; finderCache.removeResult(_finderPathCountByG_U, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_U, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByG_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalGroupId(), dataCollectionModelImpl.getOriginalStatus() }; finderCache.removeResult(_finderPathCountByG_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_S, args); args = new Object[] { dataCollectionModelImpl.getGroupId(), dataCollectionModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByG_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_S, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByU_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalUserId(), dataCollectionModelImpl.getOriginalStatus() }; finderCache.removeResult(_finderPathCountByU_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByU_S, args); args = new Object[] { dataCollectionModelImpl.getUserId(), dataCollectionModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByU_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByU_S, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByG_U_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalGroupId(), dataCollectionModelImpl.getOriginalUserId(), dataCollectionModelImpl.getOriginalStatus() }; finderCache.removeResult(_finderPathCountByG_U_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_U_S, args); args = new Object[] { dataCollectionModelImpl.getGroupId(), dataCollectionModelImpl.getUserId(), dataCollectionModelImpl.getStatus() }; finderCache.removeResult(_finderPathCountByG_U_S, args); finderCache.removeResult( _finderPathWithoutPaginationFindByG_U_S, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByName.getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalName() }; finderCache.removeResult(_finderPathCountByName, args); finderCache.removeResult( _finderPathWithoutPaginationFindByName, args); args = new Object[] {dataCollectionModelImpl.getName()}; finderCache.removeResult(_finderPathCountByName, args); finderCache.removeResult( _finderPathWithoutPaginationFindByName, args); } if ((dataCollectionModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByVariants. getColumnBitmask()) != 0) { Object[] args = new Object[] { dataCollectionModelImpl.getOriginalCopiedFrom() }; finderCache.removeResult(_finderPathCountByVariants, args); finderCache.removeResult( _finderPathWithoutPaginationFindByVariants, args); args = new Object[] {dataCollectionModelImpl.getCopiedFrom()}; finderCache.removeResult(_finderPathCountByVariants, args); finderCache.removeResult( _finderPathWithoutPaginationFindByVariants, args); } } entityCache.putResult( entityCacheEnabled, DataCollectionImpl.class, dataCollection.getPrimaryKey(), dataCollection, false); clearUniqueFindersCache(dataCollectionModelImpl, false); cacheUniqueFindersCache(dataCollectionModelImpl); dataCollection.resetOriginalValues(); return dataCollection; } /** * Returns the data collection with the primary key or throws a <code>com.liferay.portal.kernel.exception.NoSuchModelException</code> if it could not be found. * * @param primaryKey the primary key of the data collection * @return the data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection findByPrimaryKey(Serializable primaryKey) throws NoSuchDataCollectionException { DataCollection dataCollection = fetchByPrimaryKey(primaryKey); if (dataCollection == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchDataCollectionException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return dataCollection; } /** * Returns the data collection with the primary key or throws a <code>NoSuchDataCollectionException</code> if it could not be found. * * @param dataCollectionId the primary key of the data collection * @return the data collection * @throws NoSuchDataCollectionException if a data collection with the primary key could not be found */ @Override public DataCollection findByPrimaryKey(long dataCollectionId) throws NoSuchDataCollectionException { return findByPrimaryKey((Serializable)dataCollectionId); } /** * Returns the data collection with the primary key or returns <code>null</code> if it could not be found. * * @param dataCollectionId the primary key of the data collection * @return the data collection, or <code>null</code> if a data collection with the primary key could not be found */ @Override public DataCollection fetchByPrimaryKey(long dataCollectionId) { return fetchByPrimaryKey((Serializable)dataCollectionId); } /** * Returns all the data collections. * * @return the data collections */ @Override public List<DataCollection> findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the data collections. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @return the range of data collections */ @Override public List<DataCollection> findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the data collections. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of data collections */ @Override public List<DataCollection> findAll( int start, int end, OrderByComparator<DataCollection> orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the data collections. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>DataCollectionModelImpl</code>. * </p> * * @param start the lower bound of the range of data collections * @param end the upper bound of the range of data collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param useFinderCache whether to use the finder cache * @return the ordered range of data collections */ @Override public List<DataCollection> findAll( int start, int end, OrderByComparator<DataCollection> orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindAll; finderArgs = FINDER_ARGS_EMPTY; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindAll; finderArgs = new Object[] {start, end, orderByComparator}; } List<DataCollection> list = null; if (useFinderCache) { list = (List<DataCollection>)finderCache.getResult( finderPath, finderArgs, this); } if (list == null) { StringBundler sb = null; String sql = null; if (orderByComparator != null) { sb = new StringBundler( 2 + (orderByComparator.getOrderByFields().length * 2)); sb.append(_SQL_SELECT_DATACOLLECTION); appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = sb.toString(); } else { sql = _SQL_SELECT_DATACOLLECTION; sql = sql.concat(DataCollectionModelImpl.ORDER_BY_JPQL); } Session session = null; try { session = openSession(); Query query = session.createQuery(sql); list = (List<DataCollection>)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { if (useFinderCache) { finderCache.removeResult(finderPath, finderArgs); } throw processException(exception); } finally { closeSession(session); } } return list; } /** * Removes all the data collections from the database. * */ @Override public void removeAll() { for (DataCollection dataCollection : findAll()) { remove(dataCollection); } } /** * Returns the number of data collections. * * @return the number of data collections */ @Override public int countAll() { Long count = (Long)finderCache.getResult( _finderPathCountAll, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query query = session.createQuery(_SQL_COUNT_DATACOLLECTION); count = (Long)query.uniqueResult(); finderCache.putResult( _finderPathCountAll, FINDER_ARGS_EMPTY, count); } catch (Exception exception) { finderCache.removeResult( _finderPathCountAll, FINDER_ARGS_EMPTY); throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } @Override public Set<String> getBadColumnNames() { return _badColumnNames; } @Override protected EntityCache getEntityCache() { return entityCache; } @Override protected String getPKDBName() { return "dataCollectionId"; } @Override protected String getSelectSQL() { return _SQL_SELECT_DATACOLLECTION; } @Override protected Map<String, Integer> getTableColumnsMap() { return DataCollectionModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the data collection persistence. */ @Activate public void activate() { DataCollectionModelImpl.setEntityCacheEnabled(entityCacheEnabled); DataCollectionModelImpl.setFinderCacheEnabled(finderCacheEnabled); _finderPathWithPaginationFindAll = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); _finderPathWithoutPaginationFindAll = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); _finderPathCountAll = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); _finderPathWithPaginationFindByUuid = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByUuid = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid", new String[] {String.class.getName()}, DataCollectionModelImpl.UUID_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByUuid = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid", new String[] {String.class.getName()}); _finderPathFetchByUUID_G = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G", new String[] {String.class.getName(), Long.class.getName()}, DataCollectionModelImpl.UUID_COLUMN_BITMASK | DataCollectionModelImpl.GROUPID_COLUMN_BITMASK); _finderPathCountByUUID_G = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G", new String[] {String.class.getName(), Long.class.getName()}); _finderPathWithPaginationFindByUuid_C = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByUuid_C = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C", new String[] {String.class.getName(), Long.class.getName()}, DataCollectionModelImpl.UUID_COLUMN_BITMASK | DataCollectionModelImpl.COMPANYID_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByUuid_C = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C", new String[] {String.class.getName(), Long.class.getName()}); _finderPathWithPaginationFindByGroupId = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByGroupId = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId", new String[] {Long.class.getName()}, DataCollectionModelImpl.GROUPID_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByGroupId = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId", new String[] {Long.class.getName()}); _finderPathWithPaginationFindByUserId = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByUserId = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId", new String[] {Long.class.getName()}, DataCollectionModelImpl.USERID_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByUserId = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId", new String[] {Long.class.getName()}); _finderPathWithPaginationFindByStatus = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByStatus", new String[] { Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByStatus = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStatus", new String[] {Integer.class.getName()}, DataCollectionModelImpl.STATUS_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByStatus = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStatus", new String[] {Integer.class.getName()}); _finderPathWithPaginationFindByG_U = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByG_U = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U", new String[] {Long.class.getName(), Long.class.getName()}, DataCollectionModelImpl.GROUPID_COLUMN_BITMASK | DataCollectionModelImpl.USERID_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByG_U = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U", new String[] {Long.class.getName(), Long.class.getName()}); _finderPathWithPaginationFindByG_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByG_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S", new String[] {Long.class.getName(), Integer.class.getName()}, DataCollectionModelImpl.GROUPID_COLUMN_BITMASK | DataCollectionModelImpl.STATUS_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByG_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S", new String[] {Long.class.getName(), Integer.class.getName()}); _finderPathWithPaginationFindByU_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_S", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByU_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_S", new String[] {Long.class.getName(), Integer.class.getName()}, DataCollectionModelImpl.USERID_COLUMN_BITMASK | DataCollectionModelImpl.STATUS_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByU_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_S", new String[] {Long.class.getName(), Integer.class.getName()}); _finderPathWithPaginationFindByG_U_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByG_U_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, DataCollectionModelImpl.GROUPID_COLUMN_BITMASK | DataCollectionModelImpl.USERID_COLUMN_BITMASK | DataCollectionModelImpl.STATUS_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByG_U_S = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); _finderPathWithPaginationFindByName = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByName", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByName = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByName", new String[] {String.class.getName()}, DataCollectionModelImpl.NAME_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByName = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByName", new String[] {String.class.getName()}); _finderPathFetchByOrganizationId = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByOrganizationId", new String[] {Long.class.getName()}, DataCollectionModelImpl.ORGANIZATIONID_COLUMN_BITMASK); _finderPathCountByOrganizationId = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByOrganizationId", new String[] {Long.class.getName()}); _finderPathFetchByNameVersion = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByNameVersion", new String[] {String.class.getName(), String.class.getName()}, DataCollectionModelImpl.NAME_COLUMN_BITMASK | DataCollectionModelImpl.VERSION_COLUMN_BITMASK); _finderPathCountByNameVersion = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByNameVersion", new String[] {String.class.getName(), String.class.getName()}); _finderPathWithPaginationFindByVariants = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByVariants", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByVariants = new FinderPath( entityCacheEnabled, finderCacheEnabled, DataCollectionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByVariants", new String[] {Long.class.getName()}, DataCollectionModelImpl.COPIEDFROM_COLUMN_BITMASK | DataCollectionModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByVariants = new FinderPath( entityCacheEnabled, finderCacheEnabled, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVariants", new String[] {Long.class.getName()}); } @Deactivate public void deactivate() { entityCache.removeCache(DataCollectionImpl.class.getName()); finderCache.removeCache(FINDER_CLASS_NAME_ENTITY); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @Override @Reference( target = ICECAPPersistenceConstants.SERVICE_CONFIGURATION_FILTER, unbind = "-" ) public void setConfiguration(Configuration configuration) { super.setConfiguration(configuration); _columnBitmaskEnabled = GetterUtil.getBoolean( configuration.get( "value.object.column.bitmask.enabled.com.osp.icecap.model.DataCollection"), true); } @Override @Reference( target = ICECAPPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setDataSource(DataSource dataSource) { super.setDataSource(dataSource); } @Override @Reference( target = ICECAPPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setSessionFactory(SessionFactory sessionFactory) { super.setSessionFactory(sessionFactory); } private boolean _columnBitmaskEnabled; @Reference protected EntityCache entityCache; @Reference protected FinderCache finderCache; private static final String _SQL_SELECT_DATACOLLECTION = "SELECT dataCollection FROM DataCollection dataCollection"; private static final String _SQL_SELECT_DATACOLLECTION_WHERE = "SELECT dataCollection FROM DataCollection dataCollection WHERE "; private static final String _SQL_COUNT_DATACOLLECTION = "SELECT COUNT(dataCollection) FROM DataCollection dataCollection"; private static final String _SQL_COUNT_DATACOLLECTION_WHERE = "SELECT COUNT(dataCollection) FROM DataCollection dataCollection WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dataCollection.dataCollectionId"; private static final String _FILTER_SQL_SELECT_DATACOLLECTION_WHERE = "SELECT DISTINCT {dataCollection.*} FROM ICECAP_DataCollection dataCollection WHERE "; private static final String _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {ICECAP_DataCollection.*} FROM (SELECT DISTINCT dataCollection.dataCollectionId FROM ICECAP_DataCollection dataCollection WHERE "; private static final String _FILTER_SQL_SELECT_DATACOLLECTION_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN ICECAP_DataCollection ON TEMP_TABLE.dataCollectionId = ICECAP_DataCollection.dataCollectionId"; private static final String _FILTER_SQL_COUNT_DATACOLLECTION_WHERE = "SELECT COUNT(DISTINCT dataCollection.dataCollectionId) AS COUNT_VALUE FROM ICECAP_DataCollection dataCollection WHERE "; private static final String _FILTER_ENTITY_ALIAS = "dataCollection"; private static final String _FILTER_ENTITY_TABLE = "ICECAP_DataCollection"; private static final String _ORDER_BY_ENTITY_ALIAS = "dataCollection."; private static final String _ORDER_BY_ENTITY_TABLE = "ICECAP_DataCollection."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DataCollection exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DataCollection exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( DataCollectionPersistenceImpl.class); private static final Set<String> _badColumnNames = SetUtil.fromArray( new String[] {"uuid"}); static { try { Class.forName(ICECAPPersistenceConstants.class.getName()); } catch (ClassNotFoundException classNotFoundException) { throw new ExceptionInInitializerError(classNotFoundException); } } }
285,754
0.705155
0.701155
9,763
28.269794
47.532948
615
false
false
0
0
0
0
0
0
2.480283
false
false
5
fd2b79cb07aee03ae6b41e2fe7a1c5a1c6bc2281
37,752,762,565,048
fda4763042bdce31e249b8bc98cfc7ac44e13dc0
/src/test/java/cc/smartcasual/HashSetFilter.java
28e7a894f8ceeba62677a43764a29efdc391707e
[]
no_license
danborthwick/BloomFilters
https://github.com/danborthwick/BloomFilters
5074ffa8d85362f71ccce3fd8acaef6efdd2f04f
7ad2af53bdb786d88cec66e50ee2483bc7c58d21
refs/heads/master
2021-01-13T03:15:08.873000
2016-12-29T15:03:13
2016-12-29T15:03:13
77,611,204
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package cc.smartcasual; import cc.smartcasual.filter.SetFilter; import java.io.Serializable; import java.util.HashSet; public class HashSetFilter<T> implements SetFilter<T>, Serializable { HashSet<T> hashSet = new HashSet<>(); @Override public void add(T value) { hashSet.add(value); } @Override public boolean mayContain(T value) { return hashSet.contains(value); } @Override public int estimatedCount() { return hashSet.size(); } }
UTF-8
Java
505
java
HashSetFilter.java
Java
[]
null
[]
package cc.smartcasual; import cc.smartcasual.filter.SetFilter; import java.io.Serializable; import java.util.HashSet; public class HashSetFilter<T> implements SetFilter<T>, Serializable { HashSet<T> hashSet = new HashSet<>(); @Override public void add(T value) { hashSet.add(value); } @Override public boolean mayContain(T value) { return hashSet.contains(value); } @Override public int estimatedCount() { return hashSet.size(); } }
505
0.661386
0.661386
26
18.423077
17.97257
69
false
false
0
0
0
0
0
0
0.346154
false
false
5
881009e5f2d1281f931f1b47db12427c8f61683e
6,382,321,446,655
f930dcae9eef3e5d3641fb6f57c4960f58ae197f
/src/main/java/com/jjdevine/entity/SportsProduct.java
88e33bad164d3f38edf077dead797d57d1df7721
[]
no_license
jjdevine/sky-webapp-jpa
https://github.com/jjdevine/sky-webapp-jpa
7c2c70eb6d707c21d9e6928b07138d2d59fddeb5
e9592bfaf9a6fca47c0a4e1759aa8e806302e9e5
refs/heads/master
2021-01-10T09:10:32.816000
2016-01-24T20:26:47
2016-01-24T20:26:47
50,306,566
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.jjdevine.entity; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; /** * Entity class for sports products. * @author Jonathan * */ @Entity @Table(name="sports_product") public class SportsProduct { /** * The primary key. */ @Id @Column(name="id") private long id; /** * The name of the sports product. */ @Column(name="name") private String name; /** * The location id associated with the product. */ @Column(name="location_id") private Long locationId; /** * @return the id */ public long getId() { return id; } /** * @param id the id to set */ public void setId(long id) { this.id = id; } /** * @return the name */ public String getName() { return name; } /** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the locationId */ public Long getLocationId() { return locationId; } /** * @param locationId the locationId to set */ public void setLocationId(Long locationId) { this.locationId = locationId; } }
UTF-8
Java
1,143
java
SportsProduct.java
Java
[ { "context": "**\n * Entity class for sports products.\n * @author Jonathan\n *\n */\n@Entity\n@Table(name=\"sports_product\")\npubl", "end": 218, "score": 0.9996732473373413, "start": 210, "tag": "NAME", "value": "Jonathan" } ]
null
[]
package com.jjdevine.entity; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; /** * Entity class for sports products. * @author Jonathan * */ @Entity @Table(name="sports_product") public class SportsProduct { /** * The primary key. */ @Id @Column(name="id") private long id; /** * The name of the sports product. */ @Column(name="name") private String name; /** * The location id associated with the product. */ @Column(name="location_id") private Long locationId; /** * @return the id */ public long getId() { return id; } /** * @param id the id to set */ public void setId(long id) { this.id = id; } /** * @return the name */ public String getName() { return name; } /** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the locationId */ public Long getLocationId() { return locationId; } /** * @param locationId the locationId to set */ public void setLocationId(Long locationId) { this.locationId = locationId; } }
1,143
0.641295
0.641295
77
13.844156
13.363125
48
false
false
0
0
0
0
0
0
0.961039
false
false
5
c33f80c364412046ec4c203724a4d62082c3b7be
1,108,101,577,770
e90b7949342bcfaa33c8e30360c304dda0e69a0b
/20180303_cw1_menu_wyjscie/przyklad/src/com/infoshareacademy/warsaw/java/command/MenuPrinter.java
bf49defb7f6e677e84f8b9ccbfa2c4d482d9d5b5
[]
no_license
michalolafmusial/projekty_michal_musial
https://github.com/michalolafmusial/projekty_michal_musial
780265605a0be73844f3066d3c42a7a68f36d61a
408bea38b1a090c2ba2684e14428f8e56349b8de
refs/heads/master
2021-04-26T23:02:38.575000
2018-08-06T21:43:17
2018-08-06T21:43:17
123,921,265
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.infoshareacademy.warsaw.java.command; class MenuPrinter implements Command { @Override public void execute() { System.out.println("----- Witamy w super wprowadzeniu do Javy -----"); System.out.println("\t1. importy"); System.out.println("\t2. instrukcje warunkowe"); System.out.println("\t3. pętle"); System.out.println("\t4. typy proste, tablice"); System.out.println("\t5. rzutowanie"); System.out.println("----- ----------------------------------- -----"); } }
UTF-8
Java
546
java
MenuPrinter.java
Java
[]
null
[]
package com.infoshareacademy.warsaw.java.command; class MenuPrinter implements Command { @Override public void execute() { System.out.println("----- Witamy w super wprowadzeniu do Javy -----"); System.out.println("\t1. importy"); System.out.println("\t2. instrukcje warunkowe"); System.out.println("\t3. pętle"); System.out.println("\t4. typy proste, tablice"); System.out.println("\t5. rzutowanie"); System.out.println("----- ----------------------------------- -----"); } }
546
0.570642
0.561468
14
37.92857
24.949848
78
false
false
0
0
0
0
0
0
0.642857
false
false
5
26d93f1ba56eb1df22b284b2e877d0ad1aeee9ab
3,100,966,449,809
f36c4cc8bacb5195ae5bc27db9f87f487d8b690b
/SpaceStory/src/topview/welt/collision/Kollision.java
6710c7059f63fa94792dc2b20b374140e0f376e5
[]
no_license
newHoriz0n/SpaceStory
https://github.com/newHoriz0n/SpaceStory
220c81da0063c0b5e7e3ca0a3b8bb5ea29f8e937
901a1c5e0bc3870d81bd57538490cc56299f2b2a
refs/heads/master
2020-03-19T10:36:55.749000
2018-06-11T08:56:10
2018-06-11T08:56:10
136,385,665
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package topview.welt.collision; import java.util.ArrayList; import java.util.List; import topview.pbLib.Koordinate3D; public class Kollision { private static boolean computeCollision(Collidable c0, Collidable c1) { // l_n: Normalenvektor (Verbindung zwischen den beiden Kugelnn) double l_nx = c1.getPosition().getX() - c0.getPosition().getX(); double l_ny = c1.getPosition().getY() - c0.getPosition().getY(); // Abstand der beiden Kugeln double l_dist = Math.sqrt(l_nx * l_nx + l_ny * l_ny); // Kugeln kollidieren, wenn der Abstand kleiner gleich der Summe // der Radien beider Kugeln ist. if (l_dist <= c0.getRadius() + c1.getRadius()) { // Normalenvektor wird normalisiert: |l_n| = 1 l_nx /= l_dist; l_ny /= l_dist; // Tangentialvektor (senkrecht zu Normalenvektor, zwischen beiden Kugeln) double l_tx = l_ny; double l_ty = -l_nx; // Summe der Massen beider Kugeln double l_sm1m2 = c0.getMasse() + c1.getMasse(); // Überlappung der beiden Kugeln double l_overlap = (c0.getRadius() + c1.getRadius()) - l_dist; // Verschieben der beiden Kugeln entlang der Normalen, // so dass sie sich nicht mehr überlappen! double EPSILON = 0.1; c0.getTraeger().getPosition().setKoordinaten( c0.getTraeger().getPosition().getX() - l_nx * l_overlap * (c1.getMasse() / l_sm1m2) * (1 + EPSILON), c0.getTraeger().getPosition().getY() - l_ny * l_overlap * (c1.getMasse() / l_sm1m2) * (1 + EPSILON), 0); c1.getTraeger().getPosition().setKoordinaten( c1.getTraeger().getPosition().getX() + l_nx * l_overlap * (c0.getMasse() / l_sm1m2) * (1 + EPSILON), c1.getTraeger().getPosition().getY() + l_ny * l_overlap * (c0.getMasse() / l_sm1m2) * (1 + EPSILON), 0); // Zerlegung der Geschwindigkeitsvektoren in Normalen- und // Tangentialanteil: v=sn*n+st*t, wobei // v Vektor, n Normalenvektor, t Tagentialvektor und // sn, st zwei skalare Werte sind. // Es gilt: v*n = sn*(n*n)+st*(t*n) = sn, da t*n=0 und n*n = 1 // Es gilt: v*t = sn*(n*t)+st*(t*t) = st, da t*n=0 und t*t = 1 // Also ist: sn = v*n und st=v*t // Ball 1: Zerlegung des Geschwindigkeitsvektors in n- und t-Anteil double l_sn1 = l_nx * c0.getTraeger().getSpeed().getX() + l_ny * c0.getTraeger().getSpeed().getY(); double l_st1 = l_tx * c0.getTraeger().getSpeed().getX() + l_ty * c0.getTraeger().getSpeed().getY(); double l_n1x = l_nx * l_sn1; // Normalenvektor-Anteil von p_b1.vx double l_n1y = l_ny * l_sn1; double l_t1x = l_tx * l_st1; // Tangentialvektor-Anteil von p_b1.vx double l_t1y = l_ty * l_st1; // Ball 2: Zerlegung des Geschwindigkeitsvektors in n- und t-Anteil double l_sn2 = l_nx * c1.getTraeger().getSpeed().getX() + l_ny * c1.getTraeger().getSpeed().getY(); double l_st2 = l_tx * c1.getTraeger().getSpeed().getX() + l_ty * c1.getTraeger().getSpeed().getY(); double l_n2x = l_nx * l_sn2; // Normalenvektor-Anteil von p_b2.vx double l_n2y = l_ny * l_sn2; double l_t2x = l_tx * l_st2; // Tangentialvektor-Anteil von p_b2.vx double l_t2y = l_ty * l_st2; // Der Impulserhaltungssatz // m1*v1 + m2*v2 = m1*v1' + m2*v2' // (wobei m1, m2 = Massen der Körper // und v1, v2, v1', v2' die Geschwindigkeiten) // und der Energieerhaltsungssatz // 0,5*m1*v1² + 0,5*m2*v2² = 0,5*m1*v1'² + 0,5*m2*v2'² // führen nach einfachen mathematischen Umformungen zu // folgenden Beziehungen (für den eindimensionalen Fall): // v1' = 2*(m1*v1+m2*v2)/(m1+m2) - v1 // v2' = 2*(m1*v1+m2*v2)/(m1+m2) - v2 // 2*(m1*v1+m2*v2)/(m1+m2) ist die Geschwindigkeit des // gemeinsamen Schwerpunktes. // Im zweidimensionalen Fall gilt, dass die Kollision entlang // der Normalen erfolgt. Die tangentialen Anteile der der // Bewegungsrichtungen werden unverändert übernommen. double l_vspx = 2 * (c0.getMasse() * l_n1x + c1.getMasse() * l_n2x) / l_sm1m2; double l_vspy = 2 * (c0.getMasse() * l_n1y + c1.getMasse() * l_n2y) / l_sm1m2; if (!c0.getTraeger().isFixiert()) { c0.getTraeger().setSpeedNachKollision(new Koordinate3D(l_vspx - l_n1x + l_t1x, l_vspy - l_n1y + l_t1y, 0)); } if (!c1.getTraeger().isFixiert()) { c1.getTraeger().setSpeedNachKollision(new Koordinate3D(l_vspx - l_n2x + l_t2x, l_vspy - l_n2y + l_t2y, 0)); } return true; } return false; } public static boolean checkCollision(Collidable c0, Collidable c1) { List<Collidable> cs0 = new ArrayList<Collidable>(); c0.getCollidableTeile(cs0); List<Collidable> cs1 = new ArrayList<Collidable>(); c1.getCollidableTeile(cs1); boolean collision = false; for (Collidable ct0 : cs0) { for (Collidable ct1 : cs1) { if (computeCollision(ct0, ct1)) { collision = true; } } } return collision; } }
ISO-8859-1
Java
4,881
java
Kollision.java
Java
[]
null
[]
package topview.welt.collision; import java.util.ArrayList; import java.util.List; import topview.pbLib.Koordinate3D; public class Kollision { private static boolean computeCollision(Collidable c0, Collidable c1) { // l_n: Normalenvektor (Verbindung zwischen den beiden Kugelnn) double l_nx = c1.getPosition().getX() - c0.getPosition().getX(); double l_ny = c1.getPosition().getY() - c0.getPosition().getY(); // Abstand der beiden Kugeln double l_dist = Math.sqrt(l_nx * l_nx + l_ny * l_ny); // Kugeln kollidieren, wenn der Abstand kleiner gleich der Summe // der Radien beider Kugeln ist. if (l_dist <= c0.getRadius() + c1.getRadius()) { // Normalenvektor wird normalisiert: |l_n| = 1 l_nx /= l_dist; l_ny /= l_dist; // Tangentialvektor (senkrecht zu Normalenvektor, zwischen beiden Kugeln) double l_tx = l_ny; double l_ty = -l_nx; // Summe der Massen beider Kugeln double l_sm1m2 = c0.getMasse() + c1.getMasse(); // Überlappung der beiden Kugeln double l_overlap = (c0.getRadius() + c1.getRadius()) - l_dist; // Verschieben der beiden Kugeln entlang der Normalen, // so dass sie sich nicht mehr überlappen! double EPSILON = 0.1; c0.getTraeger().getPosition().setKoordinaten( c0.getTraeger().getPosition().getX() - l_nx * l_overlap * (c1.getMasse() / l_sm1m2) * (1 + EPSILON), c0.getTraeger().getPosition().getY() - l_ny * l_overlap * (c1.getMasse() / l_sm1m2) * (1 + EPSILON), 0); c1.getTraeger().getPosition().setKoordinaten( c1.getTraeger().getPosition().getX() + l_nx * l_overlap * (c0.getMasse() / l_sm1m2) * (1 + EPSILON), c1.getTraeger().getPosition().getY() + l_ny * l_overlap * (c0.getMasse() / l_sm1m2) * (1 + EPSILON), 0); // Zerlegung der Geschwindigkeitsvektoren in Normalen- und // Tangentialanteil: v=sn*n+st*t, wobei // v Vektor, n Normalenvektor, t Tagentialvektor und // sn, st zwei skalare Werte sind. // Es gilt: v*n = sn*(n*n)+st*(t*n) = sn, da t*n=0 und n*n = 1 // Es gilt: v*t = sn*(n*t)+st*(t*t) = st, da t*n=0 und t*t = 1 // Also ist: sn = v*n und st=v*t // Ball 1: Zerlegung des Geschwindigkeitsvektors in n- und t-Anteil double l_sn1 = l_nx * c0.getTraeger().getSpeed().getX() + l_ny * c0.getTraeger().getSpeed().getY(); double l_st1 = l_tx * c0.getTraeger().getSpeed().getX() + l_ty * c0.getTraeger().getSpeed().getY(); double l_n1x = l_nx * l_sn1; // Normalenvektor-Anteil von p_b1.vx double l_n1y = l_ny * l_sn1; double l_t1x = l_tx * l_st1; // Tangentialvektor-Anteil von p_b1.vx double l_t1y = l_ty * l_st1; // Ball 2: Zerlegung des Geschwindigkeitsvektors in n- und t-Anteil double l_sn2 = l_nx * c1.getTraeger().getSpeed().getX() + l_ny * c1.getTraeger().getSpeed().getY(); double l_st2 = l_tx * c1.getTraeger().getSpeed().getX() + l_ty * c1.getTraeger().getSpeed().getY(); double l_n2x = l_nx * l_sn2; // Normalenvektor-Anteil von p_b2.vx double l_n2y = l_ny * l_sn2; double l_t2x = l_tx * l_st2; // Tangentialvektor-Anteil von p_b2.vx double l_t2y = l_ty * l_st2; // Der Impulserhaltungssatz // m1*v1 + m2*v2 = m1*v1' + m2*v2' // (wobei m1, m2 = Massen der Körper // und v1, v2, v1', v2' die Geschwindigkeiten) // und der Energieerhaltsungssatz // 0,5*m1*v1² + 0,5*m2*v2² = 0,5*m1*v1'² + 0,5*m2*v2'² // führen nach einfachen mathematischen Umformungen zu // folgenden Beziehungen (für den eindimensionalen Fall): // v1' = 2*(m1*v1+m2*v2)/(m1+m2) - v1 // v2' = 2*(m1*v1+m2*v2)/(m1+m2) - v2 // 2*(m1*v1+m2*v2)/(m1+m2) ist die Geschwindigkeit des // gemeinsamen Schwerpunktes. // Im zweidimensionalen Fall gilt, dass die Kollision entlang // der Normalen erfolgt. Die tangentialen Anteile der der // Bewegungsrichtungen werden unverändert übernommen. double l_vspx = 2 * (c0.getMasse() * l_n1x + c1.getMasse() * l_n2x) / l_sm1m2; double l_vspy = 2 * (c0.getMasse() * l_n1y + c1.getMasse() * l_n2y) / l_sm1m2; if (!c0.getTraeger().isFixiert()) { c0.getTraeger().setSpeedNachKollision(new Koordinate3D(l_vspx - l_n1x + l_t1x, l_vspy - l_n1y + l_t1y, 0)); } if (!c1.getTraeger().isFixiert()) { c1.getTraeger().setSpeedNachKollision(new Koordinate3D(l_vspx - l_n2x + l_t2x, l_vspy - l_n2y + l_t2y, 0)); } return true; } return false; } public static boolean checkCollision(Collidable c0, Collidable c1) { List<Collidable> cs0 = new ArrayList<Collidable>(); c0.getCollidableTeile(cs0); List<Collidable> cs1 = new ArrayList<Collidable>(); c1.getCollidableTeile(cs1); boolean collision = false; for (Collidable ct0 : cs0) { for (Collidable ct1 : cs1) { if (computeCollision(ct0, ct1)) { collision = true; } } } return collision; } }
4,881
0.627926
0.590349
124
37.290321
31.719734
111
false
false
0
0
0
0
0
0
2.685484
false
false
5
d09911436fa87f2c0cf4b9ac2433ce4527fbc90b
19,146,964,218,683
f05a9d027a0789775587501ea6fb6f3f0a644362
/src/main/java/br/com/caelum/cdcreact/controllers/AutorController.java
ee80b8bd6e081205a9375d97dff3d4d8775bb23b
[]
no_license
asouza/cdc-crud-reactor
https://github.com/asouza/cdc-crud-reactor
b99859fd32927132f4757274aee9a1860f8d3555
543842c03f816c1da2938e4d854ca60faa993094
refs/heads/master
2016-08-23T10:42:10.619000
2016-08-03T21:04:45
2016-08-03T21:04:45
63,979,857
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package br.com.caelum.cdcreact.controllers; import javax.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import br.com.caelum.cdcreact.daos.AutorDao; import br.com.caelum.cdcreact.models.Autor; @RestController @RequestMapping("/api/autor") public class AutorController { @Autowired private AutorDao autorDao; @RequestMapping(consumes=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST) public ResponseEntity<?> salva(@Valid @RequestBody Autor autor) { autorDao.save(autor); return ResponseEntity.status(302).header("Location", "/api/autor").build(); } @RequestMapping(method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) public Iterable<Autor> lista() { return autorDao.findAll(); } }
UTF-8
Java
1,110
java
AutorController.java
Java
[]
null
[]
package br.com.caelum.cdcreact.controllers; import javax.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import br.com.caelum.cdcreact.daos.AutorDao; import br.com.caelum.cdcreact.models.Autor; @RestController @RequestMapping("/api/autor") public class AutorController { @Autowired private AutorDao autorDao; @RequestMapping(consumes=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST) public ResponseEntity<?> salva(@Valid @RequestBody Autor autor) { autorDao.save(autor); return ResponseEntity.status(302).header("Location", "/api/autor").build(); } @RequestMapping(method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) public Iterable<Autor> lista() { return autorDao.findAll(); } }
1,110
0.807207
0.804505
34
31.647058
27.661697
88
false
false
0
0
0
0
0
0
1
false
false
5
48f16f0012160bc59400b15f3195dc33ebe860df
31,439,160,670,352
249b121be0fd99b75f0c8705bb034cf67bb6459f
/transport/src/main/java/fr/eql/al35/wsrest/transport/service/TransportIService.java
dd14b48735ac3244fef8d623ee95f988fa753283
[]
no_license
mathildalandreau/Mathild-A
https://github.com/mathildalandreau/Mathild-A
b3dc6d0e757dcf1f091aa2071beaa1048f93e4a0
5b002e94f724ce6a7e83acf31c5820050fd7e693
refs/heads/main
2023-06-02T10:41:50.950000
2021-06-30T08:58:47
2021-06-30T08:58:47
378,852,256
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package fr.eql.al35.wsrest.transport.service; import java.util.List; import fr.eql.al35.wsrest.transport.entity.Tarif; public interface TransportIService { public List<Tarif> calculateTarifs(Double weight); }
UTF-8
Java
215
java
TransportIService.java
Java
[]
null
[]
package fr.eql.al35.wsrest.transport.service; import java.util.List; import fr.eql.al35.wsrest.transport.entity.Tarif; public interface TransportIService { public List<Tarif> calculateTarifs(Double weight); }
215
0.795349
0.776744
11
18.545454
21.372725
51
false
false
0
0
0
0
0
0
0.454545
false
false
10
e53d0d52dd44d3c90d4c2f58917f8aed4baf3a4d
31,344,671,378,285
f45b64671952890ea5adf5005c431af1e7717f00
/Jun/src/software1711/niit/MyPractice/multithreading/sxt_vidoes/status/SleepDemo02.java
5986046e15085d9eaa0d90df7ec335d3b0994da1
[]
no_license
xajhwj/JAVA
https://github.com/xajhwj/JAVA
345b4b5c9439bde74940ecbde7132ea99abcddf7
a06ab0b6bfa358e4361f01a2e68c6fde68fa7af0
refs/heads/master
2018-12-21T05:10:33.990000
2018-12-20T10:41:31
2018-12-20T10:41:31
149,795,759
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package software1711.niit.MyPractice.multithreading.sxt_vidoes.status; /** * sleep 模拟网络延时 * @author 笑傲江湖 * 2018-10-05 09:31 */ public class SleepDemo02 { public static void main(String[] args){ // 真实角色 Web12306 web12306 = new Web12306(); // 代理角色 Thread t1 = new Thread(web12306, "路人甲"); Thread t2 = new Thread(web12306, "程序猿"); Thread t3 = new Thread(web12306, "攻城狮"); // 启动线程 t1.start(); t2.start(); t3.start(); } } class Web12306 implements Runnable { private int number = 50; @Override public void run() { while (true){ if (number <= 0){ break; } try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(Thread.currentThread().getName() + "抢到了" + number--); } } } /* public static void main(String[] args) { //真实角色 Web12306 web= new Web12306(); Web12306 web2 = new Web12306(); //代理 Thread t1 =new Thread(web,"路人甲"); Thread t2 =new Thread(web,"黄牛已"); Thread t3 =new Thread(web,"攻城师"); //启动线程 t1.start(); t2.start(); t3.start(); } } class Web12306 implements Runnable { private int num =50; @Override public void run() { while(true){ if(num<=0){ break; //跳出循环 } try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(Thread.currentThread().getName()+"抢到了"+num--); } } } */
UTF-8
Java
1,886
java
SleepDemo02.java
Java
[ { "context": "xt_vidoes.status;\n\n/**\n * sleep 模拟网络延时\n * @author 笑傲江湖\n * 2018-10-05 09:31\n */\npublic class SleepDemo02 ", "end": 107, "score": 0.999860405921936, "start": 103, "tag": "NAME", "value": "笑傲江湖" } ]
null
[]
package software1711.niit.MyPractice.multithreading.sxt_vidoes.status; /** * sleep 模拟网络延时 * @author 笑傲江湖 * 2018-10-05 09:31 */ public class SleepDemo02 { public static void main(String[] args){ // 真实角色 Web12306 web12306 = new Web12306(); // 代理角色 Thread t1 = new Thread(web12306, "路人甲"); Thread t2 = new Thread(web12306, "程序猿"); Thread t3 = new Thread(web12306, "攻城狮"); // 启动线程 t1.start(); t2.start(); t3.start(); } } class Web12306 implements Runnable { private int number = 50; @Override public void run() { while (true){ if (number <= 0){ break; } try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(Thread.currentThread().getName() + "抢到了" + number--); } } } /* public static void main(String[] args) { //真实角色 Web12306 web= new Web12306(); Web12306 web2 = new Web12306(); //代理 Thread t1 =new Thread(web,"路人甲"); Thread t2 =new Thread(web,"黄牛已"); Thread t3 =new Thread(web,"攻城师"); //启动线程 t1.start(); t2.start(); t3.start(); } } class Web12306 implements Runnable { private int num =50; @Override public void run() { while(true){ if(num<=0){ break; //跳出循环 } try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(Thread.currentThread().getName()+"抢到了"+num--); } } } */
1,886
0.49094
0.432616
78
21.641026
18.349857
84
false
false
0
0
0
0
0
0
0.410256
false
false
10
10bf6ee283ff2f7aab19f68515a4d93e48ddfd42
16,647,293,269,183
4f33efae217b540087f8ae512e708e9a303028db
/Harmony/src/model/ProdottoDAO.java
fb1339e65ec7a47bf42c89c6f4ecb30954893491
[]
no_license
ETesauro/Harmony
https://github.com/ETesauro/Harmony
45e9e50abd2e70a52c7079320f47641ba4a91625
ec3d282fa7dcbc222c066839387579091977b276
refs/heads/master
2021-06-20T17:49:10.163000
2021-05-26T12:16:44
2021-05-26T12:16:44
219,159,258
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package model; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import java.sql.PreparedStatement; import java.sql.ResultSet; import model.Prodotto; public class ProdottoDAO { public synchronized Prodotto doRetrieveById(int id) { PreparedStatement ps = null; Prodotto bean = new Prodotto(); try (Connection conn = ConnPool.getConnection()){ ps = conn.prepareStatement("SELECT prodotto.id, prodotto.nome, prodotto.prezzo, prodotto.categoria, prodotto.descrizione FROM prodotto JOIN Categoria ON Categoria.ID=prodotto.categoria WHERE prodotto.id=?"); ps.setInt(1, id); ResultSet rs = ps.executeQuery(); if(rs.next()) { bean.setID(rs.getInt("id")); bean.setNome(rs.getString("nome")); bean.setCategoria(rs.getString("categoria")); bean.setDescrizione(rs.getString("descrizione")); bean.setPrezzo(rs.getLong("prezzo")); return bean; } return null; } catch(SQLException e) { throw new RuntimeException(e); } } public List<Prodotto> doRetrieveAll(int offset, int limit) { try (Connection con = ConnPool.getConnection()) { PreparedStatement ps = con .prepareStatement("SELECT id, nome, descrizione, prezzo FROM prodotto LIMIT ?, ?"); ps.setInt(1, offset); ps.setInt(2, limit); ArrayList<Prodotto> prodotti = new ArrayList<>(); ResultSet rs = ps.executeQuery(); while (rs.next()) { Prodotto p = new Prodotto(); p.setID(rs.getInt(1)); p.setNome(rs.getString(2)); p.setDescrizione(rs.getString(3)); p.setPrezzo(rs.getLong(4)); prodotti.add(p); } return prodotti; } catch (SQLException e) { throw new RuntimeException(e); } } public List<Prodotto> doRetrieveByCategoria(int categoria, int offset, int limit) { try (Connection con = ConnPool.getConnection()) { PreparedStatement ps = con.prepareStatement( "SELECT prodotto.id, prodotto.nome, prodotto.descrizione, prezzo FROM prodotto JOIN categoria on prodotto.categoria=categoria.id WHERE categoria.id=? LIMIT ?, ?"); ps.setInt(1, categoria); ps.setInt(2, offset); ps.setInt(3, limit); ArrayList<Prodotto> prodotti = new ArrayList<>(); ResultSet rs = ps.executeQuery(); while (rs.next()) { Prodotto p = new Prodotto(); p.setID(rs.getInt(1)); p.setNome(rs.getString(2)); p.setDescrizione(rs.getString(3)); p.setPrezzo(rs.getLong(4)); prodotti.add(p); } return prodotti; } catch (SQLException e) { throw new RuntimeException(e); } } public List<Prodotto> doRetrieveByMatch(String against, int offset, int limit) { try (Connection con = ConnPool.getConnection()) { PreparedStatement ps = con.prepareStatement( "SELECT id, nome, descrizione, prezzo FROM prodotto WHERE MATCH(nome, descrizione) AGAINST(?) LIMIT ?, ?"); ps.setString(1, against); ps.setInt(2, offset); ps.setInt(3, limit); ArrayList<Prodotto> prodotti = new ArrayList<>(); ResultSet rs = ps.executeQuery(); while (rs.next()) { Prodotto p = new Prodotto(); p.setID(rs.getInt(1)); p.setNome(rs.getString(2)); p.setDescrizione(rs.getString(3)); p.setPrezzo(rs.getLong(4)); prodotti.add(p); } return prodotti; } catch (SQLException e) { throw new RuntimeException(e); } } public int doSave(Prodotto prodotto) { try(Connection con = ConnPool.getConnection()){ PreparedStatement ps = con.prepareStatement("INSERT INTO prodotto (nome, prezzo, descrizione, categoria) VALUES(?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS); ps.setString(1, prodotto.getNome()); ps.setFloat(2, prodotto.getPrezzo()); ps.setString(3, prodotto.getDescrizione()); ps.setInt(4, Integer.parseInt(prodotto.getCategoria())); if(ps.executeUpdate() != 1) { throw new RuntimeException("INSERT error!"); } ResultSet rs = ps.getGeneratedKeys(); rs.next(); int id = rs.getInt(1); prodotto.setID(id); return id; } catch (SQLException e) { e.printStackTrace(); return -1; } } public void doDelete(int id) { try(Connection con = ConnPool.getConnection()){ PreparedStatement ps = con.prepareStatement("DELETE FROM prodotto WHERE id=?"); ps.setInt(1, id); if(ps.executeUpdate() != 1) { throw new RuntimeException("DELETE Error!"); } } catch (SQLException e) { e.printStackTrace(); } } public void doUpdate(Prodotto prodotto) { try (Connection con = ConnPool.getConnection()) { PreparedStatement ps = con .prepareStatement("UPDATE prodotto SET nome=?, descrizione=?, prezzo=?, categoria=? WHERE id=?"); ps.setString(1, prodotto.getNome()); ps.setString(2, prodotto.getDescrizione()); ps.setFloat(3, prodotto.getPrezzo()); ps.setInt(4, Integer.parseInt(prodotto.getCategoria())); ps.setInt(5, prodotto.getID()); if (ps.executeUpdate() != 1) { throw new RuntimeException("UPDATE error."); } } catch (SQLException e) { throw new RuntimeException(e); } } }
UTF-8
Java
5,010
java
ProdottoDAO.java
Java
[]
null
[]
package model; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import java.sql.PreparedStatement; import java.sql.ResultSet; import model.Prodotto; public class ProdottoDAO { public synchronized Prodotto doRetrieveById(int id) { PreparedStatement ps = null; Prodotto bean = new Prodotto(); try (Connection conn = ConnPool.getConnection()){ ps = conn.prepareStatement("SELECT prodotto.id, prodotto.nome, prodotto.prezzo, prodotto.categoria, prodotto.descrizione FROM prodotto JOIN Categoria ON Categoria.ID=prodotto.categoria WHERE prodotto.id=?"); ps.setInt(1, id); ResultSet rs = ps.executeQuery(); if(rs.next()) { bean.setID(rs.getInt("id")); bean.setNome(rs.getString("nome")); bean.setCategoria(rs.getString("categoria")); bean.setDescrizione(rs.getString("descrizione")); bean.setPrezzo(rs.getLong("prezzo")); return bean; } return null; } catch(SQLException e) { throw new RuntimeException(e); } } public List<Prodotto> doRetrieveAll(int offset, int limit) { try (Connection con = ConnPool.getConnection()) { PreparedStatement ps = con .prepareStatement("SELECT id, nome, descrizione, prezzo FROM prodotto LIMIT ?, ?"); ps.setInt(1, offset); ps.setInt(2, limit); ArrayList<Prodotto> prodotti = new ArrayList<>(); ResultSet rs = ps.executeQuery(); while (rs.next()) { Prodotto p = new Prodotto(); p.setID(rs.getInt(1)); p.setNome(rs.getString(2)); p.setDescrizione(rs.getString(3)); p.setPrezzo(rs.getLong(4)); prodotti.add(p); } return prodotti; } catch (SQLException e) { throw new RuntimeException(e); } } public List<Prodotto> doRetrieveByCategoria(int categoria, int offset, int limit) { try (Connection con = ConnPool.getConnection()) { PreparedStatement ps = con.prepareStatement( "SELECT prodotto.id, prodotto.nome, prodotto.descrizione, prezzo FROM prodotto JOIN categoria on prodotto.categoria=categoria.id WHERE categoria.id=? LIMIT ?, ?"); ps.setInt(1, categoria); ps.setInt(2, offset); ps.setInt(3, limit); ArrayList<Prodotto> prodotti = new ArrayList<>(); ResultSet rs = ps.executeQuery(); while (rs.next()) { Prodotto p = new Prodotto(); p.setID(rs.getInt(1)); p.setNome(rs.getString(2)); p.setDescrizione(rs.getString(3)); p.setPrezzo(rs.getLong(4)); prodotti.add(p); } return prodotti; } catch (SQLException e) { throw new RuntimeException(e); } } public List<Prodotto> doRetrieveByMatch(String against, int offset, int limit) { try (Connection con = ConnPool.getConnection()) { PreparedStatement ps = con.prepareStatement( "SELECT id, nome, descrizione, prezzo FROM prodotto WHERE MATCH(nome, descrizione) AGAINST(?) LIMIT ?, ?"); ps.setString(1, against); ps.setInt(2, offset); ps.setInt(3, limit); ArrayList<Prodotto> prodotti = new ArrayList<>(); ResultSet rs = ps.executeQuery(); while (rs.next()) { Prodotto p = new Prodotto(); p.setID(rs.getInt(1)); p.setNome(rs.getString(2)); p.setDescrizione(rs.getString(3)); p.setPrezzo(rs.getLong(4)); prodotti.add(p); } return prodotti; } catch (SQLException e) { throw new RuntimeException(e); } } public int doSave(Prodotto prodotto) { try(Connection con = ConnPool.getConnection()){ PreparedStatement ps = con.prepareStatement("INSERT INTO prodotto (nome, prezzo, descrizione, categoria) VALUES(?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS); ps.setString(1, prodotto.getNome()); ps.setFloat(2, prodotto.getPrezzo()); ps.setString(3, prodotto.getDescrizione()); ps.setInt(4, Integer.parseInt(prodotto.getCategoria())); if(ps.executeUpdate() != 1) { throw new RuntimeException("INSERT error!"); } ResultSet rs = ps.getGeneratedKeys(); rs.next(); int id = rs.getInt(1); prodotto.setID(id); return id; } catch (SQLException e) { e.printStackTrace(); return -1; } } public void doDelete(int id) { try(Connection con = ConnPool.getConnection()){ PreparedStatement ps = con.prepareStatement("DELETE FROM prodotto WHERE id=?"); ps.setInt(1, id); if(ps.executeUpdate() != 1) { throw new RuntimeException("DELETE Error!"); } } catch (SQLException e) { e.printStackTrace(); } } public void doUpdate(Prodotto prodotto) { try (Connection con = ConnPool.getConnection()) { PreparedStatement ps = con .prepareStatement("UPDATE prodotto SET nome=?, descrizione=?, prezzo=?, categoria=? WHERE id=?"); ps.setString(1, prodotto.getNome()); ps.setString(2, prodotto.getDescrizione()); ps.setFloat(3, prodotto.getPrezzo()); ps.setInt(4, Integer.parseInt(prodotto.getCategoria())); ps.setInt(5, prodotto.getID()); if (ps.executeUpdate() != 1) { throw new RuntimeException("UPDATE error."); } } catch (SQLException e) { throw new RuntimeException(e); } } }
5,010
0.680239
0.673054
159
30.515724
29.365376
210
false
false
0
0
0
0
0
0
3.383648
false
false
10
81101e7f03acba05d7b443dd13814d968df48c9c
14,087,492,774,719
4b02c2e6a653eca24c2d12de88a4f202ab7e5b38
/coldplacespring/src/main/java/com/github/muhin007/coldplacespring/servlets/SignUpServlet.java
2f91bf99ee803257cc098043d07f80eaf2ebf2dd
[]
no_license
Muhin007/coldplaceweb
https://github.com/Muhin007/coldplaceweb
b2d2f8869aa29662b622a600aa46dc29a489884d
3add760d2366e16fc1b2008ac7e991843e6bb74b
refs/heads/master
2020-03-08T20:04:13.573000
2018-11-07T12:01:01
2018-11-07T12:01:01
128,372,430
0
0
null
false
2018-10-24T16:43:35
2018-04-06T09:00:16
2018-10-03T17:26:37
2018-10-24T16:43:35
323
0
0
8
Java
false
null
package com.github.muhin007.coldplacespring.servlets; import com.github.muhin007.coldplaceweb.PageGenerator; import com.github.muhin007.coldplaceweb.data.ReadDB; import com.github.muhin007.coldplaceweb.data.UserProfile; import com.github.muhin007.coldplaceweb.data.WriteToDB; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.List; import java.util.Map; public class SignUpServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) { Process.process(request, response, (HttpServletRequest req, HttpServletResponse resp) -> { Map<String, Object> pageVariables = new HashMap<>(); resp.getWriter().println(PageGenerator.instance(). getPage("signUp.html", pageVariables)); } ); } protected void doPost(HttpServletRequest request, HttpServletResponse response) { Process.process(request, response, (HttpServletRequest req, HttpServletResponse resp) -> { Map<String, Object> pageVariables = new HashMap<>(); String login = req.getParameter("login"); String pass = req.getParameter("pass"); String email = req.getParameter("email"); String role = req.getParameter("role"); if (login == null || login.trim().isEmpty() || pass == null || pass.trim().isEmpty()) { pageVariables.put("message", "Вы ввели не все данные в форму. Попробуйте еще раз."); resp.getWriter().println(PageGenerator.instance(). getPage("repeatedSignUp.html", pageVariables)); return; } else { List<UserProfile> users = ReadDB.readUserFromDB(); UserProfile foundedUser = null; for (UserProfile user : users) { if (login.equals(user.getLogin())) { foundedUser = user; break; } } if (foundedUser != null) { pageVariables.put("message", "Этот логин уже занят, выберите другой."); resp.getWriter().println(PageGenerator.instance(). getPage("repeatedSignUp.html", pageVariables)); } else { WriteToDB.addUserProfile(login, pass, email, role); pageVariables.put("message", "Спасибо за регистрацию. Войдите в систему"); resp.getWriter().println(PageGenerator.instance(). getPage("signUpAnswer.html", pageVariables)); } } } ); } }
UTF-8
Java
3,209
java
SignUpServlet.java
Java
[ { "context": "package com.github.muhin007.coldplacespring.servlets;\n\nimport com.github.muhi", "end": 27, "score": 0.9986263513565063, "start": 19, "tag": "USERNAME", "value": "muhin007" }, { "context": "n007.coldplacespring.servlets;\n\nimport com.github.muhin007.coldplaceweb.PageGenerator;\nimport com.github.muh", "end": 81, "score": 0.9990367889404297, "start": 73, "tag": "USERNAME", "value": "muhin007" }, { "context": "007.coldplaceweb.PageGenerator;\nimport com.github.muhin007.coldplaceweb.data.ReadDB;\nimport com.github.muhin", "end": 136, "score": 0.9990296363830566, "start": 128, "tag": "USERNAME", "value": "muhin007" }, { "context": "in007.coldplaceweb.data.ReadDB;\nimport com.github.muhin007.coldplaceweb.data.UserProfile;\nimport com.github.", "end": 189, "score": 0.998760998249054, "start": 181, "tag": "USERNAME", "value": "muhin007" }, { "context": ".coldplaceweb.data.UserProfile;\nimport com.github.muhin007.coldplaceweb.data.WriteToDB;\n\nimport javax.servle", "end": 247, "score": 0.9983031153678894, "start": 239, "tag": "USERNAME", "value": "muhin007" } ]
null
[]
package com.github.muhin007.coldplacespring.servlets; import com.github.muhin007.coldplaceweb.PageGenerator; import com.github.muhin007.coldplaceweb.data.ReadDB; import com.github.muhin007.coldplaceweb.data.UserProfile; import com.github.muhin007.coldplaceweb.data.WriteToDB; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.List; import java.util.Map; public class SignUpServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) { Process.process(request, response, (HttpServletRequest req, HttpServletResponse resp) -> { Map<String, Object> pageVariables = new HashMap<>(); resp.getWriter().println(PageGenerator.instance(). getPage("signUp.html", pageVariables)); } ); } protected void doPost(HttpServletRequest request, HttpServletResponse response) { Process.process(request, response, (HttpServletRequest req, HttpServletResponse resp) -> { Map<String, Object> pageVariables = new HashMap<>(); String login = req.getParameter("login"); String pass = req.getParameter("pass"); String email = req.getParameter("email"); String role = req.getParameter("role"); if (login == null || login.trim().isEmpty() || pass == null || pass.trim().isEmpty()) { pageVariables.put("message", "Вы ввели не все данные в форму. Попробуйте еще раз."); resp.getWriter().println(PageGenerator.instance(). getPage("repeatedSignUp.html", pageVariables)); return; } else { List<UserProfile> users = ReadDB.readUserFromDB(); UserProfile foundedUser = null; for (UserProfile user : users) { if (login.equals(user.getLogin())) { foundedUser = user; break; } } if (foundedUser != null) { pageVariables.put("message", "Этот логин уже занят, выберите другой."); resp.getWriter().println(PageGenerator.instance(). getPage("repeatedSignUp.html", pageVariables)); } else { WriteToDB.addUserProfile(login, pass, email, role); pageVariables.put("message", "Спасибо за регистрацию. Войдите в систему"); resp.getWriter().println(PageGenerator.instance(). getPage("signUpAnswer.html", pageVariables)); } } } ); } }
3,209
0.537222
0.532388
71
42.704224
32.667507
108
false
false
0
0
0
0
0
0
0.830986
false
false
10
3f31a693995507831217c85974a3fd3cde3ca65c
14,276,471,320,054
14c5e5db1261919a1ef731295b83c91af80625fe
/List of exercise no. 1/Zadanie2.java
8336eed9bbe8fa216736301abccbc0472a49eeaf
[]
no_license
Heriad/javaExercise
https://github.com/Heriad/javaExercise
8230af3530c0e0576b3dd4404bbe4e6acc557be4
98ae8d270acf8ad056d164b4e8745dc7a92d43b2
refs/heads/master
2020-03-17T22:20:21.078000
2018-05-22T20:37:38
2018-05-22T20:37:38
133,999,600
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
import java.util.Scanner; public class Zadanie2{ public static void main(String args[]){ System.out.print("Podaj liczbę: "); Scanner liczba = new Scanner(System.in); int a = liczba.nextInt(); if(a % 4 == 0) { System.out.print("Wprowadzona liczba jest podzielna przez 4"); } else { System.out.print("Wprowadzona liczba nie jest podzielna przez 4"); } } }
UTF-8
Java
405
java
Zadanie2.java
Java
[]
null
[]
import java.util.Scanner; public class Zadanie2{ public static void main(String args[]){ System.out.print("Podaj liczbę: "); Scanner liczba = new Scanner(System.in); int a = liczba.nextInt(); if(a % 4 == 0) { System.out.print("Wprowadzona liczba jest podzielna przez 4"); } else { System.out.print("Wprowadzona liczba nie jest podzielna przez 4"); } } }
405
0.631188
0.618812
19
19.368422
21.484903
69
false
false
0
0
0
0
0
0
1.894737
false
false
10
9103a31088c516510f55c8fd56fced470cdaab70
30,511,447,682,571
8d616a577ad129ca2a4e518a51e36f1f63f3a0cb
/drools-spring-v2-app/src/main/java/drools/spring/example/SampleAppController.java
4a2c562dedfbbc1c228d7a90759cb12a82ede057
[]
no_license
SimicIlija/SBZ
https://github.com/SimicIlija/SBZ
a4d3440cd45214749c1940494899e64cbdcba932
c17d2c9a439dc83ec1f53513c8dd323e61dacb89
refs/heads/master
2020-03-17T12:08:12.572000
2018-06-17T01:22:40
2018-06-17T01:22:40
133,575,811
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package drools.spring.example; import drools.spring.example.model.Symptom; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController public class SampleAppController { private final SampleAppService sampleService; @Autowired public SampleAppController(SampleAppService sampleService) { this.sampleService = sampleService; } @RequestMapping(value = "/test3", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Symptom> test3() { sampleService.testDisRule(); return new ResponseEntity<>(HttpStatus.OK); } }
UTF-8
Java
950
java
SampleAppController.java
Java
[]
null
[]
package drools.spring.example; import drools.spring.example.model.Symptom; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController public class SampleAppController { private final SampleAppService sampleService; @Autowired public SampleAppController(SampleAppService sampleService) { this.sampleService = sampleService; } @RequestMapping(value = "/test3", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Symptom> test3() { sampleService.testDisRule(); return new ResponseEntity<>(HttpStatus.OK); } }
950
0.790526
0.788421
27
34.185184
27.337448
110
false
false
0
0
0
0
0
0
0.555556
false
false
10
88a1f36b58392787ea2c624320417effd73c8362
2,482,491,146,392
470d9f6628ccb697d4076f9ade82946a95690a54
/src/_2019_11_29/insufficientBalanceException.java
b7c8334811b29366059c9e95fc9f65c98b885d8d
[]
no_license
kwounsoungmin/Java_Fundamental
https://github.com/kwounsoungmin/Java_Fundamental
5a7a7fe9ae6f8f6c47263a747abc288785b1326a
082a17cb0febcecdb14e740d62a2ee1d6db9cab3
refs/heads/master
2020-09-16T19:47:40.978000
2019-12-20T06:50:09
2019-12-20T06:50:09
223,335,724
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package _2019_11_29; public class insufficientBalanceException extends Exception { public insufficientBalanceException(String mes){ super(mes); } }
UTF-8
Java
150
java
insufficientBalanceException.java
Java
[]
null
[]
package _2019_11_29; public class insufficientBalanceException extends Exception { public insufficientBalanceException(String mes){ super(mes); } }
150
0.806667
0.753333
7
20.428572
22.833918
61
false
false
0
0
0
0
0
0
0.428571
false
false
10
a621020313c1a7d58dfbc0f53d5a9e1847440a3c
33,741,263,142,039
67e87be3698fdd8852ac1a8712b17794565a6bb5
/pet-clinic-data/src/main/java/guru/springframwork/sfgpetclinic/services/VisitService.java
1d6eeade1d9ab96d75cb3a3b36edc46387ae433a
[]
no_license
simi1912/sfg-pet-clinic
https://github.com/simi1912/sfg-pet-clinic
7d4a786c4d98a723de354325ffff4d00954f443e
09873c22960915c376022886d03003cd093cce4a
refs/heads/main
2023-02-16T21:52:53.471000
2021-01-16T12:42:13
2021-01-16T12:42:13
323,108,990
1
0
null
false
2021-01-10T12:37:04
2020-12-20T15:56:04
2021-01-10T12:07:49
2021-01-10T12:37:03
459
1
0
9
Java
false
false
package guru.springframwork.sfgpetclinic.services; import guru.springframwork.sfgpetclinic.model.Visit; public interface VisitService extends CrudService<Visit, Long>{ }
UTF-8
Java
172
java
VisitService.java
Java
[]
null
[]
package guru.springframwork.sfgpetclinic.services; import guru.springframwork.sfgpetclinic.model.Visit; public interface VisitService extends CrudService<Visit, Long>{ }
172
0.843023
0.843023
6
27.666666
27.632509
63
false
false
0
0
0
0
0
0
0.5
false
false
10
69f0bc6114810faba39f3412675dd51fe9ecefb8
24,180,665,902,482
50f6e25c31f50af89368c6a15af7762077e4fae1
/user-service/src/main/java/com/user/repo/UserCredentialRepo.java
dd5dd980dba01b82d80985c7988a2e63297fbdf4
[]
no_license
ArunKumarDas-120/vehicle-maintenance
https://github.com/ArunKumarDas-120/vehicle-maintenance
fc1f4f2fdddfd26f7f4d165bf97efc3b3d6d2272
82acd5bcb8f4ed0f36ac280cab10741398c39e35
refs/heads/master
2020-07-21T18:44:39.561000
2020-01-26T22:36:03
2020-01-26T22:36:03
206,945,223
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.user.repo; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import com.user.entity.UserCredential; @Repository public interface UserCredentialRepo extends JpaRepository<UserCredential, Integer> { @Query(value = "Select c.id from UserCredential c where LOWER(c.userName) = LOWER(:userName) and LOWER(c.password) = LOWER(:password) ") public Optional<Integer> signIn(@Param("userName") final String userName, @Param("password") final String password); }
UTF-8
Java
677
java
UserCredentialRepo.java
Java
[ { "context": "d) \")\n public Optional<Integer> signIn(@Param(\"userName\") final String userName, @Param(\"password\") final", "end": 606, "score": 0.7838451862335205, "start": 598, "tag": "USERNAME", "value": "userName" }, { "context": "al<Integer> signIn(@Param(\"userName\") final String userName, @Param(\"password\") final String password);\n}\n", "end": 630, "score": 0.824923574924469, "start": 622, "tag": "USERNAME", "value": "userName" } ]
null
[]
package com.user.repo; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import com.user.entity.UserCredential; @Repository public interface UserCredentialRepo extends JpaRepository<UserCredential, Integer> { @Query(value = "Select c.id from UserCredential c where LOWER(c.userName) = LOWER(:userName) and LOWER(c.password) = LOWER(:password) ") public Optional<Integer> signIn(@Param("userName") final String userName, @Param("password") final String password); }
677
0.797637
0.797637
17
38.823528
42.08847
140
false
false
0
0
0
0
0
0
0.588235
false
false
10
6c7624f1aa470ca7ed4927d3e991d79b8027c54f
24,180,665,902,539
730cbe8f8626434e320bd4c0c5d1b2d1c513b8d1
/src/test/java/com/udacity/jwdnd/course1/cloudstorage/UserTests.java
c38b96ead7fef98d689bae990ab4459ff47e9d3e
[]
no_license
olucasokarin/SuperDuperDrive
https://github.com/olucasokarin/SuperDuperDrive
f7ad2c8c288c57483f2855b2a6997b633d6f7bee
839da11b17f098156c28a313ba73d8b5b3c93134
refs/heads/main
2023-02-15T11:09:04.189000
2021-01-08T04:59:48
2021-01-08T04:59:48
326,887,836
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.udacity.jwdnd.course1.cloudstorage; import com.udacity.jwdnd.course1.cloudstorage.pojo.LoginPage; import com.udacity.jwdnd.course1.cloudstorage.pojo.SignupPage; import io.github.bonigarcia.wdm.WebDriverManager; import org.junit.jupiter.api.*; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.edge.EdgeDriver; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import java.util.concurrent.TimeUnit; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class UserTests { @LocalServerPort private int port; private WebDriver driver; @BeforeAll static void beforeAll() { WebDriverManager.edgedriver().setup(); } @BeforeEach public void beforeEach() { this.driver = new EdgeDriver(); } @AfterEach public void afterEach() { if (this.driver != null) { driver.quit(); } } @Test public void testPageAccess() { driver.get("http://localhost:" + port + "/login"); Assertions.assertEquals("Login", driver.getTitle()); driver.get("http://localhost:" + port + "/signup"); Assertions.assertEquals("Sign Up", driver.getTitle()); driver.get("http://localhost:" + port + "/home"); Assertions.assertEquals("Login", driver.getTitle()); } @Test public void testSignUpLoginLogout() { driver.get("http://localhost:" + this.port + "/signup"); Assertions.assertEquals("Sign Up", driver.getTitle()); SignupPage signupPage = new SignupPage(driver); signupPage.signUp("john", "doe", "jdoe", "mypass"); driver.get("http://localhost:" + this.port + "/login"); Assertions.assertEquals("Login", driver.getTitle()); LoginPage loginPage = new LoginPage(driver); loginPage.login("jdoe", "mypass"); driver.get("http://localhost:" + this.port + "/home"); Assertions.assertEquals("Home", driver.getTitle()); driver.findElement(By.id("btnLogout")).click(); driver.get("http://localhost:" + this.port + "/home"); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); Assertions.assertEquals("Login", driver.getTitle()); } }
UTF-8
Java
2,349
java
UserTests.java
Java
[ { "context": "e1.cloudstorage.pojo.SignupPage;\nimport io.github.bonigarcia.wdm.WebDriverManager;\nimport org.junit.jupiter.ap", "end": 201, "score": 0.9970258474349976, "start": 191, "tag": "USERNAME", "value": "bonigarcia" }, { "context": "ew SignupPage(driver);\n signupPage.signUp(\"john\", \"doe\", \"jdoe\", \"mypass\");\n\n driver.get(\"", "end": 1709, "score": 0.9872531890869141, "start": 1705, "tag": "USERNAME", "value": "john" }, { "context": "pPage(driver);\n signupPage.signUp(\"john\", \"doe\", \"jdoe\", \"mypass\");\n\n driver.get(\"http://", "end": 1716, "score": 0.9899614453315735, "start": 1713, "tag": "USERNAME", "value": "doe" }, { "context": "river);\n signupPage.signUp(\"john\", \"doe\", \"jdoe\", \"mypass\");\n\n driver.get(\"http://localhos", "end": 1724, "score": 0.9304260015487671, "start": 1720, "tag": "PASSWORD", "value": "jdoe" }, { "context": " signupPage.signUp(\"john\", \"doe\", \"jdoe\", \"mypass\");\n\n driver.get(\"http://localhost:\" + this", "end": 1734, "score": 0.9906686544418335, "start": 1728, "tag": "PASSWORD", "value": "mypass" }, { "context": "= new LoginPage(driver);\n loginPage.login(\"jdoe\", \"mypass\");\n\n\n\n driver.get(\"http://localh", "end": 1946, "score": 0.9989593029022217, "start": 1942, "tag": "USERNAME", "value": "jdoe" }, { "context": "ginPage(driver);\n loginPage.login(\"jdoe\", \"mypass\");\n\n\n\n driver.get(\"http://localhost:\" + th", "end": 1956, "score": 0.98333740234375, "start": 1950, "tag": "PASSWORD", "value": "mypass" } ]
null
[]
package com.udacity.jwdnd.course1.cloudstorage; import com.udacity.jwdnd.course1.cloudstorage.pojo.LoginPage; import com.udacity.jwdnd.course1.cloudstorage.pojo.SignupPage; import io.github.bonigarcia.wdm.WebDriverManager; import org.junit.jupiter.api.*; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.edge.EdgeDriver; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import java.util.concurrent.TimeUnit; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class UserTests { @LocalServerPort private int port; private WebDriver driver; @BeforeAll static void beforeAll() { WebDriverManager.edgedriver().setup(); } @BeforeEach public void beforeEach() { this.driver = new EdgeDriver(); } @AfterEach public void afterEach() { if (this.driver != null) { driver.quit(); } } @Test public void testPageAccess() { driver.get("http://localhost:" + port + "/login"); Assertions.assertEquals("Login", driver.getTitle()); driver.get("http://localhost:" + port + "/signup"); Assertions.assertEquals("Sign Up", driver.getTitle()); driver.get("http://localhost:" + port + "/home"); Assertions.assertEquals("Login", driver.getTitle()); } @Test public void testSignUpLoginLogout() { driver.get("http://localhost:" + this.port + "/signup"); Assertions.assertEquals("Sign Up", driver.getTitle()); SignupPage signupPage = new SignupPage(driver); signupPage.signUp("john", "doe", "<PASSWORD>", "<PASSWORD>"); driver.get("http://localhost:" + this.port + "/login"); Assertions.assertEquals("Login", driver.getTitle()); LoginPage loginPage = new LoginPage(driver); loginPage.login("jdoe", "<PASSWORD>"); driver.get("http://localhost:" + this.port + "/home"); Assertions.assertEquals("Home", driver.getTitle()); driver.findElement(By.id("btnLogout")).click(); driver.get("http://localhost:" + this.port + "/home"); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); Assertions.assertEquals("Login", driver.getTitle()); } }
2,363
0.659855
0.657727
77
29.506493
25.231718
75
false
false
0
0
0
0
0
0
0.623377
false
false
10
d033a12b2bcb1f1f8471d2de70c35e2693390f24
24,618,752,562,815
dc8387bba70b341521188fe03d0739125d9dee3d
/src/nmon/PeakHourCalculator.java
4588c4c134b53c6fd89a3e2fe7a1d7acbce264c4
[]
no_license
chenmq1/Test
https://github.com/chenmq1/Test
613b73ecbdfea9e86cddc585b89e6c12113a94eb
51418ae451821a629708b211d90259ff02aa6a5f
refs/heads/master
2021-01-19T14:53:04.039000
2015-01-14T03:28:07
2015-01-14T03:28:07
29,182,356
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
/** * */ package nmon; import java.io.File; import java.util.Enumeration; import java.util.Hashtable; import java.util.TreeMap; import java.util.Vector; import jxl.Workbook; import jxl.write.Label; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import java.sql.*; /** * @author minqi *Dec 21, 2012 */ public class PeakHourCalculator { /** * @param args */ public void calculate(String sqlToAppend)throws Exception{ Connection con=DbUtil.getConnection(); PreparedStatement ps=con.prepareStatement("merge into peakhour using (select ? as hostId,? as date,? as name,? as peakHourUtil,? as peakHour,? as bottomHourUtil,? as bottomHour,? as sum,? as max,? as min,? as cnt from sysibm.sysdummy1) tmp on (peakhour.hostId=tmp.hostId and peakhour.date=tmp.date and peakhour.name=tmp.name) " + "when matched then update set peakHourUtil=tmp.peakHourUtil,peakHour=tmp.peakHour,bottomHourUtil=tmp.bottomHourUtil,bottomHour=tmp.bottomHour,sum=tmp.sum,max=tmp.max,min=tmp.min,cnt=tmp.cnt when not matched then "+ "insert (hostId,date,name,peakHourUtil,peakHour,bottomHourUtil,bottomHour,sum,max,min,cnt) values (tmp.hostId,tmp.date,tmp.name,tmp.peakHourUtil,tmp.peakHour,tmp.bottomHourUtil,tmp.bottomHour,tmp.sum,tmp.max,tmp.min,tmp.cnt)"); Hashtable servers=new Hashtable(); String sql="select hostname,date,reportId,host.hostId from host,report where report.hostid=host.hostid "+sqlToAppend;//and host.hostname like 'PEKII%' ";//and (host.hostname='PEKAX028' or host.hostname='PEKAX029')"; //date like '1205%'";// and host.hostname='PEKAX028'"; Vector titles=new Vector(); String files[][]=DbUtil.query(sql); for (int i=0;i<files.length;i++){ try{ NMonServer server=(NMonServer)(servers.get(files[i][0])); if (server==null){ server=new NMonServer(files[i][0],files[i][3]); servers.put(files[i][0],server); } NMonDay nmd=new NMonDay(); nmd.getData(server,files[i][2],files[i][1]); }catch (Exception e){System.out.println("error while processing:"+files[i][2]+" ,"+e.toString());} } Enumeration keys=servers.keys(); while (keys.hasMoreElements()){ String serverName=(String)(keys.nextElement()); NMonServer server=(NMonServer)servers.get(serverName); //Enumeration colKeys=server.columns.keys(); TreeMap tm=new TreeMap(server.columns);//use treemap to sort, but don't need it now String colKey=null; boolean hasElements=true; try { colKey=(String)(tm.firstKey()); }catch (Exception e){hasElements=false;} if (hasElements) do { //System.out.print(colKey+":"); String name=colKey; Vector vec=(Vector)(server.columns.get(colKey)); ps.setInt(1, Integer.parseInt(server.hostId)); for (int i=0;i<vec.size() ;i++ ){ System.out.println("executing "+name); ps.setString(3, name); Column col=(Column)(vec.elementAt(i)); ps.setString(2, col.date); ps.setDouble(4, col.columnValue); ps.setInt(5,col.hour); ps.setDouble(6, col.columnMinValue); ps.setInt(7, col.minHour); ps.setDouble(8,col.sum); ps.setDouble(9,col.max); ps.setDouble(10,col.min); ps.setInt(11,col.count); ps.execute(); //ps.clearParameters(); // System.out.println("executed."+vec.size()); } colKey=(String)(tm.higherKey(colKey)); }while (colKey!=null); } //System.out.println("exiting..."); ps.close(); con.close(); } public static void main(String[] args)throws Exception { PeakHourCalculator phc=new PeakHourCalculator(); phc.calculate(" and date like '1212%'"); //and hostname='PEKAX028'"); } }
UTF-8
Java
3,606
java
PeakHourCalculator.java
Java
[ { "context": "itableWorkbook;\n\nimport java.sql.*;\n/**\n * @author minqi\n *Dec 21, 2012\n */\npublic class PeakHourCalculato", "end": 310, "score": 0.9993883371353149, "start": 305, "tag": "USERNAME", "value": "minqi" } ]
null
[]
/** * */ package nmon; import java.io.File; import java.util.Enumeration; import java.util.Hashtable; import java.util.TreeMap; import java.util.Vector; import jxl.Workbook; import jxl.write.Label; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import java.sql.*; /** * @author minqi *Dec 21, 2012 */ public class PeakHourCalculator { /** * @param args */ public void calculate(String sqlToAppend)throws Exception{ Connection con=DbUtil.getConnection(); PreparedStatement ps=con.prepareStatement("merge into peakhour using (select ? as hostId,? as date,? as name,? as peakHourUtil,? as peakHour,? as bottomHourUtil,? as bottomHour,? as sum,? as max,? as min,? as cnt from sysibm.sysdummy1) tmp on (peakhour.hostId=tmp.hostId and peakhour.date=tmp.date and peakhour.name=tmp.name) " + "when matched then update set peakHourUtil=tmp.peakHourUtil,peakHour=tmp.peakHour,bottomHourUtil=tmp.bottomHourUtil,bottomHour=tmp.bottomHour,sum=tmp.sum,max=tmp.max,min=tmp.min,cnt=tmp.cnt when not matched then "+ "insert (hostId,date,name,peakHourUtil,peakHour,bottomHourUtil,bottomHour,sum,max,min,cnt) values (tmp.hostId,tmp.date,tmp.name,tmp.peakHourUtil,tmp.peakHour,tmp.bottomHourUtil,tmp.bottomHour,tmp.sum,tmp.max,tmp.min,tmp.cnt)"); Hashtable servers=new Hashtable(); String sql="select hostname,date,reportId,host.hostId from host,report where report.hostid=host.hostid "+sqlToAppend;//and host.hostname like 'PEKII%' ";//and (host.hostname='PEKAX028' or host.hostname='PEKAX029')"; //date like '1205%'";// and host.hostname='PEKAX028'"; Vector titles=new Vector(); String files[][]=DbUtil.query(sql); for (int i=0;i<files.length;i++){ try{ NMonServer server=(NMonServer)(servers.get(files[i][0])); if (server==null){ server=new NMonServer(files[i][0],files[i][3]); servers.put(files[i][0],server); } NMonDay nmd=new NMonDay(); nmd.getData(server,files[i][2],files[i][1]); }catch (Exception e){System.out.println("error while processing:"+files[i][2]+" ,"+e.toString());} } Enumeration keys=servers.keys(); while (keys.hasMoreElements()){ String serverName=(String)(keys.nextElement()); NMonServer server=(NMonServer)servers.get(serverName); //Enumeration colKeys=server.columns.keys(); TreeMap tm=new TreeMap(server.columns);//use treemap to sort, but don't need it now String colKey=null; boolean hasElements=true; try { colKey=(String)(tm.firstKey()); }catch (Exception e){hasElements=false;} if (hasElements) do { //System.out.print(colKey+":"); String name=colKey; Vector vec=(Vector)(server.columns.get(colKey)); ps.setInt(1, Integer.parseInt(server.hostId)); for (int i=0;i<vec.size() ;i++ ){ System.out.println("executing "+name); ps.setString(3, name); Column col=(Column)(vec.elementAt(i)); ps.setString(2, col.date); ps.setDouble(4, col.columnValue); ps.setInt(5,col.hour); ps.setDouble(6, col.columnMinValue); ps.setInt(7, col.minHour); ps.setDouble(8,col.sum); ps.setDouble(9,col.max); ps.setDouble(10,col.min); ps.setInt(11,col.count); ps.execute(); //ps.clearParameters(); // System.out.println("executed."+vec.size()); } colKey=(String)(tm.higherKey(colKey)); }while (colKey!=null); } //System.out.println("exiting..."); ps.close(); con.close(); } public static void main(String[] args)throws Exception { PeakHourCalculator phc=new PeakHourCalculator(); phc.calculate(" and date like '1212%'"); //and hostname='PEKAX028'"); } }
3,606
0.69218
0.678591
97
36.175259
49.389679
331
false
false
0
0
0
0
0
0
3.680412
false
false
10
0c789750488da00f6bd0ff1955d80c8ffd5db6ea
16,535,624,160,267
3325e29faaa3b432db83246b0f2a6e53727899c2
/app/src/main/java/io/github/mpao/drawerlayouttemplate/ui/NewsFragment.java
9e0a886944511a97b4599cff3a0f8530442c3e2e
[]
no_license
mpao/DrawerLayout-Navigation-Template
https://github.com/mpao/DrawerLayout-Navigation-Template
83111e50702f37a8f427315191db64b710c21ee2
9693c17ad6dc11fc9f25beae11f3e43c5792ecb4
refs/heads/master
2021-05-01T16:15:06.959000
2018-02-11T13:48:38
2018-02-11T13:48:38
121,049,304
1
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package io.github.mpao.drawerlayouttemplate.ui; import android.arch.lifecycle.ViewModelProviders; import android.databinding.DataBindingUtil; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import io.github.mpao.drawerlayouttemplate.R; import io.github.mpao.drawerlayouttemplate.databinding.FragmentNewsBinding; import io.github.mpao.drawerlayouttemplate.viewmodels.NewsViewModel; public class NewsFragment extends Fragment { public NewsFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FragmentNewsBinding binding = DataBindingUtil.inflate(inflater, R.layout.fragment_news, container, false); NewsViewModel viewModel = ViewModelProviders.of(this).get(NewsViewModel.class); viewModel.init(); viewModel.getData().observe( this, binding.mockText::setText); return binding.getRoot(); } }
UTF-8
Java
1,084
java
NewsFragment.java
Java
[]
null
[]
package io.github.mpao.drawerlayouttemplate.ui; import android.arch.lifecycle.ViewModelProviders; import android.databinding.DataBindingUtil; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import io.github.mpao.drawerlayouttemplate.R; import io.github.mpao.drawerlayouttemplate.databinding.FragmentNewsBinding; import io.github.mpao.drawerlayouttemplate.viewmodels.NewsViewModel; public class NewsFragment extends Fragment { public NewsFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FragmentNewsBinding binding = DataBindingUtil.inflate(inflater, R.layout.fragment_news, container, false); NewsViewModel viewModel = ViewModelProviders.of(this).get(NewsViewModel.class); viewModel.init(); viewModel.getData().observe( this, binding.mockText::setText); return binding.getRoot(); } }
1,084
0.776753
0.77583
32
32.875
31.451103
114
false
false
0
0
0
0
0
0
0.6875
false
false
10
80c65fcc35b4f53e74ddb3b0e1a3a9312bc21129
2,662,879,771,652
b8e84b6ab67b5c91af64c8d8747d819ce8a16e71
/project/src/com/example/library/WebServicePreferencyActivity.java
2c66ead6ad69e8e76aff562692c4c9fa2fb2299f
[]
no_license
bartosz25/android-library-sample-project
https://github.com/bartosz25/android-library-sample-project
769eb7964512cf10d4407f205c31bed7a3b9b8e5
9803d205b6becab05a411680a8a8cfaeaf9928b7
refs/heads/master
2016-09-06T18:35:03.822000
2013-05-14T19:14:32
2013-05-14T19:14:32
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.example.library; import java.util.Calendar; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentTabHost; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentTabHost; import android.util.Log; import android.view.Menu; import android.view.View; import android.widget.LinearLayout.LayoutParams; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.DatePicker; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.Spinner; import android.widget.TabHost; import android.widget.TabHost.TabSpec; import android.widget.TextView; // la classe n'est plus utilisée depuis le passage en TabHost @Deprecated public class WebServicePreferencyActivity extends BaseActivity { private final static String LOG_TAG = "WebServicePreferencyActivity"; private int choosedFrequency; private LinearLayout manualContainer; private int radioAutomaticId; private int autoManualChoice; private EditText refererUriEditText, aboutEditText; private DatePicker syncDate; private RadioGroup syncTypes; @Override protected void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "Creating WebServicePreferencyActivity"); super.onCreate(savedInstanceState); setContentView(R.layout.web_service_preferency); refererUriEditText = (EditText) findViewById(R.id.prefRefererUri); aboutEditText = (EditText) findViewById(R.id.prefAbout); radioAutomaticId = R.id.radioAutomatic; refererUriEditText.setText("http://test.com"); aboutEditText.setText("About me"); syncTypes = (RadioGroup) findViewById(R.id.prefBorrowingNotif); syncTypes.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { RadioButton checkedButton = (RadioButton) findViewById(checkedId); if(checkedId == radioAutomaticId) hideManuallyGroup(); else showManuallyGroup(); } }); RadioButton buttonAutomatic = (RadioButton) findViewById(radioAutomaticId); //buttonAutomatic.setChecked(true); manualContainer = (LinearLayout) findViewById(R.id.prefManualyContainer); if(!buttonAutomatic.isChecked()) showManuallyGroup(); else hideManuallyGroup(); syncDate = (DatePicker) findViewById(R.id.prefSyncManualDate); // get tomorrow date Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); syncDate.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); Spinner syncFrequency = (Spinner) findViewById(R.id.prefNotifFrequency); syncFrequency.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long row) { choosedFrequency = position; } @Override public void onNothingSelected(AdapterView<?> parent) {} }); syncFrequency.setSelection(choosedFrequency); } @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; } public void handleForm(View view) { String refererUri = refererUriEditText.getText().toString(); String about = aboutEditText.getText().toString(); if(syncTypes.getCheckedRadioButtonId() != radioAutomaticId) { // choosedFrequency utilisé pour soumettre les informations au web service Spinner frequencySpinner = ((Spinner) findViewById(R.id.prefNotifFrequency)); String frequency = frequencySpinner.getSelectedItem().toString(); Calendar syncCalendar = Calendar.getInstance(); syncCalendar.set(Calendar.YEAR, syncDate.getYear()); syncCalendar.set(Calendar.MONTH, syncDate.getMonth()); syncCalendar.set(Calendar.DAY_OF_MONTH, syncDate.getDayOfMonth()); Log.d(LOG_TAG, "Date " + syncCalendar); Log.d(LOG_TAG, "Frequency " + frequency); } Log.d(LOG_TAG, "Referer URI " + refererUri); Log.d(LOG_TAG, "About " + about); Log.d(LOG_TAG, "Choosen option " + syncTypes.getCheckedRadioButtonId()); } private void showManuallyGroup() { manualContainer.setVisibility(View.VISIBLE); manualContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); } private void hideManuallyGroup() { manualContainer.setVisibility(View.INVISIBLE); manualContainer.setLayoutParams(new LayoutParams(0, 0)); } }
ISO-8859-1
Java
5,138
java
WebServicePreferencyActivity.java
Java
[]
null
[]
package com.example.library; import java.util.Calendar; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentTabHost; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentTabHost; import android.util.Log; import android.view.Menu; import android.view.View; import android.widget.LinearLayout.LayoutParams; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.DatePicker; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.Spinner; import android.widget.TabHost; import android.widget.TabHost.TabSpec; import android.widget.TextView; // la classe n'est plus utilisée depuis le passage en TabHost @Deprecated public class WebServicePreferencyActivity extends BaseActivity { private final static String LOG_TAG = "WebServicePreferencyActivity"; private int choosedFrequency; private LinearLayout manualContainer; private int radioAutomaticId; private int autoManualChoice; private EditText refererUriEditText, aboutEditText; private DatePicker syncDate; private RadioGroup syncTypes; @Override protected void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "Creating WebServicePreferencyActivity"); super.onCreate(savedInstanceState); setContentView(R.layout.web_service_preferency); refererUriEditText = (EditText) findViewById(R.id.prefRefererUri); aboutEditText = (EditText) findViewById(R.id.prefAbout); radioAutomaticId = R.id.radioAutomatic; refererUriEditText.setText("http://test.com"); aboutEditText.setText("About me"); syncTypes = (RadioGroup) findViewById(R.id.prefBorrowingNotif); syncTypes.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { RadioButton checkedButton = (RadioButton) findViewById(checkedId); if(checkedId == radioAutomaticId) hideManuallyGroup(); else showManuallyGroup(); } }); RadioButton buttonAutomatic = (RadioButton) findViewById(radioAutomaticId); //buttonAutomatic.setChecked(true); manualContainer = (LinearLayout) findViewById(R.id.prefManualyContainer); if(!buttonAutomatic.isChecked()) showManuallyGroup(); else hideManuallyGroup(); syncDate = (DatePicker) findViewById(R.id.prefSyncManualDate); // get tomorrow date Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); syncDate.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); Spinner syncFrequency = (Spinner) findViewById(R.id.prefNotifFrequency); syncFrequency.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long row) { choosedFrequency = position; } @Override public void onNothingSelected(AdapterView<?> parent) {} }); syncFrequency.setSelection(choosedFrequency); } @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; } public void handleForm(View view) { String refererUri = refererUriEditText.getText().toString(); String about = aboutEditText.getText().toString(); if(syncTypes.getCheckedRadioButtonId() != radioAutomaticId) { // choosedFrequency utilisé pour soumettre les informations au web service Spinner frequencySpinner = ((Spinner) findViewById(R.id.prefNotifFrequency)); String frequency = frequencySpinner.getSelectedItem().toString(); Calendar syncCalendar = Calendar.getInstance(); syncCalendar.set(Calendar.YEAR, syncDate.getYear()); syncCalendar.set(Calendar.MONTH, syncDate.getMonth()); syncCalendar.set(Calendar.DAY_OF_MONTH, syncDate.getDayOfMonth()); Log.d(LOG_TAG, "Date " + syncCalendar); Log.d(LOG_TAG, "Frequency " + frequency); } Log.d(LOG_TAG, "Referer URI " + refererUri); Log.d(LOG_TAG, "About " + about); Log.d(LOG_TAG, "Choosen option " + syncTypes.getCheckedRadioButtonId()); } private void showManuallyGroup() { manualContainer.setVisibility(View.VISIBLE); manualContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); } private void hideManuallyGroup() { manualContainer.setVisibility(View.INVISIBLE); manualContainer.setLayoutParams(new LayoutParams(0, 0)); } }
5,138
0.718653
0.71729
137
36.496349
26.809717
124
false
false
0
0
0
0
0
0
1.335766
false
false
10
259a4ebdaf95daca4eece86121c8eab39762a1bb
29,738,353,564,526
75c5d4a727251410446973e89dd5aab5ba17e7f5
/Server/src/application/trajeto/events/AlterarTrajeto.java
f37abcc1f6b78d11deaf5c58823dcceea8959685
[]
no_license
williamcarril/passeiodecaes
https://github.com/williamcarril/passeiodecaes
a1784ccd7753f49b425e5e90865b181f63cf5b23
74c41377000c23907e14b72984ee49928010d077
refs/heads/master
2016-09-15T15:27:45.217000
2016-01-06T03:08:10
2016-01-06T03:08:10
32,216,891
2
1
null
false
2016-01-06T03:08:10
2015-03-14T14:53:25
2015-07-02T14:41:14
2016-01-06T03:08:10
3,509
1
0
0
Java
null
null
/* * 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 application.trajeto.events; import java.io.IOException; import java.util.Calendar; import java.util.Iterator; import java.util.Set; import java.util.logging.Level; import javax.json.JsonArray; import javax.json.JsonObject; import model.Endereço; import model.Multimídia; import model.Trajeto; import mvc.SimpleEvent; import org.hibernate.Session; import org.hibernate.Transaction; import server.HibernateUtil; import server.file.Repository; /** * @todo Tests * @author William */ public class AlterarTrajeto extends SimpleEvent { private final Repository repository; public AlterarTrajeto(String name, Repository repository) { super(name); this.repository = repository; } @Override public boolean handle(JsonObject params) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction transaction = null; synchronized (this.repository) { try { Trajeto route = (Trajeto) session.load(Trajeto.class, new Long(params.getString("id"))); Endereço address = route.getAddress(); if (address == null) { address = new Endereço(); route.setAddress(address); } Set<Multimídia> photos = route.getPhotos(); JsonObject jsonAddress = params.getJsonObject("address"); JsonArray jsonPhotos = params.getJsonArray("photos"); route.fromJson(params); address.fromJson(jsonAddress); for (Iterator i = photos.iterator(); i.hasNext();) { Multimídia photo = (Multimídia) i.next(); boolean removed = true; for (Iterator i2 = jsonPhotos.iterator(); i2.hasNext();) { JsonObject jsonPhoto = (JsonObject) i2.next(); if (photo.getId() == new Long(jsonPhoto.getString("id"))) { removed = false; break; } } if (removed) { photos.remove(photo); } } repository.beginTransaction(); for (int i = 0; i < jsonPhotos.size(); i++) { JsonObject jsonPhoto = jsonPhotos.getJsonObject(i); Multimídia photo = new Multimídia(); if (jsonPhoto.getString("id", null) != null) { long id = new Long(jsonPhoto.getString("id")); for (Multimídia m : photos) { if (m.getId() == id) { photo = m; break; } } } else { route.addPhoto(photo); } photo.fromJson(jsonPhoto); if (jsonPhoto.getString("base64", null) != null) { if (photo.getFilePath() != null && !photo.getFilePath().equals("")) { this.repository.delete(photo.getFilePath(), false); } photo.setDate(Calendar.getInstance().getTime()); photo.setFilePath( this.repository.storeImage( jsonPhoto.getString("base64"), "jpg" ).getAbsolutePath() ); } } transaction = session.beginTransaction(); session.save(route); transaction.commit(); this.repository.commit(); session.close(); return true; } catch (IOException | ClassCastException | NullPointerException | IllegalArgumentException ex) { try { this.repository.rollback(); } catch (IOException ex1) { } if (transaction != null) { transaction.rollback(); } java.util.logging.Logger.getLogger(AlterarTrajeto.class.getName()) .log( Level.WARNING, "An error occurred when processing the operation <{0}>. Message: {1}.", new Object[]{AlterarTrajeto.class.getName(), ex.getMessage()} ); return false; } } } }
UTF-8
Java
4,847
java
AlterarTrajeto.java
Java
[ { "context": "er.file.Repository;\n\n/**\n * @todo Tests\n * @author William\n */\npublic class AlterarTrajeto extends SimpleEve", "end": 673, "score": 0.9942409992218018, "start": 666, "tag": "NAME", "value": "William" } ]
null
[]
/* * 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 application.trajeto.events; import java.io.IOException; import java.util.Calendar; import java.util.Iterator; import java.util.Set; import java.util.logging.Level; import javax.json.JsonArray; import javax.json.JsonObject; import model.Endereço; import model.Multimídia; import model.Trajeto; import mvc.SimpleEvent; import org.hibernate.Session; import org.hibernate.Transaction; import server.HibernateUtil; import server.file.Repository; /** * @todo Tests * @author William */ public class AlterarTrajeto extends SimpleEvent { private final Repository repository; public AlterarTrajeto(String name, Repository repository) { super(name); this.repository = repository; } @Override public boolean handle(JsonObject params) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction transaction = null; synchronized (this.repository) { try { Trajeto route = (Trajeto) session.load(Trajeto.class, new Long(params.getString("id"))); Endereço address = route.getAddress(); if (address == null) { address = new Endereço(); route.setAddress(address); } Set<Multimídia> photos = route.getPhotos(); JsonObject jsonAddress = params.getJsonObject("address"); JsonArray jsonPhotos = params.getJsonArray("photos"); route.fromJson(params); address.fromJson(jsonAddress); for (Iterator i = photos.iterator(); i.hasNext();) { Multimídia photo = (Multimídia) i.next(); boolean removed = true; for (Iterator i2 = jsonPhotos.iterator(); i2.hasNext();) { JsonObject jsonPhoto = (JsonObject) i2.next(); if (photo.getId() == new Long(jsonPhoto.getString("id"))) { removed = false; break; } } if (removed) { photos.remove(photo); } } repository.beginTransaction(); for (int i = 0; i < jsonPhotos.size(); i++) { JsonObject jsonPhoto = jsonPhotos.getJsonObject(i); Multimídia photo = new Multimídia(); if (jsonPhoto.getString("id", null) != null) { long id = new Long(jsonPhoto.getString("id")); for (Multimídia m : photos) { if (m.getId() == id) { photo = m; break; } } } else { route.addPhoto(photo); } photo.fromJson(jsonPhoto); if (jsonPhoto.getString("base64", null) != null) { if (photo.getFilePath() != null && !photo.getFilePath().equals("")) { this.repository.delete(photo.getFilePath(), false); } photo.setDate(Calendar.getInstance().getTime()); photo.setFilePath( this.repository.storeImage( jsonPhoto.getString("base64"), "jpg" ).getAbsolutePath() ); } } transaction = session.beginTransaction(); session.save(route); transaction.commit(); this.repository.commit(); session.close(); return true; } catch (IOException | ClassCastException | NullPointerException | IllegalArgumentException ex) { try { this.repository.rollback(); } catch (IOException ex1) { } if (transaction != null) { transaction.rollback(); } java.util.logging.Logger.getLogger(AlterarTrajeto.class.getName()) .log( Level.WARNING, "An error occurred when processing the operation <{0}>. Message: {1}.", new Object[]{AlterarTrajeto.class.getName(), ex.getMessage()} ); return false; } } } }
4,847
0.486872
0.484598
124
38.008064
25.134315
109
false
false
0
0
0
0
0
0
0.629032
false
false
10
5c859361546c085a0ecbc409982766b1e844dd67
29,867,202,642,104
263fc689a45846e7cc4d35d0ad493957ea298f06
/leetcode-cn.com/src/topic/linkedlist/LC876_链表的中间结点.java
15c995cc8f9b6af1d30b0c10f0bdc44b02e32af4
[]
no_license
Frank-Tian/Algorithm
https://github.com/Frank-Tian/Algorithm
c33457b9ca5ac411b96727ee23806485e0ce7623
55cc5b3f3e07b395fb5d7542b6e759826ec79e2b
refs/heads/main
2023-04-18T22:01:56.365000
2021-05-05T02:10:44
2021-05-05T02:10:44
358,853,575
1
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package topic.linkedlist; import base.ListNode; public class LC876_链表的中间结点 { // 快慢指针 public ListNode middleNode1(ListNode head) { ListNode fast = head; ListNode slow = head; while (fast != null && fast.next != null) { fast = fast.next.next; slow = slow.next; } return slow; } // 遍历长度 public ListNode middleNode(ListNode head) { int len = 0; ListNode newHead = head; while (newHead != null) { len++; newHead = newHead.next; } if (len == 1) return head; newHead = head; int k = len / 2 - 1; while (k-- >= 0) { newHead = newHead.next; } return newHead; } }
UTF-8
Java
641
java
LC876_链表的中间结点.java
Java
[]
null
[]
package topic.linkedlist; import base.ListNode; public class LC876_链表的中间结点 { // 快慢指针 public ListNode middleNode1(ListNode head) { ListNode fast = head; ListNode slow = head; while (fast != null && fast.next != null) { fast = fast.next.next; slow = slow.next; } return slow; } // 遍历长度 public ListNode middleNode(ListNode head) { int len = 0; ListNode newHead = head; while (newHead != null) { len++; newHead = newHead.next; } if (len == 1) return head; newHead = head; int k = len / 2 - 1; while (k-- >= 0) { newHead = newHead.next; } return newHead; } }
641
0.615385
0.600655
34
16.970589
12.640936
45
false
false
0
0
0
0
0
0
2.058824
false
false
10
e1c430297d972e662f51d2182788e224472f3a4a
7,962,869,429,277
989d3a85ee3385e2ff522fc5ffca0f4afcad12c6
/src/test/java/ru/sorokinigor/server/requesthandlers/AsyncRequestHandlerTest.java
9e7bc4f77d1f069d4db9d22d553237aad8f93f7b
[]
no_license
MCMVP/clustering
https://github.com/MCMVP/clustering
0f6d1e2da318bd2a18d2e6913d7f6a7b740f86fe
38e6979387164eadd05ebb07524167f5b74bc88c
refs/heads/master
2016-09-15T20:43:54.347000
2015-09-26T21:32:46
2015-09-26T21:32:46
41,307,368
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package ru.sorokinigor.server.requesthandlers; import org.testng.Assert; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import ru.sorokinigor.server.CompletionHandler; import ru.sorokinigor.server.RequestDescriptor; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.function.Function; /** * Created by SorokinI on 08.09.2015. */ public class AsyncRequestHandlerTest { @DataProvider public Iterator<Object[]> testData(){ Collection<Object[]> testData = new ArrayList<>(); { Function<String, String> reverseFunction = s -> new StringBuilder(s).reverse().toString(); String request = "testString"; testData.add(new Object[]{ reverseFunction, request, reverseFunction.apply(request) }); } { RuntimeException exception = new RuntimeException("expected exception"); Function<String, String> functionWithException = s -> { throw exception; }; testData.add(new Object[]{ functionWithException, "anyRequest", exception }); } return testData.iterator(); } @Test(dataProvider = "testData") public <T, R> void testHandle(Function<T, R> function, T request, R expectedResponse){ RequestHandler<T, R> requestHandler = new AsyncRequestHandler.AsyncRequestHandlerBuilder<T, R>() .setResponseFunction(function) .build(); requestHandler.handle(new RequestDescriptor<T, R>() { @Override public T getRequest() { return request; } @Override public CompletionHandler<R> getCompletionHandler() { return new CompletionHandler<R>() { @Override public void onSuccess(R response) { Assert.assertEquals(response, expectedResponse); requestHandler.close(); } @Override public void onError(Throwable exception) { Assert.assertEquals(exception, expectedResponse); requestHandler.close(); } }; } }); } }
UTF-8
Java
2,306
java
AsyncRequestHandlerTest.java
Java
[ { "context": "rt java.util.function.Function;\n\n/**\n * Created by SorokinI on 08.09.2015.\n */\npublic class AsyncRequestHandl", "end": 398, "score": 0.9716131091117859, "start": 390, "tag": "USERNAME", "value": "SorokinI" } ]
null
[]
package ru.sorokinigor.server.requesthandlers; import org.testng.Assert; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import ru.sorokinigor.server.CompletionHandler; import ru.sorokinigor.server.RequestDescriptor; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.function.Function; /** * Created by SorokinI on 08.09.2015. */ public class AsyncRequestHandlerTest { @DataProvider public Iterator<Object[]> testData(){ Collection<Object[]> testData = new ArrayList<>(); { Function<String, String> reverseFunction = s -> new StringBuilder(s).reverse().toString(); String request = "testString"; testData.add(new Object[]{ reverseFunction, request, reverseFunction.apply(request) }); } { RuntimeException exception = new RuntimeException("expected exception"); Function<String, String> functionWithException = s -> { throw exception; }; testData.add(new Object[]{ functionWithException, "anyRequest", exception }); } return testData.iterator(); } @Test(dataProvider = "testData") public <T, R> void testHandle(Function<T, R> function, T request, R expectedResponse){ RequestHandler<T, R> requestHandler = new AsyncRequestHandler.AsyncRequestHandlerBuilder<T, R>() .setResponseFunction(function) .build(); requestHandler.handle(new RequestDescriptor<T, R>() { @Override public T getRequest() { return request; } @Override public CompletionHandler<R> getCompletionHandler() { return new CompletionHandler<R>() { @Override public void onSuccess(R response) { Assert.assertEquals(response, expectedResponse); requestHandler.close(); } @Override public void onError(Throwable exception) { Assert.assertEquals(exception, expectedResponse); requestHandler.close(); } }; } }); } }
2,306
0.594536
0.591067
68
32.911766
28.706802
104
false
false
0
0
0
0
0
0
0.617647
false
false
10
1cfd4637aff731dc0b535dd0cb2e4f5825195fc2
4,226,247,867,679
311acfdde7fefce2d8d1c307138adf303a089b67
/example/src/main/java/org/example/designpattern/flyweight/ConnectionPool.java
2882eb4a67c4b0c5b0445964c2e7155077a4ef5e
[]
no_license
GoggleHe/example
https://github.com/GoggleHe/example
ca122e3d43995c6bfbf1016cb78a93dcafcf20b7
9f2e1159cd69bfef0ff6b0dff5b9ff1a2e611c02
refs/heads/master
2023-03-10T08:05:08.942000
2021-02-03T06:26:13
2021-02-03T06:26:13
317,778,378
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package org.example.designpattern.flyweight; import java.util.ArrayList; import java.util.List; /** * **/ public class ConnectionPool { private List<Connection> pool = new ArrayList<>(); private int size; public ConnectionPool(int size) { this.size = size; } public Connection getConnection() { if (pool.size() < this.size) { Connection connection = new Connection(); pool.add(connection); connection.setAlive(); return connection; } else { for (Connection connection : pool) { if (!connection.isAlive()) { connection.setAlive(); return connection; } } Connection connection = new Connection(); connection.setAlive(); return connection; } } }
UTF-8
Java
887
java
ConnectionPool.java
Java
[]
null
[]
package org.example.designpattern.flyweight; import java.util.ArrayList; import java.util.List; /** * **/ public class ConnectionPool { private List<Connection> pool = new ArrayList<>(); private int size; public ConnectionPool(int size) { this.size = size; } public Connection getConnection() { if (pool.size() < this.size) { Connection connection = new Connection(); pool.add(connection); connection.setAlive(); return connection; } else { for (Connection connection : pool) { if (!connection.isAlive()) { connection.setAlive(); return connection; } } Connection connection = new Connection(); connection.setAlive(); return connection; } } }
887
0.537768
0.537768
37
22.972973
17.94961
54
false
false
0
0
0
0
0
0
0.405405
false
false
10
91f08244c6d193ca979ac04e76475231563113e1
18,073,222,408,691
ea9eeba5f9616e0c1f30287c35df0c0bd4b82964
/languages/Wollokito/source_gen/Wollokito/editor/EditorAspectDescriptorImpl.java
4d4ceaeb7e68bc63be96a0562ec6f68a1e905377
[]
no_license
AlvarezAriel/mps-simple-interpreter-example
https://github.com/AlvarezAriel/mps-simple-interpreter-example
9fc67e8a0efbc7ee31514a59eb984f68e15af38f
161cc5243d54cd554d1484be7bc9cd126d091309
refs/heads/master
2021-01-13T00:50:24.463000
2015-11-26T17:32:14
2015-11-26T17:32:14
46,939,599
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package Wollokito.editor; /*Generated by MPS */ import jetbrains.mps.nodeEditor.EditorAspectDescriptorBase; import java.util.Collection; import jetbrains.mps.openapi.editor.descriptor.ConceptEditor; import jetbrains.mps.smodel.runtime.ConceptDescriptor; import java.util.Arrays; import java.util.Collections; import jetbrains.mps.openapi.editor.descriptor.ConceptEditorComponent; public class EditorAspectDescriptorImpl extends EditorAspectDescriptorBase { public Collection<ConceptEditor> getEditors(ConceptDescriptor descriptor) { switch (Arrays.binarySearch(stringSwitchCases_xbvbvu_a0a0a, descriptor.getConceptFqName())) { case 0: return collectEditors(descriptor, Collections.<ConceptEditor>singletonList(new Method_Editor())); case 1: return collectEditors(descriptor, Collections.<ConceptEditor>singletonList(new MethodCall_Editor())); case 2: return collectEditors(descriptor, Collections.<ConceptEditor>singletonList(new ObjectDeclaration_Editor())); case 3: return collectEditors(descriptor, Collections.<ConceptEditor>singletonList(new ObjectReference_Editor())); case 4: return collectEditors(descriptor, Collections.<ConceptEditor>singletonList(new Program_Editor())); default: } return Collections.<ConceptEditor>emptyList(); } public Collection<ConceptEditorComponent> getEditorComponents(ConceptDescriptor descriptor, String editorComponentId) { return Collections.<ConceptEditorComponent>emptyList(); } private static String[] stringSwitchCases_xbvbvu_a0a0a = new String[]{"Wollokito.structure.Method", "Wollokito.structure.MethodCall", "Wollokito.structure.ObjectDeclaration", "Wollokito.structure.ObjectReference", "Wollokito.structure.Program"}; }
UTF-8
Java
1,776
java
EditorAspectDescriptorImpl.java
Java
[]
null
[]
package Wollokito.editor; /*Generated by MPS */ import jetbrains.mps.nodeEditor.EditorAspectDescriptorBase; import java.util.Collection; import jetbrains.mps.openapi.editor.descriptor.ConceptEditor; import jetbrains.mps.smodel.runtime.ConceptDescriptor; import java.util.Arrays; import java.util.Collections; import jetbrains.mps.openapi.editor.descriptor.ConceptEditorComponent; public class EditorAspectDescriptorImpl extends EditorAspectDescriptorBase { public Collection<ConceptEditor> getEditors(ConceptDescriptor descriptor) { switch (Arrays.binarySearch(stringSwitchCases_xbvbvu_a0a0a, descriptor.getConceptFqName())) { case 0: return collectEditors(descriptor, Collections.<ConceptEditor>singletonList(new Method_Editor())); case 1: return collectEditors(descriptor, Collections.<ConceptEditor>singletonList(new MethodCall_Editor())); case 2: return collectEditors(descriptor, Collections.<ConceptEditor>singletonList(new ObjectDeclaration_Editor())); case 3: return collectEditors(descriptor, Collections.<ConceptEditor>singletonList(new ObjectReference_Editor())); case 4: return collectEditors(descriptor, Collections.<ConceptEditor>singletonList(new Program_Editor())); default: } return Collections.<ConceptEditor>emptyList(); } public Collection<ConceptEditorComponent> getEditorComponents(ConceptDescriptor descriptor, String editorComponentId) { return Collections.<ConceptEditorComponent>emptyList(); } private static String[] stringSwitchCases_xbvbvu_a0a0a = new String[]{"Wollokito.structure.Method", "Wollokito.structure.MethodCall", "Wollokito.structure.ObjectDeclaration", "Wollokito.structure.ObjectReference", "Wollokito.structure.Program"}; }
1,776
0.788288
0.783221
37
47
52.240608
247
false
false
0
0
0
0
0
0
0.72973
false
false
10
3824c3544e5be4d37a1aaa3d5501a5da7a9a3f29
14,937,896,303,854
421441cc65900cffd6f65a15a1086a69d0b1c4ab
/src/zq/whu/zhangshangwuda/db/WifiDBUtil.java
d29d1fe1cd62f7a3e377c1868b39b529c3f54105
[ "Apache-2.0" ]
permissive
Consoar/zhangshangwuda
https://github.com/Consoar/zhangshangwuda
39c15e87b169d391dd2a7122859b97320849a98e
b9d12cebcfd520d16d0f1b78124b004b22365eff
refs/heads/master
2021-01-10T20:33:35.963000
2014-05-26T10:40:02
2014-05-26T10:40:02
17,084,318
9
5
null
false
2014-10-05T03:57:36
2014-02-22T12:27:15
2014-08-21T14:30:08
2014-05-26T10:41:21
2,941
4
13
1
Java
null
null
package zq.whu.zhangshangwuda.db; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.database.sqlite.SQLiteOpenHelper; public class WifiDBUtil extends SQLiteOpenHelper { private final static String DATABSE_NAME = "db_wifi.db"; private final static int DATABASE_VERSION = 1; public WifiDBUtil(Context context, String name, CursorFactory factory, int version) { super(context, DATABSE_NAME, null, DATABASE_VERSION); } public WifiDBUtil(Context context) { super(context, DATABSE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { createTable_wifi(db); } private void createTable_wifi(SQLiteDatabase db) { String sql = "create table if not exists " + "wifi" + "(id integer primary key autoincrement," + "username text not null, password text not null);"; db.execSQL(sql); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS wifi"); onCreate(db); } }
UTF-8
Java
1,101
java
WifiDBUtil.java
Java
[]
null
[]
package zq.whu.zhangshangwuda.db; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.database.sqlite.SQLiteOpenHelper; public class WifiDBUtil extends SQLiteOpenHelper { private final static String DATABSE_NAME = "db_wifi.db"; private final static int DATABASE_VERSION = 1; public WifiDBUtil(Context context, String name, CursorFactory factory, int version) { super(context, DATABSE_NAME, null, DATABASE_VERSION); } public WifiDBUtil(Context context) { super(context, DATABSE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { createTable_wifi(db); } private void createTable_wifi(SQLiteDatabase db) { String sql = "create table if not exists " + "wifi" + "(id integer primary key autoincrement," + "username text not null, password text not null);"; db.execSQL(sql); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS wifi"); onCreate(db); } }
1,101
0.752044
0.751135
40
26.525
24.467312
75
false
false
0
0
0
0
0
0
1.675
false
false
10
fe8a119fc5b3dd1d837fe0dbc9c3032090f5ae3b
21,990,232,557,116
928db3d25f900f82cdc3b39fe95dc4be1bfde5d4
/src/main/java/com/champak/plus/config/CustomAuthenticationProvider.java
d47739df1bd82941a4e8d423b0596e87cbe77dff
[]
no_license
virusneeraj/ChampakPlusAPI
https://github.com/virusneeraj/ChampakPlusAPI
85047b16fc47fa770354e64f97ff009efc09b811
7f0624e8f549c0f39aff97ae2045e4b388fe694e
refs/heads/master
2021-06-07T13:06:23.843000
2019-11-10T09:01:43
2019-11-10T09:01:43
147,071,204
0
0
null
false
2021-06-04T01:29:45
2018-09-02T09:18:48
2019-11-10T09:01:46
2021-06-04T01:29:45
35
0
0
1
Java
false
false
package com.champak.plus.config; import com.champak.plus.util.MyMongoCollections; import com.mongodb.BasicDBObject; import com.mongodb.DBObject; import com.champak.plus.dao.MongoDBDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.stereotype.Component; import java.io.IOException; import java.util.Collections; import java.util.regex.Pattern; @Component public class CustomAuthenticationProvider implements AuthenticationProvider { @Autowired MongoDBDao mongoDBDao; @Override public Authentication authenticate(Authentication auth) throws AuthenticationException { String username = auth.getName(); String password = auth.getCredentials().toString(); DBObject query = new BasicDBObject(); query.put("email", Pattern.compile("^" + username + "$", Pattern.CASE_INSENSITIVE)); query.put("password", password); try { mongoDBDao.findOne(MyMongoCollections.USER,query); } catch (IOException e) { throw new BadCredentialsException("Get data from DB exception", e); } if ("externaluser".equals(username) && "pass".equals(password)) { return new UsernamePasswordAuthenticationToken (username, password, Collections.emptyList()); } else { throw new BadCredentialsException("External system authentication failed"); } } @Override public boolean supports(Class<?> auth) { return auth.equals(UsernamePasswordAuthenticationToken.class); } }
UTF-8
Java
1,968
java
CustomAuthenticationProvider.java
Java
[ { "context": ".CASE_INSENSITIVE));\n query.put(\"password\", password);\n\n try {\n mongoDBDao.findOne(M", "end": 1283, "score": 0.9981895089149475, "start": 1275, "tag": "PASSWORD", "value": "password" }, { "context": "ta from DB exception\", e);\n }\n if (\"externaluser\".equals(username) && \"pass\".equals(password)) {\n ", "end": 1513, "score": 0.9816431999206543, "start": 1501, "tag": "USERNAME", "value": "externaluser" } ]
null
[]
package com.champak.plus.config; import com.champak.plus.util.MyMongoCollections; import com.mongodb.BasicDBObject; import com.mongodb.DBObject; import com.champak.plus.dao.MongoDBDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.stereotype.Component; import java.io.IOException; import java.util.Collections; import java.util.regex.Pattern; @Component public class CustomAuthenticationProvider implements AuthenticationProvider { @Autowired MongoDBDao mongoDBDao; @Override public Authentication authenticate(Authentication auth) throws AuthenticationException { String username = auth.getName(); String password = auth.getCredentials().toString(); DBObject query = new BasicDBObject(); query.put("email", Pattern.compile("^" + username + "$", Pattern.CASE_INSENSITIVE)); query.put("password", <PASSWORD>); try { mongoDBDao.findOne(MyMongoCollections.USER,query); } catch (IOException e) { throw new BadCredentialsException("Get data from DB exception", e); } if ("externaluser".equals(username) && "pass".equals(password)) { return new UsernamePasswordAuthenticationToken (username, password, Collections.emptyList()); } else { throw new BadCredentialsException("External system authentication failed"); } } @Override public boolean supports(Class<?> auth) { return auth.equals(UsernamePasswordAuthenticationToken.class); } }
1,970
0.727642
0.727642
52
36.846153
27.771309
92
false
false
0
0
0
0
0
0
0.634615
false
false
10
b26d5a2d3fc2f44516a74c246e7f70967fe5959c
5,781,026,009,305
71b70f86a536317841ae0f8a8df35551f4118418
/scd/src/main/java/com/bcpv/service/impl/LocalidadManagerImpl.java
d169e1c93dba02112b56caf4443c0ae17a0df36a
[]
no_license
LeoBur/ProyectoSCD
https://github.com/LeoBur/ProyectoSCD
4ea3c0f78b653722591c6eae3a3a407f4a2b944d
31d20d7835d954eb171c6c2ddb8e33e4b103afa0
refs/heads/master
2016-09-08T01:56:31.924000
2015-04-01T23:58:11
2015-04-01T23:58:11
18,351,187
0
0
null
false
2015-04-01T21:05:33
2014-04-02T01:43:42
2015-04-01T00:25:18
2015-04-01T21:05:33
100,939
0
1
1
Java
null
null
package com.bcpv.service.impl; import java.util.ArrayList; import java.util.List; import javax.jws.WebService; import javax.persistence.EntityExistsException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.bcpv.dao.LocalidadDao; import com.bcpv.model.Localidad; import com.bcpv.service.LocalidadManager; import com.bcpv.service.LocalidadService; @Service("localidadManager") @WebService(serviceName = "LocalidadService", endpointInterface = "com.bcpv.service.LocalidadService") @Transactional public class LocalidadManagerImpl extends GenericManagerImpl<Localidad, Long> implements LocalidadService, LocalidadManager{ private LocalidadDao localidadDao; @Override @Autowired public void setLocalidadDao(LocalidadDao localidadDao) { this.dao = localidadDao; this.localidadDao = localidadDao; } @Override public Localidad getLocalidad(String id) { return localidadDao.get(new Long(id)); } @Override public Localidad getLocalidad(Long id) { return localidadDao.get(id); } @Override public List<Localidad> getLocalidades() { if (localidadDao!=null){ return localidadDao.getAllDistinct(); } return new ArrayList<Localidad>(); } @Override public Localidad saveLocalidad(final Localidad localidad) throws EntityExistsException { try { return localidadDao.saveLocalidad(localidad); } catch (final Exception e){ e.printStackTrace(); log.warn(e.getMessage()); throw new EntityExistsException("La Localidad ya existe"); } } @Override public List<Localidad> search(String searchTerm) { return super.search(searchTerm, Localidad.class); } @Override public void removeLocalidad(Localidad localidad) { log.debug("removing localidad: " + localidad.getNombre()); localidadDao.remove(localidad); } @Override public void removeLocalidad(String id) { log.debug("removing persona: " + id); localidadDao.remove(new Long(id)); } @Override public List<Localidad> getLocalidadByNombreYProvincia(String nombre, String provincia) { log.debug("Searching Localidad by Nombre and Provincia"); return localidadDao.getByNombreYProv(nombre, provincia); } }
UTF-8
Java
2,291
java
LocalidadManagerImpl.java
Java
[]
null
[]
package com.bcpv.service.impl; import java.util.ArrayList; import java.util.List; import javax.jws.WebService; import javax.persistence.EntityExistsException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.bcpv.dao.LocalidadDao; import com.bcpv.model.Localidad; import com.bcpv.service.LocalidadManager; import com.bcpv.service.LocalidadService; @Service("localidadManager") @WebService(serviceName = "LocalidadService", endpointInterface = "com.bcpv.service.LocalidadService") @Transactional public class LocalidadManagerImpl extends GenericManagerImpl<Localidad, Long> implements LocalidadService, LocalidadManager{ private LocalidadDao localidadDao; @Override @Autowired public void setLocalidadDao(LocalidadDao localidadDao) { this.dao = localidadDao; this.localidadDao = localidadDao; } @Override public Localidad getLocalidad(String id) { return localidadDao.get(new Long(id)); } @Override public Localidad getLocalidad(Long id) { return localidadDao.get(id); } @Override public List<Localidad> getLocalidades() { if (localidadDao!=null){ return localidadDao.getAllDistinct(); } return new ArrayList<Localidad>(); } @Override public Localidad saveLocalidad(final Localidad localidad) throws EntityExistsException { try { return localidadDao.saveLocalidad(localidad); } catch (final Exception e){ e.printStackTrace(); log.warn(e.getMessage()); throw new EntityExistsException("La Localidad ya existe"); } } @Override public List<Localidad> search(String searchTerm) { return super.search(searchTerm, Localidad.class); } @Override public void removeLocalidad(Localidad localidad) { log.debug("removing localidad: " + localidad.getNombre()); localidadDao.remove(localidad); } @Override public void removeLocalidad(String id) { log.debug("removing persona: " + id); localidadDao.remove(new Long(id)); } @Override public List<Localidad> getLocalidadByNombreYProvincia(String nombre, String provincia) { log.debug("Searching Localidad by Nombre and Provincia"); return localidadDao.getByNombreYProv(nombre, provincia); } }
2,291
0.76735
0.76735
86
25.639534
25.681824
124
false
false
0
0
0
0
0
0
1.302326
false
false
10
6d5f83145cd1020a1d157f4af443ec03b808f6b2
11,544,872,126,646
2ca7dd773756629a3313b58e652ab3eba316ab2a
/java1/src/main/java/kr/ac/sejong/java1/JavaReview2.java
8518fb0deedc1196308532036eaf83204061c10c
[]
no_license
HongEunho/AppPrograming
https://github.com/HongEunho/AppPrograming
2299e16baa8b9b712f4371fa617e73e8e12dedbb
3e4278b98b68f70ae407fef356d7c50a9a37a573
refs/heads/master
2021-04-17T23:35:19.551000
2020-06-10T09:06:51
2020-06-10T09:06:51
249,486,023
0
0
null
false
2020-10-13T20:35:38
2020-03-23T16:35:46
2020-06-10T09:07:08
2020-10-13T20:35:37
4,101
0
0
1
Java
false
false
package kr.ac.sejong.java1; import java.util.Scanner; public class JavaReview2 { public static void main(String[] args) {//ctrl+shift+f // ctrl+space Scanner scanner = new Scanner(System.in); System.out.println("10나누기 x 프로그램 : x를 입력하세요"); while(true) { int x = scanner.nextInt(); try { System.out.println(10/x); } catch(ArithmeticException e) { System.out.println("0은 쓰시면 안됩니다."); } } } }
UTF-8
Java
500
java
JavaReview2.java
Java
[]
null
[]
package kr.ac.sejong.java1; import java.util.Scanner; public class JavaReview2 { public static void main(String[] args) {//ctrl+shift+f // ctrl+space Scanner scanner = new Scanner(System.in); System.out.println("10나누기 x 프로그램 : x를 입력하세요"); while(true) { int x = scanner.nextInt(); try { System.out.println(10/x); } catch(ArithmeticException e) { System.out.println("0은 쓰시면 안됩니다."); } } } }
500
0.606987
0.591703
24
17.083334
16.958076
55
false
false
0
0
0
0
0
0
1.958333
false
false
10
a5f56261d7e50b26629287202feeb014b343434a
27,015,344,314,735
5cd2ff397ace4a77f9c078ca1ed54f059738ddac
/app/src/main/java/com/tjut/mianliao/mycollege/EmployCalenderActivity.java
50413cfc8b4b6c095f86801bf76555706b171e82
[]
no_license
wongainia/Mianliao2
https://github.com/wongainia/Mianliao2
31025ce77c68775741ff4ad504a3c3d82450762a
d1a999b990816a5a5a747ad31d7c2eea1ffa7d0d
refs/heads/master
2022-01-10T20:58:21.758000
2019-05-14T22:35:31
2019-05-14T22:35:31
186,710,163
0
1
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.tjut.mianliao.mycollege; import java.util.ArrayList; import java.util.Calendar; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; import com.tjut.mianliao.BaseActivity; import com.tjut.mianliao.R; import com.tjut.mianliao.curriculum.CourseManager; import com.tjut.mianliao.curriculum.CourseUtil; import com.tjut.mianliao.curriculum.cell.BaseCellAdapter; import com.tjut.mianliao.curriculum.cell.CellLayout; import com.tjut.mianliao.curriculum.cell.CellLayout.OnCellClickListener; import com.tjut.mianliao.data.job.Job; public class EmployCalenderActivity extends BaseActivity implements OnClickListener, OnCellClickListener { private static final int REQUEST_CODE = 100; private int mCellHeight; private int mNumRows = 12; private CourseManager mCourseManager; private CurriculumAdapter mAdapter; private String[] mWeeksDesc; private int mCurrentWeek; private int mCurrentWeekDay = -1; private int mColorCellB; private int mColorCellNum; private ArrayList<Job> mJobs; @Override protected int getLayoutResID() { return R.layout.activity_employ_calender; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Resources res = getResources(); mColorCellB = res.getColor(R.color.cur_cell_b); mColorCellNum = res.getColor(R.color.cur_color_number); mCellHeight = calculateCellHeight(); mWeeksDesc = new String[CourseUtil.MAX_WEEK + 1]; mJobs = new ArrayList<Job>(); mCourseManager = CourseManager.getInstance(this); mCurrentWeek = mCourseManager.getCurrentWeek(); mAdapter = new CurriculumAdapter(); mAdapter.fillCells(mJobs); CellLayout courseLayout = (CellLayout) findViewById(R.id.cl_course_content); courseLayout.setAdapter(mAdapter); courseLayout.setOnCellClickListener(this); showWeekDay(); showPeriod(); updateWeeksDesc(); getTitleBar().showTitleArrow(); getTitleBar().showTitleText(mWeeksDesc[mCurrentWeek - 1], this); getTitleBar().showRightButton(R.drawable.icon_more, this); } private void fillJobData() { for (int i = 0; i < 3; i++) { Job job = new Job(); job.corpName = "产品经理"; job.categoryName = "泰聚泰"; job.cTime = System.currentTimeMillis(); mJobs.add(job); } } private void updateWeeksDesc() { int initWeek = mCourseManager.getInitWeek(); for (int i = 1; i <= mWeeksDesc.length; i++) { mWeeksDesc[i - 1] = i == initWeek ? getString(R.string.cur_current_week, i) : getString( R.string.cur_title_num_week, i); } } private int calculateCellHeight() { Resources res = getResources(); int headHeight = res.getDimensionPixelSize(R.dimen.title_bar_height) + res.getDimensionPixelSize(R.dimen.cur_header_height); int totalHeight = getResources().getDisplayMetrics().heightPixels - headHeight; int origCellHeight = getResources().getDimensionPixelSize(R.dimen.cur_cell_height); if ((origCellHeight + 1) * mNumRows < totalHeight) { return totalHeight / mNumRows - 1; } else { return origCellHeight; } } private void showWeekDay() { LinearLayout llWeekDay = (LinearLayout) findViewById(R.id.ll_weekday); int weekDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK) % 7; int monDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH); int monOfYear = Calendar.getInstance().get(Calendar.MONTH); TextView tvMonth = (TextView) llWeekDay.findViewById(R.id.tv_month); tvMonth.setText((monOfYear + 1) + "月"); if (mCurrentWeekDay != weekDay) { mCurrentWeekDay = weekDay; for (int i = 1; i < 8; i++) { LinearLayout ll = (LinearLayout) llWeekDay.getChildAt(i); int color = mColorCellNum; TextView day = (TextView) ll.getChildAt(0); TextView v = (TextView) ll.getChildAt(1); int wd = ((i - 1) + Calendar.MONDAY) % 7; if (wd == weekDay) { ll.setBackgroundResource(R.drawable.bg_week_day_today); color = 0xFFFFFFFF; } else if ((i - 1) % 2 == 0) { ll.setBackgroundColor(mColorCellB); } else { ll.setBackgroundResource(0); } if (weekDay > 1) { if (wd > 1) { day.setText((monDay - weekDay + wd) + ""); } else { day.setText((monDay - weekDay + wd + 7) + ""); } } } } } private void showPeriod() { LinearLayout llPeriod = (LinearLayout) findViewById(R.id.ll_period); int height = mCellHeight + 1; for (int i = 1; i <= mNumRows; i++) { TextView tvPeriod = (TextView) getLayoutInflater().inflate(R.layout.item_period_number, null); tvPeriod.setText(String.valueOf(i)); if ((i & 1) == 1) { tvPeriod.setBackgroundColor(mColorCellB); } if (i == mNumRows) { height -= 1; } LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height); llPeriod.addView(tvPeriod, lp); } } @Override public void onClick(View v) { } @Override public void onCellClicked(int col, int row) { toast("" + col + "--" + row); startActivityForResult(new Intent(this, AddJobsInfoActivity.class), REQUEST_CODE); } private class CurriculumAdapter extends BaseCellAdapter { private ArrayList<CellLayout.Cell> mCells = new ArrayList<CellLayout.Cell>(); private void fillCells(ArrayList<Job> jobs) { mCells.clear(); int size = jobs.size(); ArrayList<CellLayout.Cell> overlapCells = new ArrayList<CellLayout.Cell>(); for (int i = 0; i < size; i++) { Job job = jobs.get(i); CellLayout.Cell newCell = new CellLayout.Cell(); newCell.col = job.cls; newCell.rowStart = 2 + i; newCell.rowEnd = 3 + i; ArrayList<Job> newEntries = new ArrayList<Job>(); newEntries.add(job); for (CellLayout.Cell cell : overlapCells) { mCells.remove(cell); newEntries.addAll(mJobs); newCell.merge(cell.col, cell.rowStart, cell.rowEnd); } mCells.add(newCell); } } @Override public int getCount() { return mCells.size(); } @Override public Object getItem(int position) { return mCells.get(position); } @Override public View getView(int position, View convertView, ViewGroup parent) { View view; if (convertView == null) { view = getLayoutInflater().inflate(R.layout.course_item, parent, false); } else { view = convertView; } return view; } @Override public CellLayout.Cell getCell(int position) { return mCells.get(position); } @Override public int getNumCols() { return 7; } @Override public int getNumRows() { return mNumRows; } @Override public int getCellHeight() { return mCellHeight; } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { fillDataToCell(); } private void fillDataToCell() { fillJobData(); mAdapter.fillCells(mJobs); } }
UTF-8
Java
8,335
java
EmployCalenderActivity.java
Java
[ { "context": " Job job = new Job();\n job.corpName = \"产品经理\";\n job.categoryName = \"泰聚泰\";\n ", "end": 2549, "score": 0.4534228444099426, "start": 2547, "tag": "NAME", "value": "产品" } ]
null
[]
package com.tjut.mianliao.mycollege; import java.util.ArrayList; import java.util.Calendar; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; import com.tjut.mianliao.BaseActivity; import com.tjut.mianliao.R; import com.tjut.mianliao.curriculum.CourseManager; import com.tjut.mianliao.curriculum.CourseUtil; import com.tjut.mianliao.curriculum.cell.BaseCellAdapter; import com.tjut.mianliao.curriculum.cell.CellLayout; import com.tjut.mianliao.curriculum.cell.CellLayout.OnCellClickListener; import com.tjut.mianliao.data.job.Job; public class EmployCalenderActivity extends BaseActivity implements OnClickListener, OnCellClickListener { private static final int REQUEST_CODE = 100; private int mCellHeight; private int mNumRows = 12; private CourseManager mCourseManager; private CurriculumAdapter mAdapter; private String[] mWeeksDesc; private int mCurrentWeek; private int mCurrentWeekDay = -1; private int mColorCellB; private int mColorCellNum; private ArrayList<Job> mJobs; @Override protected int getLayoutResID() { return R.layout.activity_employ_calender; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Resources res = getResources(); mColorCellB = res.getColor(R.color.cur_cell_b); mColorCellNum = res.getColor(R.color.cur_color_number); mCellHeight = calculateCellHeight(); mWeeksDesc = new String[CourseUtil.MAX_WEEK + 1]; mJobs = new ArrayList<Job>(); mCourseManager = CourseManager.getInstance(this); mCurrentWeek = mCourseManager.getCurrentWeek(); mAdapter = new CurriculumAdapter(); mAdapter.fillCells(mJobs); CellLayout courseLayout = (CellLayout) findViewById(R.id.cl_course_content); courseLayout.setAdapter(mAdapter); courseLayout.setOnCellClickListener(this); showWeekDay(); showPeriod(); updateWeeksDesc(); getTitleBar().showTitleArrow(); getTitleBar().showTitleText(mWeeksDesc[mCurrentWeek - 1], this); getTitleBar().showRightButton(R.drawable.icon_more, this); } private void fillJobData() { for (int i = 0; i < 3; i++) { Job job = new Job(); job.corpName = "产品经理"; job.categoryName = "泰聚泰"; job.cTime = System.currentTimeMillis(); mJobs.add(job); } } private void updateWeeksDesc() { int initWeek = mCourseManager.getInitWeek(); for (int i = 1; i <= mWeeksDesc.length; i++) { mWeeksDesc[i - 1] = i == initWeek ? getString(R.string.cur_current_week, i) : getString( R.string.cur_title_num_week, i); } } private int calculateCellHeight() { Resources res = getResources(); int headHeight = res.getDimensionPixelSize(R.dimen.title_bar_height) + res.getDimensionPixelSize(R.dimen.cur_header_height); int totalHeight = getResources().getDisplayMetrics().heightPixels - headHeight; int origCellHeight = getResources().getDimensionPixelSize(R.dimen.cur_cell_height); if ((origCellHeight + 1) * mNumRows < totalHeight) { return totalHeight / mNumRows - 1; } else { return origCellHeight; } } private void showWeekDay() { LinearLayout llWeekDay = (LinearLayout) findViewById(R.id.ll_weekday); int weekDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK) % 7; int monDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH); int monOfYear = Calendar.getInstance().get(Calendar.MONTH); TextView tvMonth = (TextView) llWeekDay.findViewById(R.id.tv_month); tvMonth.setText((monOfYear + 1) + "月"); if (mCurrentWeekDay != weekDay) { mCurrentWeekDay = weekDay; for (int i = 1; i < 8; i++) { LinearLayout ll = (LinearLayout) llWeekDay.getChildAt(i); int color = mColorCellNum; TextView day = (TextView) ll.getChildAt(0); TextView v = (TextView) ll.getChildAt(1); int wd = ((i - 1) + Calendar.MONDAY) % 7; if (wd == weekDay) { ll.setBackgroundResource(R.drawable.bg_week_day_today); color = 0xFFFFFFFF; } else if ((i - 1) % 2 == 0) { ll.setBackgroundColor(mColorCellB); } else { ll.setBackgroundResource(0); } if (weekDay > 1) { if (wd > 1) { day.setText((monDay - weekDay + wd) + ""); } else { day.setText((monDay - weekDay + wd + 7) + ""); } } } } } private void showPeriod() { LinearLayout llPeriod = (LinearLayout) findViewById(R.id.ll_period); int height = mCellHeight + 1; for (int i = 1; i <= mNumRows; i++) { TextView tvPeriod = (TextView) getLayoutInflater().inflate(R.layout.item_period_number, null); tvPeriod.setText(String.valueOf(i)); if ((i & 1) == 1) { tvPeriod.setBackgroundColor(mColorCellB); } if (i == mNumRows) { height -= 1; } LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height); llPeriod.addView(tvPeriod, lp); } } @Override public void onClick(View v) { } @Override public void onCellClicked(int col, int row) { toast("" + col + "--" + row); startActivityForResult(new Intent(this, AddJobsInfoActivity.class), REQUEST_CODE); } private class CurriculumAdapter extends BaseCellAdapter { private ArrayList<CellLayout.Cell> mCells = new ArrayList<CellLayout.Cell>(); private void fillCells(ArrayList<Job> jobs) { mCells.clear(); int size = jobs.size(); ArrayList<CellLayout.Cell> overlapCells = new ArrayList<CellLayout.Cell>(); for (int i = 0; i < size; i++) { Job job = jobs.get(i); CellLayout.Cell newCell = new CellLayout.Cell(); newCell.col = job.cls; newCell.rowStart = 2 + i; newCell.rowEnd = 3 + i; ArrayList<Job> newEntries = new ArrayList<Job>(); newEntries.add(job); for (CellLayout.Cell cell : overlapCells) { mCells.remove(cell); newEntries.addAll(mJobs); newCell.merge(cell.col, cell.rowStart, cell.rowEnd); } mCells.add(newCell); } } @Override public int getCount() { return mCells.size(); } @Override public Object getItem(int position) { return mCells.get(position); } @Override public View getView(int position, View convertView, ViewGroup parent) { View view; if (convertView == null) { view = getLayoutInflater().inflate(R.layout.course_item, parent, false); } else { view = convertView; } return view; } @Override public CellLayout.Cell getCell(int position) { return mCells.get(position); } @Override public int getNumCols() { return 7; } @Override public int getNumRows() { return mNumRows; } @Override public int getCellHeight() { return mCellHeight; } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { fillDataToCell(); } private void fillDataToCell() { fillJobData(); mAdapter.fillCells(mJobs); } }
8,335
0.583604
0.578916
248
32.544353
25.149353
121
false
false
0
0
0
0
0
0
0.600806
false
false
10
b6dac25dd9174f8a6bb1b7784f1b5f0144aa7ba4
31,327,491,473,547
6ab812934a7e9b6cd6028c4cf2295e9ef2cf1e30
/src/main/java/utils/RandomGenerator.java
459ed745c8d34f3e062376c0a9aaddfc62fccbaf
[]
no_license
eidrien/economicsCD
https://github.com/eidrien/economicsCD
ee65d8c00b2076062a1501ac57ca75120f9af57f
f6bdc08a8bb6286aa872b6d74ab642a26073ebcb
refs/heads/master
2021-01-19T17:03:48.852000
2017-08-25T12:07:31
2017-08-25T12:07:31
101,042,047
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package utils; import java.util.Iterator; import java.util.Random; import java.util.Set; import cd.Functionality; public class RandomGenerator { protected Random randomGenerator; public RandomGenerator(){ randomGenerator = new Random(); } public void setRandomSeed(int seed){ randomGenerator.setSeed(seed); } public Functionality getRandomItem(Set<Functionality> items) { int position = getRandomNumber(items.size()); Iterator<Functionality> iterator = items.iterator(); Functionality randomItem = iterator.next(); for(int i=0; i<position; i++){ randomItem = iterator.next(); } return randomItem; } public int getRandomNumber(int max){ return randomGenerator.nextInt(max); } public boolean chooseWithProbability(double probability){ return randomGenerator.nextDouble() < probability; } }
UTF-8
Java
835
java
RandomGenerator.java
Java
[]
null
[]
package utils; import java.util.Iterator; import java.util.Random; import java.util.Set; import cd.Functionality; public class RandomGenerator { protected Random randomGenerator; public RandomGenerator(){ randomGenerator = new Random(); } public void setRandomSeed(int seed){ randomGenerator.setSeed(seed); } public Functionality getRandomItem(Set<Functionality> items) { int position = getRandomNumber(items.size()); Iterator<Functionality> iterator = items.iterator(); Functionality randomItem = iterator.next(); for(int i=0; i<position; i++){ randomItem = iterator.next(); } return randomItem; } public int getRandomNumber(int max){ return randomGenerator.nextInt(max); } public boolean chooseWithProbability(double probability){ return randomGenerator.nextDouble() < probability; } }
835
0.747305
0.746108
39
20.410257
19.554943
63
false
false
0
0
0
0
0
0
1.384615
false
false
10
a14739f27c326c962fdee5549fa126b8dc577b56
17,059,610,150,211
c7c7c5d8d4a064e7cfed3c5280d610f3984b5983
/Koordinator/src/ggTCalculator/CoordinatorPackage/noStarterHolder.java
f1b8c69638e8bf4a53f70bc77aed324e39840123
[]
no_license
fettlaus/ggTCalculator
https://github.com/fettlaus/ggTCalculator
c6d810dcd8fa968cd7dbcc463198e92f69590fc3
66deb381fd3665c70d59ca372849a4a0b31ad5aa
refs/heads/master
2021-03-12T20:23:12.767000
2011-06-03T07:14:55
2011-06-03T07:14:55
1,837,286
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package ggTCalculator.CoordinatorPackage; /** * ggTCalculator/CoordinatorPackage/noStarterHolder.java . * Generated by the IDL-to-Java compiler (portable), version "3.2" * from ggTCalculator.idl * Donnerstag, 2. Juni 2011 22:33 Uhr UTC */ public final class noStarterHolder implements org.omg.CORBA.portable.Streamable { public ggTCalculator.CoordinatorPackage.noStarter value = null; public noStarterHolder () { } public noStarterHolder (ggTCalculator.CoordinatorPackage.noStarter initialValue) { value = initialValue; } public void _read (org.omg.CORBA.portable.InputStream i) { value = ggTCalculator.CoordinatorPackage.noStarterHelper.read (i); } public void _write (org.omg.CORBA.portable.OutputStream o) { ggTCalculator.CoordinatorPackage.noStarterHelper.write (o, value); } public org.omg.CORBA.TypeCode _type () { return ggTCalculator.CoordinatorPackage.noStarterHelper.type (); } }
UTF-8
Java
984
java
noStarterHolder.java
Java
[ { "context": "table), version \"3.2\"\r\n* from ggTCalculator.idl\r\n* Donnerstag, 2. Juni 2011 22:33 Uhr UTC\r\n*/\r\n\r\npublic final c", "end": 214, "score": 0.9995592832565308, "start": 204, "tag": "NAME", "value": "Donnerstag" } ]
null
[]
package ggTCalculator.CoordinatorPackage; /** * ggTCalculator/CoordinatorPackage/noStarterHolder.java . * Generated by the IDL-to-Java compiler (portable), version "3.2" * from ggTCalculator.idl * Donnerstag, 2. Juni 2011 22:33 Uhr UTC */ public final class noStarterHolder implements org.omg.CORBA.portable.Streamable { public ggTCalculator.CoordinatorPackage.noStarter value = null; public noStarterHolder () { } public noStarterHolder (ggTCalculator.CoordinatorPackage.noStarter initialValue) { value = initialValue; } public void _read (org.omg.CORBA.portable.InputStream i) { value = ggTCalculator.CoordinatorPackage.noStarterHelper.read (i); } public void _write (org.omg.CORBA.portable.OutputStream o) { ggTCalculator.CoordinatorPackage.noStarterHelper.write (o, value); } public org.omg.CORBA.TypeCode _type () { return ggTCalculator.CoordinatorPackage.noStarterHelper.type (); } }
984
0.722561
0.711382
38
23.894737
28.686867
82
false
false
0
0
0
0
0
0
0.236842
false
false
10
5cab87c0fc324893115ef5778f640847106f05a7
17,059,610,148,952
663b748eaa740d3b817f14d8b75420a099cd30b4
/src/main/java/com/smk/quotebook/model/Members.java
6ac9dde2cf270b611b24965f9d3527db412bf8c0
[]
no_license
shin-minkyung/quotebook
https://github.com/shin-minkyung/quotebook
032d05af0da53cee2672e3e473def9345773a567
f2de8c1cd28df52e741310a277a6d9ccde73c341
refs/heads/master
2020-03-16T01:21:50.785000
2018-05-07T13:18:39
2018-05-07T13:18:39
132,438,385
1
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.smk.quotebook.model; import java.sql.Timestamp; public class Members { private String mid; private String mname; private String mpw; private Timestamp mdate; private String mphoto; private String aboutme; private int mlevel; private int mpoint; private int mdrop; private int melimi; private String mlname; private int mllowp; private int mlhighp; private double progress; private int heartCnt; private int quoteCnt; private int postCnt; public Members() { super(); } public int getHeartCnt() { return heartCnt; } public void setHeartCnt(int heartCnt) { this.heartCnt = heartCnt; } public int getQuoteCnt() { return quoteCnt; } public void setQuoteCnt(int quoteCnt) { this.quoteCnt = quoteCnt; } public int getPostCnt() { return postCnt; } public void setPostCnt(int postCnt) { this.postCnt = postCnt; } public double getProgress() { return progress; } public void setProgress(double progress) { this.progress = progress; } public int getMllowp() { return mllowp; } public void setMllowp(int mllowp) { this.mllowp = mllowp; } public int getMlhighp() { return mlhighp; } public void setMlhighp(int mlhighp) { this.mlhighp = mlhighp; } public String getMlname() { return mlname; } public void setMlname(String mlname) { this.mlname = mlname; } public String getMid() { return mid; } public void setMid(String mid) { this.mid = mid; } public String getMname() { return mname; } public void setMname(String mname) { this.mname = mname; } public String getMpw() { return mpw; } public void setMpw(String mpw) { this.mpw = mpw; } public Timestamp getMdate() { return mdate; } public void setMdate(Timestamp mdate) { this.mdate = mdate; } public String getMphoto() { return mphoto; } public void setMphoto(String mphoto) { this.mphoto = mphoto; } public String getAboutme() { return aboutme; } public void setAboutme(String aboutme) { this.aboutme = aboutme; } public int getMlevel() { return mlevel; } public void setMlevel(int mlevel) { this.mlevel = mlevel; } public int getMpoint() { return mpoint; } public void setMpoint(int mpoint) { this.mpoint = mpoint; } public int getMdrop() { return mdrop; } public void setMdrop(int mdrop) { this.mdrop = mdrop; } public int getMelimi() { return melimi; } public void setMelimi(int melimi) { this.melimi = melimi; } @Override public String toString() { return "Members [mid=" + mid + ", mname=" + mname + ", mpw=" + mpw + ", mdate=" + mdate + ", mphoto=" + mphoto + ", aboutme=" + aboutme + ", mlevel=" + mlevel + ", mpoint=" + mpoint + ", mdrop=" + mdrop + ", melimi=" + melimi + "]"; } }
UTF-8
Java
2,759
java
Members.java
Java
[]
null
[]
package com.smk.quotebook.model; import java.sql.Timestamp; public class Members { private String mid; private String mname; private String mpw; private Timestamp mdate; private String mphoto; private String aboutme; private int mlevel; private int mpoint; private int mdrop; private int melimi; private String mlname; private int mllowp; private int mlhighp; private double progress; private int heartCnt; private int quoteCnt; private int postCnt; public Members() { super(); } public int getHeartCnt() { return heartCnt; } public void setHeartCnt(int heartCnt) { this.heartCnt = heartCnt; } public int getQuoteCnt() { return quoteCnt; } public void setQuoteCnt(int quoteCnt) { this.quoteCnt = quoteCnt; } public int getPostCnt() { return postCnt; } public void setPostCnt(int postCnt) { this.postCnt = postCnt; } public double getProgress() { return progress; } public void setProgress(double progress) { this.progress = progress; } public int getMllowp() { return mllowp; } public void setMllowp(int mllowp) { this.mllowp = mllowp; } public int getMlhighp() { return mlhighp; } public void setMlhighp(int mlhighp) { this.mlhighp = mlhighp; } public String getMlname() { return mlname; } public void setMlname(String mlname) { this.mlname = mlname; } public String getMid() { return mid; } public void setMid(String mid) { this.mid = mid; } public String getMname() { return mname; } public void setMname(String mname) { this.mname = mname; } public String getMpw() { return mpw; } public void setMpw(String mpw) { this.mpw = mpw; } public Timestamp getMdate() { return mdate; } public void setMdate(Timestamp mdate) { this.mdate = mdate; } public String getMphoto() { return mphoto; } public void setMphoto(String mphoto) { this.mphoto = mphoto; } public String getAboutme() { return aboutme; } public void setAboutme(String aboutme) { this.aboutme = aboutme; } public int getMlevel() { return mlevel; } public void setMlevel(int mlevel) { this.mlevel = mlevel; } public int getMpoint() { return mpoint; } public void setMpoint(int mpoint) { this.mpoint = mpoint; } public int getMdrop() { return mdrop; } public void setMdrop(int mdrop) { this.mdrop = mdrop; } public int getMelimi() { return melimi; } public void setMelimi(int melimi) { this.melimi = melimi; } @Override public String toString() { return "Members [mid=" + mid + ", mname=" + mname + ", mpw=" + mpw + ", mdate=" + mdate + ", mphoto=" + mphoto + ", aboutme=" + aboutme + ", mlevel=" + mlevel + ", mpoint=" + mpoint + ", mdrop=" + mdrop + ", melimi=" + melimi + "]"; } }
2,759
0.667271
0.667271
173
14.947977
16.191507
112
false
false
0
0
0
0
0
0
1.387283
false
false
10
a70ca54382717faf2af280240e2a29aa0714191b
25,520,695,723,742
b53e4568f07c0a307d00fefdee8aaa175a92f318
/Java/src/majorityElementII/SolutionQSelect.java
d7c1da250f9c8d8dac6e0e8c1bc7d6c732a03e95
[]
no_license
Oliver-Ren/Leetcode
https://github.com/Oliver-Ren/Leetcode
3d3f9f9b84fcb0f9d214a2fbb4209e6943863466
068ce6feb091cb79039dca40a212d063af7e932b
refs/heads/master
2021-01-04T14:21:32.118000
2016-01-27T04:57:34
2016-01-27T04:57:34
29,097,545
1
0
null
null
null
null
null
null
null
null
null
null
null
null
null
/** * Solution based on the quick select algorithm. * 0 1/3 2/3 1 * .........cand1........cand2.......... * if there is a candidate, it must cover the 1/3th * of the 2/3 smallest position in a sorted array. * Time complexity: O(n) in average case. * Space complexity: O(1). * Status: Accepted. */ public class Solution { public List<Integer> majorityElement(int[] nums) { // precondition: nums is not null if (nums == null) throw new NullPointerException(); List<Integer> result = new ArrayList<Integer>(); if (nums.length == 0) return result; int cand1 = select(nums, nums.length / 3); int cand2 = select(nums, 2 * nums.length / 3); int count1 = 0; int count2 = 0; for (int n : nums) { if (n == cand1) { count1++; } if (n == cand2) { count2++; } } if (count1 > nums.length / 3) { result.add(cand1); } if (cand1 != cand2 && count2 > nums.length / 3) { result.add(cand2); } return result; } private int select(int[] nums, int k) { int lo = 0; int hi = nums.length; while (lo + 1 < hi) { int mid = partition(nums, lo, hi); if (mid == k) { return nums[k]; } else if (mid > k) { hi = mid; } else if (mid < k) { lo = mid + 1; } } return nums[lo]; } private int partition(int[] nums, int lo, int hi) { int pivot = nums[lo]; int i = lo; int j = hi; while (true) { while (i < hi - 1 && nums[++i] < pivot); while (j > 0 && nums[--j] > pivot); if (i < j) { exch(nums, i, j); } else { break; } } exch(nums, lo, j); return j; } private void exch(int[] nums, int i, int j) { int temp = nums[i]; nums[i] = nums[j]; nums[j] = temp; } }
UTF-8
Java
2,192
java
SolutionQSelect.java
Java
[]
null
[]
/** * Solution based on the quick select algorithm. * 0 1/3 2/3 1 * .........cand1........cand2.......... * if there is a candidate, it must cover the 1/3th * of the 2/3 smallest position in a sorted array. * Time complexity: O(n) in average case. * Space complexity: O(1). * Status: Accepted. */ public class Solution { public List<Integer> majorityElement(int[] nums) { // precondition: nums is not null if (nums == null) throw new NullPointerException(); List<Integer> result = new ArrayList<Integer>(); if (nums.length == 0) return result; int cand1 = select(nums, nums.length / 3); int cand2 = select(nums, 2 * nums.length / 3); int count1 = 0; int count2 = 0; for (int n : nums) { if (n == cand1) { count1++; } if (n == cand2) { count2++; } } if (count1 > nums.length / 3) { result.add(cand1); } if (cand1 != cand2 && count2 > nums.length / 3) { result.add(cand2); } return result; } private int select(int[] nums, int k) { int lo = 0; int hi = nums.length; while (lo + 1 < hi) { int mid = partition(nums, lo, hi); if (mid == k) { return nums[k]; } else if (mid > k) { hi = mid; } else if (mid < k) { lo = mid + 1; } } return nums[lo]; } private int partition(int[] nums, int lo, int hi) { int pivot = nums[lo]; int i = lo; int j = hi; while (true) { while (i < hi - 1 && nums[++i] < pivot); while (j > 0 && nums[--j] > pivot); if (i < j) { exch(nums, i, j); } else { break; } } exch(nums, lo, j); return j; } private void exch(int[] nums, int i, int j) { int temp = nums[i]; nums[i] = nums[j]; nums[j] = temp; } }
2,192
0.422445
0.404197
82
25.719513
16.207703
59
false
false
0
0
0
0
0
0
0.548781
false
false
10
0a21c463833c1a43cb97c87407b857ba776fd6c9
19,533,511,323,487
43099ef6d7192f60d7090722c87418d3be1e3cd7
/web/src/main/java/com/tms/controller/ui/MainController.java
998c8d81dcf10949d28f3f955cfccf16ad52580e
[]
no_license
shavrova/test-management-system
https://github.com/shavrova/test-management-system
fd84314d49c5eff5e972399b1162b22882deb9d9
7a289aaead9dc12bd4a76e9ab500659fdab6a813
refs/heads/master
2020-09-08T18:09:57.568000
2020-09-07T15:27:35
2020-09-07T15:27:35
221,205,842
0
1
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.tms.controller.ui; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import java.security.Principal; @Controller public class MainController { @GetMapping("/") public String root() { return "redirect:user"; } @GetMapping("/login") public String login() { return "login"; } @GetMapping("/user") public String userIndex(Principal principal) { if (principal.getName().equals("manager")) return "redirect:admin"; else return "redirect:myTests"; } }
UTF-8
Java
614
java
MainController.java
Java
[ { "context": "ncipal) {\n if (principal.getName().equals(\"manager\"))\n return \"redirect:admin\";\n e", "end": 513, "score": 0.8374826312065125, "start": 506, "tag": "USERNAME", "value": "manager" } ]
null
[]
package com.tms.controller.ui; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import java.security.Principal; @Controller public class MainController { @GetMapping("/") public String root() { return "redirect:user"; } @GetMapping("/login") public String login() { return "login"; } @GetMapping("/user") public String userIndex(Principal principal) { if (principal.getName().equals("manager")) return "redirect:admin"; else return "redirect:myTests"; } }
614
0.64658
0.64658
28
20.928572
17.707804
58
false
false
0
0
0
0
0
0
0.285714
false
false
10
fce345e58d0d0581ce0415e7215b7edb3046f97f
6,562,710,044,550
b8b77b409503aad10373e1ca4142f4f89a747aca
/biolaboratory-core/src/main/java/hu/bioinformatics/biolaboratory/sequence/protein/AminoAcid.java
2789af226544e8df36bef2dcb35e30a883a23585
[]
no_license
LordSerius/biolaboratory
https://github.com/LordSerius/biolaboratory
a72034fbe97c06b8e972360650ec77b6a2d23f2e
fe3e671d62b84259feacd406bbcd84bf92da591e
refs/heads/master
2021-01-09T06:10:43.484000
2018-01-13T22:17:07
2018-01-13T22:17:07
80,934,141
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package hu.bioinformatics.biolaboratory.sequence.protein; import com.google.common.collect.Sets; import hu.bioinformatics.biolaboratory.sequence.SequenceElement; import hu.bioinformatics.biolaboratory.utils.ArgumentValidator; import java.util.HashMap; import java.util.Map; import java.util.Set; import static com.google.common.base.Preconditions.checkArgument; import static hu.bioinformatics.biolaboratory.utils.ArgumentValidator.checkNotBlankString; /** * Contains the nucleotide information and data which are the building pieces of a protein. * * @author Attila Radi */ public enum AminoAcid implements SequenceElement { ARGININE("arginine", "Arg", 'R', 156), HISTIDINE("histidine", "His", 'H', 137), LYSINE("lysine", "Lys", 'K', 128), ASPARTIC_ACID("aspartic acid", "Asp", 'D', 115), GLUTAMIC_ACID("glutamic acid", "Glu", 'E', 129), SERINE("serine", "Ser", 'S', 87), THREONINE("threonine", "Thr", 'T', 101), ASPARAGINE("asparagine", "Asn", 'N', 114), GLUTAMINE("glutamine", "Gln", 'Q', 128), CYSTEINE("cysteine", "Cys", 'C', 103), GLYCINE("glycine", "Gly", 'G', 57), PROLINE("proline", "Pro", 'P', 97), ALANINE("alanine", "Ala", 'A', 71), ISOLEUCINE("isoleucine", "Ile", 'I', 113), LEUCINE("leucine", "Leu", 'L', 113), METHIONINE("methionine", "Met", 'M', 131), PHENYLALANINE("phenylalanine", "Phe", 'F', 147), TRYPTOPHAN("tryptophan", "Trp", 'W', 186), TYROSIN("tyrosin", "Tyr", 'Y', 163), VALINE("valine", "Val", 'V', 99); private static final Map<Character, AminoAcid> CHARACTER_AMINO_ACD_LOOKUP = initializeLookupTable(); /** * Set of all {@link AminoAcid}s. */ public static final Set<AminoAcid> AMINO_ACID_SET = Sets.newHashSet(values()); private static Map<Character, AminoAcid> initializeLookupTable() { Object[][] rawMapElements = new Object[][] { { ARGININE.getLetter(), ARGININE }, { HISTIDINE.getLetter(), HISTIDINE }, { LYSINE.getLetter(), LYSINE }, { ASPARTIC_ACID.getLetter(), ASPARTIC_ACID }, { GLUTAMIC_ACID.getLetter(), GLUTAMIC_ACID }, { SERINE.getLetter(), SERINE }, { THREONINE.getLetter(), THREONINE }, { ASPARAGINE.getLetter(), ASPARAGINE }, { GLUTAMINE.getLetter(), GLUTAMINE }, { CYSTEINE.getLetter(), CYSTEINE }, { GLYCINE.getLetter(), GLYCINE }, { PROLINE.getLetter(), PROLINE }, { ALANINE.getLetter(), ALANINE }, { ISOLEUCINE.getLetter(), ISOLEUCINE }, { LEUCINE.getLetter(), LEUCINE }, { METHIONINE.getLetter(), METHIONINE }, { PHENYLALANINE.getLetter(), PHENYLALANINE }, { TRYPTOPHAN.getLetter(), TRYPTOPHAN }, { TYROSIN.getLetter(), TYROSIN }, { VALINE.getLetter(), VALINE } }; Map<Character, AminoAcid> lookupTable = new HashMap<>(); for (Object[] row : rawMapElements) { lookupTable.put((Character) row[0], (AminoAcid) row[1]); } return lookupTable; } /** * Find amino acid about its amino acid letter in {@link String} format. * * @param aminoAcidLetter The amino acid letter. * @return The corresponding amino acid. * @throws IllegalArgumentException If aminoAcidLetter is not 1 character after trim. */ public static AminoAcid findAminoAcid(final String aminoAcidLetter) { checkNotBlankString("Amino acid letter", aminoAcidLetter); String normalizedAminoAcidLetter = aminoAcidLetter.trim(); ArgumentValidator.checkEqualNumberTo("Letter", normalizedAminoAcidLetter.length(), 1); return findAminoAcid(normalizedAminoAcidLetter.charAt(0)); } /** * Find the amino acid about its amino acid letter. * * @param aminoAcidLetter The amino acid letter. * @return The corresponding amino acid. * @throws IllegalArgumentException If aminoAcidLetter is not part of {@link AminoAcid}s. */ public static AminoAcid findAminoAcid(final char aminoAcidLetter) { AminoAcid aminoAcid = CHARACTER_AMINO_ACD_LOOKUP.get(Character.toUpperCase(aminoAcidLetter)); checkArgument(aminoAcid != null, "\"" + aminoAcidLetter + "\" is not a amino acid letter"); return aminoAcid; } private String name; private String abbreviation; private char letter; private int mass; AminoAcid(String name, String abbreviation, char letter, int mass) { this.name = name; this.abbreviation = abbreviation; this.letter = letter; this.mass = mass; } @Override public String getName() { return name; } @Override public char getLetter() { return letter; } @Override public String toString() { return getName(); } public String getAbbreviation() { return abbreviation; } public int getMass() { return mass; } }
UTF-8
Java
5,101
java
AminoAcid.java
Java
[ { "context": "re the building pieces of a protein.\n *\n * @author Attila Radi\n */\npublic enum AminoAcid implements SequenceElem", "end": 578, "score": 0.999873161315918, "start": 567, "tag": "NAME", "value": "Attila Radi" }, { "context": "han\", \"Trp\", 'W', 186),\n TYROSIN(\"tyrosin\", \"Tyr\", 'Y', 163),\n VALINE(\"valine\", \"Val\", 'V', 99)", "end": 1467, "score": 0.5296398997306824, "start": 1466, "tag": "NAME", "value": "r" } ]
null
[]
package hu.bioinformatics.biolaboratory.sequence.protein; import com.google.common.collect.Sets; import hu.bioinformatics.biolaboratory.sequence.SequenceElement; import hu.bioinformatics.biolaboratory.utils.ArgumentValidator; import java.util.HashMap; import java.util.Map; import java.util.Set; import static com.google.common.base.Preconditions.checkArgument; import static hu.bioinformatics.biolaboratory.utils.ArgumentValidator.checkNotBlankString; /** * Contains the nucleotide information and data which are the building pieces of a protein. * * @author <NAME> */ public enum AminoAcid implements SequenceElement { ARGININE("arginine", "Arg", 'R', 156), HISTIDINE("histidine", "His", 'H', 137), LYSINE("lysine", "Lys", 'K', 128), ASPARTIC_ACID("aspartic acid", "Asp", 'D', 115), GLUTAMIC_ACID("glutamic acid", "Glu", 'E', 129), SERINE("serine", "Ser", 'S', 87), THREONINE("threonine", "Thr", 'T', 101), ASPARAGINE("asparagine", "Asn", 'N', 114), GLUTAMINE("glutamine", "Gln", 'Q', 128), CYSTEINE("cysteine", "Cys", 'C', 103), GLYCINE("glycine", "Gly", 'G', 57), PROLINE("proline", "Pro", 'P', 97), ALANINE("alanine", "Ala", 'A', 71), ISOLEUCINE("isoleucine", "Ile", 'I', 113), LEUCINE("leucine", "Leu", 'L', 113), METHIONINE("methionine", "Met", 'M', 131), PHENYLALANINE("phenylalanine", "Phe", 'F', 147), TRYPTOPHAN("tryptophan", "Trp", 'W', 186), TYROSIN("tyrosin", "Tyr", 'Y', 163), VALINE("valine", "Val", 'V', 99); private static final Map<Character, AminoAcid> CHARACTER_AMINO_ACD_LOOKUP = initializeLookupTable(); /** * Set of all {@link AminoAcid}s. */ public static final Set<AminoAcid> AMINO_ACID_SET = Sets.newHashSet(values()); private static Map<Character, AminoAcid> initializeLookupTable() { Object[][] rawMapElements = new Object[][] { { ARGININE.getLetter(), ARGININE }, { HISTIDINE.getLetter(), HISTIDINE }, { LYSINE.getLetter(), LYSINE }, { ASPARTIC_ACID.getLetter(), ASPARTIC_ACID }, { GLUTAMIC_ACID.getLetter(), GLUTAMIC_ACID }, { SERINE.getLetter(), SERINE }, { THREONINE.getLetter(), THREONINE }, { ASPARAGINE.getLetter(), ASPARAGINE }, { GLUTAMINE.getLetter(), GLUTAMINE }, { CYSTEINE.getLetter(), CYSTEINE }, { GLYCINE.getLetter(), GLYCINE }, { PROLINE.getLetter(), PROLINE }, { ALANINE.getLetter(), ALANINE }, { ISOLEUCINE.getLetter(), ISOLEUCINE }, { LEUCINE.getLetter(), LEUCINE }, { METHIONINE.getLetter(), METHIONINE }, { PHENYLALANINE.getLetter(), PHENYLALANINE }, { TRYPTOPHAN.getLetter(), TRYPTOPHAN }, { TYROSIN.getLetter(), TYROSIN }, { VALINE.getLetter(), VALINE } }; Map<Character, AminoAcid> lookupTable = new HashMap<>(); for (Object[] row : rawMapElements) { lookupTable.put((Character) row[0], (AminoAcid) row[1]); } return lookupTable; } /** * Find amino acid about its amino acid letter in {@link String} format. * * @param aminoAcidLetter The amino acid letter. * @return The corresponding amino acid. * @throws IllegalArgumentException If aminoAcidLetter is not 1 character after trim. */ public static AminoAcid findAminoAcid(final String aminoAcidLetter) { checkNotBlankString("Amino acid letter", aminoAcidLetter); String normalizedAminoAcidLetter = aminoAcidLetter.trim(); ArgumentValidator.checkEqualNumberTo("Letter", normalizedAminoAcidLetter.length(), 1); return findAminoAcid(normalizedAminoAcidLetter.charAt(0)); } /** * Find the amino acid about its amino acid letter. * * @param aminoAcidLetter The amino acid letter. * @return The corresponding amino acid. * @throws IllegalArgumentException If aminoAcidLetter is not part of {@link AminoAcid}s. */ public static AminoAcid findAminoAcid(final char aminoAcidLetter) { AminoAcid aminoAcid = CHARACTER_AMINO_ACD_LOOKUP.get(Character.toUpperCase(aminoAcidLetter)); checkArgument(aminoAcid != null, "\"" + aminoAcidLetter + "\" is not a amino acid letter"); return aminoAcid; } private String name; private String abbreviation; private char letter; private int mass; AminoAcid(String name, String abbreviation, char letter, int mass) { this.name = name; this.abbreviation = abbreviation; this.letter = letter; this.mass = mass; } @Override public String getName() { return name; } @Override public char getLetter() { return letter; } @Override public String toString() { return getName(); } public String getAbbreviation() { return abbreviation; } public int getMass() { return mass; } }
5,096
0.619878
0.608116
140
35.435715
26.870113
104
false
false
0
0
0
0
0
0
1.178571
false
false
10
f4301f75476fc367b19e6ffe9aa2e0ba81473fb9
584,115,604,853
a666ac40ad2c33d130d9d6b06925a5948b25cc6a
/ooad/src/main/java/design_mode/template_mode/TemplateMode.java
1224f7e80abed1d015ea029937ccbe22025ee98b
[]
no_license
hotenglish/StudyInAction
https://github.com/hotenglish/StudyInAction
e8a46ef963be6a9c506cc4606c96a7433a974c7d
941d7a254dbbd22976d8110ff5cf0d18166c0462
refs/heads/master
2022-12-22T16:04:32.592000
2020-06-23T23:30:40
2020-06-23T23:30:40
137,567,024
0
0
null
false
2022-12-16T07:16:06
2018-06-16T08:51:49
2020-06-23T23:31:57
2022-12-16T07:16:01
241,099
0
0
107
HTML
false
false
package design_mode.template_mode; abstract class Account { protected String accountNumber; public Account(String accountNumber) { this.accountNumber = accountNumber; } public final double calculateInterest() { double interestRate = doCalculateInterestRate(); String accountType = doCalculateAccountType(); double amount = calculateAmount(accountType, accountNumber); return amount * interestRate; } abstract protected String doCalculateAccountType() ; abstract protected double doCalculateInterestRate() ; public final double calculateAmount(String accountType, String accountNumber) { //retrieve amount from database...here is only a mock-up return 1680.00D; } } class DollarAccount extends Account { public DollarAccount(String accountNumber) { super(accountNumber); } public String doCalculateAccountType() { return "Dollar"; } public double doCalculateInterestRate() { return 0.085D; } } class RMBAccount extends Account { public RMBAccount(String accountNumber) { super(accountNumber); } public String doCalculateAccountType() { return "RMB"; } public double doCalculateInterestRate() { return 0.075D; } } public class TemplateMode { public static void main(String[] args) { RMBAccount rmb=new RMBAccount("10001"); DollarAccount dollar=new DollarAccount("10002"); System.out.println("RMB:"+rmb.calculateInterest()+" Dollar:"+dollar.calculateInterest()); } }
UTF-8
Java
1,708
java
TemplateMode.java
Java
[]
null
[]
package design_mode.template_mode; abstract class Account { protected String accountNumber; public Account(String accountNumber) { this.accountNumber = accountNumber; } public final double calculateInterest() { double interestRate = doCalculateInterestRate(); String accountType = doCalculateAccountType(); double amount = calculateAmount(accountType, accountNumber); return amount * interestRate; } abstract protected String doCalculateAccountType() ; abstract protected double doCalculateInterestRate() ; public final double calculateAmount(String accountType, String accountNumber) { //retrieve amount from database...here is only a mock-up return 1680.00D; } } class DollarAccount extends Account { public DollarAccount(String accountNumber) { super(accountNumber); } public String doCalculateAccountType() { return "Dollar"; } public double doCalculateInterestRate() { return 0.085D; } } class RMBAccount extends Account { public RMBAccount(String accountNumber) { super(accountNumber); } public String doCalculateAccountType() { return "RMB"; } public double doCalculateInterestRate() { return 0.075D; } } public class TemplateMode { public static void main(String[] args) { RMBAccount rmb=new RMBAccount("10001"); DollarAccount dollar=new DollarAccount("10002"); System.out.println("RMB:"+rmb.calculateInterest()+" Dollar:"+dollar.calculateInterest()); } }
1,708
0.635831
0.62178
79
19.620253
22.626469
91
false
false
0
0
0
0
0
0
0.607595
false
false
10
2cac36585caed3cf6f27c352e2ac4abe92715c8a
584,115,601,178
c87aa5c98194da2af3ccb78e9db637193908ea9f
/WordQuizzle/src/Utente.java
0d9f281010f977b09a8d0d5d9c9f346f3cf6f0fc
[]
no_license
MartinaTrigilia/WordQuizzle
https://github.com/MartinaTrigilia/WordQuizzle
52a96bbf3aa95593daaeb046a24d8f3f5b2667ff
e25792a3f41497ed1c390e649129bb620c7e63ab
refs/heads/master
2023-01-31T18:05:56.961000
2020-12-12T19:10:28
2020-12-12T19:10:28
320,896,544
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
import java.util.ArrayList; import java.util.List; import org.json.simple.JSONArray; import org.json.simple.JSONObject; public class Utente { private final String nickUtente; private final String password; private int score; private List<String> friends; public Utente(String nick,String pw){ password=pw; nickUtente=nick; score = 0; friends = new ArrayList<String>(); } public String getNick(){ return this.nickUtente; } public String getPassword(){ return this.password; } public void setFriends(List<String> list) { friends=list; } public void setScore(int num){ score += num; } public int getScore(int num){ return this.score; } @SuppressWarnings("unchecked") public JSONObject PlayerToJSON() { JSONObject PlayerData = new JSONObject(); JSONArray PlayerFriends = new JSONArray(); PlayerFriends.addAll(friends); PlayerData.put("Nome", nickUtente); PlayerData.put("Password", password); //inizializzazione PlayerData.put("Punteggio", score); PlayerData.put("Amici", PlayerFriends); // PlayerData è un oggetto contenente info del giocatore return PlayerData; } }
WINDOWS-1252
Java
1,401
java
Utente.java
Java
[ { "context": "tente(String nick,String pw){\n \t\n \tpassword=pw;\n \tnickUtente=nick;\n score = 0;\n ", "end": 339, "score": 0.9993297457695007, "start": 337, "tag": "PASSWORD", "value": "pw" }, { "context": "\", nickUtente);\n PlayerData.put(\"Password\", password);\n \n //inizializzazione \n Pl", "end": 1151, "score": 0.9989726543426514, "start": 1143, "tag": "PASSWORD", "value": "password" } ]
null
[]
import java.util.ArrayList; import java.util.List; import org.json.simple.JSONArray; import org.json.simple.JSONObject; public class Utente { private final String nickUtente; private final String password; private int score; private List<String> friends; public Utente(String nick,String pw){ password=pw; nickUtente=nick; score = 0; friends = new ArrayList<String>(); } public String getNick(){ return this.nickUtente; } public String getPassword(){ return this.password; } public void setFriends(List<String> list) { friends=list; } public void setScore(int num){ score += num; } public int getScore(int num){ return this.score; } @SuppressWarnings("unchecked") public JSONObject PlayerToJSON() { JSONObject PlayerData = new JSONObject(); JSONArray PlayerFriends = new JSONArray(); PlayerFriends.addAll(friends); PlayerData.put("Nome", nickUtente); PlayerData.put("Password", <PASSWORD>); //inizializzazione PlayerData.put("Punteggio", score); PlayerData.put("Amici", PlayerFriends); // PlayerData è un oggetto contenente info del giocatore return PlayerData; } }
1,403
0.59
0.589286
72
18.430555
16.339136
61
false
false
0
0
0
0
0
0
0.708333
false
false
10
d315903d783eedbdcd85a6f187c1c6619949371a
7,765,300,937,718
d9d26915b60f569cf438bd657d98082bf48e621b
/src/main/java/kaptainwutax/featureutils/loot/entry/LootEntry.java
0b2bdc8ea880f0b892d2674c5a9427b81afc9ddf
[ "MIT" ]
permissive
KaptainWutax/FeatureUtils
https://github.com/KaptainWutax/FeatureUtils
42711e63c34c2c8a981c6f25e8bd79a1d64be697
a271711f58e283547634ca31e466b9b8b0e5d825
refs/heads/master
2023-04-25T18:10:33.349000
2022-08-17T20:59:19
2022-08-17T20:59:19
268,331,926
30
23
MIT
false
2023-06-30T21:04:32
2020-05-31T17:42:37
2023-05-27T13:07:07
2022-08-17T20:59:19
672
26
13
1
Java
false
false
package kaptainwutax.featureutils.loot.entry; import kaptainwutax.featureutils.loot.LootContext; import kaptainwutax.featureutils.loot.LootGenerator; import kaptainwutax.featureutils.loot.function.LootFunction; import kaptainwutax.mcutils.version.MCVersion; import kaptainwutax.mcutils.version.VersionMap; import kaptainwutax.noiseutils.utils.MathHelper; import java.util.Arrays; import java.util.function.Function; import java.util.function.Supplier; public abstract class LootEntry extends LootGenerator { public final int weight; public final int quality; public MCVersion introducedVersion = null; public MCVersion deprecatedVersion = null; public LootEntry() { this(1); } public LootEntry(int weight) { this(weight, 0); } public LootEntry(int weight, int quality) { this.weight = weight; this.quality = quality; } public LootEntry introducedVersion(MCVersion version) { introducedVersion = version; return this; } public LootEntry deprecatedVersion(MCVersion version) { deprecatedVersion = version; return this; } public int getWeight(LootContext context) { return this.weight; } public int getEffectiveWeight(int luck) { return Math.max(MathHelper.floor((float)this.weight + (float)this.quality * luck), 0); } @SafeVarargs public final LootEntry apply(Function<MCVersion,LootFunction>... lootFunctions) { this.apply(Arrays.asList(lootFunctions)); return this; } }
UTF-8
Java
1,427
java
LootEntry.java
Java
[]
null
[]
package kaptainwutax.featureutils.loot.entry; import kaptainwutax.featureutils.loot.LootContext; import kaptainwutax.featureutils.loot.LootGenerator; import kaptainwutax.featureutils.loot.function.LootFunction; import kaptainwutax.mcutils.version.MCVersion; import kaptainwutax.mcutils.version.VersionMap; import kaptainwutax.noiseutils.utils.MathHelper; import java.util.Arrays; import java.util.function.Function; import java.util.function.Supplier; public abstract class LootEntry extends LootGenerator { public final int weight; public final int quality; public MCVersion introducedVersion = null; public MCVersion deprecatedVersion = null; public LootEntry() { this(1); } public LootEntry(int weight) { this(weight, 0); } public LootEntry(int weight, int quality) { this.weight = weight; this.quality = quality; } public LootEntry introducedVersion(MCVersion version) { introducedVersion = version; return this; } public LootEntry deprecatedVersion(MCVersion version) { deprecatedVersion = version; return this; } public int getWeight(LootContext context) { return this.weight; } public int getEffectiveWeight(int luck) { return Math.max(MathHelper.floor((float)this.weight + (float)this.quality * luck), 0); } @SafeVarargs public final LootEntry apply(Function<MCVersion,LootFunction>... lootFunctions) { this.apply(Arrays.asList(lootFunctions)); return this; } }
1,427
0.779257
0.777155
57
24.035088
23.674669
95
false
false
0
0
0
0
0
0
1.298246
false
false
10
7051a20fed10e269e03182813255d0512830fb30
23,682,449,713,845
405d2d94951b0286c74ac22403a25f2101dd9f1b
/src/main/java/com/yitong/weixin/front/receive/utils/CF.java
2f92f436c1e9f3a34fe41fad408a6a7fdb378ee4
[ "Apache-2.0" ]
permissive
xielina/wechatMBank
https://github.com/xielina/wechatMBank
c721b1ab0460ab4b88782c7b095a5c4a0461e0a6
65746f9359eb716bec2311277e5c3c6a8a877492
refs/heads/master
2020-12-02T16:29:40.970000
2016-03-01T09:53:18
2016-03-01T09:53:18
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.yitong.weixin.front.receive.utils; import com.yitong.weixin.common.utils.PropertiesLoader; public class CF { public final static String Text = "text"; //文本消息msgType public final static String Image = "image"; //图片消息msgType public final static String Voice = "voice"; //语音和语音识别结果消息msgType public final static String Video = "video"; //视频消息msgType public final static String Location = "location"; //地理位置消息msgType public final static String Link = "link"; //连接消息msgType public final static float SessionTime = 5f; //整数单位为分 public final static int moreNum = 10; //更多明细查询 public static String AccessToken=""; public static String appId = getConfig("appId");//测试公众账号 public static String appsecret = getConfig("appsecret");//测试公众 public static String ip = getConfig("webIp");//外网跳转地址 public static String lanIp = getConfig("lanIp");//内网接口访问地址 public static String Token = getConfig("token");//微信验证所需token public static String title_val1 = getConfig("jcqy"); //解除签约 public static String title_val2 = getConfig("dlwz"); //网点查询 public static String title_val3 = getConfig("welcome"); //欢迎消息 public static String title_val4 = getConfig("atm"); //ATM查询 public static String title_val5 = getConfig("qybd"); //签约绑定 public static String common_val1 = getConfig("czqbx2"); //您要查找的全部消息如下: public static String common_val2 = getConfig("wqywxyh"); //亲,您尚未签约绑定重庆三峡银行微信银行。轻松签约绑定微信,即可享受重庆三峡银行的便捷服务。 public static String common_val3 = getConfig("wxyhktg"); //微信银行可提供: public static String common_val4 = getConfig("template_id"); public static String common_val5 = getConfig("qscdlwz"); //请上传地理位置信息! // public static String error_val = getConfig("error_val"); //亲,对您输入的内容我们无法检索到相关信息,我们将不断学习为您提供更优质的服务,请重新输入问题关键字! public static String picurl_val1 = getConfig("picurl_val1"); public static String url_val1 = getConfig("url_val1"); public static String picurl_val2 = getConfig("picurl_val2"); public static String url_val2 = getConfig("url_val2"); public static String description_val = "description_val"; public static String accessTokenUrl = getConfig("accessTokenUrl"); //"https://api.weixin.qq.com/cgi-bin/token"; public static String publishUrl = getConfig("publishUrl"); //"https://api.weixin.qq.com/cgi-bin/menu/create?access_token="; public static String getUserInfoUrl = getConfig("getUserInfoUrl"); //"https://api.weixin.qq.com/cgi-bin/user/info?access_token=%s&openid=%s"; public static String KeFuPostMsg = getConfig("KeFuPostMsg"); //"https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=%s"; public static String TemplateMsg = getConfig("TemplateMsg"); //public static String TemplateMsg = "https://mp.weixin.qq.com/advanced/tmplmsg?action=faq&token=%s&lang=zh_CN"; //"https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=%s"; public static String QunFaPostMsg = getConfig("QunFaPostMsg"); //"https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=%s"; /** * 属性文件加载对象 */ private static PropertiesLoader propertiesLoader; /** * 获取配置 */ public static String getConfig(String key) { if (propertiesLoader == null) { propertiesLoader = new PropertiesLoader("wechat.properties","application-hsh.properties"); } return propertiesLoader.getProperty(key); } }
UTF-8
Java
3,869
java
CF.java
Java
[]
null
[]
package com.yitong.weixin.front.receive.utils; import com.yitong.weixin.common.utils.PropertiesLoader; public class CF { public final static String Text = "text"; //文本消息msgType public final static String Image = "image"; //图片消息msgType public final static String Voice = "voice"; //语音和语音识别结果消息msgType public final static String Video = "video"; //视频消息msgType public final static String Location = "location"; //地理位置消息msgType public final static String Link = "link"; //连接消息msgType public final static float SessionTime = 5f; //整数单位为分 public final static int moreNum = 10; //更多明细查询 public static String AccessToken=""; public static String appId = getConfig("appId");//测试公众账号 public static String appsecret = getConfig("appsecret");//测试公众 public static String ip = getConfig("webIp");//外网跳转地址 public static String lanIp = getConfig("lanIp");//内网接口访问地址 public static String Token = getConfig("token");//微信验证所需token public static String title_val1 = getConfig("jcqy"); //解除签约 public static String title_val2 = getConfig("dlwz"); //网点查询 public static String title_val3 = getConfig("welcome"); //欢迎消息 public static String title_val4 = getConfig("atm"); //ATM查询 public static String title_val5 = getConfig("qybd"); //签约绑定 public static String common_val1 = getConfig("czqbx2"); //您要查找的全部消息如下: public static String common_val2 = getConfig("wqywxyh"); //亲,您尚未签约绑定重庆三峡银行微信银行。轻松签约绑定微信,即可享受重庆三峡银行的便捷服务。 public static String common_val3 = getConfig("wxyhktg"); //微信银行可提供: public static String common_val4 = getConfig("template_id"); public static String common_val5 = getConfig("qscdlwz"); //请上传地理位置信息! // public static String error_val = getConfig("error_val"); //亲,对您输入的内容我们无法检索到相关信息,我们将不断学习为您提供更优质的服务,请重新输入问题关键字! public static String picurl_val1 = getConfig("picurl_val1"); public static String url_val1 = getConfig("url_val1"); public static String picurl_val2 = getConfig("picurl_val2"); public static String url_val2 = getConfig("url_val2"); public static String description_val = "description_val"; public static String accessTokenUrl = getConfig("accessTokenUrl"); //"https://api.weixin.qq.com/cgi-bin/token"; public static String publishUrl = getConfig("publishUrl"); //"https://api.weixin.qq.com/cgi-bin/menu/create?access_token="; public static String getUserInfoUrl = getConfig("getUserInfoUrl"); //"https://api.weixin.qq.com/cgi-bin/user/info?access_token=%s&openid=%s"; public static String KeFuPostMsg = getConfig("KeFuPostMsg"); //"https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=%s"; public static String TemplateMsg = getConfig("TemplateMsg"); //public static String TemplateMsg = "https://mp.weixin.qq.com/advanced/tmplmsg?action=faq&token=%s&lang=zh_CN"; //"https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=%s"; public static String QunFaPostMsg = getConfig("QunFaPostMsg"); //"https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=%s"; /** * 属性文件加载对象 */ private static PropertiesLoader propertiesLoader; /** * 获取配置 */ public static String getConfig(String key) { if (propertiesLoader == null) { propertiesLoader = new PropertiesLoader("wechat.properties","application-hsh.properties"); } return propertiesLoader.getProperty(key); } }
3,869
0.71416
0.70771
87
37.206898
28.867569
113
false
false
0
0
0
0
0
0
1.609195
false
false
10
ef61cba28e278ad386af6c5cdb0427e706dd50cf
11,175,504,953,634
c25f2a57a51270d59593b00e93e3961f6704bba0
/src/exercicioModelo/Cliente.java
8124452c7aaf2c6c23e0c1c09f33d0c4a41612bd
[]
no_license
LuizCasagrande/devBootCamp
https://github.com/LuizCasagrande/devBootCamp
8db76365c3918cf37160002b1ddbe33fb73c6299
58dc97b2617f3f51ff93b59ac62ccb1d28238d5d
refs/heads/master
2020-08-30T05:16:22.053000
2019-11-04T20:56:20
2019-11-04T20:56:20
218,274,269
0
1
null
null
null
null
null
null
null
null
null
null
null
null
null
package exercicioModelo; import java.util.ArrayList; import java.util.List; public class Cliente { private Long id; private String nome; private String cpf; private List<Endereco> enderecos = new ArrayList<>(); public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getNome() { return nome; } public void setNome(String nome) { this.nome = nome; } public String getCpf() { return cpf; } public void setCpf(String cpf) { this.cpf = cpf; } public List<Endereco> getEnderecos() { return enderecos; } public void setEnderecos(List<Endereco> enderecos) { this.enderecos = enderecos; } public void populaDados() { System.out.println("Id do Cliente: " + id); System.out.println("Nome: " + nome); System.out.println("Cpf: " + cpf); for (Endereco e : enderecos) { System.out.println("Rua: " + e.getRua()); System.out.println("Número: " + e.getNumero()); System.out.println("Bairro: " + e.getBairro()); System.out.println("Tipo de Endereco: "+ e.getTipo().getLabel()); } } }
UTF-8
Java
1,257
java
Cliente.java
Java
[ { "context": "te: \" + id);\n System.out.println(\"Nome: \" + nome);\n System.out.println(\"Cpf: \" + cpf);\n\n ", "end": 901, "score": 0.9333059191703796, "start": 897, "tag": "NAME", "value": "nome" } ]
null
[]
package exercicioModelo; import java.util.ArrayList; import java.util.List; public class Cliente { private Long id; private String nome; private String cpf; private List<Endereco> enderecos = new ArrayList<>(); public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getNome() { return nome; } public void setNome(String nome) { this.nome = nome; } public String getCpf() { return cpf; } public void setCpf(String cpf) { this.cpf = cpf; } public List<Endereco> getEnderecos() { return enderecos; } public void setEnderecos(List<Endereco> enderecos) { this.enderecos = enderecos; } public void populaDados() { System.out.println("Id do Cliente: " + id); System.out.println("Nome: " + nome); System.out.println("Cpf: " + cpf); for (Endereco e : enderecos) { System.out.println("Rua: " + e.getRua()); System.out.println("Número: " + e.getNumero()); System.out.println("Bairro: " + e.getBairro()); System.out.println("Tipo de Endereco: "+ e.getTipo().getLabel()); } } }
1,257
0.566879
0.566879
57
21.052631
19.610615
77
false
false
0
0
0
0
0
0
0.385965
false
false
10
3a93a7630bc7a606023378be38242899879bc9ea
21,234,318,373,223
daa50e97b0d3fd0e3bf80f76d90049f47310bc1b
/src/computingSimpleInterest.java
3d603b9b8b0d2a3799b505c09eb8a5e9a281ea46
[]
no_license
mad-dejene/Resilient-Coders
https://github.com/mad-dejene/Resilient-Coders
59979d6f615d11db8233f2837b9ccc846c1152e5
163a66744617533009166d19ad545d94b8613666
refs/heads/master
2021-01-10T07:48:20.077000
2016-02-02T22:42:37
2016-02-02T22:42:37
50,957,237
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
import java.util.Scanner; public class computingSimpleInterest { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the principal: "); double principal = scan.nextDouble(); System.out.print("Enter the interest: "); double interest = scan.nextDouble() / 100; System.out.print("Enter the year: "); double year = scan.nextDouble(); System.out.println("After " + year + " years at " + interest * 100 + "%, the investment will be worth " + interestCalc(principal, interest, year) + "."); } public static double interestCalc( double principal, double interest, double year){ double worth = principal * (1 + interest * year); return worth; } }
UTF-8
Java
727
java
computingSimpleInterest.java
Java
[]
null
[]
import java.util.Scanner; public class computingSimpleInterest { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the principal: "); double principal = scan.nextDouble(); System.out.print("Enter the interest: "); double interest = scan.nextDouble() / 100; System.out.print("Enter the year: "); double year = scan.nextDouble(); System.out.println("After " + year + " years at " + interest * 100 + "%, the investment will be worth " + interestCalc(principal, interest, year) + "."); } public static double interestCalc( double principal, double interest, double year){ double worth = principal * (1 + interest * year); return worth; } }
727
0.685007
0.675378
24
29.291666
34.523518
155
false
false
0
0
0
0
0
0
1.916667
false
false
10
758856e13baed9be4ae943b1f193cd51832e2d83
8,297,876,885,119
01dc907fd7d86fe9590d611df1029e252c0e36cd
/app/src/main/java/nl/omniex/omniexshopping/ui/app/order/payment/OrderPaymentPresenter.java
40d704348b06bebe00b43d4eab167112ec3507a3
[]
no_license
mich994/android-omniex-shopping
https://github.com/mich994/android-omniex-shopping
8a6b15f3c3285eea4a5f94949535e257a993514e
eee2c4baae15339748585adc2912e704ffdf3991
refs/heads/master
2020-03-28T20:51:19.003000
2018-10-17T12:16:18
2018-10-17T12:16:18
149,108,542
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package nl.omniex.omniexshopping.ui.app.order.payment; import java.util.ArrayList; import java.util.HashSet; import javax.inject.Inject; import nl.omniex.omniexshopping.data.model.address.Address; import nl.omniex.omniexshopping.data.repository.AddressRepository; import nl.omniex.omniexshopping.ui.base.BasePresenter; public class OrderPaymentPresenter extends BasePresenter<OrderPaymentView> { private AddressRepository mAddressRepository; @Inject OrderPaymentPresenter(AddressRepository addressRepository) { mAddressRepository = addressRepository; } void getPaymentAddresses() { addDisposable(mAddressRepository .getPaymentAddresses() .subscribe( shippingAddressesResponse -> { ifViewAttached(view -> view.onPaymentAddressesFetched(new ArrayList<>(new HashSet<>(shippingAddressesResponse.body().getShippingAddressList().getAddressList())))); }, Throwable::printStackTrace)); } void setPaymentAddress(Address existingAddress) { addDisposable(mAddressRepository .setExistingPaymentAddress(existingAddress) .subscribe(voidResponse -> { ifViewAttached(view -> view.onPaymentMethodSet()); }, Throwable::printStackTrace)); } }
UTF-8
Java
1,365
java
OrderPaymentPresenter.java
Java
[]
null
[]
package nl.omniex.omniexshopping.ui.app.order.payment; import java.util.ArrayList; import java.util.HashSet; import javax.inject.Inject; import nl.omniex.omniexshopping.data.model.address.Address; import nl.omniex.omniexshopping.data.repository.AddressRepository; import nl.omniex.omniexshopping.ui.base.BasePresenter; public class OrderPaymentPresenter extends BasePresenter<OrderPaymentView> { private AddressRepository mAddressRepository; @Inject OrderPaymentPresenter(AddressRepository addressRepository) { mAddressRepository = addressRepository; } void getPaymentAddresses() { addDisposable(mAddressRepository .getPaymentAddresses() .subscribe( shippingAddressesResponse -> { ifViewAttached(view -> view.onPaymentAddressesFetched(new ArrayList<>(new HashSet<>(shippingAddressesResponse.body().getShippingAddressList().getAddressList())))); }, Throwable::printStackTrace)); } void setPaymentAddress(Address existingAddress) { addDisposable(mAddressRepository .setExistingPaymentAddress(existingAddress) .subscribe(voidResponse -> { ifViewAttached(view -> view.onPaymentMethodSet()); }, Throwable::printStackTrace)); } }
1,365
0.688645
0.688645
37
35.864864
35.715969
191
false
false
0
0
0
0
0
0
0.405405
false
false
10
74eb8a612363117b204f4a4929f885d14e6b9a37
29,970,281,832,326
19efd558400c192a60bee320488e34be2ff68573
/Football_Scores-master/app/src/main/java/barqsoft/footballscores/widget/DetailWidgetRemoteViewsService.java
a601e56538b3e0797937de2260c323836b782c2b
[]
no_license
lokesht/UdacitySuperDuo
https://github.com/lokesht/UdacitySuperDuo
4e1e336d31d453b344b2e7d55ec1054ac28c6067
878def7a9ac6d9cdd9077c7ef360533363d408ca
refs/heads/master
2021-01-10T08:14:53.410000
2016-03-13T14:04:22
2016-03-13T14:04:22
49,736,704
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package barqsoft.footballscores.widget; import android.annotation.TargetApi; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; import android.net.Uri; import android.os.Binder; import android.os.Build; import android.util.Log; import android.widget.AdapterView; import android.widget.RemoteViews; import android.widget.RemoteViewsService; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.ExecutionException; import barqsoft.footballscores.DatabaseContract; import barqsoft.footballscores.R; import barqsoft.footballscores.Utilies; /** * RemoteViewsService controlling the data being shown in the scrollable weather detail widget */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public class DetailWidgetRemoteViewsService extends RemoteViewsService { public final String LOG_TAG = DetailWidgetRemoteViewsService.class.getSimpleName(); private static final String[] SCORE_COLUMNS = { DatabaseContract.scores_table.DATE_COL, DatabaseContract.scores_table.TIME_COL, DatabaseContract.scores_table.HOME_COL, DatabaseContract.scores_table.AWAY_COL, DatabaseContract.scores_table.LEAGUE_COL, DatabaseContract.scores_table.HOME_GOALS_COL, DatabaseContract.scores_table.AWAY_GOALS_COL, DatabaseContract.scores_table.MATCH_ID, DatabaseContract.scores_table.MATCH_DAY }; // these indices must match the projection public static final int COL_DATE = 0; public static final int COL_MATCHTIME = 1; public static final int COL_HOME = 2; public static final int COL_AWAY = 3; public static final int COL_LEAGUE = 4; public static final int COL_HOME_GOALS = 5; public static final int COL_AWAY_GOALS = 6; public static final int COL_MATCH_ID = 7; public static final int COL_MATCHDAY = 8; @Override public RemoteViewsFactory onGetViewFactory(Intent intent) { return new RemoteViewsFactory() { private Cursor data = null; @Override public void onCreate() { // Nothing to do } @Override public void onDataSetChanged() { if (data != null) { data.close(); } // This method is called by the app hosting the widget (e.g., the launcher) // However, our ContentProvider is not exported so it doesn't have access to the // data. Therefore we need to clear (and finally restore) the calling identity so // that calls use our process and permission final long identityToken = Binder.clearCallingIdentity(); Date fragmentdate = new Date(System.currentTimeMillis()); SimpleDateFormat mformat = new SimpleDateFormat("yyyy-MM-dd"); String todayDate = mformat.format(fragmentdate); Uri todaysUri = DatabaseContract.scores_table.buildScoreWithDate(); data = getContentResolver().query(todaysUri, SCORE_COLUMNS, null, new String[]{todayDate}, DatabaseContract.scores_table.TIME_COL); Binder.restoreCallingIdentity(identityToken); } @Override public void onDestroy() { if (data != null) { data.close(); data = null; } } @Override public int getCount() { return data == null ? 0 : data.getCount(); } @Override public RemoteViews getViewAt(int position) { if (position == AdapterView.INVALID_POSITION || data == null || !data.moveToPosition(position)) { return null; } RemoteViews views = new RemoteViews(getPackageName(), R.layout.scores_list_item); views.setTextViewText(R.id.home_name,data.getString(COL_HOME)); views.setTextViewText(R.id.away_name,data.getString(COL_AWAY)); views.setTextViewText(R.id.data_textview,data.getString(COL_DATE)); int home_goal = data.getInt(COL_HOME_GOALS); int away_goal = data.getInt(COL_AWAY_GOALS); if (home_goal > away_goal) { views.setTextColor(R.id.home_name,getResources().getColor(R.color.green)); views.setTextColor(R.id.away_name,getResources().getColor(R.color.red)); } else if (home_goal < away_goal) { views.setTextColor(R.id.home_name,getResources().getColor(R.color.red)); views.setTextColor(R.id.away_name,getResources().getColor(R.color.green)); }else { views.setTextColor(R.id.home_name,getResources().getColor(R.color.primary_text)); views.setTextColor(R.id.away_name,getResources().getColor(R.color.primary_text)); } String goal = Utilies.getScores(home_goal, away_goal); views.setTextViewText(R.id.score_textview,goal); String time = data.getString(COL_MATCHTIME); views.setTextViewText(R.id.data_textview,time); views.setTextColor(R.id.score_textview,getResources().getColor(R.color.primary_text)); views.setTextColor(R.id.data_textview,getResources().getColor(R.color.primary_text)); views.setImageViewResource(R.id.home_crest,Utilies.getTeamCrestByTeamName(data.getString(COL_HOME))); views.setImageViewResource(R.id.away_crest,Utilies.getTeamCrestByTeamName(data.getString(COL_AWAY))); return views; } @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) private void setRemoteContentDescription(RemoteViews views, String description) { views.setContentDescription(R.id.widget_icon, description); } @Override public RemoteViews getLoadingView() { return new RemoteViews(getPackageName(), R.layout.scores_list_item); } @Override public int getViewTypeCount() { return 1; } @Override public long getItemId(int position) { if (data.moveToPosition(position)) return data.getLong(COL_MATCH_ID); return position; } @Override public boolean hasStableIds() { return true; } }; } }
UTF-8
Java
6,749
java
DetailWidgetRemoteViewsService.java
Java
[]
null
[]
package barqsoft.footballscores.widget; import android.annotation.TargetApi; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; import android.net.Uri; import android.os.Binder; import android.os.Build; import android.util.Log; import android.widget.AdapterView; import android.widget.RemoteViews; import android.widget.RemoteViewsService; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.ExecutionException; import barqsoft.footballscores.DatabaseContract; import barqsoft.footballscores.R; import barqsoft.footballscores.Utilies; /** * RemoteViewsService controlling the data being shown in the scrollable weather detail widget */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public class DetailWidgetRemoteViewsService extends RemoteViewsService { public final String LOG_TAG = DetailWidgetRemoteViewsService.class.getSimpleName(); private static final String[] SCORE_COLUMNS = { DatabaseContract.scores_table.DATE_COL, DatabaseContract.scores_table.TIME_COL, DatabaseContract.scores_table.HOME_COL, DatabaseContract.scores_table.AWAY_COL, DatabaseContract.scores_table.LEAGUE_COL, DatabaseContract.scores_table.HOME_GOALS_COL, DatabaseContract.scores_table.AWAY_GOALS_COL, DatabaseContract.scores_table.MATCH_ID, DatabaseContract.scores_table.MATCH_DAY }; // these indices must match the projection public static final int COL_DATE = 0; public static final int COL_MATCHTIME = 1; public static final int COL_HOME = 2; public static final int COL_AWAY = 3; public static final int COL_LEAGUE = 4; public static final int COL_HOME_GOALS = 5; public static final int COL_AWAY_GOALS = 6; public static final int COL_MATCH_ID = 7; public static final int COL_MATCHDAY = 8; @Override public RemoteViewsFactory onGetViewFactory(Intent intent) { return new RemoteViewsFactory() { private Cursor data = null; @Override public void onCreate() { // Nothing to do } @Override public void onDataSetChanged() { if (data != null) { data.close(); } // This method is called by the app hosting the widget (e.g., the launcher) // However, our ContentProvider is not exported so it doesn't have access to the // data. Therefore we need to clear (and finally restore) the calling identity so // that calls use our process and permission final long identityToken = Binder.clearCallingIdentity(); Date fragmentdate = new Date(System.currentTimeMillis()); SimpleDateFormat mformat = new SimpleDateFormat("yyyy-MM-dd"); String todayDate = mformat.format(fragmentdate); Uri todaysUri = DatabaseContract.scores_table.buildScoreWithDate(); data = getContentResolver().query(todaysUri, SCORE_COLUMNS, null, new String[]{todayDate}, DatabaseContract.scores_table.TIME_COL); Binder.restoreCallingIdentity(identityToken); } @Override public void onDestroy() { if (data != null) { data.close(); data = null; } } @Override public int getCount() { return data == null ? 0 : data.getCount(); } @Override public RemoteViews getViewAt(int position) { if (position == AdapterView.INVALID_POSITION || data == null || !data.moveToPosition(position)) { return null; } RemoteViews views = new RemoteViews(getPackageName(), R.layout.scores_list_item); views.setTextViewText(R.id.home_name,data.getString(COL_HOME)); views.setTextViewText(R.id.away_name,data.getString(COL_AWAY)); views.setTextViewText(R.id.data_textview,data.getString(COL_DATE)); int home_goal = data.getInt(COL_HOME_GOALS); int away_goal = data.getInt(COL_AWAY_GOALS); if (home_goal > away_goal) { views.setTextColor(R.id.home_name,getResources().getColor(R.color.green)); views.setTextColor(R.id.away_name,getResources().getColor(R.color.red)); } else if (home_goal < away_goal) { views.setTextColor(R.id.home_name,getResources().getColor(R.color.red)); views.setTextColor(R.id.away_name,getResources().getColor(R.color.green)); }else { views.setTextColor(R.id.home_name,getResources().getColor(R.color.primary_text)); views.setTextColor(R.id.away_name,getResources().getColor(R.color.primary_text)); } String goal = Utilies.getScores(home_goal, away_goal); views.setTextViewText(R.id.score_textview,goal); String time = data.getString(COL_MATCHTIME); views.setTextViewText(R.id.data_textview,time); views.setTextColor(R.id.score_textview,getResources().getColor(R.color.primary_text)); views.setTextColor(R.id.data_textview,getResources().getColor(R.color.primary_text)); views.setImageViewResource(R.id.home_crest,Utilies.getTeamCrestByTeamName(data.getString(COL_HOME))); views.setImageViewResource(R.id.away_crest,Utilies.getTeamCrestByTeamName(data.getString(COL_AWAY))); return views; } @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) private void setRemoteContentDescription(RemoteViews views, String description) { views.setContentDescription(R.id.widget_icon, description); } @Override public RemoteViews getLoadingView() { return new RemoteViews(getPackageName(), R.layout.scores_list_item); } @Override public int getViewTypeCount() { return 1; } @Override public long getItemId(int position) { if (data.moveToPosition(position)) return data.getLong(COL_MATCH_ID); return position; } @Override public boolean hasStableIds() { return true; } }; } }
6,749
0.606312
0.604534
164
40.152439
30.794479
147
false
false
0
0
0
0
0
0
0.658537
false
false
10
080258b3861648ac9afd8bbe58be9f20c375a99c
10,264,971,909,191
a35a0615a94572c15a0cb1fab6c38dd5df65cc8d
/app/src/main/java/com/example/latika/LoginActivity.java
9917724801c35c883af66bae0ff6646392f8a4c6
[]
no_license
salsabilarahma/LATIKA
https://github.com/salsabilarahma/LATIKA
2aa397769d42becef2635507a3887d388562806e
d2efe3de75671418b61195165234ba59c60aef47
refs/heads/master
2020-09-16T01:36:37.011000
2019-11-23T15:37:15
2019-11-23T15:37:15
223,610,807
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.example.latika; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class LoginActivity extends AppCompatActivity { Button btLogin; TextView eUser, epass; String user, pass; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); btLogin = (Button)findViewById(R.id.MaLogin); //dari button login agar dapat dieksekusi ke coding eUser = (TextView)findViewById(R.id.eUser); //dari textview user epass = (TextView)findViewById(R.id.epass); //digunakan untuk coding dari desain layout agar dapat dieksekusi btLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { user = eUser.getText().toString(); pass = epass.getText().toString(); Bundle b = new Bundle(); b.putString("u", user); b.putString("p", pass); Intent in = new Intent(LoginActivity.this, MenuActivity.class); in.putExtras(b); startActivity(in); } }); } }
UTF-8
Java
1,352
java
LoginActivity.java
Java
[]
null
[]
package com.example.latika; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class LoginActivity extends AppCompatActivity { Button btLogin; TextView eUser, epass; String user, pass; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); btLogin = (Button)findViewById(R.id.MaLogin); //dari button login agar dapat dieksekusi ke coding eUser = (TextView)findViewById(R.id.eUser); //dari textview user epass = (TextView)findViewById(R.id.epass); //digunakan untuk coding dari desain layout agar dapat dieksekusi btLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { user = eUser.getText().toString(); pass = epass.getText().toString(); Bundle b = new Bundle(); b.putString("u", user); b.putString("p", pass); Intent in = new Intent(LoginActivity.this, MenuActivity.class); in.putExtras(b); startActivity(in); } }); } }
1,352
0.638314
0.638314
41
31.975609
27.754576
117
false
false
0
0
0
0
0
0
0.707317
false
false
10
883412ddd37e7d622319a377fb63d8aab34ed4a3
35,021,163,346,745
93b210724d5e1b9a1b2b89c64c12d8582135f2aa
/EliteCSM-new/Applications/netvertex/src/com/elitecore/netvertex/core/serverinstance/ServerInstanceRegistrationProcess.java
57b8e080b8af8e115bf1c7c29ebf3d2b818f2d50
[]
no_license
sunilkumarpvns/newbrs
https://github.com/sunilkumarpvns/newbrs
e6b205a41898b25203f34a902d1334a83baafb09
38e8c22ea5deaee2e46938970be405a307918ce7
refs/heads/master
2021-06-17T08:45:52.964000
2019-08-21T02:58:00
2019-08-21T02:58:00
203,326,404
0
0
null
false
2021-05-12T00:24:10
2019-08-20T07:47:41
2019-08-21T03:00:28
2021-05-12T00:24:10
252,939
0
0
10
Java
false
false
package com.elitecore.netvertex.core.serverinstance; import com.elitecore.core.systemx.esix.http.HTTPMethodType; import com.elitecore.core.systemx.esix.http.RemoteMethod; import com.elitecore.corenetvertex.sm.serverinstance.ConfigurationDatabase; import com.elitecore.corenetvertex.sm.serverinstance.ServerInstanceRegistrationRequest; import static com.elitecore.commons.logging.LogManager.getLogger; public class ServerInstanceRegistrationProcess { private static final String MODULE = "SEREVER-INSTANCE-REGISTRATION-PROCESS"; private String serverHome; private ServerInstanceRequestData serverInstanceReqData; private ServerInstanceReaderAndWriter readerAndWriter; private ServerInstanceDBInfoWriter serverInstanceDbInfowriter; private ServerInstanceRegistrationCall instanceRegCall; private String jmxPort; public ServerInstanceRegistrationProcess(String serverHome, ServerInstanceRequestData serverInstanceReqData, ServerInstanceReaderAndWriter readerAndWriter, ServerInstanceDBInfoWriter serverInstanceDbInfowriter, ServerInstanceRegistrationCall instanceRegCall, String jmxPort){ this.serverHome = serverHome; this.serverInstanceReqData = serverInstanceReqData; this.jmxPort=jmxPort; this.readerAndWriter = readerAndWriter; this.serverInstanceDbInfowriter = serverInstanceDbInfowriter; this.instanceRegCall = instanceRegCall; } public void calltoSMToGetDBAndServerInstance(){ if(getLogger().isInfoLogLevel()) { getLogger().info(MODULE, "Calling ServerManager to register Server infomation"); } ConfigurationDatabase configurationDB = null; String serverInstanceId = null; String serverInstanceName = null; try { if (readerAndWriter.isFileExits()) { if(getLogger().isInfoLogLevel()) { getLogger().info(MODULE, "SysInfo file is available"); } readerAndWriter.read(); serverInstanceName = readerAndWriter.getName(); if (serverInstanceReqData.getServerName().equalsIgnoreCase(serverInstanceName)) { if(getLogger().isInfoLogLevel()) { getLogger().info(MODULE, "SysInfo file is available, Environment instance name is matched with file's instance name"); } serverInstanceId = readerAndWriter.getId(); } } ServerInstanceRegistrationRequest serverInstanceRegistrationRequest = callToSm(serverInstanceId,jmxPort, serverHome); if (serverInstanceRegistrationRequest == null) { return; } serverInstanceId = serverInstanceRegistrationRequest.getServerInstanceId(); serverInstanceName = serverInstanceRegistrationRequest.getServerName(); configurationDB = ConfigurationDatabase.from(serverInstanceRegistrationRequest); // write _sys.info readerAndWriter.writeServerInfo(serverInstanceId,serverInstanceName); // write dabase.json serverInstanceDbInfowriter.writeDBInfo(configurationDB); } catch (Exception e) { getLogger().error(MODULE, "Error while reading server info. Reason: " + e.getMessage()); getLogger().trace(MODULE,e); } } private ServerInstanceRegistrationRequest callToSm(String serverId, String jmxPort, String serverHome){ try { RemoteMethod remoteMethod = new RemoteMethod("/integration/serverinstanceregistration/server-instance-registration/*","/registerServerInstance.json", HTTPMethodType.POST); remoteMethod.addArgument("serverInstanceId",serverId); remoteMethod.addArgument("serverName",serverInstanceReqData.getServerName()); remoteMethod.addArgument("serverGroupName",serverInstanceReqData.getServerGroupName()); remoteMethod.addArgument("originHost",serverInstanceReqData.getOriginHost()); remoteMethod.addArgument("originRealm",serverInstanceReqData.getOriginRealm()); remoteMethod.addArgument("jmxPort",jmxPort); remoteMethod.addArgument("serverHome",serverHome); remoteMethod.addArgument("javaHome",System.getenv("JAVA_HOME")); return instanceRegCall.callToSm(remoteMethod); }catch(Exception e){ getLogger().error(MODULE, "Exception occurred while calling server manager to register instance. Reason: " + e.getMessage()); getLogger().trace(MODULE, e); } return null; } }
UTF-8
Java
4,974
java
ServerInstanceRegistrationProcess.java
Java
[]
null
[]
package com.elitecore.netvertex.core.serverinstance; import com.elitecore.core.systemx.esix.http.HTTPMethodType; import com.elitecore.core.systemx.esix.http.RemoteMethod; import com.elitecore.corenetvertex.sm.serverinstance.ConfigurationDatabase; import com.elitecore.corenetvertex.sm.serverinstance.ServerInstanceRegistrationRequest; import static com.elitecore.commons.logging.LogManager.getLogger; public class ServerInstanceRegistrationProcess { private static final String MODULE = "SEREVER-INSTANCE-REGISTRATION-PROCESS"; private String serverHome; private ServerInstanceRequestData serverInstanceReqData; private ServerInstanceReaderAndWriter readerAndWriter; private ServerInstanceDBInfoWriter serverInstanceDbInfowriter; private ServerInstanceRegistrationCall instanceRegCall; private String jmxPort; public ServerInstanceRegistrationProcess(String serverHome, ServerInstanceRequestData serverInstanceReqData, ServerInstanceReaderAndWriter readerAndWriter, ServerInstanceDBInfoWriter serverInstanceDbInfowriter, ServerInstanceRegistrationCall instanceRegCall, String jmxPort){ this.serverHome = serverHome; this.serverInstanceReqData = serverInstanceReqData; this.jmxPort=jmxPort; this.readerAndWriter = readerAndWriter; this.serverInstanceDbInfowriter = serverInstanceDbInfowriter; this.instanceRegCall = instanceRegCall; } public void calltoSMToGetDBAndServerInstance(){ if(getLogger().isInfoLogLevel()) { getLogger().info(MODULE, "Calling ServerManager to register Server infomation"); } ConfigurationDatabase configurationDB = null; String serverInstanceId = null; String serverInstanceName = null; try { if (readerAndWriter.isFileExits()) { if(getLogger().isInfoLogLevel()) { getLogger().info(MODULE, "SysInfo file is available"); } readerAndWriter.read(); serverInstanceName = readerAndWriter.getName(); if (serverInstanceReqData.getServerName().equalsIgnoreCase(serverInstanceName)) { if(getLogger().isInfoLogLevel()) { getLogger().info(MODULE, "SysInfo file is available, Environment instance name is matched with file's instance name"); } serverInstanceId = readerAndWriter.getId(); } } ServerInstanceRegistrationRequest serverInstanceRegistrationRequest = callToSm(serverInstanceId,jmxPort, serverHome); if (serverInstanceRegistrationRequest == null) { return; } serverInstanceId = serverInstanceRegistrationRequest.getServerInstanceId(); serverInstanceName = serverInstanceRegistrationRequest.getServerName(); configurationDB = ConfigurationDatabase.from(serverInstanceRegistrationRequest); // write _sys.info readerAndWriter.writeServerInfo(serverInstanceId,serverInstanceName); // write dabase.json serverInstanceDbInfowriter.writeDBInfo(configurationDB); } catch (Exception e) { getLogger().error(MODULE, "Error while reading server info. Reason: " + e.getMessage()); getLogger().trace(MODULE,e); } } private ServerInstanceRegistrationRequest callToSm(String serverId, String jmxPort, String serverHome){ try { RemoteMethod remoteMethod = new RemoteMethod("/integration/serverinstanceregistration/server-instance-registration/*","/registerServerInstance.json", HTTPMethodType.POST); remoteMethod.addArgument("serverInstanceId",serverId); remoteMethod.addArgument("serverName",serverInstanceReqData.getServerName()); remoteMethod.addArgument("serverGroupName",serverInstanceReqData.getServerGroupName()); remoteMethod.addArgument("originHost",serverInstanceReqData.getOriginHost()); remoteMethod.addArgument("originRealm",serverInstanceReqData.getOriginRealm()); remoteMethod.addArgument("jmxPort",jmxPort); remoteMethod.addArgument("serverHome",serverHome); remoteMethod.addArgument("javaHome",System.getenv("JAVA_HOME")); return instanceRegCall.callToSm(remoteMethod); }catch(Exception e){ getLogger().error(MODULE, "Exception occurred while calling server manager to register instance. Reason: " + e.getMessage()); getLogger().trace(MODULE, e); } return null; } }
4,974
0.658022
0.658022
97
50.278351
38.109104
183
false
false
0
0
0
0
0
0
0.804124
false
false
10
30c46031de5637e6e4f93ea3985423cd9cfb354e
31,825,707,721,686
981994869bbb01c514956f35324042c4d9bdaf1a
/elasticsearch/quarkus-elasticsearch/src/main/java/com/mycompany/quarkuselasticsearch/rest/MovieResource.java
8c536c168d4b34fdbd90576173e3e17069298dcb
[]
no_license
abmessaoud/graalvm-quarkus-micronaut-springboot
https://github.com/abmessaoud/graalvm-quarkus-micronaut-springboot
14afb9ad3eaf7170e560203094297763cdc9652a
b26bbd459f1cc833b5c1a9f08880c0c368ac057a
refs/heads/master
2023-08-15T22:15:46.816000
2021-10-16T10:56:40
2021-10-16T10:56:40
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.mycompany.quarkuselasticsearch.rest; import com.mycompany.quarkuselasticsearch.model.Movie; import com.mycompany.quarkuselasticsearch.rest.dto.CreateMovieRequest; import com.mycompany.quarkuselasticsearch.rest.dto.SearchMovieResponse; import com.mycompany.quarkuselasticsearch.service.MovieService; import javax.inject.Inject; import javax.validation.Valid; import javax.validation.constraints.NotBlank; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; @Path("/api/movies") public class MovieResource { @Inject MovieService movieService; @POST public Response createMovie(@Valid CreateMovieRequest createMovieRequest) { Movie movie = toMovie(createMovieRequest); String id = movieService.saveMovie(movie); return Response.status(Response.Status.CREATED).entity(id).build(); } @GET public SearchMovieResponse searchMovies(@QueryParam("title") @NotBlank String title) { return movieService.searchMovies(title); } private Movie toMovie(CreateMovieRequest createMovieRequest) { return new Movie(createMovieRequest.getImdb(), createMovieRequest.getTitle()); } }
UTF-8
Java
1,246
java
MovieResource.java
Java
[]
null
[]
package com.mycompany.quarkuselasticsearch.rest; import com.mycompany.quarkuselasticsearch.model.Movie; import com.mycompany.quarkuselasticsearch.rest.dto.CreateMovieRequest; import com.mycompany.quarkuselasticsearch.rest.dto.SearchMovieResponse; import com.mycompany.quarkuselasticsearch.service.MovieService; import javax.inject.Inject; import javax.validation.Valid; import javax.validation.constraints.NotBlank; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; @Path("/api/movies") public class MovieResource { @Inject MovieService movieService; @POST public Response createMovie(@Valid CreateMovieRequest createMovieRequest) { Movie movie = toMovie(createMovieRequest); String id = movieService.saveMovie(movie); return Response.status(Response.Status.CREATED).entity(id).build(); } @GET public SearchMovieResponse searchMovies(@QueryParam("title") @NotBlank String title) { return movieService.searchMovies(title); } private Movie toMovie(CreateMovieRequest createMovieRequest) { return new Movie(createMovieRequest.getImdb(), createMovieRequest.getTitle()); } }
1,246
0.771268
0.771268
38
31.789474
27.862593
90
false
false
0
0
0
0
0
0
0.526316
false
false
10
ea06b254e3f87cfe4c13b2d60c2bcc5ae49923b4
6,425,271,120,095
2a31f87dbdd4777921e1d47962b68a9cda084891
/user-manager/src/main/java/com/sellercube/usermanager/server/base/entity/PrintType.java
ef307f99a61314451d7d80d893e51e7bf25bfc86
[]
no_license
JokeyFeng/free-print
https://github.com/JokeyFeng/free-print
5d7de93db617f62c45ae3784570b0547bb664587
4dcd39422c9812097d0e6d64f925cf40efd73916
refs/heads/master
2020-03-16T21:06:56.457000
2019-04-12T05:51:47
2019-04-12T05:51:47
132,985,320
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.sellercube.usermanager.server.base.entity; import java.io.Serializable; import java.util.Date; public class PrintType implements Serializable { private Integer id; private String typeName; private Date createTime; private String creator; private Date updateTime; private String updator; private Date delTime; private String deletor; private Boolean isDelete; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getTypeName() { return typeName; } public void setTypeName(String typeName) { this.typeName = typeName == null ? null : typeName.trim(); } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public String getCreator() { return creator; } public void setCreator(String creator) { this.creator = creator == null ? null : creator.trim(); } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } public String getUpdator() { return updator; } public void setUpdator(String updator) { this.updator = updator == null ? null : updator.trim(); } public Date getDelTime() { return delTime; } public void setDelTime(Date delTime) { this.delTime = delTime; } public String getDeletor() { return deletor; } public void setDeletor(String deletor) { this.deletor = deletor == null ? null : deletor.trim(); } public Boolean getIsDelete() { return isDelete; } public void setIsDelete(Boolean isDelete) { this.isDelete = isDelete; } @Override public String toString() { return "printType{" + "id=" + id + ", typeName='" + typeName + '\'' + ", createTime=" + createTime + ", creator='" + creator + '\'' + ", updateTime=" + updateTime + ", updator='" + updator + '\'' + ", delTime=" + delTime + ", deletor='" + deletor + '\'' + ", isDelete=" + isDelete + '}'; } }
UTF-8
Java
2,397
java
PrintType.java
Java
[]
null
[]
package com.sellercube.usermanager.server.base.entity; import java.io.Serializable; import java.util.Date; public class PrintType implements Serializable { private Integer id; private String typeName; private Date createTime; private String creator; private Date updateTime; private String updator; private Date delTime; private String deletor; private Boolean isDelete; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getTypeName() { return typeName; } public void setTypeName(String typeName) { this.typeName = typeName == null ? null : typeName.trim(); } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public String getCreator() { return creator; } public void setCreator(String creator) { this.creator = creator == null ? null : creator.trim(); } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } public String getUpdator() { return updator; } public void setUpdator(String updator) { this.updator = updator == null ? null : updator.trim(); } public Date getDelTime() { return delTime; } public void setDelTime(Date delTime) { this.delTime = delTime; } public String getDeletor() { return deletor; } public void setDeletor(String deletor) { this.deletor = deletor == null ? null : deletor.trim(); } public Boolean getIsDelete() { return isDelete; } public void setIsDelete(Boolean isDelete) { this.isDelete = isDelete; } @Override public String toString() { return "printType{" + "id=" + id + ", typeName='" + typeName + '\'' + ", createTime=" + createTime + ", creator='" + creator + '\'' + ", updateTime=" + updateTime + ", updator='" + updator + '\'' + ", delTime=" + delTime + ", deletor='" + deletor + '\'' + ", isDelete=" + isDelete + '}'; } }
2,397
0.561535
0.561535
111
20.603603
18.941484
66
false
false
0
0
0
0
0
0
0.351351
false
false
10
7efe724c042e3a047aeccaf4b338278b40083658
38,311,108,288,539
df5a2179368e4e9db2a8a9117e4e6938e5361cb4
/src/main/java/com/cugb/entity/Video.java
9de9e2cef773c377eb376fd53b35f8486b84b7df
[]
no_license
JanusV-G/iiMooc
https://github.com/JanusV-G/iiMooc
6f4d3296cf062e76c2d2941eca102957a32cdf44
12639d3c6aaf6ea5d591e98cc6e5fe558cec76bd
refs/heads/master
2023-04-01T20:01:41.268000
2021-04-14T12:28:02
2021-04-14T12:28:02
357,895,658
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.cugb.entity; import java.util.Date; //具体网课表 public class Video { public Video() { } public Video(String video_name, String upload_user_name, String lesson_name, String video_file, String video_description, Date video_create_time) { super(); this.video_name = video_name; this.upload_user_name = upload_user_name; this.lesson_name = lesson_name; this.video_file = video_file; this.video_description = video_description; this.video_create_time = video_create_time; } public Video(int video_id, String video_name, String upload_user_name, String lesson_name, String video_file, String video_description, Date video_create_time) { super(); this.video_id = video_id; this.video_name = video_name; this.upload_user_name = upload_user_name; this.lesson_name = lesson_name; this.video_file = video_file; this.video_description = video_description; this.video_create_time = video_create_time; } private int video_id;//系统分配的id private String video_name;//视频名字 private String upload_user_name;//上传者名字 private String lesson_name;//所属课程名字 private String video_file;//文件 private String video_description;//描述 private Date video_create_time;//创建时间 public int getVideo_id() { return video_id; } public void setVideo_id(int video_id) { this.video_id = video_id; } public String getVideo_name() { return video_name; } public void setVideo_name(String video_name) { this.video_name = video_name; } public String getUpload_user_name() { return upload_user_name; } public void setUpload_user_name(String upload_user_name) { this.upload_user_name = upload_user_name; } public String getLesson_name() { return lesson_name; } public void setLesson_name(String lesson_name) { this.lesson_name = lesson_name; } public String getVideo_file() { return video_file; } public void setVideo_file(String video_file) { this.video_file = video_file; } public String getVideo_description() { return video_description; } public void setVideo_description(String video_description) { this.video_description = video_description; } public Date getVideo_create_time() { return video_create_time; } public void setVideo_create_time(Date video_create_time) { this.video_create_time = video_create_time; } }
GB18030
Java
2,443
java
Video.java
Java
[]
null
[]
package com.cugb.entity; import java.util.Date; //具体网课表 public class Video { public Video() { } public Video(String video_name, String upload_user_name, String lesson_name, String video_file, String video_description, Date video_create_time) { super(); this.video_name = video_name; this.upload_user_name = upload_user_name; this.lesson_name = lesson_name; this.video_file = video_file; this.video_description = video_description; this.video_create_time = video_create_time; } public Video(int video_id, String video_name, String upload_user_name, String lesson_name, String video_file, String video_description, Date video_create_time) { super(); this.video_id = video_id; this.video_name = video_name; this.upload_user_name = upload_user_name; this.lesson_name = lesson_name; this.video_file = video_file; this.video_description = video_description; this.video_create_time = video_create_time; } private int video_id;//系统分配的id private String video_name;//视频名字 private String upload_user_name;//上传者名字 private String lesson_name;//所属课程名字 private String video_file;//文件 private String video_description;//描述 private Date video_create_time;//创建时间 public int getVideo_id() { return video_id; } public void setVideo_id(int video_id) { this.video_id = video_id; } public String getVideo_name() { return video_name; } public void setVideo_name(String video_name) { this.video_name = video_name; } public String getUpload_user_name() { return upload_user_name; } public void setUpload_user_name(String upload_user_name) { this.upload_user_name = upload_user_name; } public String getLesson_name() { return lesson_name; } public void setLesson_name(String lesson_name) { this.lesson_name = lesson_name; } public String getVideo_file() { return video_file; } public void setVideo_file(String video_file) { this.video_file = video_file; } public String getVideo_description() { return video_description; } public void setVideo_description(String video_description) { this.video_description = video_description; } public Date getVideo_create_time() { return video_create_time; } public void setVideo_create_time(Date video_create_time) { this.video_create_time = video_create_time; } }
2,443
0.697518
0.697518
85
25.964706
21.665613
110
false
false
0
0
0
0
0
0
1.858824
false
false
10
9fcc42e44e36a288fbda324329516d3c8b9cabe1
2,482,491,118,806
1a32d704493deb99d3040646afbd0f6568d2c8e7
/BOOT-INF/lib/org/springframework/objenesis/instantiator/util/UnsafeUtils.java
df0577596636ed491c09bbad80814a7249cf090c
[]
no_license
yanrumei/bullet-zone-server-2.0
https://github.com/yanrumei/bullet-zone-server-2.0
e748ff40f601792405143ec21d3f77aa4d34ce69
474c4d1a8172a114986d16e00f5752dc019cdcd2
refs/heads/master
2020-05-19T11:16:31.172000
2019-03-25T17:38:31
2019-03-25T17:38:31
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
/* */ package org.springframework.objenesis.instantiator.util; /* */ /* */ import java.lang.reflect.Field; /* */ import org.springframework.objenesis.ObjenesisException; /* */ import sun.misc.Unsafe; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public final class UnsafeUtils /* */ { /* */ private static final Unsafe unsafe; /* */ /* */ static /* */ { /* */ try /* */ { /* 36 */ f = Unsafe.class.getDeclaredField("theUnsafe"); /* */ } catch (NoSuchFieldException e) { Field f; /* 38 */ throw new ObjenesisException(e); } /* */ Field f; /* 40 */ f.setAccessible(true); /* */ try { /* 42 */ unsafe = (Unsafe)f.get(null); /* */ } catch (IllegalAccessException e) { /* 44 */ throw new ObjenesisException(e); /* */ } /* */ } /* */ /* */ /* */ public static Unsafe getUnsafe() /* */ { /* 51 */ return unsafe; /* */ } /* */ } /* Location: C:\Users\ikatwal\Downloads\bullet-zone-server-2.0.jar!\BOOT-INF\lib\spring-core-4.3.14.RELEASE.jar!\org\springframework\objenesis\instantiato\\util\UnsafeUtils.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */
UTF-8
Java
1,422
java
UnsafeUtils.java
Java
[ { "context": "}\n/* */ }\n\n\n/* Location: C:\\Users\\ikatwal\\Downloads\\bullet-zone-server-2.0.jar!\\BOOT-INF\\li", "end": 1202, "score": 0.9514358639717102, "start": 1195, "tag": "USERNAME", "value": "ikatwal" } ]
null
[]
/* */ package org.springframework.objenesis.instantiator.util; /* */ /* */ import java.lang.reflect.Field; /* */ import org.springframework.objenesis.ObjenesisException; /* */ import sun.misc.Unsafe; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public final class UnsafeUtils /* */ { /* */ private static final Unsafe unsafe; /* */ /* */ static /* */ { /* */ try /* */ { /* 36 */ f = Unsafe.class.getDeclaredField("theUnsafe"); /* */ } catch (NoSuchFieldException e) { Field f; /* 38 */ throw new ObjenesisException(e); } /* */ Field f; /* 40 */ f.setAccessible(true); /* */ try { /* 42 */ unsafe = (Unsafe)f.get(null); /* */ } catch (IllegalAccessException e) { /* 44 */ throw new ObjenesisException(e); /* */ } /* */ } /* */ /* */ /* */ public static Unsafe getUnsafe() /* */ { /* 51 */ return unsafe; /* */ } /* */ } /* Location: C:\Users\ikatwal\Downloads\bullet-zone-server-2.0.jar!\BOOT-INF\lib\spring-core-4.3.14.RELEASE.jar!\org\springframework\objenesis\instantiato\\util\UnsafeUtils.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */
1,422
0.45218
0.434599
59
23.118645
27.976433
191
false
false
0
0
0
0
0
0
0.220339
false
false
10
f939ccc0dbb8fd016fab9b355740df8fa805ce9a
5,102,421,212,523
7cab5ad8b64003c7a45fa50d0c108e8ca8f12d25
/Item.java
86b6cc5b3ddcabe512880e5b1a964894f005e24f
[]
no_license
gelaxidiya/final-trpg-v3
https://github.com/gelaxidiya/final-trpg-v3
12d3b4eb23ed66b1d1287caadf4c7d8d8e6bbcb3
e6006d2b77268f5d85fa158b718c5a2c6313ee01
refs/heads/master
2020-06-03T21:43:53.828000
2019-06-13T10:38:05
2019-06-13T10:38:05
191,743,014
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
class Item { String name; String description; Entity target; Entity currentTarget; int damage; String changeStat; int amount; Item() { } Item(String name, String description, Entity target, String changeStat) { this.name = name; this.description = description; this.changeStat = changeStat; } Item(String name, String description, Entity target, String changeStat, int amount) { this.name = name; this.description = description; this.changeStat = changeStat; this.amount = amount; } void effect() { if(target instanceof Character) { switch(changeStat) { case "hp": target.hp += damage; if(target.hp > target.hpCap) { target.hp = target.hpCap; } break; case "mp": target.mp += damage; break; case "atk": target.atk += damage; break; case "def": target.def += damage; break; case "recover": if(target.ko == true) { target.ko = false; target.hp = target.hpCap; break; } } } } }
UTF-8
Java
1,214
java
Item.java
Java
[]
null
[]
class Item { String name; String description; Entity target; Entity currentTarget; int damage; String changeStat; int amount; Item() { } Item(String name, String description, Entity target, String changeStat) { this.name = name; this.description = description; this.changeStat = changeStat; } Item(String name, String description, Entity target, String changeStat, int amount) { this.name = name; this.description = description; this.changeStat = changeStat; this.amount = amount; } void effect() { if(target instanceof Character) { switch(changeStat) { case "hp": target.hp += damage; if(target.hp > target.hpCap) { target.hp = target.hpCap; } break; case "mp": target.mp += damage; break; case "atk": target.atk += damage; break; case "def": target.def += damage; break; case "recover": if(target.ko == true) { target.ko = false; target.hp = target.hpCap; break; } } } } }
1,214
0.519769
0.519769
51
21.843138
16.154125
87
false
false
0
0
0
0
0
0
0.745098
false
false
10
673e50f21205714ac86116bafb95e61044ef2f23
14,705,968,060,017
6c16dd95888d76320ab771d12334b118bb4e2ed7
/logging/src/main/java/com/raven/logging/repo/AuditLogRepository.java
638c6ef76aba5395cd13dbc26962d454921c7445
[]
no_license
paras16jul1991/orderCommonParent
https://github.com/paras16jul1991/orderCommonParent
26bc38bf4b6d7013ff7d37407a68f2bf4f8b60b4
98796c80933ff109af6f471aab9af1211837dcab
refs/heads/main
2023-04-03T20:15:00.488000
2021-04-26T19:30:13
2021-04-26T19:30:13
360,147,843
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.raven.logging.repo; import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.stereotype.Repository; import com.raven.order.model.Order; @Repository public interface AuditLogRepository extends MongoRepository<Order, String> { }
UTF-8
Java
279
java
AuditLogRepository.java
Java
[]
null
[]
package com.raven.logging.repo; import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.stereotype.Repository; import com.raven.order.model.Order; @Repository public interface AuditLogRepository extends MongoRepository<Order, String> { }
279
0.842294
0.842294
10
27
27.720028
76
false
false
0
0
0
0
0
0
0.5
false
false
10
99d32473bdb8e04b15bccc863f219cc5f3b2483e
4,690,104,321,778
c8ac2f8e00e12d080118a62c180244b61d80ab55
/Assignments/src/Assignment10_1.java
7ef4cb262fbb1b9705925218cf1b31928e8f6ec1
[ "MIT" ]
permissive
yashimself/Java
https://github.com/yashimself/Java
9e6c10f889276c13109140a8c1c4504e4f7630ac
30a5bbb13c30f4abfe219bed3bc3ba05fb321e3e
refs/heads/master
2022-10-30T11:10:25.231000
2020-06-20T10:33:02
2020-06-20T10:33:02
254,959,471
1
1
null
null
null
null
null
null
null
null
null
null
null
null
null
public class Assignment10_1 extends Thread { public void run() { System.out.print("Thread will be suspended for 500 milliseconds!"); try { sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("\nThread is running!"); } public static void main(String[] args) { Assignment10_1 obj=new Assignment10_1(); obj.start(); } }
UTF-8
Java
417
java
Assignment10_1.java
Java
[]
null
[]
public class Assignment10_1 extends Thread { public void run() { System.out.print("Thread will be suspended for 500 milliseconds!"); try { sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("\nThread is running!"); } public static void main(String[] args) { Assignment10_1 obj=new Assignment10_1(); obj.start(); } }
417
0.618705
0.582734
23
16.043478
19.13903
69
false
false
0
0
0
0
0
0
1.695652
false
false
10
101cb341da5a13ea8976bdb55cefafaca948790f
24,610,162,677,079
c8d4108d125db90d2e6e8ff8b06e019b7ea886c4
/taotao-manager/taotao-manager-service/src/main/java/com/taotao/service/impl/ItemServiceImpl.java
e69735ef599b4bb5d5d3ae9be0ef49df3212862f
[]
no_license
jziver/ssm_demo
https://github.com/jziver/ssm_demo
53760c47ecdeca8f8032022fc710d4290f1aac77
40625a1a1248ca303242f25c2514e4e69a13d057
refs/heads/master
2016-06-12T13:50:33.139000
2016-05-18T13:18:08
2016-05-18T13:18:08
59,024,280
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.taotao.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.taotao.common.EUDateResult; import com.taotao.mapper.TbItemMapper; import com.taotao.pojo.TbItem; import com.taotao.pojo.TbItemExample; import com.taotao.service.ItemService; @Service public class ItemServiceImpl implements ItemService { @Autowired private TbItemMapper itemMapper; @Override public EUDateResult getItemList(Integer pageNum, Integer pageSize) { TbItemExample example = new TbItemExample(); PageHelper.startPage(pageNum, pageSize); List<TbItem> list = itemMapper.selectByExample(example); PageInfo<TbItem> pageInfo = new PageInfo<>(list); EUDateResult result = new EUDateResult(); result.setRows(list); result.setTotal(pageInfo.getTotal()); return result; } }
UTF-8
Java
995
java
ItemServiceImpl.java
Java
[]
null
[]
package com.taotao.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.taotao.common.EUDateResult; import com.taotao.mapper.TbItemMapper; import com.taotao.pojo.TbItem; import com.taotao.pojo.TbItemExample; import com.taotao.service.ItemService; @Service public class ItemServiceImpl implements ItemService { @Autowired private TbItemMapper itemMapper; @Override public EUDateResult getItemList(Integer pageNum, Integer pageSize) { TbItemExample example = new TbItemExample(); PageHelper.startPage(pageNum, pageSize); List<TbItem> list = itemMapper.selectByExample(example); PageInfo<TbItem> pageInfo = new PageInfo<>(list); EUDateResult result = new EUDateResult(); result.setRows(list); result.setTotal(pageInfo.getTotal()); return result; } }
995
0.771859
0.771859
34
27.264706
20.855679
69
false
false
0
0
0
0
0
0
1.294118
false
false
10
8595fd81a8c072d313e77dfb18df3ce7fcc5c498
16,106,127,420,189
40f4fe2c817526e1990d05f43665bb4b92cd45d2
/app/src/main/java/com/example/tetris/env/TouchPad.java
77f24c829b77c61b0f856d688229863a52d6a783
[]
no_license
stjdans/tetris
https://github.com/stjdans/tetris
ba649aeb98ae65c76cda2ea7fd19e397d5b048af
478917898edc922d0e0a28fd7161010ace5e2f3b
refs/heads/master
2021-01-19T10:57:42.037000
2015-01-15T11:39:51
2015-01-15T11:39:51
29,001,235
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.example.tetris.env; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; public class TouchPad { public static final int NOTTHING = -1; public static final int LEFT = 0; public static final int RIGHT = 1; public static final int BOTTOM = 2; public static final int ROTATION = 3; private static final int TOUCHPAD_LENGTH = 4; Rect[] touchPad; Paint p[]; public TouchPad(int width, int height) { // TODO Auto-generated constructor stub p = new Paint[TOUCHPAD_LENGTH]; for (int i = 0; i < TOUCHPAD_LENGTH; i++) { p[i] = new Paint(); } p[0].setColor(Color.RED); p[0].setAlpha(30); p[1].setColor(Color.MAGENTA); p[1].setAlpha(30); p[2].setColor(Color.BLUE); p[2].setAlpha(30); p[3].setColor(Color.GREEN); p[3].setAlpha(30); int c_x = width / 4; int c_y = height / 5 * 4; int size_w = width / 5; int size_h = height / 6; touchPad = new Rect[TOUCHPAD_LENGTH]; touchPad[0] = new Rect(c_x - size_w - 15, c_y - size_h - 15, c_x - 15, c_y - 15); touchPad[1] = new Rect(c_x + 15, c_y - size_h - 15, c_x + size_w + 15, c_y - 15); touchPad[2] = new Rect(c_x - size_w / 2, c_y, c_x + size_w / 2, c_y + size_h); int r_x = width / 4 * 3; touchPad[3] = new Rect(r_x - size_w, c_y - size_h, r_x + size_w, c_y + size_h); } public void draw(Canvas can) { for (int i = 0; i < TOUCHPAD_LENGTH; i++) { can.drawRect(touchPad[i], p[i]); } // can.drawCircle(c_x, c_y, 5, p[0]); // can.drawCircle(r_x, c_y, 5, p[0]); } public void changeColor(int where) { if (where == NOTTHING) return; p[where].setAlpha(100); } public void clearRect() { for (int i = 0; i < TOUCHPAD_LENGTH; i++) { p[i].setAlpha(30); } } public int isClickPad(int x, int y) { for (int where = 0; where < TOUCHPAD_LENGTH; where++) { if (touchPad[where].contains(x, y)) return where; } return NOTTHING; } }
UTF-8
Java
1,958
java
TouchPad.java
Java
[]
null
[]
package com.example.tetris.env; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; public class TouchPad { public static final int NOTTHING = -1; public static final int LEFT = 0; public static final int RIGHT = 1; public static final int BOTTOM = 2; public static final int ROTATION = 3; private static final int TOUCHPAD_LENGTH = 4; Rect[] touchPad; Paint p[]; public TouchPad(int width, int height) { // TODO Auto-generated constructor stub p = new Paint[TOUCHPAD_LENGTH]; for (int i = 0; i < TOUCHPAD_LENGTH; i++) { p[i] = new Paint(); } p[0].setColor(Color.RED); p[0].setAlpha(30); p[1].setColor(Color.MAGENTA); p[1].setAlpha(30); p[2].setColor(Color.BLUE); p[2].setAlpha(30); p[3].setColor(Color.GREEN); p[3].setAlpha(30); int c_x = width / 4; int c_y = height / 5 * 4; int size_w = width / 5; int size_h = height / 6; touchPad = new Rect[TOUCHPAD_LENGTH]; touchPad[0] = new Rect(c_x - size_w - 15, c_y - size_h - 15, c_x - 15, c_y - 15); touchPad[1] = new Rect(c_x + 15, c_y - size_h - 15, c_x + size_w + 15, c_y - 15); touchPad[2] = new Rect(c_x - size_w / 2, c_y, c_x + size_w / 2, c_y + size_h); int r_x = width / 4 * 3; touchPad[3] = new Rect(r_x - size_w, c_y - size_h, r_x + size_w, c_y + size_h); } public void draw(Canvas can) { for (int i = 0; i < TOUCHPAD_LENGTH; i++) { can.drawRect(touchPad[i], p[i]); } // can.drawCircle(c_x, c_y, 5, p[0]); // can.drawCircle(r_x, c_y, 5, p[0]); } public void changeColor(int where) { if (where == NOTTHING) return; p[where].setAlpha(100); } public void clearRect() { for (int i = 0; i < TOUCHPAD_LENGTH; i++) { p[i].setAlpha(30); } } public int isClickPad(int x, int y) { for (int where = 0; where < TOUCHPAD_LENGTH; where++) { if (touchPad[where].contains(x, y)) return where; } return NOTTHING; } }
1,958
0.609295
0.576609
79
23.784811
18.431997
72
true
false
0
0
0
0
0
0
2.405063
false
false
10
a07a90d8d1ecef6221d527aa892534558cd810c7
30,348,238,916,306
70beac17427eed8e27c83184f2bf22efafb9d98d
/src/uebung2/Aufgabe2.java
0baa7b0d64f4040631beccafe32205510aa8232d
[]
no_license
chrisharsch/ADS
https://github.com/chrisharsch/ADS
2d857d262a2713d4c5d37493abcddd79094c95c9
e54fa183e12a22f233090789cfe034bc457f4f58
refs/heads/master
2021-05-28T04:02:05.711000
2013-11-26T20:56:49
2013-11-26T20:56:49
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package uebung2; import java.util.Stack; public class Aufgabe2 { public static void main(String[] args) { System.out.println(rek(10000)); } public static long rek(long n) { if (n > 0) { System.out.println(n); return n + rek(n - 1); } else if (n < 0) { System.out.println(n); return n + rek(n + 1); }else{ System.out.println(n); return n; } } }
UTF-8
Java
389
java
Aufgabe2.java
Java
[]
null
[]
package uebung2; import java.util.Stack; public class Aufgabe2 { public static void main(String[] args) { System.out.println(rek(10000)); } public static long rek(long n) { if (n > 0) { System.out.println(n); return n + rek(n - 1); } else if (n < 0) { System.out.println(n); return n + rek(n + 1); }else{ System.out.println(n); return n; } } }
389
0.586118
0.557841
27
13.407408
12.646941
41
false
false
0
0
0
0
0
0
1.703704
false
false
10
4c30efbf58474a30d04ce536a6fea4025280cb4e
12,902,081,769,141
ac7d037d391b52f59b02c7134e7712dbbe9b4e93
/SharePic/src/com/hts/SharePic/UpdateCheckService.java
840773c732aef38c2acab0cfb472a074e07e50eb
[]
no_license
Nishadk/sharepic
https://github.com/Nishadk/sharepic
741c946a68ef8b5ad8ac67cd749dc22228b079e9
e62ca15d0151ac5246cd4aa636254d8b2e0eb677
refs/heads/master
2021-01-13T02:07:05.850000
2013-06-28T03:43:10
2013-06-28T03:43:10
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.hts.SharePic; import java.io.IOException; import java.net.MalformedURLException; import java.sql.Date; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Map; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.annotation.SuppressLint; import android.app.IntentService; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.IBinder; import android.util.Log; public class UpdateCheckService extends IntentService { private String mAccessToken = "457548647601301|kWtjZuefJFr9zFETWAZepe7EA8k"; private Facebook facebook = new Facebook(getResources().getString(R.string.APP_ID)); ArrayList<String> strMArListImageurlslast=new ArrayList<String>(); ArrayList<String> strMarListCommentsdatelast=new ArrayList<String>(); ArrayList<String> strMArListDBData=new ArrayList<String>(); ArrayList<String> strMArListPrefImageurls=new ArrayList<String>(); ArrayList<String> strMArListPrefCommentsdate=new ArrayList<String>(); ArrayList<String> strMArListPrefComments=new ArrayList<String>(); ArrayList<String> strMArListPrefDate=new ArrayList<String>(); ArrayList<String> strMArListImageurls=new ArrayList<String>(); ArrayList<String> strMarListCommentsdate=new ArrayList<String>(); ArrayList<String> strMArlistComments=new ArrayList<String>(); ArrayList<String> strMArlistDate=new ArrayList<String>(); ArrayList<String> strMArlstUpdatedpost=new ArrayList<String>(); String[] strPic; String[] strCmd; String[] strDte; String strUrl=""; String strMessage = null; String strDate = null; static String strSrc = null; public String TAG_CMNT = "comment"; public String TAG_PIC = "pic"; Database objdb; public UpdateCheckService() { super("UpdateCheckService"); } @Override protected void onHandleIntent(Intent intent) { Log.i(SharePicMain.TAG,"UpdateCheckService : onHandleIntent()"); strMArListImageurls.clear(); strMarListCommentsdate.clear(); strMArlistComments.clear(); strMArlistDate.clear(); strMArlstUpdatedpost.clear(); strMArListPrefImageurls.clear(); strMArListPrefDate.clear(); strMArListPrefCommentsdate.clear(); strMArListPrefComments.clear(); UpdateCheckService.this.getCommunityInformation(); UpdateCheckService.this.IteratingToprefernceDB(); } public String getAccessToken() { return mAccessToken; } private void IteratingToprefernceDB() { Log.i(SharePicMain.TAG,"UpdateCheckService : IteratingToprefernceDB()"); strMArListPrefDate.clear(); strMArListPrefComments.clear(); strMArListPrefImageurls.clear(); String strPreferenceprevalue=""; String strSharedvalue=""; SharedPreferences msharedpreference=getSharedPreferences("Mpref", MODE_PRIVATE); if(msharedpreference.contains("post1")) { strSharedvalue=msharedpreference.getString("post1",""); } Log.i(SharePicMain.TAG,"UpdateCheckService : sharedpost="+strSharedvalue); if(strSharedvalue.equals(strPreferenceprevalue)) { UpdateCheckService.this.clearpreference(); Log.i(SharePicMain.TAG,"UpdateCheckService : ITeratinginsideifloop"); for(int inI=1;inI<=strMArlistDate.size();inI++) { String strValuepost=""; strValuepost=strMArlistDate.get(inI-1).toString()+"nichu"+strMArlistComments.get(inI-1).toString() +"nichu"+strMArListImageurls.get(inI-1); String strKeypost=""; strKeypost="post"+(inI); UpdateCheckService.this.savepreference(strKeypost,strValuepost); String strDate=""; String strComment=""; String strImage=""; strDate=strMArlistDate.get(inI-1).toString(); strComment=strMArlistComments.get(inI-1).toString(); strImage=strMArListImageurls.get(inI-1).toString(); objdb=new Database(getApplicationContext()); objdb.openTowrite(); objdb.insert(strDate, strComment, strImage); objdb.close(); } } else if (!strSharedvalue.equals(strPreferenceprevalue)) { for(int inR=1;inR<=strMArlistDate.size();inR++) { int inEvaluate=0; int inPreferencesize=0; String strValuepost=""; strValuepost=strMArlistDate.get(inR-1).toString()+"nichu"+strMArlistComments.get(inR-1).toString() +"nichu"+strMArListImageurls.get(inR-1); for(Map.Entry<String, ?>entry:msharedpreference.getAll().entrySet()) { inPreferencesize++; String strPreferValue=""; strPreferValue=entry.getValue().toString(); if(strPreferValue!="") { if(!strPreferValue.equals(strValuepost)) { inEvaluate++; } } } if(inPreferencesize==inEvaluate) { //insert strValuepost to db and new araylist String strDate=""; String strComment=""; String strImage=""; strDate=strMArlistDate.get(inR-1).toString(); strComment=strMArlistComments.get(inR-1).toString(); strImage=strMArListImageurls.get(inR-1).toString(); objdb=new Database(getApplicationContext()); objdb.openTowrite(); objdb.insert(strDate,strComment,strImage); objdb.close(); strMArListPrefDate.add(strDate); strMArListPrefComments.add(strComment); strMArListPrefImageurls.add(strImage); } } if(!strMArListPrefDate.isEmpty()) { UpdateCheckService.this.clearpreference(); for(int inI=1;inI<=strMArListPrefDate.size();inI++) { String strValuepost=""; strValuepost=strMArListPrefDate.get(inI-1).toString()+"nichu"+strMArListPrefComments.get(inI-1).toString() +"nichu"+strMArListPrefImageurls.get(inI-1); String strKeypost=""; strKeypost="post"+(inI); UpdateCheckService.this.savepreference(strKeypost,strValuepost); } } } } @Override public void onDestroy() { super.onDestroy(); } @SuppressLint("SimpleDateFormat") public void getCommunityInformation() { JSONArray jArr = null; JSONArray jArr2 = null; String jsonuser = null; String fql = "SELECT updated_time, message, attachment FROM stream WHERE source_id =228398190627075"; Bundle parameters = new Bundle(); parameters.putString("format", "json"); parameters.putString("query", fql); parameters.putString("method", "fql.query"); parameters.putString("access_token",getAccessToken()); JSONObject JOmessage=null; JSONObject JOmessage2=null; try { jsonuser = "{\"data\":" + facebook.request(parameters) + "}"; JSONObject JObj = new JSONObject(jsonuser); jArr = JObj.getJSONArray("data"); strPic = new String[jArr.length()]; strCmd = new String[jArr.length()]; strDte = new String[jArr.length()]; for(int inI =0 ; inI<jArr.length(); inI++) { System.out.println(""+inI); JOmessage = jArr.getJSONObject(inI); strMessage = JOmessage.getString("message"); strDate = JOmessage.getString("updated_time"); long lngTimeStamp = Long.valueOf(strDate); Date dteGetDate = new Date(lngTimeStamp * 1000L); SimpleDateFormat sdfTimeFormatter = new SimpleDateFormat("dd-MM-yyyy hh:mm aa"); String strGetTime = sdfTimeFormatter.format(dteGetDate); Log.i(SharePicMain.TAG,"UpdateCheckService : DATE="+strGetTime); JSONObject JOattachment = JOmessage.getJSONObject("attachment"); if(JOattachment.getJSONArray("media") != null) { jArr2 = JOattachment.getJSONArray("media"); JOmessage2 = jArr2.getJSONObject(0); strSrc = JOmessage2.getString("src"); } strCmd[inI] = ("\t"+strMessage); strDte[inI] = ("\n\tDate :"+strGetTime+"\n"); strPic[inI]=strSrc; strMArListImageurls.add(strPic[inI]); strMArlistComments.add(strCmd[inI]); strMArlistDate.add(strDte[inI]); strMarListCommentsdate.add(strCmd[inI]+""+strDte[inI]); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } } private void clearpreference() { SharedPreferences msharedpreference=getSharedPreferences("Mpref", MODE_PRIVATE); SharedPreferences.Editor editor=msharedpreference.edit(); editor.clear(); editor.commit(); } private void savepreference(String key,String value) { SharedPreferences msharedpreference=getSharedPreferences("Mpref", MODE_PRIVATE); SharedPreferences.Editor editor=msharedpreference.edit(); editor.putString(key, value); editor.commit(); } @Override public IBinder onBind(Intent intent) { return null; } }
UTF-8
Java
8,699
java
UpdateCheckService.java
Java
[ { "context": "IntentService\r\n{\r\n\tprivate String mAccessToken = \"457548647601301|kWtjZuefJFr9zFETWAZepe7EA8k\";\r\n\tprivate Facebook facebook = new Facebook(getR", "end": 665, "score": 0.9758173227310181, "start": 622, "tag": "KEY", "value": "457548647601301|kWtjZuefJFr9zFETWAZepe7EA8k" } ]
null
[]
package com.hts.SharePic; import java.io.IOException; import java.net.MalformedURLException; import java.sql.Date; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Map; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.annotation.SuppressLint; import android.app.IntentService; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.IBinder; import android.util.Log; public class UpdateCheckService extends IntentService { private String mAccessToken = "<KEY>"; private Facebook facebook = new Facebook(getResources().getString(R.string.APP_ID)); ArrayList<String> strMArListImageurlslast=new ArrayList<String>(); ArrayList<String> strMarListCommentsdatelast=new ArrayList<String>(); ArrayList<String> strMArListDBData=new ArrayList<String>(); ArrayList<String> strMArListPrefImageurls=new ArrayList<String>(); ArrayList<String> strMArListPrefCommentsdate=new ArrayList<String>(); ArrayList<String> strMArListPrefComments=new ArrayList<String>(); ArrayList<String> strMArListPrefDate=new ArrayList<String>(); ArrayList<String> strMArListImageurls=new ArrayList<String>(); ArrayList<String> strMarListCommentsdate=new ArrayList<String>(); ArrayList<String> strMArlistComments=new ArrayList<String>(); ArrayList<String> strMArlistDate=new ArrayList<String>(); ArrayList<String> strMArlstUpdatedpost=new ArrayList<String>(); String[] strPic; String[] strCmd; String[] strDte; String strUrl=""; String strMessage = null; String strDate = null; static String strSrc = null; public String TAG_CMNT = "comment"; public String TAG_PIC = "pic"; Database objdb; public UpdateCheckService() { super("UpdateCheckService"); } @Override protected void onHandleIntent(Intent intent) { Log.i(SharePicMain.TAG,"UpdateCheckService : onHandleIntent()"); strMArListImageurls.clear(); strMarListCommentsdate.clear(); strMArlistComments.clear(); strMArlistDate.clear(); strMArlstUpdatedpost.clear(); strMArListPrefImageurls.clear(); strMArListPrefDate.clear(); strMArListPrefCommentsdate.clear(); strMArListPrefComments.clear(); UpdateCheckService.this.getCommunityInformation(); UpdateCheckService.this.IteratingToprefernceDB(); } public String getAccessToken() { return mAccessToken; } private void IteratingToprefernceDB() { Log.i(SharePicMain.TAG,"UpdateCheckService : IteratingToprefernceDB()"); strMArListPrefDate.clear(); strMArListPrefComments.clear(); strMArListPrefImageurls.clear(); String strPreferenceprevalue=""; String strSharedvalue=""; SharedPreferences msharedpreference=getSharedPreferences("Mpref", MODE_PRIVATE); if(msharedpreference.contains("post1")) { strSharedvalue=msharedpreference.getString("post1",""); } Log.i(SharePicMain.TAG,"UpdateCheckService : sharedpost="+strSharedvalue); if(strSharedvalue.equals(strPreferenceprevalue)) { UpdateCheckService.this.clearpreference(); Log.i(SharePicMain.TAG,"UpdateCheckService : ITeratinginsideifloop"); for(int inI=1;inI<=strMArlistDate.size();inI++) { String strValuepost=""; strValuepost=strMArlistDate.get(inI-1).toString()+"nichu"+strMArlistComments.get(inI-1).toString() +"nichu"+strMArListImageurls.get(inI-1); String strKeypost=""; strKeypost="post"+(inI); UpdateCheckService.this.savepreference(strKeypost,strValuepost); String strDate=""; String strComment=""; String strImage=""; strDate=strMArlistDate.get(inI-1).toString(); strComment=strMArlistComments.get(inI-1).toString(); strImage=strMArListImageurls.get(inI-1).toString(); objdb=new Database(getApplicationContext()); objdb.openTowrite(); objdb.insert(strDate, strComment, strImage); objdb.close(); } } else if (!strSharedvalue.equals(strPreferenceprevalue)) { for(int inR=1;inR<=strMArlistDate.size();inR++) { int inEvaluate=0; int inPreferencesize=0; String strValuepost=""; strValuepost=strMArlistDate.get(inR-1).toString()+"nichu"+strMArlistComments.get(inR-1).toString() +"nichu"+strMArListImageurls.get(inR-1); for(Map.Entry<String, ?>entry:msharedpreference.getAll().entrySet()) { inPreferencesize++; String strPreferValue=""; strPreferValue=entry.getValue().toString(); if(strPreferValue!="") { if(!strPreferValue.equals(strValuepost)) { inEvaluate++; } } } if(inPreferencesize==inEvaluate) { //insert strValuepost to db and new araylist String strDate=""; String strComment=""; String strImage=""; strDate=strMArlistDate.get(inR-1).toString(); strComment=strMArlistComments.get(inR-1).toString(); strImage=strMArListImageurls.get(inR-1).toString(); objdb=new Database(getApplicationContext()); objdb.openTowrite(); objdb.insert(strDate,strComment,strImage); objdb.close(); strMArListPrefDate.add(strDate); strMArListPrefComments.add(strComment); strMArListPrefImageurls.add(strImage); } } if(!strMArListPrefDate.isEmpty()) { UpdateCheckService.this.clearpreference(); for(int inI=1;inI<=strMArListPrefDate.size();inI++) { String strValuepost=""; strValuepost=strMArListPrefDate.get(inI-1).toString()+"nichu"+strMArListPrefComments.get(inI-1).toString() +"nichu"+strMArListPrefImageurls.get(inI-1); String strKeypost=""; strKeypost="post"+(inI); UpdateCheckService.this.savepreference(strKeypost,strValuepost); } } } } @Override public void onDestroy() { super.onDestroy(); } @SuppressLint("SimpleDateFormat") public void getCommunityInformation() { JSONArray jArr = null; JSONArray jArr2 = null; String jsonuser = null; String fql = "SELECT updated_time, message, attachment FROM stream WHERE source_id =228398190627075"; Bundle parameters = new Bundle(); parameters.putString("format", "json"); parameters.putString("query", fql); parameters.putString("method", "fql.query"); parameters.putString("access_token",getAccessToken()); JSONObject JOmessage=null; JSONObject JOmessage2=null; try { jsonuser = "{\"data\":" + facebook.request(parameters) + "}"; JSONObject JObj = new JSONObject(jsonuser); jArr = JObj.getJSONArray("data"); strPic = new String[jArr.length()]; strCmd = new String[jArr.length()]; strDte = new String[jArr.length()]; for(int inI =0 ; inI<jArr.length(); inI++) { System.out.println(""+inI); JOmessage = jArr.getJSONObject(inI); strMessage = JOmessage.getString("message"); strDate = JOmessage.getString("updated_time"); long lngTimeStamp = Long.valueOf(strDate); Date dteGetDate = new Date(lngTimeStamp * 1000L); SimpleDateFormat sdfTimeFormatter = new SimpleDateFormat("dd-MM-yyyy hh:mm aa"); String strGetTime = sdfTimeFormatter.format(dteGetDate); Log.i(SharePicMain.TAG,"UpdateCheckService : DATE="+strGetTime); JSONObject JOattachment = JOmessage.getJSONObject("attachment"); if(JOattachment.getJSONArray("media") != null) { jArr2 = JOattachment.getJSONArray("media"); JOmessage2 = jArr2.getJSONObject(0); strSrc = JOmessage2.getString("src"); } strCmd[inI] = ("\t"+strMessage); strDte[inI] = ("\n\tDate :"+strGetTime+"\n"); strPic[inI]=strSrc; strMArListImageurls.add(strPic[inI]); strMArlistComments.add(strCmd[inI]); strMArlistDate.add(strDte[inI]); strMarListCommentsdate.add(strCmd[inI]+""+strDte[inI]); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } } private void clearpreference() { SharedPreferences msharedpreference=getSharedPreferences("Mpref", MODE_PRIVATE); SharedPreferences.Editor editor=msharedpreference.edit(); editor.clear(); editor.commit(); } private void savepreference(String key,String value) { SharedPreferences msharedpreference=getSharedPreferences("Mpref", MODE_PRIVATE); SharedPreferences.Editor editor=msharedpreference.edit(); editor.putString(key, value); editor.commit(); } @Override public IBinder onBind(Intent intent) { return null; } }
8,661
0.699276
0.691574
256
31.988281
23.646894
111
false
false
0
0
0
0
0
0
3.472656
false
false
10
8950d46806c0857c2cdfb77f20af8a1342b9bdd4
23,373,212,065,125
0db353541034a03f555e5c88e3d2237469974146
/src/main/java/com/github/djbamba/service/weather/api/response/Clouds.java
47184041c095ea534750fef4ec9ea7741b9375d7
[]
no_license
djbamba/weather-service
https://github.com/djbamba/weather-service
b3015f8b38389ce9040d4e5635681696f544710a
9741bdc63498d5a2903a226b334c90d24603ee5b
refs/heads/main
2023-08-27T20:31:04.906000
2021-11-08T22:02:59
2021-11-08T22:02:59
408,613,999
0
0
null
false
2021-11-08T22:02:59
2021-09-20T22:07:54
2021-10-26T23:52:33
2021-11-08T22:02:59
4,226
0
0
0
Java
false
false
package com.github.djbamba.service.weather.api.response; import com.fasterxml.jackson.annotation.JsonAlias; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @Getter @Setter @NoArgsConstructor public class Clouds { //percentage @JsonAlias("all") private Double cloudiness; }
UTF-8
Java
308
java
Clouds.java
Java
[ { "context": "package com.github.djbamba.service.weather.api.response;\n\nimport com.fasterx", "end": 26, "score": 0.8419522047042847, "start": 19, "tag": "USERNAME", "value": "djbamba" } ]
null
[]
package com.github.djbamba.service.weather.api.response; import com.fasterxml.jackson.annotation.JsonAlias; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @Getter @Setter @NoArgsConstructor public class Clouds { //percentage @JsonAlias("all") private Double cloudiness; }
308
0.805195
0.805195
15
19.533333
16.272131
56
false
false
0
0
0
0
0
0
0.4
false
false
10
c1691d6f4af0dbaa657487ec20bd78086566c789
2,929,167,732,490
1c970ccf67349e2d6684df626cbbd1c166f9365a
/src/vm/game/player/Player.java
648b427db089db44ebd063342c77d6b837a03aa5
[]
no_license
victorparmar/vMoney
https://github.com/victorparmar/vMoney
13f8e45a7f26e3f5a8f7cc07c78eb5defe6550cb
5810a1bd085b79d3c687c05e6c0d686a3cc23999
refs/heads/master
2015-08-06T03:04:34
2012-04-18T15:04:24
2012-04-18T15:04:24
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package vm.game.player; public abstract class Player { private final String name; private long cash; private int location; protected Player(String name) { this.name = name; this.cash = 500; } public String getName() { return name; } public long getCash() { return cash; } public void setCash(long cash) { this.cash = cash; } public int getLocation() { return location; } public void setLocation(int location) { this.location = location; } } // end class
UTF-8
Java
675
java
Player.java
Java
[]
null
[]
package vm.game.player; public abstract class Player { private final String name; private long cash; private int location; protected Player(String name) { this.name = name; this.cash = 500; } public String getName() { return name; } public long getCash() { return cash; } public void setCash(long cash) { this.cash = cash; } public int getLocation() { return location; } public void setLocation(int location) { this.location = location; } } // end class
675
0.494815
0.49037
41
14.463414
11.983928
41
false
false
0
0
0
0
0
0
0.268293
false
false
10
efc8fa684df2a2fe99cac34978856ddc0726fd5e
10,376,641,029,208
f5e954d9efb514721cafb8e1997c926821dce74a
/src/niuke/jianzhioffer/ReplaceKongge.java
1dc10ff7afa42fefa990ba58c6f620ad5f4a1a7c
[]
no_license
fjf3997/algorithm
https://github.com/fjf3997/algorithm
a18b91610b6914b3614422088d34b7a5b13d4787
125752f4d9f5dd2971438521c2feb39f12353ec1
refs/heads/master
2020-07-07T08:55:34.535000
2019-08-20T06:51:38
2019-08-20T06:51:38
203,309,721
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package niuke.jianzhioffer; /** * 题目描述 * 请实现一个函数,将一个字符串中的每个空格替换成“%20”。 * 例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。 */ public class ReplaceKongge { public static void main(String[] args) { String str = "we are happy"; // System.out.println(str.indexOf(" ",3)); String newStr = replaceSpace(new StringBuffer(" hello ")); System.out.println(newStr); } /** * 1.调用自带函数 str.toString().replace(" ","%20"); * 2.用新的数组存 * public String replaceSpace(StringBuffer str) { * StringBuilder sb = new StringBuilder(); * for(int i=0;i<str.length();i++){ * char c = str.charAt(i); * if(c == ' '){ * sb.append("%20"); * }else{ * sb.append(c); * } * } * return sb.toString(); * } * @param str * @return */ public static String replaceSpace(StringBuffer str) { return str.toString().replace(" ","%20"); } }
UTF-8
Java
1,189
java
ReplaceKongge.java
Java
[]
null
[]
package niuke.jianzhioffer; /** * 题目描述 * 请实现一个函数,将一个字符串中的每个空格替换成“%20”。 * 例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。 */ public class ReplaceKongge { public static void main(String[] args) { String str = "we are happy"; // System.out.println(str.indexOf(" ",3)); String newStr = replaceSpace(new StringBuffer(" hello ")); System.out.println(newStr); } /** * 1.调用自带函数 str.toString().replace(" ","%20"); * 2.用新的数组存 * public String replaceSpace(StringBuffer str) { * StringBuilder sb = new StringBuilder(); * for(int i=0;i<str.length();i++){ * char c = str.charAt(i); * if(c == ' '){ * sb.append("%20"); * }else{ * sb.append(c); * } * } * return sb.toString(); * } * @param str * @return */ public static String replaceSpace(StringBuffer str) { return str.toString().replace(" ","%20"); } }
1,189
0.494826
0.479774
38
26.973684
19.554897
66
false
false
0
0
0
0
0
0
0.447368
false
false
10
2ff9713ea8c77927ba49c38878e4fb1b74151167
7,464,653,189,685
374672aeb7ba56ce5047ca2bc9c1381a00512cce
/finans/src/br/com/prosoft/finans/dao/BandeiraCartaoDao.java
66ac6114cb35e75011886d7918d8d227e76170cd
[]
no_license
acaldas12/prosoft
https://github.com/acaldas12/prosoft
3285199d6f20b138e75d9c833e6b018694c1d551
2d55e16c87f38dd60234d95ee670a85ebb98bc1e
refs/heads/master
2019-04-03T19:04:19.932000
2016-10-03T18:49:37
2016-10-03T18:53:26
59,117,940
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package br.com.prosoft.finans.dao; import java.util.ArrayList; import br.com.caelum.vraptor.ioc.Component; import br.com.caelum.vraptor.ioc.RequestScoped; import br.com.prosoft.finans.bean.BandeiraCartao; @Component @RequestScoped public class BandeiraCartaoDao { private ArrayList<BandeiraCartao> list; public BandeiraCartaoDao() { list = new ArrayList<BandeiraCartao>(); list.add(new BandeiraCartao("VISA", "VISA")); list.add(new BandeiraCartao("MACA", "MASTER CARD")); list.add(new BandeiraCartao("ELO", "ELO")); list.add(new BandeiraCartao("AMEX", "AMERICAN EXPRESS")); } public ArrayList<BandeiraCartao> list(){ return this.list; } }
UTF-8
Java
671
java
BandeiraCartaoDao.java
Java
[]
null
[]
package br.com.prosoft.finans.dao; import java.util.ArrayList; import br.com.caelum.vraptor.ioc.Component; import br.com.caelum.vraptor.ioc.RequestScoped; import br.com.prosoft.finans.bean.BandeiraCartao; @Component @RequestScoped public class BandeiraCartaoDao { private ArrayList<BandeiraCartao> list; public BandeiraCartaoDao() { list = new ArrayList<BandeiraCartao>(); list.add(new BandeiraCartao("VISA", "VISA")); list.add(new BandeiraCartao("MACA", "MASTER CARD")); list.add(new BandeiraCartao("ELO", "ELO")); list.add(new BandeiraCartao("AMEX", "AMERICAN EXPRESS")); } public ArrayList<BandeiraCartao> list(){ return this.list; } }
671
0.739195
0.739195
29
22.137932
20.563986
59
false
false
0
0
0
0
0
0
1.344828
false
false
10
44ba7995ef47f65bc8ab2f9f499c133f092e12ba
13,993,003,479,779
de362689457e5d1aa27522c83987f87b8c13040b
/src/ru/job4j/StudentInfo.java
f6ea0c0e17cc3533669383e458ace24d062be88f
[]
no_license
morpheus322/job4j_elementary
https://github.com/morpheus322/job4j_elementary
2ed29c4a67b7629b8a02e6bf0c150b457f1cead7
646ba7802eea36071dd9d6299a7aedc2ade08990
refs/heads/master
2023-03-19T07:52:07.761000
2021-03-12T09:33:58
2021-03-12T09:33:58
292,644,711
0
0
null
true
2020-09-03T18:06:58
2020-09-03T18:06:58
2020-05-26T09:05:22
2020-07-10T01:17:55
545
0
0
0
null
false
false
package ru.job4j; public class StudentInfo { public static void main(String[] args) { System.out.println("Aleksandr Kremer"); System.out.println("12.02.1994"); } }
UTF-8
Java
195
java
StudentInfo.java
Java
[ { "context": "ain(String[] args) {\n System.out.println(\"Aleksandr Kremer\");\n System.out.println(\"12.02.1994\");\n ", "end": 138, "score": 0.9998674392700195, "start": 122, "tag": "NAME", "value": "Aleksandr Kremer" } ]
null
[]
package ru.job4j; public class StudentInfo { public static void main(String[] args) { System.out.println("<NAME>"); System.out.println("12.02.1994"); } }
185
0.620513
0.574359
8
23.375
18.640932
48
false
false
0
0
0
0
0
0
0.375
false
false
10
a6bb4bb0795fe7f14684679b0845382e5a1eda94
25,907,242,760,693
7966b5a9b2b49473a73ec67ab5939f567594720c
/GestiondeProjet2/src/main/java/com/fst/demo/models/Projet.java
81f3339ca40556ede5d908be8534f785255e4fa8
[]
no_license
oussamaayari/pfa-backend
https://github.com/oussamaayari/pfa-backend
8df74e794dce67519526ec9d11b0ee9ca8381795
0b0448d9dd8f1021e75445ed07ac46836fc6f580
refs/heads/master
2022-07-10T14:55:50.700000
2020-02-18T10:06:00
2020-02-18T10:06:00
241,327,365
0
0
null
false
2022-06-21T02:49:17
2020-02-18T09:59:00
2020-02-18T10:38:33
2022-06-21T02:49:13
78
0
0
1
Java
false
false
package com.fst.demo.models; import java.io.Serializable; import java.util.Date; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.OneToMany; import javax.persistence.Table; @Entity @Table(name="projet") public class Projet implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private long id_entr; private String type_entr; private String lieu_entr; // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date date_entr; // private String description; private String nom_projet; private Date date_fin; private String techno; public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getNom_projet() { return nom_projet; } public void setNom_projet(String nom_projet) { this.nom_projet = nom_projet; } public Date getDate_fin() { return date_fin; } public void setDate_fin(Date date_fin) { this.date_fin = date_fin; } //Cardinality with candidate @OneToMany(mappedBy="AppUser" , cascade=CascadeType.ALL) private List<AppUser> AppUsers; //Cardinality with taches @ManyToMany(cascade=CascadeType.ALL) @JoinTable(name = "projet_tache", joinColumns = @JoinColumn(name="projet_id", referencedColumnName = "id_entr"), inverseJoinColumns = @JoinColumn(name = "tache_id", referencedColumnName = "id_ques")) private List<Tache> taches; public Projet() { super(); } public Projet(long id_entr,String type_entr,String lieu_entr, Date date_entr) { this.id_entr =id_entr; this.type_entr=type_entr; this.lieu_entr=lieu_entr; this.date_entr=date_entr; } public long getId() { return id_entr; } public void setId(long id) { this.id_entr = id; } public String getType() { return type_entr; } public void setType(String type) { this.type_entr = type; } public String getLieu() { return lieu_entr; } public void setLieu(String lieu) { this.lieu_entr = lieu; } public Date getDate() { return date_entr; } public static long getSerialversionuid() { return serialVersionUID; } public void setDate(Date date) { this.date_entr = date; } public List<AppUser> getAppUsers() { return AppUsers; } public void setAppUsers(List<AppUser> appUsers) { AppUsers = appUsers; } public List<Tache> getTaches() { return taches; } public void setTaches(List<Tache> taches) { this.taches = taches; } public String getTechno() { return techno; } public void setTechno(String techno) { this.techno = techno; } }
UTF-8
Java
2,943
java
Projet.java
Java
[]
null
[]
package com.fst.demo.models; import java.io.Serializable; import java.util.Date; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.OneToMany; import javax.persistence.Table; @Entity @Table(name="projet") public class Projet implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private long id_entr; private String type_entr; private String lieu_entr; // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date date_entr; // private String description; private String nom_projet; private Date date_fin; private String techno; public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getNom_projet() { return nom_projet; } public void setNom_projet(String nom_projet) { this.nom_projet = nom_projet; } public Date getDate_fin() { return date_fin; } public void setDate_fin(Date date_fin) { this.date_fin = date_fin; } //Cardinality with candidate @OneToMany(mappedBy="AppUser" , cascade=CascadeType.ALL) private List<AppUser> AppUsers; //Cardinality with taches @ManyToMany(cascade=CascadeType.ALL) @JoinTable(name = "projet_tache", joinColumns = @JoinColumn(name="projet_id", referencedColumnName = "id_entr"), inverseJoinColumns = @JoinColumn(name = "tache_id", referencedColumnName = "id_ques")) private List<Tache> taches; public Projet() { super(); } public Projet(long id_entr,String type_entr,String lieu_entr, Date date_entr) { this.id_entr =id_entr; this.type_entr=type_entr; this.lieu_entr=lieu_entr; this.date_entr=date_entr; } public long getId() { return id_entr; } public void setId(long id) { this.id_entr = id; } public String getType() { return type_entr; } public void setType(String type) { this.type_entr = type; } public String getLieu() { return lieu_entr; } public void setLieu(String lieu) { this.lieu_entr = lieu; } public Date getDate() { return date_entr; } public static long getSerialversionuid() { return serialVersionUID; } public void setDate(Date date) { this.date_entr = date; } public List<AppUser> getAppUsers() { return AppUsers; } public void setAppUsers(List<AppUser> appUsers) { AppUsers = appUsers; } public List<Tache> getTaches() { return taches; } public void setTaches(List<Tache> taches) { this.taches = taches; } public String getTechno() { return techno; } public void setTechno(String techno) { this.techno = techno; } }
2,943
0.712878
0.712538
166
16.728916
19.007101
116
false
false
0
0
0
0
0
0
1.198795
false
false
10
e7f4090f8898ac06a2b72e2edb6f52f51df75ee4
25,907,242,761,949
b587d157ec646f38358712029cf23c18b0b8ee0c
/netconnect/src/com/example/netconnect/CheckNetworkActivity.java
b189c93c7f7dd62f1bd28c7d5fc4c20e02bd9f24
[]
no_license
chautn/A
https://github.com/chautn/A
f828b647747b19e4a4a2b1213c0194cf47cba767
1796311428edd2b8a09b89b342b3be0e2022ca76
refs/heads/master
2021-01-17T08:00:39.993000
2016-07-25T10:59:58
2016-07-25T10:59:58
35,338,210
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.example.netconnect; import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.sip.SipSession.State; import android.os.Bundle; import android.widget.LinearLayout; import android.widget.TextView; public class CheckNetworkActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); TextView view_wifi = new TextView(this); view_wifi.setText("Wifi: " + checkWifi()); TextView view_mobile = new TextView(this); view_mobile.setText("Mobile: " + checkMobile()); layout.addView(view_wifi); layout.addView(view_mobile); setContentView(layout); } public String checkWifi() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return(netInfo.getState().toString()); } public String checkMobile() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); return(netInfo.getState().toString()); } }
UTF-8
Java
1,338
java
CheckNetworkActivity.java
Java
[]
null
[]
package com.example.netconnect; import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.sip.SipSession.State; import android.os.Bundle; import android.widget.LinearLayout; import android.widget.TextView; public class CheckNetworkActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); TextView view_wifi = new TextView(this); view_wifi.setText("Wifi: " + checkWifi()); TextView view_mobile = new TextView(this); view_mobile.setText("Mobile: " + checkMobile()); layout.addView(view_wifi); layout.addView(view_mobile); setContentView(layout); } public String checkWifi() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return(netInfo.getState().toString()); } public String checkMobile() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); return(netInfo.getState().toString()); } }
1,338
0.777279
0.777279
43
30.11628
24.93919
96
false
false
0
0
0
0
0
0
1.72093
false
false
10
e3b350661678bb19593db94a08a2116fcd596c95
31,928,786,910,988
66bdcbd3fb721f34e5de086b5ea245bbb5db3c2a
/src/wd_excercise/A22_WindowTitles.java
2d50b218aa755b27dcc41727b5e7887caa77977f
[]
no_license
vijaybabu07/may2020
https://github.com/vijaybabu07/may2020
2097a59ff29f454676b8620d3ed51cb5900f69ad
727339869977a862e1396ae6d592e17e3f9d2d8c
refs/heads/master
2022-07-11T06:17:24.059000
2020-05-13T06:14:12
2020-05-13T06:14:12
263,538,956
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package wd_excercise; import java.util.ArrayList; import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class A22_WindowTitles { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "E:\\Sel\\Jars\\chromedriver.exe"); WebDriver driver=new ChromeDriver(); driver.get("https://www.idbibank.in/index.asp"); driver.manage().window().maximize(); driver.findElement(By.xpath("//a[contains(@href,'twitter')]")).click(); ArrayList win_count=new ArrayList(driver.getWindowHandles()); System.out.println("No of windows opened :"+win_count.size()); String title; for(int i=0;i<win_count.size();i++) { title=driver.switchTo().window((String)win_count.get(i)).getTitle(); System.out.println("window "+(i+1)+" title: "+title); List links_count=driver.switchTo().window((String)win_count.get(i)).findElements(By.tagName("a")); System.out.println("No of links in window "+(i+1)+" is "+ links_count.size()); /*for(int j=0;j<links_count.size();j++) { links_count.get(j). }*/ driver.switchTo().window((String)win_count.get(i)).close(); System.out.println("window "+(i+1)+" is closed"); } } }
UTF-8
Java
1,294
java
A22_WindowTitles.java
Java
[]
null
[]
package wd_excercise; import java.util.ArrayList; import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class A22_WindowTitles { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "E:\\Sel\\Jars\\chromedriver.exe"); WebDriver driver=new ChromeDriver(); driver.get("https://www.idbibank.in/index.asp"); driver.manage().window().maximize(); driver.findElement(By.xpath("//a[contains(@href,'twitter')]")).click(); ArrayList win_count=new ArrayList(driver.getWindowHandles()); System.out.println("No of windows opened :"+win_count.size()); String title; for(int i=0;i<win_count.size();i++) { title=driver.switchTo().window((String)win_count.get(i)).getTitle(); System.out.println("window "+(i+1)+" title: "+title); List links_count=driver.switchTo().window((String)win_count.get(i)).findElements(By.tagName("a")); System.out.println("No of links in window "+(i+1)+" is "+ links_count.size()); /*for(int j=0;j<links_count.size();j++) { links_count.get(j). }*/ driver.switchTo().window((String)win_count.get(i)).close(); System.out.println("window "+(i+1)+" is closed"); } } }
1,294
0.669243
0.663833
35
34.971428
27.820328
101
false
false
0
0
0
0
0
0
2.314286
false
false
10
2fdca3e06f0747cf0efec86132216a2a3d49da12
23,450,521,483,734
f6511e582cc904af40879064b75ddddf8e5467b8
/Java/SeleniumExample/src/test/TestWikipedia.java
15e6c5db3652b0b73e454b8a511a566cb5d8d41e
[]
no_license
burnettk/origin
https://github.com/burnettk/origin
bbc73e166642182d941ed986b1868c7efdb1f48f
bb4e0067227937cf9d0e2595cc63d8527e4a950a
refs/heads/master
2020-12-24T15:41:10.131000
2016-02-29T21:24:51
2016-02-29T21:24:51
52,836,795
0
0
null
true
2016-03-01T01:01:38
2016-03-01T01:01:38
2016-02-09T19:19:33
2016-02-29T21:25:24
111,775
0
0
0
null
null
null
package test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class TestWikipedia { public static void main(String[] args) { // Open new driver WebDriver driver = new FirefoxDriver(); driver.get("http://www.wikipedia.org"); // Click on English link WebElement link; link = driver.findElement(By.linkText("English")); link.click(); // Wait 5 seconds wait(5); // Click on id searchInput element WebElement searchBox; searchBox = driver.findElement(By.id("searchInput")); searchBox.sendKeys("Software"); // Wait 5 seconds and then quit wait(5); driver.quit(); } static void wait(int seconds) { try { Thread.sleep(seconds * 1000); } catch (InterruptedException e) { e.printStackTrace(); } } }
UTF-8
Java
870
java
TestWikipedia.java
Java
[]
null
[]
package test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class TestWikipedia { public static void main(String[] args) { // Open new driver WebDriver driver = new FirefoxDriver(); driver.get("http://www.wikipedia.org"); // Click on English link WebElement link; link = driver.findElement(By.linkText("English")); link.click(); // Wait 5 seconds wait(5); // Click on id searchInput element WebElement searchBox; searchBox = driver.findElement(By.id("searchInput")); searchBox.sendKeys("Software"); // Wait 5 seconds and then quit wait(5); driver.quit(); } static void wait(int seconds) { try { Thread.sleep(seconds * 1000); } catch (InterruptedException e) { e.printStackTrace(); } } }
870
0.697701
0.688506
42
19.714285
16.839983
55
false
false
0
0
0
0
0
0
1.714286
false
false
10
d0c447382bc1789f60ce2884590dfb04e8860338
31,610,959,302,488
f95500409686a709e731003e3fa01c81ccfeb5d7
/java_progs/str2.java
b532cc4245641191f16fab2c9a2d0877ba9f6535
[]
no_license
devutsav/C-Programs
https://github.com/devutsav/C-Programs
685bc28fa880b8ee4c2123e074195ca95966a242
3f6cd434e681e7227d360ccddabcb03d4df1fe7e
refs/heads/master
2021-05-25T09:33:31.313000
2020-07-14T07:25:13
2020-07-14T07:25:13
68,452,951
0
0
null
false
2017-12-21T18:02:32
2016-09-17T13:14:01
2017-11-12T14:36:01
2017-12-21T18:02:27
47
0
0
1
C
false
null
import java.util.*; public class str2 { public static void main(String []args) { System.out.println("Enter the sentence"); Scanner in = new Scanner(System.in); String l=in.nextLine(); System.out.println("Enter the word"); String ll = in.next(); l = l+" "; String temp=""; String newstr = ""; for(int i=0;i<l.length();i++) { char x=l.charAt(i); temp = temp + x; /*if(x!=' ') { temp = temp + x; } */ // else //{ if(ll.equals(temp)) { //newstr = newstr; } else { newstr = newstr + temp; newstr = newstr + ""; } temp = ""; //} } System.out.println(newstr); } }
UTF-8
Java
842
java
str2.java
Java
[]
null
[]
import java.util.*; public class str2 { public static void main(String []args) { System.out.println("Enter the sentence"); Scanner in = new Scanner(System.in); String l=in.nextLine(); System.out.println("Enter the word"); String ll = in.next(); l = l+" "; String temp=""; String newstr = ""; for(int i=0;i<l.length();i++) { char x=l.charAt(i); temp = temp + x; /*if(x!=' ') { temp = temp + x; } */ // else //{ if(ll.equals(temp)) { //newstr = newstr; } else { newstr = newstr + temp; newstr = newstr + ""; } temp = ""; //} } System.out.println(newstr); } }
842
0.4038
0.401425
42
19.023809
13.495128
49
false
false
0
0
0
0
0
0
1.071429
false
false
10
2d124a9d0a96618797ad8215c04d4c034e77d2f7
13,271,448,953,613
012210570915dbe810f629badacf76515462ac7f
/src/test/java/VectorTest.java
896ca1ac145222872762b61a10bc277dd756bcd5
[]
no_license
labourel/point
https://github.com/labourel/point
5caba7806d5c9d9cf155093276f4800278e68892
7f23047d720e3fb9605664791e51fc4c797b64ef
refs/heads/master
2020-03-31T08:17:14.055000
2018-10-08T09:27:51
2018-10-08T09:27:51
152,052,562
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; /** * Created by Arnaud Labourel on 30/09/2018. */ public class VectorTest { @Test public void testVectorInt() { Vector vector = new Vector(123); assertEquals(vector.capacity(), 123); assertEquals(vector.size(), 0); } @Test public void testVector() { Vector vector = new Vector(); assertEquals(vector.capacity(), 10); assertEquals(vector.size(), 0); } @Test public void testEnsureCapacityCapacityDoubled() { Vector vector = new Vector(23); vector.ensureCapacity(24); assertThat(vector.capacity(), greaterThanOrEqualTo(23*2)); } @Test public void testEnsureCapacityCapacitySatisfied() { Vector vector = new Vector(23); vector.ensureCapacity(120); assertThat(vector.capacity(), greaterThanOrEqualTo(120)); } @Test public void testEnsureCapacityCapacityAlwaysIncreased() { Vector vector = new Vector(120); vector.ensureCapacity(10); assertEquals(vector.capacity(), 120); } @Test @Disabled public void testResize() { Vector vector = new Vector(); vector.resize(120); /* TODO */ fail("not yet implemented"); } @Test public void testResizeZeros() { Vector vector = new Vector(1); vector.add(2); vector.resize(0); vector.resize(1); assertThat(vector.get(0), equalTo(0)); } @Test @Disabled public void testResizeCapacityIncreased() { /* TODO */ fail("not yet implemented"); } @Test @Disabled public void testResizeCapacityAlwaysIncreased() { /* TODO */ fail("not yet implemented"); } @Test @Disabled public void testIsEmpty() { Vector vector = new Vector(); assertThat(vector.isEmpty(), equalTo(true)); vector.resize(12); /* TODO */ fail("not yet implemented"); } @Test public void testAdd() { Vector vector = new Vector(); vector.add(12); vector.add(13); vector.add(10); assertEquals(vector.size(), 3); assertEquals(vector.get(0),12); assertEquals(vector.get(1), 13); assertEquals(vector.get(2), 10); vector.resize(1); vector.add(2); assertEquals(vector.size(), 2); assertEquals(vector.get(1), 2); } @Test @Disabled public void testSet() { Vector vector = new Vector(); vector.add(12); vector.add(13); vector.add(10); vector.set(0, 2); vector.set(2, 4); vector.set(3, 123); /* TODO */ fail("not yet implemented"); } @Test @Disabled public void testGet() { Vector vector = new Vector(); vector.add(12); vector.add(13); /* TODO : tester également le fait d'être en dehors des bornes. */ fail("not yet implemented"); } }
UTF-8
Java
3,347
java
VectorTest.java
Java
[ { "context": "it.jupiter.api.Assertions.fail;\n\n/**\n * Created by Arnaud Labourel on 30/09/2018.\n */\npublic class VectorTest {\n\n ", "end": 399, "score": 0.9998923540115356, "start": 384, "tag": "NAME", "value": "Arnaud Labourel" } ]
null
[]
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; /** * Created by <NAME> on 30/09/2018. */ public class VectorTest { @Test public void testVectorInt() { Vector vector = new Vector(123); assertEquals(vector.capacity(), 123); assertEquals(vector.size(), 0); } @Test public void testVector() { Vector vector = new Vector(); assertEquals(vector.capacity(), 10); assertEquals(vector.size(), 0); } @Test public void testEnsureCapacityCapacityDoubled() { Vector vector = new Vector(23); vector.ensureCapacity(24); assertThat(vector.capacity(), greaterThanOrEqualTo(23*2)); } @Test public void testEnsureCapacityCapacitySatisfied() { Vector vector = new Vector(23); vector.ensureCapacity(120); assertThat(vector.capacity(), greaterThanOrEqualTo(120)); } @Test public void testEnsureCapacityCapacityAlwaysIncreased() { Vector vector = new Vector(120); vector.ensureCapacity(10); assertEquals(vector.capacity(), 120); } @Test @Disabled public void testResize() { Vector vector = new Vector(); vector.resize(120); /* TODO */ fail("not yet implemented"); } @Test public void testResizeZeros() { Vector vector = new Vector(1); vector.add(2); vector.resize(0); vector.resize(1); assertThat(vector.get(0), equalTo(0)); } @Test @Disabled public void testResizeCapacityIncreased() { /* TODO */ fail("not yet implemented"); } @Test @Disabled public void testResizeCapacityAlwaysIncreased() { /* TODO */ fail("not yet implemented"); } @Test @Disabled public void testIsEmpty() { Vector vector = new Vector(); assertThat(vector.isEmpty(), equalTo(true)); vector.resize(12); /* TODO */ fail("not yet implemented"); } @Test public void testAdd() { Vector vector = new Vector(); vector.add(12); vector.add(13); vector.add(10); assertEquals(vector.size(), 3); assertEquals(vector.get(0),12); assertEquals(vector.get(1), 13); assertEquals(vector.get(2), 10); vector.resize(1); vector.add(2); assertEquals(vector.size(), 2); assertEquals(vector.get(1), 2); } @Test @Disabled public void testSet() { Vector vector = new Vector(); vector.add(12); vector.add(13); vector.add(10); vector.set(0, 2); vector.set(2, 4); vector.set(3, 123); /* TODO */ fail("not yet implemented"); } @Test @Disabled public void testGet() { Vector vector = new Vector(); vector.add(12); vector.add(13); /* TODO : tester également le fait d'être en dehors des bornes. */ fail("not yet implemented"); } }
3,338
0.593423
0.566218
131
24.534351
18.289988
74
false
false
0
0
0
0
0
0
0.59542
false
false
10
8934dd135c6938af5e5cca0ca76570aafeacc59b
13,271,448,955,310
4a22e70d5a869cb1f695f96284f249aaa91cb2d1
/BankingUtill.java
ca0f10c1b6d9621a732dd8eaa0f0e2d2cd9f7795
[]
no_license
Lakshmi-chowdary-96/Banking-1
https://github.com/Lakshmi-chowdary-96/Banking-1
1391eab5f3105a2685c2a73dd974d403d2cf518d
632539879e3d80bc669472319aaee2f22d3a03f3
refs/heads/master
2020-04-14T05:31:45.341000
2019-01-03T14:03:34
2019-01-03T14:03:34
163,662,840
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.cg.banking.bankingutill; import com.cg.banking.beans.Customer; public class BankingUtill { private static int Customer_ID_COUNTER=101; private static int Customer_IDX=0; public static Customer[] associates=new Customer[10]; public static Customer[] customer; public static int getCustomer_ID_COUNTER() { return ++Customer_ID_COUNTER; } public static int getCustomer_IDX() { return Customer_IDX++; } }
UTF-8
Java
446
java
BankingUtill.java
Java
[]
null
[]
package com.cg.banking.bankingutill; import com.cg.banking.beans.Customer; public class BankingUtill { private static int Customer_ID_COUNTER=101; private static int Customer_IDX=0; public static Customer[] associates=new Customer[10]; public static Customer[] customer; public static int getCustomer_ID_COUNTER() { return ++Customer_ID_COUNTER; } public static int getCustomer_IDX() { return Customer_IDX++; } }
446
0.726457
0.713004
18
22.777779
18.810621
54
false
false
0
0
0
0
0
0
1.055556
false
false
10
d1d61f92fdb229fdb71adabc8989a02decf124b1
6,751,688,655,082
92bb33ecc2fccd777e5e1dda469b15ac8caeb14c
/src/auca/library/view/bookView.java
153fc1adf62e7ea51c1b6b09a5851096b805f679
[]
no_license
nellyganza/Libray-System-With-RMI
https://github.com/nellyganza/Libray-System-With-RMI
4eaf5c925bde1881aad44d45a37fb8eed8324c05
9818ed031a6b07b65975e95fd68491c151584b03
refs/heads/master
2022-12-06T06:55:47.397000
2020-08-27T10:34:52
2020-08-27T10:34:52
266,447,080
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
/* * 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 auca.library.view; import auca.library.Interface.BookCategoryInter; import auca.library.Interface.BookInter; import auca.library.Interface.MethodsInter; import auca.library.Servers.Methods; import auca.library.model.BookView; import auca.library.model.BookcategoryView; import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; /** * * @author NISHIMWE Elyse */ public class bookView extends javax.swing.JInternalFrame{ Registry reg = LocateRegistry.getRegistry(2005); MethodsInter m = (MethodsInter) reg.lookup("ServerMethods"); /** * Creates new form bookView * @throws java.lang.Exception */ public bookView() throws Exception{ initComponents(); populateBook(); populateClientCategoryView(); } /** * 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() { buttonGroup1 = new javax.swing.ButtonGroup(); buttonGroup2 = new javax.swing.ButtonGroup(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); jScrollPane3 = new javax.swing.JScrollPane(); tblBook = new javax.swing.JTable(); jPanel4 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); bookidtxt = new javax.swing.JTextField(); titletxt = new javax.swing.JTextField(); phousetxt = new javax.swing.JTextField(); dop = new com.toedter.calendar.JDateChooser(); authortxt = new javax.swing.JTextField(); bcattxt = new javax.swing.JComboBox<>(); numofpage = new javax.swing.JSpinner(); numofcopy = new javax.swing.JSpinner(); jPanel5 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); savebook = new javax.swing.JButton(); updatebook = new javax.swing.JButton(); deletebook = new javax.swing.JButton(); jButton5 = new javax.swing.JButton(); jLabel9 = new javax.swing.JLabel(); idrd = new javax.swing.JRadioButton(); titlerd = new javax.swing.JRadioButton(); sachbook = new javax.swing.JTextField(); jPanel2 = new javax.swing.JPanel(); jPanel6 = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel7 = new javax.swing.JPanel(); jLabel10 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); catidtxt = new javax.swing.JTextField(); catnametxt = new javax.swing.JTextField(); jPanel8 = new javax.swing.JPanel(); jButton6 = new javax.swing.JButton(); jButton7 = new javax.swing.JButton(); jButton8 = new javax.swing.JButton(); jButton9 = new javax.swing.JButton(); jButton10 = new javax.swing.JButton(); jLabel12 = new javax.swing.JLabel(); catrdid = new javax.swing.JRadioButton(); catrdtitle = new javax.swing.JRadioButton(); sachcattxt = new javax.swing.JTextField(); setClosable(true); setIconifiable(true); setMaximizable(true); setResizable(true); setTitle("Book & Book Category form"); addInternalFrameListener(new javax.swing.event.InternalFrameListener() { public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) { formInternalFrameOpened(evt); } }); jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jTabbedPane1StateChanged(evt); } }); tblBook.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); tblBook.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { tblBookMouseClicked(evt); } }); jScrollPane3.setViewportView(tblBook); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane3) .addContainerGap()) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(32, Short.MAX_VALUE)) ); jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Book Info")); jLabel1.setText("Book Id"); jLabel2.setText("Title"); jLabel3.setText("Publishing House"); jLabel4.setText("Date of Publication"); jLabel5.setText("Book Category"); jLabel6.setText("Number of Pages"); jLabel7.setText("Number of Copies"); jLabel8.setText("Author"); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel2) .addComponent(jLabel3) .addComponent(jLabel4)) .addGap(39, 39, 39) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(bookidtxt) .addComponent(titletxt) .addComponent(phousetxt) .addComponent(dop, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)) .addGap(26, 26, 26) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel8) .addComponent(jLabel5) .addComponent(jLabel6) .addComponent(jLabel7)) .addGap(29, 29, 29) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(authortxt) .addComponent(bcattxt, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(numofpage, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE) .addComponent(numofcopy)) .addContainerGap()) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addGap(16, 16, 16) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jLabel8) .addComponent(bookidtxt) .addComponent(authortxt)) .addGap(18, 18, 18) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jLabel5) .addComponent(titletxt) .addComponent(bcattxt)) .addGap(18, 18, 18) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(jLabel6) .addComponent(phousetxt) .addComponent(numofpage)) .addGap(18, 18, 18) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel7) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(numofcopy))) .addComponent(dop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(38, 38, 38)) ); jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Button")); jButton1.setText("New Book"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); savebook.setText("Save"); savebook.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { savebookActionPerformed(evt); } }); updatebook.setText("Update"); updatebook.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { updatebookActionPerformed(evt); } }); deletebook.setText("Delete"); deletebook.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { deletebookActionPerformed(evt); } }); jButton5.setText("Clear"); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addGap(46, 46, 46) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(savebook, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(updatebook, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(deletebook, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(50, 50, 50)) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addContainerGap() .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(11, 11, 11) .addComponent(savebook, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18) .addComponent(updatebook, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18) .addComponent(deletebook, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(13, 13, 13) .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); jLabel9.setText("Search By "); buttonGroup1.add(idrd); idrd.setText("Id"); buttonGroup1.add(titlerd); titlerd.setText("Title"); sachbook.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { sachbookKeyPressed(evt); } public void keyReleased(java.awt.event.KeyEvent evt) { sachbookKeyReleased(evt); } public void keyTyped(java.awt.event.KeyEvent evt) { sachbookKeyTyped(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(43, 43, 43) .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap()) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jLabel9) .addGap(18, 18, 18) .addComponent(idrd) .addGap(35, 35, 35) .addComponent(titlerd) .addGap(54, 54, 54) .addComponent(sachbook, javax.swing.GroupLayout.PREFERRED_SIZE, 284, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel9) .addComponent(idrd) .addComponent(titlerd) .addComponent(sachbook, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(8, 8, 8) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(28, 28, 28) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(110, 110, 110)) ); jTabbedPane1.addTab("Book ", jPanel1); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); jTable1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jTable1MouseClicked(evt); } }); jScrollPane2.setViewportView(jTable1); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane2)) ); jPanel6Layout.setVerticalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() .addGap(13, 13, 13) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE)) ); jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Book Category Info")); jLabel10.setText("Category Id"); jLabel11.setText("Category Name"); javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); jPanel7.setLayout(jPanel7Layout); jPanel7Layout.setHorizontalGroup( jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup() .addGap(31, 31, 31) .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel10) .addComponent(jLabel11)) .addGap(89, 89, 89) .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(catidtxt) .addComponent(catnametxt, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)) .addGap(105, 105, 105)) ); jPanel7Layout.setVerticalGroup( jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup() .addGap(17, 17, 17) .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel10) .addComponent(catidtxt, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(catnametxt, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel11)) .addGap(29, 29, 29)) ); jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Button")); jButton6.setText("New Book cat"); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); jButton7.setText("Save"); jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton7ActionPerformed(evt); } }); jButton8.setText("Update"); jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton8ActionPerformed(evt); } }); jButton9.setText("Delete"); jButton9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton9ActionPerformed(evt); } }); jButton10.setText("Clear"); jButton10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton10ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8); jPanel8.setLayout(jPanel8Layout); jPanel8Layout.setHorizontalGroup( jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel8Layout.createSequentialGroup() .addGap(46, 46, 46) .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(36, 36, 36)) ); jPanel8Layout.setVerticalGroup( jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel8Layout.createSequentialGroup() .addContainerGap() .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(11, 11, 11) .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(32, 32, 32)) ); jLabel12.setText("Search By "); buttonGroup2.add(catrdid); catrdid.setText("Id"); buttonGroup2.add(catrdtitle); catrdtitle.setText("Title"); sachcattxt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { sachcattxtActionPerformed(evt); } }); sachcattxt.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { sachcattxtKeyReleased(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(52, 52, 52) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(35, 35, 35) .addComponent(jLabel12) .addGap(32, 32, 32) .addComponent(catrdid) .addGap(35, 35, 35) .addComponent(catrdtitle) .addGap(50, 50, 50) .addComponent(sachcattxt))) .addGap(47, 47, 47) .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(12, 12, 12))) .addGap(51, 51, 51)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(33, 33, 33) .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(23, 23, 23) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel12) .addComponent(catrdid) .addComponent(catrdtitle) .addComponent(sachcattxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(5, 5, 5))) .addGap(13, 13, 13) .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); jTabbedPane1.addTab("Book Category", jPanel2); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTabbedPane1) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTabbedPane1) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed enablebook(); }//GEN-LAST:event_jButton1ActionPerformed private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed enablebookcat(); }//GEN-LAST:event_jButton6ActionPerformed private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened desablebook(); desablebookcat(); }//GEN-LAST:event_formInternalFrameOpened private void savebookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_savebookActionPerformed try { BookView b = new BookView(); Registry registry = LocateRegistry.getRegistry(2002); BookInter bdao = (BookInter) registry.lookup("ServerBook"); String id = bdao.getId("BookcategoryView", "categoryname", bcattxt.getSelectedItem().toString(), "categoryid"); b.setBookid(bookidtxt.getText()); b.setTitle(titletxt.getText()); b.setPublishinghouse(phousetxt.getText()); b.setDateofpublication(dop.getDate()); b.setAuthor(authortxt.getText()); b.setBookcategoryView(new BookcategoryView(id)); b.setPages(Integer.valueOf(numofpage.getValue().toString())); b.setNumberofcopies(Integer.valueOf(numofcopy.getValue().toString())); bdao.saveBook(b); populateBook(); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_savebookActionPerformed private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed try { BookcategoryView bc = new BookcategoryView(); bc.setCategoryid(catidtxt.getText()); bc.setCategoryname(catnametxt.getText()); Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter bcdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); bcdao.saveBookcategoryView(bc); populateClientCategoryView(); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_jButton7ActionPerformed private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed try { BookcategoryView bc = new BookcategoryView(); bc.setCategoryid(catidtxt.getText()); bc.setCategoryname(catnametxt.getText()); Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter bcdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); bcdao.updateBookcategoryView(bc); populateClientCategoryView(); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_jButton8ActionPerformed private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed try { BookcategoryView bc = new BookcategoryView(catidtxt.getText()); Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter bcdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); bcdao.deleteBookcategoryView(bc); populateClientCategoryView(); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_jButton9ActionPerformed private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed clearbookcat(); }//GEN-LAST:event_jButton10ActionPerformed private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed clearbook(); }//GEN-LAST:event_jButton5ActionPerformed private void updatebookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updatebookActionPerformed try { BookView b = new BookView(); Registry registry = LocateRegistry.getRegistry(2002); BookInter bdao = (BookInter) registry.lookup("ServerBook"); String id = bdao.getId("BookcategoryView", "categoryname", bcattxt.getSelectedItem().toString(), "categoryid"); b.setBookid(bookidtxt.getText()); b.setTitle(titletxt.getText()); b.setPublishinghouse(phousetxt.getText()); b.setDateofpublication(dop.getDate()); b.setAuthor(authortxt.getText()); b.setBookcategoryView(new BookcategoryView(id)); b.setPages(Integer.valueOf(numofpage.getValue().toString())); b.setNumberofcopies(Integer.valueOf(numofcopy.getValue().toString())); bdao.updateBook(b); populateBook(); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_updatebookActionPerformed private void deletebookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deletebookActionPerformed try { BookView b = new BookView(bookidtxt.getText()); Registry registry = LocateRegistry.getRegistry(2002); BookInter bdao = (BookInter) registry.lookup("ServerBook"); bdao.deleteBook(b); populateBook(); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_deletebookActionPerformed private void sachbookKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_sachbookKeyTyped }//GEN-LAST:event_sachbookKeyTyped private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged addData(); }//GEN-LAST:event_jTabbedPane1StateChanged private void sachbookKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_sachbookKeyPressed }//GEN-LAST:event_sachbookKeyPressed private void sachbookKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_sachbookKeyReleased if(idrd.isSelected()){ try { Registry registry = LocateRegistry.getRegistry(2002); BookInter bdao = (BookInter) registry.lookup("ServerBook"); BookView b = bdao.findById(sachbook.getText()); if(b!=null){ bookidtxt.setText(b.getBookid()); titletxt.setText(b.getTitle()); phousetxt.setText(b.getPublishinghouse()); dop.setDate(b.getDateofpublication()); authortxt.setText(b.getAuthor()); bcattxt.setSelectedItem(b.getBookcategoryView()); numofpage.setValue(b.getPages()); numofcopy.setValue(b.getNumberofcopies()); } } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } else if(titlerd.isSelected()){ try { Registry registry = LocateRegistry.getRegistry(2002); BookInter bdao = (BookInter) registry.lookup("ServerBook"); List<BookView> b = bdao.findByTitle(sachbook.getText()); if(b!=null){ for(Iterator it = b.iterator();it.hasNext();){ BookView bv = (BookView) it.next(); bookidtxt.setText(bv.getBookid()); titletxt.setText(bv.getTitle()); phousetxt.setText(bv.getPublishinghouse()); dop.setDate(bv.getDateofpublication()); authortxt.setText(bv.getAuthor()); bcattxt.setSelectedItem(bv.getBookcategoryView()); numofpage.setValue(bv.getPages()); numofcopy.setValue(bv.getNumberofcopies()); } } } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(this, "Please Select The type of searching you need "); } }//GEN-LAST:event_sachbookKeyReleased private void sachcattxtKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_sachcattxtKeyReleased if(catrdid.isSelected()){ try { Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter bdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); BookcategoryView b = bdao.findById(sachcattxt.getText()); if(b!=null){ catidtxt.setText(b.getCategoryid()); catnametxt.setText(b.getCategoryname()); } } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } else if(catrdtitle.isSelected()){ try { Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter bdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); List<BookcategoryView> b = bdao.findByTitle(sachcattxt.getText()); if(b!=null){ for(Iterator it = b.iterator();it.hasNext();){ BookcategoryView bv = (BookcategoryView) it.next(); catidtxt.setText(bv.getCategoryid()); catnametxt.setText(bv.getCategoryname()); } } } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(this, "Please Select The type of searching you need "); } }//GEN-LAST:event_sachcattxtKeyReleased private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked int x = jTable1.getSelectedRow(); catidtxt.setText((String) jTable1.getValueAt(x, 0)); catnametxt.setText((String) jTable1.getValueAt(x, 1)); }//GEN-LAST:event_jTable1MouseClicked private void tblBookMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblBookMouseClicked try { int x = tblBook.getSelectedRow(); bookidtxt.setText((String) tblBook.getValueAt(x, 0)); titletxt.setText((String) tblBook.getValueAt(x, 1)); phousetxt.setText((String) tblBook.getValueAt(x, 2)); Date d = new SimpleDateFormat("dd-MM-yyyy").parse((String) tblBook.getValueAt(x, 3)); dop.setDate(d); authortxt.setText((String) tblBook.getValueAt(x, 4)); bcattxt.setSelectedItem(tblBook.getValueAt(x, 6).toString()); numofpage.setValue(Integer.parseInt(tblBook.getValueAt(x, 5).toString())); numofcopy.setValue(Integer.parseInt(tblBook.getValueAt(x, 7).toString())); } catch (ParseException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_tblBookMouseClicked private void sachcattxtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sachcattxtActionPerformed // TODO add your handling code here: }//GEN-LAST:event_sachcattxtActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField authortxt; private javax.swing.JComboBox<String> bcattxt; private javax.swing.JTextField bookidtxt; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.ButtonGroup buttonGroup2; private javax.swing.JTextField catidtxt; private javax.swing.JTextField catnametxt; private javax.swing.JRadioButton catrdid; private javax.swing.JRadioButton catrdtitle; private javax.swing.JButton deletebook; private com.toedter.calendar.JDateChooser dop; private javax.swing.JRadioButton idrd; private javax.swing.JButton jButton1; private javax.swing.JButton jButton10; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JButton jButton7; private javax.swing.JButton jButton8; private javax.swing.JButton jButton9; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; private javax.swing.JPanel jPanel8; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JTable jTable1; private javax.swing.JSpinner numofcopy; private javax.swing.JSpinner numofpage; private javax.swing.JTextField phousetxt; private javax.swing.JTextField sachbook; private javax.swing.JTextField sachcattxt; private javax.swing.JButton savebook; private javax.swing.JTable tblBook; private javax.swing.JRadioButton titlerd; private javax.swing.JTextField titletxt; private javax.swing.JButton updatebook; // End of variables declaration//GEN-END:variables public void desablebookcat(){ catidtxt.setEnabled(false); catnametxt.setEnabled(false); } public void enablebookcat(){ catidtxt.setEnabled(true); catnametxt.setEnabled(true); } public void desablebook(){ bookidtxt.setEnabled(false); titletxt.setEnabled(false); phousetxt.setEnabled(false); dop.setEnabled(false); authortxt.setEnabled(false); bcattxt.setEnabled(false); numofpage.setEnabled(false); numofcopy.setEnabled(false); } public void enablebook(){ bookidtxt.setEnabled(true); titletxt.setEnabled(true); phousetxt.setEnabled(true); dop.setEnabled(true); authortxt.setEnabled(true); bcattxt.setEnabled(true); numofpage.setEnabled(true); numofcopy.setEnabled(true); } public void clearbookcat(){ catidtxt.setText(""); catnametxt.setText(""); } public void clearbook(){ bookidtxt.setText(""); titletxt.setText(""); phousetxt.setText(""); dop.setDate(null); authortxt.setText(""); bcattxt.setSelectedItem(null); numofpage.setValue(0); numofcopy.setValue(0); } public void addData(){ try { Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter bcdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); List<BookcategoryView> catnames = bcdao.getDataIntoBookViewCatCmb(); bcattxt.removeAllItems(); for(Object b:catnames){ bcattxt.addItem(b.toString()); } } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } private void populateClientCategoryView(){ try { Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter cdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); List<BookcategoryView> cats = cdao.getBookcategoryView(); String[] colnames = {"CATEGORY ID","CATEGORY NAME"}; DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); model.setRowCount(0); model.setColumnIdentifiers(colnames); for(Iterator it = cats.iterator();it.hasNext();){ BookcategoryView c = (BookcategoryView) it.next(); Object[] cl = {c.getCategoryid(),c.getCategoryname()}; model.addRow(cl); } jTable1.setModel(model); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } private void populateBook(){ try { Registry registry = LocateRegistry.getRegistry(2002); BookInter bdao = (BookInter) registry.lookup("ServerBook"); List<BookView> books = bdao.getBookData(); DefaultTableModel model = (DefaultTableModel) tblBook.getModel(); model.setRowCount(0); String[] header = {"BOOK ID","TITLE","PUBLISHING HOUSE","DATE OF PUBLICATION","AUTHOR","NUM OF PAGES","BOOK CATEGORY","NUM OF COPIES"}; model.setColumnIdentifiers(header); for(BookView book:books) { String[] row = {book.getBookid(),book.getTitle(),book.getPublishinghouse(),new SimpleDateFormat("dd-MM-yyyy").format(book.getDateofpublication()),book.getAuthor(),book.getPages().toString(),m.getName("categoryname","BookcategoryView","categoryId",book.getBookcategoryView().getCategoryid()),book.getNumberofcopies().toString()}; model.addRow(row); } tblBook.setModel(model); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } }
UTF-8
Java
49,979
java
bookView.java
Java
[ { "context": ".swing.table.DefaultTableModel;\n\n/**\n *\n * @author NISHIMWE Elyse\n */\npublic class bookView extends javax.swing.JIn", "end": 923, "score": 0.999853789806366, "start": 909, "tag": "NAME", "value": "NISHIMWE Elyse" } ]
null
[]
/* * 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 auca.library.view; import auca.library.Interface.BookCategoryInter; import auca.library.Interface.BookInter; import auca.library.Interface.MethodsInter; import auca.library.Servers.Methods; import auca.library.model.BookView; import auca.library.model.BookcategoryView; import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; /** * * @author <NAME> */ public class bookView extends javax.swing.JInternalFrame{ Registry reg = LocateRegistry.getRegistry(2005); MethodsInter m = (MethodsInter) reg.lookup("ServerMethods"); /** * Creates new form bookView * @throws java.lang.Exception */ public bookView() throws Exception{ initComponents(); populateBook(); populateClientCategoryView(); } /** * 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() { buttonGroup1 = new javax.swing.ButtonGroup(); buttonGroup2 = new javax.swing.ButtonGroup(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); jScrollPane3 = new javax.swing.JScrollPane(); tblBook = new javax.swing.JTable(); jPanel4 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); bookidtxt = new javax.swing.JTextField(); titletxt = new javax.swing.JTextField(); phousetxt = new javax.swing.JTextField(); dop = new com.toedter.calendar.JDateChooser(); authortxt = new javax.swing.JTextField(); bcattxt = new javax.swing.JComboBox<>(); numofpage = new javax.swing.JSpinner(); numofcopy = new javax.swing.JSpinner(); jPanel5 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); savebook = new javax.swing.JButton(); updatebook = new javax.swing.JButton(); deletebook = new javax.swing.JButton(); jButton5 = new javax.swing.JButton(); jLabel9 = new javax.swing.JLabel(); idrd = new javax.swing.JRadioButton(); titlerd = new javax.swing.JRadioButton(); sachbook = new javax.swing.JTextField(); jPanel2 = new javax.swing.JPanel(); jPanel6 = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel7 = new javax.swing.JPanel(); jLabel10 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); catidtxt = new javax.swing.JTextField(); catnametxt = new javax.swing.JTextField(); jPanel8 = new javax.swing.JPanel(); jButton6 = new javax.swing.JButton(); jButton7 = new javax.swing.JButton(); jButton8 = new javax.swing.JButton(); jButton9 = new javax.swing.JButton(); jButton10 = new javax.swing.JButton(); jLabel12 = new javax.swing.JLabel(); catrdid = new javax.swing.JRadioButton(); catrdtitle = new javax.swing.JRadioButton(); sachcattxt = new javax.swing.JTextField(); setClosable(true); setIconifiable(true); setMaximizable(true); setResizable(true); setTitle("Book & Book Category form"); addInternalFrameListener(new javax.swing.event.InternalFrameListener() { public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) { } public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) { formInternalFrameOpened(evt); } }); jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jTabbedPane1StateChanged(evt); } }); tblBook.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); tblBook.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { tblBookMouseClicked(evt); } }); jScrollPane3.setViewportView(tblBook); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane3) .addContainerGap()) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(32, Short.MAX_VALUE)) ); jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Book Info")); jLabel1.setText("Book Id"); jLabel2.setText("Title"); jLabel3.setText("Publishing House"); jLabel4.setText("Date of Publication"); jLabel5.setText("Book Category"); jLabel6.setText("Number of Pages"); jLabel7.setText("Number of Copies"); jLabel8.setText("Author"); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel2) .addComponent(jLabel3) .addComponent(jLabel4)) .addGap(39, 39, 39) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(bookidtxt) .addComponent(titletxt) .addComponent(phousetxt) .addComponent(dop, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)) .addGap(26, 26, 26) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel8) .addComponent(jLabel5) .addComponent(jLabel6) .addComponent(jLabel7)) .addGap(29, 29, 29) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(authortxt) .addComponent(bcattxt, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(numofpage, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE) .addComponent(numofcopy)) .addContainerGap()) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addGap(16, 16, 16) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jLabel8) .addComponent(bookidtxt) .addComponent(authortxt)) .addGap(18, 18, 18) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jLabel5) .addComponent(titletxt) .addComponent(bcattxt)) .addGap(18, 18, 18) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(jLabel6) .addComponent(phousetxt) .addComponent(numofpage)) .addGap(18, 18, 18) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel7) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(numofcopy))) .addComponent(dop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(38, 38, 38)) ); jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Button")); jButton1.setText("New Book"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); savebook.setText("Save"); savebook.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { savebookActionPerformed(evt); } }); updatebook.setText("Update"); updatebook.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { updatebookActionPerformed(evt); } }); deletebook.setText("Delete"); deletebook.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { deletebookActionPerformed(evt); } }); jButton5.setText("Clear"); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addGap(46, 46, 46) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(savebook, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(updatebook, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(deletebook, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(50, 50, 50)) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addContainerGap() .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(11, 11, 11) .addComponent(savebook, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18) .addComponent(updatebook, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18) .addComponent(deletebook, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(13, 13, 13) .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); jLabel9.setText("Search By "); buttonGroup1.add(idrd); idrd.setText("Id"); buttonGroup1.add(titlerd); titlerd.setText("Title"); sachbook.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { sachbookKeyPressed(evt); } public void keyReleased(java.awt.event.KeyEvent evt) { sachbookKeyReleased(evt); } public void keyTyped(java.awt.event.KeyEvent evt) { sachbookKeyTyped(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(43, 43, 43) .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap()) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jLabel9) .addGap(18, 18, 18) .addComponent(idrd) .addGap(35, 35, 35) .addComponent(titlerd) .addGap(54, 54, 54) .addComponent(sachbook, javax.swing.GroupLayout.PREFERRED_SIZE, 284, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel9) .addComponent(idrd) .addComponent(titlerd) .addComponent(sachbook, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(8, 8, 8) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(28, 28, 28) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(110, 110, 110)) ); jTabbedPane1.addTab("Book ", jPanel1); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); jTable1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jTable1MouseClicked(evt); } }); jScrollPane2.setViewportView(jTable1); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane2)) ); jPanel6Layout.setVerticalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() .addGap(13, 13, 13) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE)) ); jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Book Category Info")); jLabel10.setText("Category Id"); jLabel11.setText("Category Name"); javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); jPanel7.setLayout(jPanel7Layout); jPanel7Layout.setHorizontalGroup( jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup() .addGap(31, 31, 31) .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel10) .addComponent(jLabel11)) .addGap(89, 89, 89) .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(catidtxt) .addComponent(catnametxt, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)) .addGap(105, 105, 105)) ); jPanel7Layout.setVerticalGroup( jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup() .addGap(17, 17, 17) .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel10) .addComponent(catidtxt, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(catnametxt, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel11)) .addGap(29, 29, 29)) ); jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Button")); jButton6.setText("New Book cat"); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); jButton7.setText("Save"); jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton7ActionPerformed(evt); } }); jButton8.setText("Update"); jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton8ActionPerformed(evt); } }); jButton9.setText("Delete"); jButton9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton9ActionPerformed(evt); } }); jButton10.setText("Clear"); jButton10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton10ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8); jPanel8.setLayout(jPanel8Layout); jPanel8Layout.setHorizontalGroup( jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel8Layout.createSequentialGroup() .addGap(46, 46, 46) .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(36, 36, 36)) ); jPanel8Layout.setVerticalGroup( jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel8Layout.createSequentialGroup() .addContainerGap() .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(11, 11, 11) .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(32, 32, 32)) ); jLabel12.setText("Search By "); buttonGroup2.add(catrdid); catrdid.setText("Id"); buttonGroup2.add(catrdtitle); catrdtitle.setText("Title"); sachcattxt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { sachcattxtActionPerformed(evt); } }); sachcattxt.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { sachcattxtKeyReleased(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(52, 52, 52) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(35, 35, 35) .addComponent(jLabel12) .addGap(32, 32, 32) .addComponent(catrdid) .addGap(35, 35, 35) .addComponent(catrdtitle) .addGap(50, 50, 50) .addComponent(sachcattxt))) .addGap(47, 47, 47) .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(12, 12, 12))) .addGap(51, 51, 51)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(33, 33, 33) .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(23, 23, 23) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel12) .addComponent(catrdid) .addComponent(catrdtitle) .addComponent(sachcattxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(5, 5, 5))) .addGap(13, 13, 13) .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); jTabbedPane1.addTab("Book Category", jPanel2); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTabbedPane1) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTabbedPane1) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed enablebook(); }//GEN-LAST:event_jButton1ActionPerformed private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed enablebookcat(); }//GEN-LAST:event_jButton6ActionPerformed private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened desablebook(); desablebookcat(); }//GEN-LAST:event_formInternalFrameOpened private void savebookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_savebookActionPerformed try { BookView b = new BookView(); Registry registry = LocateRegistry.getRegistry(2002); BookInter bdao = (BookInter) registry.lookup("ServerBook"); String id = bdao.getId("BookcategoryView", "categoryname", bcattxt.getSelectedItem().toString(), "categoryid"); b.setBookid(bookidtxt.getText()); b.setTitle(titletxt.getText()); b.setPublishinghouse(phousetxt.getText()); b.setDateofpublication(dop.getDate()); b.setAuthor(authortxt.getText()); b.setBookcategoryView(new BookcategoryView(id)); b.setPages(Integer.valueOf(numofpage.getValue().toString())); b.setNumberofcopies(Integer.valueOf(numofcopy.getValue().toString())); bdao.saveBook(b); populateBook(); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_savebookActionPerformed private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed try { BookcategoryView bc = new BookcategoryView(); bc.setCategoryid(catidtxt.getText()); bc.setCategoryname(catnametxt.getText()); Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter bcdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); bcdao.saveBookcategoryView(bc); populateClientCategoryView(); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_jButton7ActionPerformed private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed try { BookcategoryView bc = new BookcategoryView(); bc.setCategoryid(catidtxt.getText()); bc.setCategoryname(catnametxt.getText()); Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter bcdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); bcdao.updateBookcategoryView(bc); populateClientCategoryView(); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_jButton8ActionPerformed private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed try { BookcategoryView bc = new BookcategoryView(catidtxt.getText()); Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter bcdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); bcdao.deleteBookcategoryView(bc); populateClientCategoryView(); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_jButton9ActionPerformed private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed clearbookcat(); }//GEN-LAST:event_jButton10ActionPerformed private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed clearbook(); }//GEN-LAST:event_jButton5ActionPerformed private void updatebookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updatebookActionPerformed try { BookView b = new BookView(); Registry registry = LocateRegistry.getRegistry(2002); BookInter bdao = (BookInter) registry.lookup("ServerBook"); String id = bdao.getId("BookcategoryView", "categoryname", bcattxt.getSelectedItem().toString(), "categoryid"); b.setBookid(bookidtxt.getText()); b.setTitle(titletxt.getText()); b.setPublishinghouse(phousetxt.getText()); b.setDateofpublication(dop.getDate()); b.setAuthor(authortxt.getText()); b.setBookcategoryView(new BookcategoryView(id)); b.setPages(Integer.valueOf(numofpage.getValue().toString())); b.setNumberofcopies(Integer.valueOf(numofcopy.getValue().toString())); bdao.updateBook(b); populateBook(); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_updatebookActionPerformed private void deletebookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deletebookActionPerformed try { BookView b = new BookView(bookidtxt.getText()); Registry registry = LocateRegistry.getRegistry(2002); BookInter bdao = (BookInter) registry.lookup("ServerBook"); bdao.deleteBook(b); populateBook(); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_deletebookActionPerformed private void sachbookKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_sachbookKeyTyped }//GEN-LAST:event_sachbookKeyTyped private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged addData(); }//GEN-LAST:event_jTabbedPane1StateChanged private void sachbookKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_sachbookKeyPressed }//GEN-LAST:event_sachbookKeyPressed private void sachbookKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_sachbookKeyReleased if(idrd.isSelected()){ try { Registry registry = LocateRegistry.getRegistry(2002); BookInter bdao = (BookInter) registry.lookup("ServerBook"); BookView b = bdao.findById(sachbook.getText()); if(b!=null){ bookidtxt.setText(b.getBookid()); titletxt.setText(b.getTitle()); phousetxt.setText(b.getPublishinghouse()); dop.setDate(b.getDateofpublication()); authortxt.setText(b.getAuthor()); bcattxt.setSelectedItem(b.getBookcategoryView()); numofpage.setValue(b.getPages()); numofcopy.setValue(b.getNumberofcopies()); } } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } else if(titlerd.isSelected()){ try { Registry registry = LocateRegistry.getRegistry(2002); BookInter bdao = (BookInter) registry.lookup("ServerBook"); List<BookView> b = bdao.findByTitle(sachbook.getText()); if(b!=null){ for(Iterator it = b.iterator();it.hasNext();){ BookView bv = (BookView) it.next(); bookidtxt.setText(bv.getBookid()); titletxt.setText(bv.getTitle()); phousetxt.setText(bv.getPublishinghouse()); dop.setDate(bv.getDateofpublication()); authortxt.setText(bv.getAuthor()); bcattxt.setSelectedItem(bv.getBookcategoryView()); numofpage.setValue(bv.getPages()); numofcopy.setValue(bv.getNumberofcopies()); } } } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(this, "Please Select The type of searching you need "); } }//GEN-LAST:event_sachbookKeyReleased private void sachcattxtKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_sachcattxtKeyReleased if(catrdid.isSelected()){ try { Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter bdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); BookcategoryView b = bdao.findById(sachcattxt.getText()); if(b!=null){ catidtxt.setText(b.getCategoryid()); catnametxt.setText(b.getCategoryname()); } } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } else if(catrdtitle.isSelected()){ try { Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter bdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); List<BookcategoryView> b = bdao.findByTitle(sachcattxt.getText()); if(b!=null){ for(Iterator it = b.iterator();it.hasNext();){ BookcategoryView bv = (BookcategoryView) it.next(); catidtxt.setText(bv.getCategoryid()); catnametxt.setText(bv.getCategoryname()); } } } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(this, "Please Select The type of searching you need "); } }//GEN-LAST:event_sachcattxtKeyReleased private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked int x = jTable1.getSelectedRow(); catidtxt.setText((String) jTable1.getValueAt(x, 0)); catnametxt.setText((String) jTable1.getValueAt(x, 1)); }//GEN-LAST:event_jTable1MouseClicked private void tblBookMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblBookMouseClicked try { int x = tblBook.getSelectedRow(); bookidtxt.setText((String) tblBook.getValueAt(x, 0)); titletxt.setText((String) tblBook.getValueAt(x, 1)); phousetxt.setText((String) tblBook.getValueAt(x, 2)); Date d = new SimpleDateFormat("dd-MM-yyyy").parse((String) tblBook.getValueAt(x, 3)); dop.setDate(d); authortxt.setText((String) tblBook.getValueAt(x, 4)); bcattxt.setSelectedItem(tblBook.getValueAt(x, 6).toString()); numofpage.setValue(Integer.parseInt(tblBook.getValueAt(x, 5).toString())); numofcopy.setValue(Integer.parseInt(tblBook.getValueAt(x, 7).toString())); } catch (ParseException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_tblBookMouseClicked private void sachcattxtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sachcattxtActionPerformed // TODO add your handling code here: }//GEN-LAST:event_sachcattxtActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField authortxt; private javax.swing.JComboBox<String> bcattxt; private javax.swing.JTextField bookidtxt; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.ButtonGroup buttonGroup2; private javax.swing.JTextField catidtxt; private javax.swing.JTextField catnametxt; private javax.swing.JRadioButton catrdid; private javax.swing.JRadioButton catrdtitle; private javax.swing.JButton deletebook; private com.toedter.calendar.JDateChooser dop; private javax.swing.JRadioButton idrd; private javax.swing.JButton jButton1; private javax.swing.JButton jButton10; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JButton jButton7; private javax.swing.JButton jButton8; private javax.swing.JButton jButton9; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; private javax.swing.JPanel jPanel8; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JTable jTable1; private javax.swing.JSpinner numofcopy; private javax.swing.JSpinner numofpage; private javax.swing.JTextField phousetxt; private javax.swing.JTextField sachbook; private javax.swing.JTextField sachcattxt; private javax.swing.JButton savebook; private javax.swing.JTable tblBook; private javax.swing.JRadioButton titlerd; private javax.swing.JTextField titletxt; private javax.swing.JButton updatebook; // End of variables declaration//GEN-END:variables public void desablebookcat(){ catidtxt.setEnabled(false); catnametxt.setEnabled(false); } public void enablebookcat(){ catidtxt.setEnabled(true); catnametxt.setEnabled(true); } public void desablebook(){ bookidtxt.setEnabled(false); titletxt.setEnabled(false); phousetxt.setEnabled(false); dop.setEnabled(false); authortxt.setEnabled(false); bcattxt.setEnabled(false); numofpage.setEnabled(false); numofcopy.setEnabled(false); } public void enablebook(){ bookidtxt.setEnabled(true); titletxt.setEnabled(true); phousetxt.setEnabled(true); dop.setEnabled(true); authortxt.setEnabled(true); bcattxt.setEnabled(true); numofpage.setEnabled(true); numofcopy.setEnabled(true); } public void clearbookcat(){ catidtxt.setText(""); catnametxt.setText(""); } public void clearbook(){ bookidtxt.setText(""); titletxt.setText(""); phousetxt.setText(""); dop.setDate(null); authortxt.setText(""); bcattxt.setSelectedItem(null); numofpage.setValue(0); numofcopy.setValue(0); } public void addData(){ try { Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter bcdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); List<BookcategoryView> catnames = bcdao.getDataIntoBookViewCatCmb(); bcattxt.removeAllItems(); for(Object b:catnames){ bcattxt.addItem(b.toString()); } } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } private void populateClientCategoryView(){ try { Registry registry = LocateRegistry.getRegistry(2001); BookCategoryInter cdao = (BookCategoryInter) registry.lookup("ServerBookCategory"); List<BookcategoryView> cats = cdao.getBookcategoryView(); String[] colnames = {"CATEGORY ID","CATEGORY NAME"}; DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); model.setRowCount(0); model.setColumnIdentifiers(colnames); for(Iterator it = cats.iterator();it.hasNext();){ BookcategoryView c = (BookcategoryView) it.next(); Object[] cl = {c.getCategoryid(),c.getCategoryname()}; model.addRow(cl); } jTable1.setModel(model); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } private void populateBook(){ try { Registry registry = LocateRegistry.getRegistry(2002); BookInter bdao = (BookInter) registry.lookup("ServerBook"); List<BookView> books = bdao.getBookData(); DefaultTableModel model = (DefaultTableModel) tblBook.getModel(); model.setRowCount(0); String[] header = {"BOOK ID","TITLE","PUBLISHING HOUSE","DATE OF PUBLICATION","AUTHOR","NUM OF PAGES","BOOK CATEGORY","NUM OF COPIES"}; model.setColumnIdentifiers(header); for(BookView book:books) { String[] row = {book.getBookid(),book.getTitle(),book.getPublishinghouse(),new SimpleDateFormat("dd-MM-yyyy").format(book.getDateofpublication()),book.getAuthor(),book.getPages().toString(),m.getName("categoryname","BookcategoryView","categoryId",book.getBookcategoryView().getCategoryid()),book.getNumberofcopies().toString()}; model.addRow(row); } tblBook.setModel(model); } catch (RemoteException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(bookView.class.getName()).log(Level.SEVERE, null, ex); } } }
49,971
0.631225
0.616939
1,015
48.240395
34.435738
344
false
false
0
0
0
0
0
0
0.796059
false
false
10
4c45d4418ab3d966fc986b6fc666469fdc9fdfd3
22,273,700,449,060
d9cbe0104a8fffe935145303ef23c779bf5f04f7
/android/app/src/main/java/de/hdm/project/billtracker/fragments/CameraFragment.java
915dae0fbfd2cefe6f5e0a47c86d4be1601ba59c
[ "MIT" ]
permissive
knksknsy/billtracker
https://github.com/knksknsy/billtracker
162feb5c39e6ce4b9f0f69d1d8bd4545a9a3a012
9621b9067658092e8515949c561bd960a92b3b26
refs/heads/master
2021-11-22T22:12:49.142000
2021-11-07T12:30:49
2021-11-07T12:30:49
167,814,186
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package de.hdm.project.billtracker.fragments; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.IntentFilter; import androidx.fragment.app.DialogFragment; import android.content.Intent; import androidx.annotation.Nullable; import androidx.annotation.NonNull; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import android.text.Editable; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.TextureView; import android.view.View; import android.view.ViewGroup; import java.util.Date; import android.content.Context; import android.content.pm.PackageManager; import android.widget.EditText; import android.widget.ImageButton; import android.widget.Toast; import de.hdm.project.billtracker.helpers.CameraPreview; import de.hdm.project.billtracker.helpers.FirebaseDatabaseHelper; import de.hdm.project.billtracker.models.Bill; import de.hdm.project.billtracker.helpers.ImageHelper; import de.hdm.project.billtracker.R; public class CameraFragment extends Fragment { private static final int REQUEST_CAMERA_PERMISSION = 200; public static final int SAVE_DIALOG_FRAGMENT = 1; int dialogStack = 0; private TextureView textureView; private ImageButton photoButton; private ImageButton saveButton; private EditText totalSum; private boolean isSumEmpty; private boolean pictureTaken = false; private ImageHelper imageHelper; private FirebaseDatabaseHelper fDatabaseHelper; private CameraPreview cameraPreview; public static ChartFragment newInstance() { return new ChartFragment(); } private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { /** * Update UI when image has saved picture successfully on device * * @param context * @param intent */ @Override public void onReceive(Context context, Intent intent) { if (getActivity() != null) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { enableSaveButton(true); } }); } } }; @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View inflatedView = inflater.inflate(R.layout.fragment_camera, container, false); if (savedInstanceState != null) { dialogStack = savedInstanceState.getInt("dialog-level"); } fDatabaseHelper = new FirebaseDatabaseHelper(getActivity()); imageHelper = new ImageHelper(getActivity()); textureView = inflatedView.findViewById(R.id.textureView); // Initialize camera preview cameraPreview = new CameraPreview(getActivity(), textureView, imageHelper); textureView.setSurfaceTextureListener(cameraPreview.getTextureListener()); totalSum = inflatedView.findViewById(R.id.totalSum); totalSum.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { isSumEmpty = totalSum.getText().toString().isEmpty(); enableSaveButton(); } }); isSumEmpty = totalSum.getText().toString().isEmpty(); photoButton = inflatedView.findViewById(R.id.photoButton); photoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!pictureTaken) { togglePhotoButtonIcon(true); cameraPreview.capturePicture(); } else { recaptureImage(); imageHelper.deleteTmpImage(); } } }); togglePhotoButtonIcon(false); saveButton = inflatedView.findViewById(R.id.saveButton); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showSaveDialog(SAVE_DIALOG_FRAGMENT); } }); saveButton.setImageResource(R.drawable.ic_save_black_48dp); enableSaveButton(); // Broadcast signaling if image capture in CameraPreview is complete LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver, new IntentFilter("capture-complete-event")); return inflatedView; } /** * Reset states of control elements and reinitialize camera preview */ private void recaptureImage() { togglePhotoButtonIcon(false); enableSaveButton(false); cameraPreview.createCameraPreview(textureView); } /** * Display the CategoryDialogFragment * * @param type */ private void showSaveDialog(int type) { dialogStack++; FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment prev = getFragmentManager().findFragmentByTag("save-dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); switch (type) { case SAVE_DIALOG_FRAGMENT: DialogFragment dialogFrag = CategoryDialogFragment.newInstance(123); dialogFrag.setTargetFragment(this, SAVE_DIALOG_FRAGMENT); dialogFrag.show(getFragmentManager().beginTransaction(), "save-dialog"); break; } } /** * Handle the result of the CategoryDialogFragment * * @param requestCode * @param resultCode * @param data */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case SAVE_DIALOG_FRAGMENT: /** * Create a bill object and upload it to firebase */ if (resultCode == Activity.RESULT_OK) { enableSaveButton(false); togglePhotoButtonIcon(false); String category = data.getStringExtra("category"); String title = data.getStringExtra("title"); prepareAndUploadBill(category, title); cameraPreview.createCameraPreview(textureView); } break; } } /** * Prepares a Bill object and uploads it to firebase * * @param category * @param title */ private void prepareAndUploadBill(String category, String title) { imageHelper.moveToPicturesDir(category); Double sum = Double.parseDouble(totalSum.getText().toString()); totalSum.getText().clear(); Bill bill = new Bill(title, category, new Date().getTime(), sum, imageHelper.getImagePath(), imageHelper.getThumbnailPath()); // Upload bill to firebase fDatabaseHelper.createBill(bill); } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (requestCode == REQUEST_CAMERA_PERMISSION) { if (grantResults[0] == PackageManager.PERMISSION_DENIED) { Toast.makeText(getActivity(), "You can't use this app without granting permission", Toast.LENGTH_SHORT).show(); System.exit(0); } } } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("dialog-level", dialogStack); } /** * Start camera preview thread, reinitialize UI controls and open camera */ @Override public void onResume() { super.onResume(); cameraPreview.startBackgroundThread(); enableSaveButton(false); togglePhotoButtonIcon(false); if (textureView.isAvailable()) { cameraPreview.openCamera(); } else { textureView.setSurfaceTextureListener(cameraPreview.getTextureListener()); } } /** * Close camera and stop camera preview thread */ @Override public void onPause() { cameraPreview.closeCamera(); cameraPreview.stopBackgroundThread(); super.onPause(); } @Override public void onDestroy() { super.onDestroy(); } /** * Set the photo button's icon * * @param state */ private void togglePhotoButtonIcon(boolean state) { photoButton.setImageResource(!state ? R.drawable.ic_photo_camera_black_48dp: R.drawable.ic_refresh_black_48dp); } /** * Set the save button's state * @param pictureTaken */ private void enableSaveButton(boolean pictureTaken) { this.pictureTaken = pictureTaken; boolean enabled = !isSumEmpty && this.pictureTaken; saveButton.setImageResource(enabled ? R.drawable.ic_save_black_48dp : R.drawable.ic_save_white_48dp); saveButton.setEnabled(enabled); } /** * Set the save button's state */ private void enableSaveButton() { boolean enabled = !isSumEmpty && this.pictureTaken; saveButton.setImageResource(enabled ? R.drawable.ic_save_black_48dp : R.drawable.ic_save_white_48dp); saveButton.setEnabled(enabled); } }
UTF-8
Java
10,087
java
CameraFragment.java
Java
[]
null
[]
package de.hdm.project.billtracker.fragments; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.IntentFilter; import androidx.fragment.app.DialogFragment; import android.content.Intent; import androidx.annotation.Nullable; import androidx.annotation.NonNull; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import android.text.Editable; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.TextureView; import android.view.View; import android.view.ViewGroup; import java.util.Date; import android.content.Context; import android.content.pm.PackageManager; import android.widget.EditText; import android.widget.ImageButton; import android.widget.Toast; import de.hdm.project.billtracker.helpers.CameraPreview; import de.hdm.project.billtracker.helpers.FirebaseDatabaseHelper; import de.hdm.project.billtracker.models.Bill; import de.hdm.project.billtracker.helpers.ImageHelper; import de.hdm.project.billtracker.R; public class CameraFragment extends Fragment { private static final int REQUEST_CAMERA_PERMISSION = 200; public static final int SAVE_DIALOG_FRAGMENT = 1; int dialogStack = 0; private TextureView textureView; private ImageButton photoButton; private ImageButton saveButton; private EditText totalSum; private boolean isSumEmpty; private boolean pictureTaken = false; private ImageHelper imageHelper; private FirebaseDatabaseHelper fDatabaseHelper; private CameraPreview cameraPreview; public static ChartFragment newInstance() { return new ChartFragment(); } private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { /** * Update UI when image has saved picture successfully on device * * @param context * @param intent */ @Override public void onReceive(Context context, Intent intent) { if (getActivity() != null) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { enableSaveButton(true); } }); } } }; @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View inflatedView = inflater.inflate(R.layout.fragment_camera, container, false); if (savedInstanceState != null) { dialogStack = savedInstanceState.getInt("dialog-level"); } fDatabaseHelper = new FirebaseDatabaseHelper(getActivity()); imageHelper = new ImageHelper(getActivity()); textureView = inflatedView.findViewById(R.id.textureView); // Initialize camera preview cameraPreview = new CameraPreview(getActivity(), textureView, imageHelper); textureView.setSurfaceTextureListener(cameraPreview.getTextureListener()); totalSum = inflatedView.findViewById(R.id.totalSum); totalSum.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { isSumEmpty = totalSum.getText().toString().isEmpty(); enableSaveButton(); } }); isSumEmpty = totalSum.getText().toString().isEmpty(); photoButton = inflatedView.findViewById(R.id.photoButton); photoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!pictureTaken) { togglePhotoButtonIcon(true); cameraPreview.capturePicture(); } else { recaptureImage(); imageHelper.deleteTmpImage(); } } }); togglePhotoButtonIcon(false); saveButton = inflatedView.findViewById(R.id.saveButton); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showSaveDialog(SAVE_DIALOG_FRAGMENT); } }); saveButton.setImageResource(R.drawable.ic_save_black_48dp); enableSaveButton(); // Broadcast signaling if image capture in CameraPreview is complete LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver, new IntentFilter("capture-complete-event")); return inflatedView; } /** * Reset states of control elements and reinitialize camera preview */ private void recaptureImage() { togglePhotoButtonIcon(false); enableSaveButton(false); cameraPreview.createCameraPreview(textureView); } /** * Display the CategoryDialogFragment * * @param type */ private void showSaveDialog(int type) { dialogStack++; FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment prev = getFragmentManager().findFragmentByTag("save-dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); switch (type) { case SAVE_DIALOG_FRAGMENT: DialogFragment dialogFrag = CategoryDialogFragment.newInstance(123); dialogFrag.setTargetFragment(this, SAVE_DIALOG_FRAGMENT); dialogFrag.show(getFragmentManager().beginTransaction(), "save-dialog"); break; } } /** * Handle the result of the CategoryDialogFragment * * @param requestCode * @param resultCode * @param data */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case SAVE_DIALOG_FRAGMENT: /** * Create a bill object and upload it to firebase */ if (resultCode == Activity.RESULT_OK) { enableSaveButton(false); togglePhotoButtonIcon(false); String category = data.getStringExtra("category"); String title = data.getStringExtra("title"); prepareAndUploadBill(category, title); cameraPreview.createCameraPreview(textureView); } break; } } /** * Prepares a Bill object and uploads it to firebase * * @param category * @param title */ private void prepareAndUploadBill(String category, String title) { imageHelper.moveToPicturesDir(category); Double sum = Double.parseDouble(totalSum.getText().toString()); totalSum.getText().clear(); Bill bill = new Bill(title, category, new Date().getTime(), sum, imageHelper.getImagePath(), imageHelper.getThumbnailPath()); // Upload bill to firebase fDatabaseHelper.createBill(bill); } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (requestCode == REQUEST_CAMERA_PERMISSION) { if (grantResults[0] == PackageManager.PERMISSION_DENIED) { Toast.makeText(getActivity(), "You can't use this app without granting permission", Toast.LENGTH_SHORT).show(); System.exit(0); } } } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("dialog-level", dialogStack); } /** * Start camera preview thread, reinitialize UI controls and open camera */ @Override public void onResume() { super.onResume(); cameraPreview.startBackgroundThread(); enableSaveButton(false); togglePhotoButtonIcon(false); if (textureView.isAvailable()) { cameraPreview.openCamera(); } else { textureView.setSurfaceTextureListener(cameraPreview.getTextureListener()); } } /** * Close camera and stop camera preview thread */ @Override public void onPause() { cameraPreview.closeCamera(); cameraPreview.stopBackgroundThread(); super.onPause(); } @Override public void onDestroy() { super.onDestroy(); } /** * Set the photo button's icon * * @param state */ private void togglePhotoButtonIcon(boolean state) { photoButton.setImageResource(!state ? R.drawable.ic_photo_camera_black_48dp: R.drawable.ic_refresh_black_48dp); } /** * Set the save button's state * @param pictureTaken */ private void enableSaveButton(boolean pictureTaken) { this.pictureTaken = pictureTaken; boolean enabled = !isSumEmpty && this.pictureTaken; saveButton.setImageResource(enabled ? R.drawable.ic_save_black_48dp : R.drawable.ic_save_white_48dp); saveButton.setEnabled(enabled); } /** * Set the save button's state */ private void enableSaveButton() { boolean enabled = !isSumEmpty && this.pictureTaken; saveButton.setImageResource(enabled ? R.drawable.ic_save_black_48dp : R.drawable.ic_save_white_48dp); saveButton.setEnabled(enabled); } }
10,087
0.636958
0.634183
315
31.022223
27.645422
133
false
false
0
0
0
0
0
0
0.492063
false
false
10
cfa86dd621000f34139c5e75aee46e3652164c9d
27,075,473,834,037
a669b834682036402aed954287924c3af689d546
/src/gui/ToolBox.java
99c67f629f147d32c21b752a80ec78ec7e3ac51f
[]
no_license
neo-take-lucy/leveleditor
https://github.com/neo-take-lucy/leveleditor
932cdc869039ee5f0249599d8ed29e607e3d1aee
a614ccd1dc53bc1c1bbb157241c405146a913d3e
refs/heads/master
2023-07-30T03:54:01.320000
2021-09-21T14:39:29
2021-09-21T14:39:29
402,454,447
1
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package gui; import composition.BrushType; import files.FileManager; import handler.TerminalHandler; import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.io.File; /** * Toolbox is used to create and model the selection of entities on the side of the screen. Yeah, this * class is pretty poorly written. Probably a better method would be to store the buttons as lists of my own * object class and that way they can be passed to a single constructor to make each pane but... this thing * is due in like a week. */ public class ToolBox extends JPanel { private final int BUTTON_SIZE = 64; private final float BUTTON_SCALE = 0.63f; private final int GRID_WIDTH = 4; private JPanel configPanel; private ActionListener configListener; private JPanel terrainPanel; private ActionListener brushListener; private JPanel activePanel; private JPanel zoomPanel; private TerminalHandler handler; private BufferedImage spriteSheet; private GridLayout grid; private GridBagConstraints c; //this.setLayout(grid); public ToolBox(TerminalHandler handler) { super(); this.handler = handler; initMainPanel(); initIcons(); } private void initIcons() { try { spriteSheet = ImageIO.read(new File("source/core/assets/configs/ragEditAssets/spritesheet.png")); } catch (Exception e) { System.err.print("Couldn't load spritesheet. Check: in configs/ragEditAssets/spritesheet.png\n"); } // Initialses the SubSpr icons of the ConfigButtons for (ConfigButtons cB : ConfigButtons.values()) { SubSpr sS = cB.getSubSprite(); int x = sS.x; int y = sS.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE * BUTTON_SCALE), (int) (BUTTON_SIZE * BUTTON_SCALE), Image.SCALE_FAST); Icon buttonIcon = new ImageIcon(sprite); cB.getButton().setIcon(buttonIcon); cB.getButton().setBorderPainted(false); } for (BrushButtons bB : BrushButtons.values()) { SubSpr sS = bB.getSubSprite(); int x = sS.x; int y = sS.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE * BUTTON_SCALE), (int) (BUTTON_SIZE * BUTTON_SCALE), Image.SCALE_FAST); Icon buttonIcon = new ImageIcon(sprite); bB.getButton().setIcon(buttonIcon); bB.getButton().setBorderPainted(false); } for (ActiveEntityButtons aB : ActiveEntityButtons.values()) { SubSpr sS = aB.getSubSprite(); int x = sS.x; int y = sS.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE * BUTTON_SCALE), (int) (BUTTON_SIZE * BUTTON_SCALE), Image.SCALE_FAST); Icon buttonIcon = new ImageIcon(sprite); aB.getButton().setIcon(buttonIcon); aB.getButton().setBorderPainted(false); //subSprites.put(cT, sprite); } for (ZoomScrollButtons zB : ZoomScrollButtons.values()) { SubSpr sS = zB.getSubSprite(); int x = sS.x; int y = sS.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE * BUTTON_SCALE), (int) (BUTTON_SIZE * BUTTON_SCALE), Image.SCALE_FAST); Icon buttonIcon = new ImageIcon(sprite); zB.getButton().setIcon(buttonIcon); zB.getButton().setBorderPainted(false); } } private void initMainPanel() { grid = new GridLayout(4, 0); this.setLayout(grid); c = new GridBagConstraints(); configPanel = initConfigPanel(); terrainPanel = initTerrainPanel(); activePanel = initActiveEntityPanel(); zoomPanel = initZoomPanel(); Color bg = new Color(16774076); configPanel.setBackground(bg); terrainPanel.setBackground(bg); activePanel.setBackground(bg); zoomPanel.setBackground(bg); c.fill = GridBagConstraints.NONE; this.add(configPanel, c); this.add(terrainPanel, c); this.add(activePanel, c); this.add(zoomPanel, c); } private JPanel initConfigPanel() { // buttons: (3 x 2) // new, save, load, // undo, redo configPanel = new JPanel(new GridBagLayout()); configPanel.setPreferredSize(new Dimension(BUTTON_SIZE * 2, BUTTON_SIZE * 3)); GridBagConstraints c = new GridBagConstraints(); //Make the Label c.fill = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 0; c.gridwidth = GRID_WIDTH; c.gridheight = 1; configPanel.add(new JLabel("Configure"), c); // The config panel gets the action command and then switches to determine which dialog to // open configListener = new ActionListener() { public void actionPerformed(ActionEvent e) { //handler.parseString(e.getActionCommand()); switch (e.getActionCommand()) { case ">new": String newArguments = getNewDialog(); handler.parseString("new " + newArguments); break; case ">save": //open save dialog String file = getSaveDialog(); if (file.equals("")) { break; } else { handler.parseString("save " + file); } break; case ">load": // open load dialog file = getLoadDialog(); if (file.equals("")) break; handler.parseString("load " + file); break; case ">undo": // parse "u" handler.parseString("u"); break; case ">redo": handler.parseString("r"); break; // parse "r" case ">toggleterm": handler.parseString("toggleterm"); break; case ">world": String world = getWorldDialog(); if (world.equals("")) break; handler.parseString("world " + world); break; } } }; c.gridwidth = 1; c.gridheight = 1; //Make the Buttons and Put Them In int i = GRID_WIDTH; for (ConfigButtons b : ConfigButtons.values()) { int y = i / GRID_WIDTH; int x = i % GRID_WIDTH; //System.out.printf("%s: grid x %d grid y %d\n", b.toString(), x, y); //b.getButton().setText(b.toString()); b.getButton().addActionListener(configListener); b.getButton().setActionCommand(b.getSetting()); b.getButton().setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE)); //c.fill = GridBagConstraints.CENTER c.gridx = x; c.gridy = y; configPanel.add(b.getButton(), c); i++; } return configPanel; } private JPanel initTerrainPanel() { // buttons: // eraser, floor, platform // rocks, spikes terrainPanel = new JPanel(new GridBagLayout()); terrainPanel.setMaximumSize(new Dimension(BUTTON_SIZE * 3, BUTTON_SIZE * 3)); GridBagConstraints c = new GridBagConstraints(); //Make the Label c.fill = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 0; c.gridwidth = GRID_WIDTH; c.gridheight = 1; terrainPanel.add(new JLabel("Terrain Brushes"), c); // Makes the action listener, the actionCommand is set in the Loop below // actionCommand takes the Enum "brushSetting" and then parses it to handler brushListener = new ActionListener() { public void actionPerformed(ActionEvent e) { handler.parseString(e.getActionCommand()); } }; c.gridwidth = 1; c.gridheight = 1; //Make the Buttons and Put Them In int i = GRID_WIDTH; for (BrushButtons b : BrushButtons.values()) { int y = i / GRID_WIDTH; int x = i % GRID_WIDTH; //System.out.printf("%s: grid x %d grid y %d\n", b.toString(), x, y); //b.getButton().setText(b.toString()); b.getButton().addActionListener(brushListener); b.getButton().setActionCommand(b.getSetting()); b.getButton().setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE)); //c.fill = GridBagConstraints.CENTER c.gridx = x; c.gridy = y; terrainPanel.add(b.getButton(), c); i++; } return terrainPanel; } private JPanel initActiveEntityPanel() { // buttons: // delete, wolf, skeleton activePanel = new JPanel(new GridBagLayout()); activePanel.setPreferredSize(new Dimension(BUTTON_SIZE * 3, BUTTON_SIZE * 3)); GridBagConstraints c = new GridBagConstraints(); //Make the Label c.fill = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 0; c.gridwidth = GRID_WIDTH; c.gridheight = 1; activePanel.add(new JLabel("Enemies and Power Ups"), c); c.gridwidth = 1; c.gridheight = 1; //Make the Buttons and Put Them In int i = GRID_WIDTH; for (ActiveEntityButtons b : ActiveEntityButtons.values()) { int y = i / GRID_WIDTH; int x = i % GRID_WIDTH; //b.getButton().setText(b.toString()); b.getButton().addActionListener(brushListener); b.getButton().setActionCommand(b.getSetting()); b.getButton().setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE)); //c.fill = GridBagConstraints.CENTER c.gridx = x; c.gridy = y; activePanel.add(b.getButton(), c); i++; } return activePanel; } private JPanel initZoomPanel() { zoomPanel = new JPanel(new GridBagLayout()); zoomPanel.setPreferredSize(new Dimension(BUTTON_SIZE * 3, BUTTON_SIZE * 2)); GridBagConstraints c = new GridBagConstraints(); //Make the Label c.fill = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 0; c.gridwidth = 3; c.gridheight = 1; zoomPanel.add(new JLabel("Zoom / Scroll"), c); c.gridwidth = 1; c.gridheight = 1; //Make the Buttons and Put Them In int i = GRID_WIDTH; for (ZoomScrollButtons b : ZoomScrollButtons.values()) { int y = i / GRID_WIDTH; int x = i % GRID_WIDTH; //b.getButton().setText(b.toString()); b.getButton().addActionListener(brushListener); b.getButton().setActionCommand(b.getSetting()); b.getButton().setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE)); //c.fill = GridBagConstraints.CENTER c.gridx = x; c.gridy = y; zoomPanel.add(b.getButton(), c); i++; } return zoomPanel; } private String getLoadDialog() { int x = SubSpr.LOAD.x; int y = SubSpr.LOAD.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE), (int) (BUTTON_SIZE), Image.SCALE_FAST); Icon icon = new ImageIcon(sprite); Object[] files = FileManager.getRags().toArray(); String file = (String) JOptionPane.showInputDialog(this, "Select .rag to Load", "Load .rag", JOptionPane.PLAIN_MESSAGE, icon, files, ""); return file; } private String getWorldDialog() { int x = SubSpr.RESET_ZOOM.x; // change dis int y = SubSpr.RESET_ZOOM.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE), (int) (BUTTON_SIZE), Image.SCALE_FAST); Icon icon = new ImageIcon(sprite); Object[] worlds = FileManager.getRawWorlds().toArray(); String world = (String) JOptionPane.showInputDialog(this, "Select World Type", "Select World Type", JOptionPane.PLAIN_MESSAGE, icon, worlds, ""); return world; } private String getSaveDialog() { int x = SubSpr.SAVE.x; int y = SubSpr.SAVE.y; String file = ""; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE), (int) (BUTTON_SIZE), Image.SCALE_FAST); Icon icon = new ImageIcon(sprite); //Object[] files = FileManager.getRags().toArray(); String firstFile = (String) JOptionPane.showInputDialog(this, "Save .rag as", "Save .rag", JOptionPane.PLAIN_MESSAGE, icon, null, ""); if (firstFile.equals("")) return ""; if (FileManager.isSaveFileInRags(firstFile)) { String s = String.format("%s.rag already in rag directory, would you like to override?\n" , firstFile); int confirm = (int) JOptionPane.showConfirmDialog(this, s, "Confirm save Override", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, icon); // confirm = 0 , YES // confirm = 1, NO if (confirm == 1) return ""; } file = firstFile; return file; } private String getNewDialog() { JTextField title = new JTextField(); JTextField width = new JTextField(); JTextField height = new JTextField(); JComponent[] inputs = { new JLabel("Title:"), title, new JLabel("Width:"), width, new JLabel("Height:"), height, }; int x = SubSpr.NEW.x; int y = SubSpr.NEW.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE), (int) (BUTTON_SIZE), Image.SCALE_FAST); Icon icon = new ImageIcon(sprite); JOptionPane.showMessageDialog(this, inputs, "Make New .rag", JOptionPane.INFORMATION_MESSAGE, icon); try { Integer.parseInt(width.getText()); Integer.parseInt(height.getText()); } catch (NumberFormatException e) { System.err.printf("\nProvided invalid numbers to width or height while making New in Gui\n"); JOptionPane.showMessageDialog(this, "Width or Height is not an Integer", "Error making New", JOptionPane.INFORMATION_MESSAGE, icon); } return String.format("%s [%s,%s]", title.getText(), width.getText(), height.getText()); } } /** * Enum representing the Configuration Buttons */ enum ConfigButtons { // in the () can make icon // maybe also save values relating to the coordinates in this? NEW(">new", SubSpr.NEW), // sets brush to null SAVE(">save", SubSpr.SAVE), LOAD(">load", SubSpr.LOAD), TOGGLE_TERM(">toggleterm", SubSpr.TOGGLE_TERM), UNDO(">undo", SubSpr.UNDO), REDO(">redo", SubSpr.REDO), CHANGE_WORLD(">world", SubSpr.RESET_ZOOM); private JButton butt; private String setting; private SubSpr subSprite; ConfigButtons(String configSetting, SubSpr ss) { butt = new JButton(); setting = configSetting; subSprite = ss; } public JButton getButton() { return butt; } public String getSetting() { return setting; } public SubSpr getSubSprite() { return subSprite; } } /** * Enum representing the Brush (Terrain Tile) Buttons */ enum BrushButtons { // in the () can make icon // maybe also save values relating to the coordinates in this? ERASER(BrushType.ERASER), // sets brush to null FLOOR(BrushType.FLOOR), PLATFORM(BrushType.PLATFORM), ROCKS(BrushType.ROCKS), SPIKES(BrushType.SPIKES); private JButton butt; private String setting; private SubSpr subSprite; BrushButtons(BrushType brushType) { butt = new JButton(); setting = brushType.brush; subSprite = brushType.subSpr; } public JButton getButton() { return butt; } public String getSetting() { return setting; } public SubSpr getSubSprite() { return subSprite; } } /** * Enum representing the ActiveEntity (Active/PowerUp) Buttons */ enum ActiveEntityButtons { // in the () can make icon // maybe also save values relating to the coordinates in this? DELETE(BrushType.DELETE), DELETE_POW(BrushType.DELETE_POW), SKELETON(BrushType.SKELETON), WOLF(BrushType.WOLF), FIRE_SPIRIT(BrushType.FIRE_SPIRIT), LIGHTNING(BrushType.LIGHTNING), SPEAR(BrushType.SPEAR), SHIELD(BrushType.SHIELD); private JButton butt; private String setting; private SubSpr subSprite; ActiveEntityButtons(BrushType brushType) { butt = new JButton(); setting = brushType.brush; subSprite = brushType.subSpr; } public JButton getButton() { return butt; } public String getSetting() { return setting; } public SubSpr getSubSprite() { return subSprite; } } /** * Enum representing the Zoom/Scroll Buttons */ enum ZoomScrollButtons { // in the () can make icon // maybe also save values relating to the coordinates in this? ARROW_LEFT("con_o -100 0", SubSpr.ARROW_LEFT), ARROW_RIGHT("con_o 100 0", SubSpr.ARROW_RIGHT), ARROW_UP("con_o 0 -100", SubSpr.ARROW_UP), ARROW_DOWN("con_o 0 100", SubSpr.ARROW_DOWN), ZOOM_IN("con_z 10", SubSpr.ZOOM_IN), ZOOM_OUT("con_z -10", SubSpr.ZOOM_OUT); private JButton butt; private String setting; private SubSpr subSprite; ZoomScrollButtons(String brushSetting, SubSpr ss) { butt = new JButton(); setting = brushSetting; subSprite = ss; } public JButton getButton() { return butt; } public String getSetting() { return setting; } public SubSpr getSubSprite() { return subSprite; } }
UTF-8
Java
19,369
java
ToolBox.java
Java
[]
null
[]
package gui; import composition.BrushType; import files.FileManager; import handler.TerminalHandler; import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.io.File; /** * Toolbox is used to create and model the selection of entities on the side of the screen. Yeah, this * class is pretty poorly written. Probably a better method would be to store the buttons as lists of my own * object class and that way they can be passed to a single constructor to make each pane but... this thing * is due in like a week. */ public class ToolBox extends JPanel { private final int BUTTON_SIZE = 64; private final float BUTTON_SCALE = 0.63f; private final int GRID_WIDTH = 4; private JPanel configPanel; private ActionListener configListener; private JPanel terrainPanel; private ActionListener brushListener; private JPanel activePanel; private JPanel zoomPanel; private TerminalHandler handler; private BufferedImage spriteSheet; private GridLayout grid; private GridBagConstraints c; //this.setLayout(grid); public ToolBox(TerminalHandler handler) { super(); this.handler = handler; initMainPanel(); initIcons(); } private void initIcons() { try { spriteSheet = ImageIO.read(new File("source/core/assets/configs/ragEditAssets/spritesheet.png")); } catch (Exception e) { System.err.print("Couldn't load spritesheet. Check: in configs/ragEditAssets/spritesheet.png\n"); } // Initialses the SubSpr icons of the ConfigButtons for (ConfigButtons cB : ConfigButtons.values()) { SubSpr sS = cB.getSubSprite(); int x = sS.x; int y = sS.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE * BUTTON_SCALE), (int) (BUTTON_SIZE * BUTTON_SCALE), Image.SCALE_FAST); Icon buttonIcon = new ImageIcon(sprite); cB.getButton().setIcon(buttonIcon); cB.getButton().setBorderPainted(false); } for (BrushButtons bB : BrushButtons.values()) { SubSpr sS = bB.getSubSprite(); int x = sS.x; int y = sS.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE * BUTTON_SCALE), (int) (BUTTON_SIZE * BUTTON_SCALE), Image.SCALE_FAST); Icon buttonIcon = new ImageIcon(sprite); bB.getButton().setIcon(buttonIcon); bB.getButton().setBorderPainted(false); } for (ActiveEntityButtons aB : ActiveEntityButtons.values()) { SubSpr sS = aB.getSubSprite(); int x = sS.x; int y = sS.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE * BUTTON_SCALE), (int) (BUTTON_SIZE * BUTTON_SCALE), Image.SCALE_FAST); Icon buttonIcon = new ImageIcon(sprite); aB.getButton().setIcon(buttonIcon); aB.getButton().setBorderPainted(false); //subSprites.put(cT, sprite); } for (ZoomScrollButtons zB : ZoomScrollButtons.values()) { SubSpr sS = zB.getSubSprite(); int x = sS.x; int y = sS.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE * BUTTON_SCALE), (int) (BUTTON_SIZE * BUTTON_SCALE), Image.SCALE_FAST); Icon buttonIcon = new ImageIcon(sprite); zB.getButton().setIcon(buttonIcon); zB.getButton().setBorderPainted(false); } } private void initMainPanel() { grid = new GridLayout(4, 0); this.setLayout(grid); c = new GridBagConstraints(); configPanel = initConfigPanel(); terrainPanel = initTerrainPanel(); activePanel = initActiveEntityPanel(); zoomPanel = initZoomPanel(); Color bg = new Color(16774076); configPanel.setBackground(bg); terrainPanel.setBackground(bg); activePanel.setBackground(bg); zoomPanel.setBackground(bg); c.fill = GridBagConstraints.NONE; this.add(configPanel, c); this.add(terrainPanel, c); this.add(activePanel, c); this.add(zoomPanel, c); } private JPanel initConfigPanel() { // buttons: (3 x 2) // new, save, load, // undo, redo configPanel = new JPanel(new GridBagLayout()); configPanel.setPreferredSize(new Dimension(BUTTON_SIZE * 2, BUTTON_SIZE * 3)); GridBagConstraints c = new GridBagConstraints(); //Make the Label c.fill = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 0; c.gridwidth = GRID_WIDTH; c.gridheight = 1; configPanel.add(new JLabel("Configure"), c); // The config panel gets the action command and then switches to determine which dialog to // open configListener = new ActionListener() { public void actionPerformed(ActionEvent e) { //handler.parseString(e.getActionCommand()); switch (e.getActionCommand()) { case ">new": String newArguments = getNewDialog(); handler.parseString("new " + newArguments); break; case ">save": //open save dialog String file = getSaveDialog(); if (file.equals("")) { break; } else { handler.parseString("save " + file); } break; case ">load": // open load dialog file = getLoadDialog(); if (file.equals("")) break; handler.parseString("load " + file); break; case ">undo": // parse "u" handler.parseString("u"); break; case ">redo": handler.parseString("r"); break; // parse "r" case ">toggleterm": handler.parseString("toggleterm"); break; case ">world": String world = getWorldDialog(); if (world.equals("")) break; handler.parseString("world " + world); break; } } }; c.gridwidth = 1; c.gridheight = 1; //Make the Buttons and Put Them In int i = GRID_WIDTH; for (ConfigButtons b : ConfigButtons.values()) { int y = i / GRID_WIDTH; int x = i % GRID_WIDTH; //System.out.printf("%s: grid x %d grid y %d\n", b.toString(), x, y); //b.getButton().setText(b.toString()); b.getButton().addActionListener(configListener); b.getButton().setActionCommand(b.getSetting()); b.getButton().setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE)); //c.fill = GridBagConstraints.CENTER c.gridx = x; c.gridy = y; configPanel.add(b.getButton(), c); i++; } return configPanel; } private JPanel initTerrainPanel() { // buttons: // eraser, floor, platform // rocks, spikes terrainPanel = new JPanel(new GridBagLayout()); terrainPanel.setMaximumSize(new Dimension(BUTTON_SIZE * 3, BUTTON_SIZE * 3)); GridBagConstraints c = new GridBagConstraints(); //Make the Label c.fill = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 0; c.gridwidth = GRID_WIDTH; c.gridheight = 1; terrainPanel.add(new JLabel("Terrain Brushes"), c); // Makes the action listener, the actionCommand is set in the Loop below // actionCommand takes the Enum "brushSetting" and then parses it to handler brushListener = new ActionListener() { public void actionPerformed(ActionEvent e) { handler.parseString(e.getActionCommand()); } }; c.gridwidth = 1; c.gridheight = 1; //Make the Buttons and Put Them In int i = GRID_WIDTH; for (BrushButtons b : BrushButtons.values()) { int y = i / GRID_WIDTH; int x = i % GRID_WIDTH; //System.out.printf("%s: grid x %d grid y %d\n", b.toString(), x, y); //b.getButton().setText(b.toString()); b.getButton().addActionListener(brushListener); b.getButton().setActionCommand(b.getSetting()); b.getButton().setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE)); //c.fill = GridBagConstraints.CENTER c.gridx = x; c.gridy = y; terrainPanel.add(b.getButton(), c); i++; } return terrainPanel; } private JPanel initActiveEntityPanel() { // buttons: // delete, wolf, skeleton activePanel = new JPanel(new GridBagLayout()); activePanel.setPreferredSize(new Dimension(BUTTON_SIZE * 3, BUTTON_SIZE * 3)); GridBagConstraints c = new GridBagConstraints(); //Make the Label c.fill = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 0; c.gridwidth = GRID_WIDTH; c.gridheight = 1; activePanel.add(new JLabel("Enemies and Power Ups"), c); c.gridwidth = 1; c.gridheight = 1; //Make the Buttons and Put Them In int i = GRID_WIDTH; for (ActiveEntityButtons b : ActiveEntityButtons.values()) { int y = i / GRID_WIDTH; int x = i % GRID_WIDTH; //b.getButton().setText(b.toString()); b.getButton().addActionListener(brushListener); b.getButton().setActionCommand(b.getSetting()); b.getButton().setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE)); //c.fill = GridBagConstraints.CENTER c.gridx = x; c.gridy = y; activePanel.add(b.getButton(), c); i++; } return activePanel; } private JPanel initZoomPanel() { zoomPanel = new JPanel(new GridBagLayout()); zoomPanel.setPreferredSize(new Dimension(BUTTON_SIZE * 3, BUTTON_SIZE * 2)); GridBagConstraints c = new GridBagConstraints(); //Make the Label c.fill = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 0; c.gridwidth = 3; c.gridheight = 1; zoomPanel.add(new JLabel("Zoom / Scroll"), c); c.gridwidth = 1; c.gridheight = 1; //Make the Buttons and Put Them In int i = GRID_WIDTH; for (ZoomScrollButtons b : ZoomScrollButtons.values()) { int y = i / GRID_WIDTH; int x = i % GRID_WIDTH; //b.getButton().setText(b.toString()); b.getButton().addActionListener(brushListener); b.getButton().setActionCommand(b.getSetting()); b.getButton().setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE)); //c.fill = GridBagConstraints.CENTER c.gridx = x; c.gridy = y; zoomPanel.add(b.getButton(), c); i++; } return zoomPanel; } private String getLoadDialog() { int x = SubSpr.LOAD.x; int y = SubSpr.LOAD.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE), (int) (BUTTON_SIZE), Image.SCALE_FAST); Icon icon = new ImageIcon(sprite); Object[] files = FileManager.getRags().toArray(); String file = (String) JOptionPane.showInputDialog(this, "Select .rag to Load", "Load .rag", JOptionPane.PLAIN_MESSAGE, icon, files, ""); return file; } private String getWorldDialog() { int x = SubSpr.RESET_ZOOM.x; // change dis int y = SubSpr.RESET_ZOOM.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE), (int) (BUTTON_SIZE), Image.SCALE_FAST); Icon icon = new ImageIcon(sprite); Object[] worlds = FileManager.getRawWorlds().toArray(); String world = (String) JOptionPane.showInputDialog(this, "Select World Type", "Select World Type", JOptionPane.PLAIN_MESSAGE, icon, worlds, ""); return world; } private String getSaveDialog() { int x = SubSpr.SAVE.x; int y = SubSpr.SAVE.y; String file = ""; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE), (int) (BUTTON_SIZE), Image.SCALE_FAST); Icon icon = new ImageIcon(sprite); //Object[] files = FileManager.getRags().toArray(); String firstFile = (String) JOptionPane.showInputDialog(this, "Save .rag as", "Save .rag", JOptionPane.PLAIN_MESSAGE, icon, null, ""); if (firstFile.equals("")) return ""; if (FileManager.isSaveFileInRags(firstFile)) { String s = String.format("%s.rag already in rag directory, would you like to override?\n" , firstFile); int confirm = (int) JOptionPane.showConfirmDialog(this, s, "Confirm save Override", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, icon); // confirm = 0 , YES // confirm = 1, NO if (confirm == 1) return ""; } file = firstFile; return file; } private String getNewDialog() { JTextField title = new JTextField(); JTextField width = new JTextField(); JTextField height = new JTextField(); JComponent[] inputs = { new JLabel("Title:"), title, new JLabel("Width:"), width, new JLabel("Height:"), height, }; int x = SubSpr.NEW.x; int y = SubSpr.NEW.y; Image sprite = spriteSheet.getSubimage(x, y, 8, 8) .getScaledInstance((int) (BUTTON_SIZE), (int) (BUTTON_SIZE), Image.SCALE_FAST); Icon icon = new ImageIcon(sprite); JOptionPane.showMessageDialog(this, inputs, "Make New .rag", JOptionPane.INFORMATION_MESSAGE, icon); try { Integer.parseInt(width.getText()); Integer.parseInt(height.getText()); } catch (NumberFormatException e) { System.err.printf("\nProvided invalid numbers to width or height while making New in Gui\n"); JOptionPane.showMessageDialog(this, "Width or Height is not an Integer", "Error making New", JOptionPane.INFORMATION_MESSAGE, icon); } return String.format("%s [%s,%s]", title.getText(), width.getText(), height.getText()); } } /** * Enum representing the Configuration Buttons */ enum ConfigButtons { // in the () can make icon // maybe also save values relating to the coordinates in this? NEW(">new", SubSpr.NEW), // sets brush to null SAVE(">save", SubSpr.SAVE), LOAD(">load", SubSpr.LOAD), TOGGLE_TERM(">toggleterm", SubSpr.TOGGLE_TERM), UNDO(">undo", SubSpr.UNDO), REDO(">redo", SubSpr.REDO), CHANGE_WORLD(">world", SubSpr.RESET_ZOOM); private JButton butt; private String setting; private SubSpr subSprite; ConfigButtons(String configSetting, SubSpr ss) { butt = new JButton(); setting = configSetting; subSprite = ss; } public JButton getButton() { return butt; } public String getSetting() { return setting; } public SubSpr getSubSprite() { return subSprite; } } /** * Enum representing the Brush (Terrain Tile) Buttons */ enum BrushButtons { // in the () can make icon // maybe also save values relating to the coordinates in this? ERASER(BrushType.ERASER), // sets brush to null FLOOR(BrushType.FLOOR), PLATFORM(BrushType.PLATFORM), ROCKS(BrushType.ROCKS), SPIKES(BrushType.SPIKES); private JButton butt; private String setting; private SubSpr subSprite; BrushButtons(BrushType brushType) { butt = new JButton(); setting = brushType.brush; subSprite = brushType.subSpr; } public JButton getButton() { return butt; } public String getSetting() { return setting; } public SubSpr getSubSprite() { return subSprite; } } /** * Enum representing the ActiveEntity (Active/PowerUp) Buttons */ enum ActiveEntityButtons { // in the () can make icon // maybe also save values relating to the coordinates in this? DELETE(BrushType.DELETE), DELETE_POW(BrushType.DELETE_POW), SKELETON(BrushType.SKELETON), WOLF(BrushType.WOLF), FIRE_SPIRIT(BrushType.FIRE_SPIRIT), LIGHTNING(BrushType.LIGHTNING), SPEAR(BrushType.SPEAR), SHIELD(BrushType.SHIELD); private JButton butt; private String setting; private SubSpr subSprite; ActiveEntityButtons(BrushType brushType) { butt = new JButton(); setting = brushType.brush; subSprite = brushType.subSpr; } public JButton getButton() { return butt; } public String getSetting() { return setting; } public SubSpr getSubSprite() { return subSprite; } } /** * Enum representing the Zoom/Scroll Buttons */ enum ZoomScrollButtons { // in the () can make icon // maybe also save values relating to the coordinates in this? ARROW_LEFT("con_o -100 0", SubSpr.ARROW_LEFT), ARROW_RIGHT("con_o 100 0", SubSpr.ARROW_RIGHT), ARROW_UP("con_o 0 -100", SubSpr.ARROW_UP), ARROW_DOWN("con_o 0 100", SubSpr.ARROW_DOWN), ZOOM_IN("con_z 10", SubSpr.ZOOM_IN), ZOOM_OUT("con_z -10", SubSpr.ZOOM_OUT); private JButton butt; private String setting; private SubSpr subSprite; ZoomScrollButtons(String brushSetting, SubSpr ss) { butt = new JButton(); setting = brushSetting; subSprite = ss; } public JButton getButton() { return butt; } public String getSetting() { return setting; } public SubSpr getSubSprite() { return subSprite; } }
19,369
0.555114
0.550674
677
27.610044
24.618658
115
false
false
0
0
0
0
0
0
0.646972
false
false
10
1006b5deb33db50903c45f1121578762c4138692
19,370,302,560,855
f87df61ff9873ac9f4d496fbdb725eb9edfc100d
/app/src/main/java/com/mediatek/mtklogger/taglog/db/TaglogTable.java
9d598357773a8631e35ea5f77aa657cabf939cea
[]
no_license
YCole/Alog
https://github.com/YCole/Alog
24124312aaa2026c41e04cdb17a9c0b33c37bf06
6574f942d25196a25e78e9fc572e69fcda983dd2
refs/heads/master
2020-03-23T10:09:31.124000
2018-07-18T11:55:46
2018-07-18T11:55:46
141,428,343
1
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.mediatek.mtklogger.taglog.db; import android.os.Parcel; import android.os.Parcelable; /** * This class is used to record owner info. */ public class TaglogTable implements Parcelable { private int mTaglogId; private String mTargetfolder; private String mState; private String mFileList; private String mDBPath; private String mDBFileName; private String mDBZZFileName; private String mIsNeedZip; private String mIsNeedAllLogs; private int mNeedlogType; private String mReason; private String mFromWhere; private String mZzInternalTime; /**. * TaglogTable */ public TaglogTable(){ } /** * @param id int * @param targetFolder String * @param state String * @param filelist String * @param dbPath String * @param dbfileName String * @param zzFileName String * @param isneedzip String * @param isneedalllogs String * @param needlogtype String * @param reason String * @param fromwhere String * @param expTime String */ public TaglogTable(int id, String targetFolder, String state, String filelist , String dbPath, String dbfileName, String zzFileName, String isneedzip, String isneedalllogs, int needlogtype, String reason, String fromwhere, String expTime) { super(); this.mTaglogId = id; this.mTargetfolder = targetFolder; this.mState = state; this.mFileList = filelist; this.mDBPath = dbPath; this.mDBFileName = dbfileName; this.mDBZZFileName = zzFileName; this.mIsNeedZip = isneedzip; this.mIsNeedAllLogs = isneedalllogs; this.mNeedlogType = needlogtype; this.mReason = reason; this.mFromWhere = fromwhere; this.mZzInternalTime = expTime; } @Override public String toString() { return " id:" + mTaglogId + ", mTargetfolder:" + mTargetfolder + ", mState:" + mState + ", mFileList:" + mFileList + ", mDBPath:" + mDBPath + ", mDBFileName:" + mDBFileName + ", mDBZZFileName:" + mDBZZFileName + ", mIsNeedZip:" + mIsNeedZip + ", mIsNeedAllLogs:" + mIsNeedAllLogs + ", mNeedlogType:" + mNeedlogType + ", mReason:" + mReason + ", mFromWhere:" + mFromWhere + ", mExpTime: " + mZzInternalTime; } public int getTagLogId() { return mTaglogId; } public void setTagLogId(int id) { this.mTaglogId = id; } public String getTargetFolder() { return mTargetfolder; } public void setTargetFolder(String targetfolder) { this.mTargetfolder = targetfolder; } public String getState() { return mState; } public void setState(String state) { this.mState = state; } public String getFileList() { return mFileList; } public void setFileList(String filelist) { this.mFileList = filelist; } public String getDBPath() { return mDBPath; } public void setDBPath(String dbPath) { this.mDBPath = dbPath; } public String getDBFileName() { return mDBFileName; } public void setDBFileName(String dbfilename) { this.mDBFileName = dbfilename; } /** * @return String */ public String getmDBZZFileName() { return mDBZZFileName; } public void setDBZZFileName(String dbzzfile) { this.mDBZZFileName = dbzzfile; } public String isNeedZip() { return this.mIsNeedZip; } public void setIsNeedZip(String needzip) { this.mIsNeedZip = needzip; } public String isNeedAllLogs() { return this.mIsNeedAllLogs; } public void setIsNeedAllLogs(String needzip) { this.mIsNeedAllLogs = needzip; } public int getNeedLogType() { return this.mNeedlogType; } public void setNeedLogType(int logtype) { this.mNeedlogType = logtype; } public String getReason() { return this.mReason; } public void setReason(String reason) { this.mReason = reason; } public String getFromWhere() { return this.mFromWhere; } public void setFromWhere(String where) { this.mFromWhere = where; } public void setZzInternalTime(String expTime) { this.mZzInternalTime = expTime; } public String getZzInternalTime() { return this.mZzInternalTime; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(mTargetfolder); dest.writeString(mState); dest.writeString(mFileList); dest.writeString(mDBPath); dest.writeString(mDBFileName); dest.writeString(mDBZZFileName); dest.writeString(mIsNeedZip); dest.writeString(mIsNeedAllLogs); dest.writeInt(mNeedlogType); dest.writeString(mReason); dest.writeString(mFromWhere); dest.writeString(mZzInternalTime); } public static final Creator<TaglogTable> CREATOR = new Creator<TaglogTable>() { @Override public TaglogTable createFromParcel(Parcel source) { int id = source.readInt(); String tartgetfolder = source.readString(); String state = source.readString(); String filelist = source.readString(); String dbpath = source.readString(); String dbfilename = source.readString(); String dbzzfilename = source.readString(); String isneedzip = source.readString(); String isneedalllog = source.readString(); int needlogtype = source.readInt(); String reason = source.readString(); String fromwhere = source.readString(); String expTime = source.readString(); TaglogTable tagloginfo = new TaglogTable(id, tartgetfolder, state, filelist, dbpath, dbfilename, dbzzfilename, isneedzip, isneedalllog, needlogtype, reason, fromwhere, expTime); return tagloginfo; } @Override public TaglogTable[] newArray(int size) { return new TaglogTable[size]; } }; }
UTF-8
Java
6,374
java
TaglogTable.java
Java
[]
null
[]
package com.mediatek.mtklogger.taglog.db; import android.os.Parcel; import android.os.Parcelable; /** * This class is used to record owner info. */ public class TaglogTable implements Parcelable { private int mTaglogId; private String mTargetfolder; private String mState; private String mFileList; private String mDBPath; private String mDBFileName; private String mDBZZFileName; private String mIsNeedZip; private String mIsNeedAllLogs; private int mNeedlogType; private String mReason; private String mFromWhere; private String mZzInternalTime; /**. * TaglogTable */ public TaglogTable(){ } /** * @param id int * @param targetFolder String * @param state String * @param filelist String * @param dbPath String * @param dbfileName String * @param zzFileName String * @param isneedzip String * @param isneedalllogs String * @param needlogtype String * @param reason String * @param fromwhere String * @param expTime String */ public TaglogTable(int id, String targetFolder, String state, String filelist , String dbPath, String dbfileName, String zzFileName, String isneedzip, String isneedalllogs, int needlogtype, String reason, String fromwhere, String expTime) { super(); this.mTaglogId = id; this.mTargetfolder = targetFolder; this.mState = state; this.mFileList = filelist; this.mDBPath = dbPath; this.mDBFileName = dbfileName; this.mDBZZFileName = zzFileName; this.mIsNeedZip = isneedzip; this.mIsNeedAllLogs = isneedalllogs; this.mNeedlogType = needlogtype; this.mReason = reason; this.mFromWhere = fromwhere; this.mZzInternalTime = expTime; } @Override public String toString() { return " id:" + mTaglogId + ", mTargetfolder:" + mTargetfolder + ", mState:" + mState + ", mFileList:" + mFileList + ", mDBPath:" + mDBPath + ", mDBFileName:" + mDBFileName + ", mDBZZFileName:" + mDBZZFileName + ", mIsNeedZip:" + mIsNeedZip + ", mIsNeedAllLogs:" + mIsNeedAllLogs + ", mNeedlogType:" + mNeedlogType + ", mReason:" + mReason + ", mFromWhere:" + mFromWhere + ", mExpTime: " + mZzInternalTime; } public int getTagLogId() { return mTaglogId; } public void setTagLogId(int id) { this.mTaglogId = id; } public String getTargetFolder() { return mTargetfolder; } public void setTargetFolder(String targetfolder) { this.mTargetfolder = targetfolder; } public String getState() { return mState; } public void setState(String state) { this.mState = state; } public String getFileList() { return mFileList; } public void setFileList(String filelist) { this.mFileList = filelist; } public String getDBPath() { return mDBPath; } public void setDBPath(String dbPath) { this.mDBPath = dbPath; } public String getDBFileName() { return mDBFileName; } public void setDBFileName(String dbfilename) { this.mDBFileName = dbfilename; } /** * @return String */ public String getmDBZZFileName() { return mDBZZFileName; } public void setDBZZFileName(String dbzzfile) { this.mDBZZFileName = dbzzfile; } public String isNeedZip() { return this.mIsNeedZip; } public void setIsNeedZip(String needzip) { this.mIsNeedZip = needzip; } public String isNeedAllLogs() { return this.mIsNeedAllLogs; } public void setIsNeedAllLogs(String needzip) { this.mIsNeedAllLogs = needzip; } public int getNeedLogType() { return this.mNeedlogType; } public void setNeedLogType(int logtype) { this.mNeedlogType = logtype; } public String getReason() { return this.mReason; } public void setReason(String reason) { this.mReason = reason; } public String getFromWhere() { return this.mFromWhere; } public void setFromWhere(String where) { this.mFromWhere = where; } public void setZzInternalTime(String expTime) { this.mZzInternalTime = expTime; } public String getZzInternalTime() { return this.mZzInternalTime; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(mTargetfolder); dest.writeString(mState); dest.writeString(mFileList); dest.writeString(mDBPath); dest.writeString(mDBFileName); dest.writeString(mDBZZFileName); dest.writeString(mIsNeedZip); dest.writeString(mIsNeedAllLogs); dest.writeInt(mNeedlogType); dest.writeString(mReason); dest.writeString(mFromWhere); dest.writeString(mZzInternalTime); } public static final Creator<TaglogTable> CREATOR = new Creator<TaglogTable>() { @Override public TaglogTable createFromParcel(Parcel source) { int id = source.readInt(); String tartgetfolder = source.readString(); String state = source.readString(); String filelist = source.readString(); String dbpath = source.readString(); String dbfilename = source.readString(); String dbzzfilename = source.readString(); String isneedzip = source.readString(); String isneedalllog = source.readString(); int needlogtype = source.readInt(); String reason = source.readString(); String fromwhere = source.readString(); String expTime = source.readString(); TaglogTable tagloginfo = new TaglogTable(id, tartgetfolder, state, filelist, dbpath, dbfilename, dbzzfilename, isneedzip, isneedalllog, needlogtype, reason, fromwhere, expTime); return tagloginfo; } @Override public TaglogTable[] newArray(int size) { return new TaglogTable[size]; } }; }
6,374
0.616097
0.61594
230
26.713043
21.259787
96
false
false
0
0
0
0
0
0
0.53913
false
false
10
448a97dfcea357d09e9a03ad56b87556045e51e3
19,370,302,561,816
ea14287ee95cb9638c9c3547f7857a30af2b2e66
/src/main/java/br/com/sysacademico/util/AppContextListener.java
cf0cc7074c0695c74e646b88fc0416ec48769eb9
[]
no_license
cristianoliveira063/SysAcademico
https://github.com/cristianoliveira063/SysAcademico
4024812acce0b7c135867d34c4e3ed4934aa6cdf
125556144327e6ef3b41d9bc78394bf38ca51315
refs/heads/master
2016-09-14T04:20:22.169000
2016-05-03T01:34:42
2016-05-03T01:34:42
56,449,261
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
/* * 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 br.com.sysacademico.util; import br.com.sysacademico.validation.NotBlankClientValidationConstraint; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import org.hibernate.validator.constraints.NotBlank; import org.primefaces.validate.bean.BeanValidationMetadataMapper; /** * * @author 016255421 */ @WebListener public class AppContextListener implements ServletContextListener { @Override public void contextDestroyed(ServletContextEvent event) { } @Override public void contextInitialized(ServletContextEvent event) { BeanValidationMetadataMapper.registerConstraintMapping(NotBlank.class, new NotBlankClientValidationConstraint()); } }
UTF-8
Java
1,012
java
AppContextListener.java
Java
[ { "context": "nValidationMetadataMapper;\r\n\r\n/**\r\n *\r\n * @author 016255421\r\n */\r\n@WebListener\r\npublic class AppContextListen", "end": 589, "score": 0.9660234451293945, "start": 580, "tag": "USERNAME", "value": "016255421" } ]
null
[]
/* * 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 br.com.sysacademico.util; import br.com.sysacademico.validation.NotBlankClientValidationConstraint; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import org.hibernate.validator.constraints.NotBlank; import org.primefaces.validate.bean.BeanValidationMetadataMapper; /** * * @author 016255421 */ @WebListener public class AppContextListener implements ServletContextListener { @Override public void contextDestroyed(ServletContextEvent event) { } @Override public void contextInitialized(ServletContextEvent event) { BeanValidationMetadataMapper.registerConstraintMapping(NotBlank.class, new NotBlankClientValidationConstraint()); } }
1,012
0.751976
0.743083
34
27.764706
27.844166
79
false
false
0
0
0
0
0
0
0.352941
false
false
10
246efd265d9ada631636baa39a1f01987a508d1b
5,712,306,513,746
66556388f7ec300f8fb23f795c283e8d98aab863
/test09/Maker.java
2ae3f1adcd1fd3d9d62348908a08546a1c3268c5
[]
no_license
siarhei/ocpjp7
https://github.com/siarhei/ocpjp7
de2063d5f9c93e9a40a2a4e85a6bee3b8e38b2f1
8e24913d4874fe74ec64eacdf3ec82a7cb11349c
refs/heads/master
2021-01-21T12:07:54.638000
2015-11-04T21:19:19
2015-11-04T21:19:19
34,564,183
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
import java.io.*; public class Maker { public static void main(String[] args) { File dir = new File("dir3"); //File file = new File("dir3", "file3"); //OK File file = new File(dir, "file3"); //OK try { dir.mkdir(); file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } finally { //file.delete(); //dir.delete(); } } }
UTF-8
Java
369
java
Maker.java
Java
[]
null
[]
import java.io.*; public class Maker { public static void main(String[] args) { File dir = new File("dir3"); //File file = new File("dir3", "file3"); //OK File file = new File(dir, "file3"); //OK try { dir.mkdir(); file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } finally { //file.delete(); //dir.delete(); } } }
369
0.579946
0.569106
18
19.555555
14.146936
48
false
false
0
0
0
0
0
0
2.555556
false
false
10
e18decee5d269782701a46049a4c697883620450
5,806,795,849,072
1ca6f6e293acda05e8d07e3b24a5ca5224fe5797
/src/main/java/com/hexad/library/repository/BookRepository.java
bd670fd2ff2721779be10da84cdc20ffe38bd841
[]
no_license
gouravtiwari489/library
https://github.com/gouravtiwari489/library
37dd2745a435edbdc55fea038f716a469c340bad
b67f19f62e3058546a4b31a3f5f2c0a25ff73993
refs/heads/master
2023-01-28T19:58:46.928000
2020-12-09T07:22:13
2020-12-09T07:22:13
315,876,135
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.hexad.library.repository; import com.hexad.library.model.Book; import org.springframework.stereotype.Repository; import java.util.HashMap; import java.util.Map; @Repository public class BookRepository { private Map<Integer, Book> bookMap = new HashMap<>(); public Map<Integer, Book> save(Book book){ bookMap.put(book.getId(), book); return bookMap; } public Map<Integer, Book> getAll() { return bookMap; } }
UTF-8
Java
471
java
BookRepository.java
Java
[]
null
[]
package com.hexad.library.repository; import com.hexad.library.model.Book; import org.springframework.stereotype.Repository; import java.util.HashMap; import java.util.Map; @Repository public class BookRepository { private Map<Integer, Book> bookMap = new HashMap<>(); public Map<Integer, Book> save(Book book){ bookMap.put(book.getId(), book); return bookMap; } public Map<Integer, Book> getAll() { return bookMap; } }
471
0.687898
0.687898
22
20.40909
18.705029
57
false
false
0
0
0
0
0
0
0.590909
false
false
10
dce78a35f30cc71f36075ddcef018bd79e8e4c8b
6,141,803,289,756
96e99987e2079ead3377961ec2c7863818fbf3ac
/webshop/src/main/java/richard/forgo/dbs/webshop/domain/MostValuableBasket.java
b5904e32080c20053e5134a430c6182d3df8f1a3
[]
no_license
Silent947/dbs
https://github.com/Silent947/dbs
0058cb295b5b1907259aef9ca043e282285b5086
e0c0485a163b7e5913d309dc8d082d0195f8c9da
refs/heads/master
2020-05-15T21:56:34.913000
2019-05-17T22:02:04
2019-05-17T22:02:04
182,512,946
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package richard.forgo.dbs.webshop.domain; import lombok.Data; import lombok.NoArgsConstructor; @Data @NoArgsConstructor public class MostValuableBasket { private Integer totalPrice; private String userName; }
UTF-8
Java
213
java
MostValuableBasket.java
Java
[]
null
[]
package richard.forgo.dbs.webshop.domain; import lombok.Data; import lombok.NoArgsConstructor; @Data @NoArgsConstructor public class MostValuableBasket { private Integer totalPrice; private String userName; }
213
0.821596
0.821596
11
18.363636
14.156737
41
false
false
0
0
0
0
0
0
0.636364
false
false
10
70a3d4129271934dd3954f3992ee6f075392438e
25,383,256,787,396
0dfd512a7d84b41c6788967f99acefdb8856d271
/GuavaPrj/src/guava4/FluentIterablesTestes.java
78a6f87412a73236f13974f6811e036c8570987a
[]
no_license
SruthiVenkat/Projetos
https://github.com/SruthiVenkat/Projetos
cf7e7ae099613beaa54a1735466915a2d256e133
238e2234b7889cad18c04fa8ad1f42a7bbdf57f1
refs/heads/master
2023-03-17T05:03:32.724000
2015-10-28T20:06:25
2015-10-28T20:06:25
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package guava4; import java.util.Arrays; import java.util.List; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; public class FluentIterablesTestes { public static void main(String...agrs) { FluentIterablesTestes.filter(); transform(); toList(); } private static void filter() { List<Integer> l = Arrays.asList(1,2,3,4,5,6,7,8,9); Iterable<Integer> i = FluentIterable.from(l).filter(new Predicate<Integer>() { @Override public boolean apply(Integer input) { return (input%2)==0; } }); System.out.println(Joiner.on("|").join(i)); } private static void transform() { List<Integer> l = Arrays.asList(1,2,3,4,5,6,7,8,9); System.out.println(FluentIterable.from(l).transform( new Function<Integer,Integer>() { @Override public Integer apply(Integer input) { return (int) Math.pow(input, 2); } })); FluentIterable.from(l).transform(new Function<Integer,Integer>() { @Override public Integer apply(Integer input) { System.out.println(input); return input; } }); } private static void toList() { List<Integer> l = Arrays.asList(1,2,3,4,5,6,7,8,9); ImmutableList<Integer> il = FluentIterable.from(l).transform(new Function<Integer,Integer>() { @Override public Integer apply(Integer input) { return (int) Math.pow(input, 2); } }).toList(); System.out.println(Joiner.on("|").join(il)); ImmutableSet<Integer> is = FluentIterable.from(l).transform(new Function<Integer,Integer>() { @Override public Integer apply(Integer input) { return (int) Math.pow(input, 2); } }).toSet(); System.out.println(is); } }
UTF-8
Java
1,989
java
FluentIterablesTestes.java
Java
[]
null
[]
package guava4; import java.util.Arrays; import java.util.List; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; public class FluentIterablesTestes { public static void main(String...agrs) { FluentIterablesTestes.filter(); transform(); toList(); } private static void filter() { List<Integer> l = Arrays.asList(1,2,3,4,5,6,7,8,9); Iterable<Integer> i = FluentIterable.from(l).filter(new Predicate<Integer>() { @Override public boolean apply(Integer input) { return (input%2)==0; } }); System.out.println(Joiner.on("|").join(i)); } private static void transform() { List<Integer> l = Arrays.asList(1,2,3,4,5,6,7,8,9); System.out.println(FluentIterable.from(l).transform( new Function<Integer,Integer>() { @Override public Integer apply(Integer input) { return (int) Math.pow(input, 2); } })); FluentIterable.from(l).transform(new Function<Integer,Integer>() { @Override public Integer apply(Integer input) { System.out.println(input); return input; } }); } private static void toList() { List<Integer> l = Arrays.asList(1,2,3,4,5,6,7,8,9); ImmutableList<Integer> il = FluentIterable.from(l).transform(new Function<Integer,Integer>() { @Override public Integer apply(Integer input) { return (int) Math.pow(input, 2); } }).toList(); System.out.println(Joiner.on("|").join(il)); ImmutableSet<Integer> is = FluentIterable.from(l).transform(new Function<Integer,Integer>() { @Override public Integer apply(Integer input) { return (int) Math.pow(input, 2); } }).toSet(); System.out.println(is); } }
1,989
0.637004
0.620412
87
20.862068
23.465883
96
false
false
0
0
0
0
0
0
2.505747
false
false
10
5fb481daf6ab7c96d625805b5d5526038037a203
16,312,285,848,614
973238bc7fa2f929204fbd75ee54a5aa1a34781e
/Revise_GUI/src/MatrixIO/View.java
e04696270279e7bf307ac0d467f941097f03550a
[]
no_license
nguyenvanson9x/JAVA
https://github.com/nguyenvanson9x/JAVA
00aa60e1611a37f61be7a393f2254899367fb106
9b41608015cc23668f57b9cc450ad86cbcffd2b9
refs/heads/master
2021-01-20T00:20:26.286000
2017-05-31T14:23:52
2017-05-31T14:23:52
89,112,692
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package MatrixIO; import java.awt.BorderLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.border.EmptyBorder; public class View extends JFrame { /** * */ private static final long serialVersionUID = 1L; /** * */ // 0 private static final long serialVersionUID = 1L; private JPanel contentPane; private JPanel pnCenter; private JLabel lbStatus; private JButton btnTheHe; private JButton[][] btnGround; public JButton getBtnTheHe() { return btnTheHe; } public void setLbStatus(String s) { lbStatus.setText(s); } public View() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(500, 400); setLocationRelativeTo(null); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JPanel pnButton = new JPanel(); pnButton.setBorder(new EmptyBorder(5, 50, 10, 50)); btnTheHe = new JButton("The he tiep theo"); pnButton.add(btnTheHe); contentPane.add(pnButton, BorderLayout.SOUTH); lbStatus = new JLabel("Thế hệ thứ nhât"); lbStatus.setHorizontalAlignment(SwingConstants.CENTER); contentPane.add(lbStatus, BorderLayout.NORTH); pnCenter = new JPanel(); contentPane.add(pnCenter, BorderLayout.CENTER); pnCenter.setLayout(new GridLayout(10, 10, 0, 0)); } public void initButton(int[][] matrix) { btnGround = new JButton[matrix.length][matrix.length]; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix.length; j++) { btnGround[i][j] = new JButton(); if (matrix[i][j] == 1) { btnGround[i][j].setText("#"); } btnGround[i][j].setEnabled(false); pnCenter.add(btnGround[i][j]); } } } public void updateButton(int[][] m) { for (int i = 0; i < m.length; i++) { for (int j = 0; j < m.length; j++) { btnGround[i][j].setText(""); } } for (int i = 0; i < m.length; i++) { for (int j = 0; j < m.length; j++) { if (m[i][j] == 1) { btnGround[i][j].setText("#"); } } } } }
UTF-8
Java
2,290
java
View.java
Java
[]
null
[]
package MatrixIO; import java.awt.BorderLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.border.EmptyBorder; public class View extends JFrame { /** * */ private static final long serialVersionUID = 1L; /** * */ // 0 private static final long serialVersionUID = 1L; private JPanel contentPane; private JPanel pnCenter; private JLabel lbStatus; private JButton btnTheHe; private JButton[][] btnGround; public JButton getBtnTheHe() { return btnTheHe; } public void setLbStatus(String s) { lbStatus.setText(s); } public View() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(500, 400); setLocationRelativeTo(null); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JPanel pnButton = new JPanel(); pnButton.setBorder(new EmptyBorder(5, 50, 10, 50)); btnTheHe = new JButton("The he tiep theo"); pnButton.add(btnTheHe); contentPane.add(pnButton, BorderLayout.SOUTH); lbStatus = new JLabel("Thế hệ thứ nhât"); lbStatus.setHorizontalAlignment(SwingConstants.CENTER); contentPane.add(lbStatus, BorderLayout.NORTH); pnCenter = new JPanel(); contentPane.add(pnCenter, BorderLayout.CENTER); pnCenter.setLayout(new GridLayout(10, 10, 0, 0)); } public void initButton(int[][] matrix) { btnGround = new JButton[matrix.length][matrix.length]; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix.length; j++) { btnGround[i][j] = new JButton(); if (matrix[i][j] == 1) { btnGround[i][j].setText("#"); } btnGround[i][j].setEnabled(false); pnCenter.add(btnGround[i][j]); } } } public void updateButton(int[][] m) { for (int i = 0; i < m.length; i++) { for (int j = 0; j < m.length; j++) { btnGround[i][j].setText(""); } } for (int i = 0; i < m.length; i++) { for (int j = 0; j < m.length; j++) { if (m[i][j] == 1) { btnGround[i][j].setText("#"); } } } } }
2,290
0.629435
0.613666
100
20.83
18.585508
57
false
false
0
0
0
0
0
0
2.06
false
false
10
083b3e8827331158d3af35de7c1205c63d516ce4
25,091,199,011,635
4dc6e0946b3fc7e3c70d9b3d849445ce84ebc558
/decals-ui/src/com/eduworks/decals/ui/client/util/DsMessage.java
815c2ce390cd92ce34db8fa753fd878b6e322e6d
[ "Apache-2.0" ]
permissive
alexliu9800/DECALS
https://github.com/alexliu9800/DECALS
5bb3281a02a4416af78bd69b9a915f5221c8fe0d
97d428859fae9ab4165fc50d588075a52f8e7d33
refs/heads/master
2020-11-29T16:54:08.435000
2016-06-02T19:31:40
2016-06-02T19:31:40
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.eduworks.decals.ui.client.util; /** * Message container class. * * @author Eduworks Corporation * */ public class DsMessage { private String html; private String closeBtnId; public DsMessage(String html, String closeBtnId) { this.html = html; this.closeBtnId = closeBtnId; } public String getHtml() {return html;} public String getCloseBtnId() {return closeBtnId;} }
UTF-8
Java
435
java
DsMessage.java
Java
[]
null
[]
package com.eduworks.decals.ui.client.util; /** * Message container class. * * @author Eduworks Corporation * */ public class DsMessage { private String html; private String closeBtnId; public DsMessage(String html, String closeBtnId) { this.html = html; this.closeBtnId = closeBtnId; } public String getHtml() {return html;} public String getCloseBtnId() {return closeBtnId;} }
435
0.664368
0.664368
22
18.772728
18.145702
53
false
false
0
0
0
0
0
0
0.363636
false
false
10
640a2a2dbd3adc8574ae5d66e975a3fba5aeb19a
14,955,076,145,502
aa95f096ba419de49eeb635b996df4a5b84a8004
/app/src/main/java/com/abroad/ruianju/adapter/UIShowAdapter.java
e127c5d95db1a8afbb01a54bfd3a7ee361949bd0
[]
no_license
zhangyubao/RuiAnJu
https://github.com/zhangyubao/RuiAnJu
d36df448f3e2b7894bebf792e0400fb515c3ed7f
b09461dd99ae046caa1cb62d42873ab5ab0a7e4e
refs/heads/master
2018-02-10T21:25:05.511000
2017-04-21T02:53:04
2017-04-21T02:53:04
62,046,266
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.abroad.ruianju.adapter; import android.content.Context; import android.support.v4.view.PagerAdapter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.abroad.ruianju.R; import com.abroad.ruianju.db.DBUtils; import java.util.ArrayList; import java.util.List; /** * Created by zhangYB on 2016/7/8. * <p/> * 分享界面背景适配器 */ public class UIShowAdapter extends PagerAdapter { DBUtils dbUtils; private Context mContext; private List<String> mList=new ArrayList<>(); public UIShowAdapter(Context context) { dbUtils=DBUtils.getInstance(); this.mContext = context; } public void setDate(List<String> list){ if(list!=null) this.mList=list; } @Override public int getCount() { return mList.size(); } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public Object instantiateItem(ViewGroup container, int position) { View view = LayoutInflater.from(mContext).inflate(R.layout.item_breaker_layout, null); return view; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View)object); } }
UTF-8
Java
1,336
java
UIShowAdapter.java
Java
[ { "context": "rayList;\nimport java.util.List;\n\n/**\n * Created by zhangYB on 2016/7/8.\n * <p/>\n * 分享界面背景适配器\n */\npublic clas", "end": 353, "score": 0.999436616897583, "start": 346, "tag": "USERNAME", "value": "zhangYB" } ]
null
[]
package com.abroad.ruianju.adapter; import android.content.Context; import android.support.v4.view.PagerAdapter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.abroad.ruianju.R; import com.abroad.ruianju.db.DBUtils; import java.util.ArrayList; import java.util.List; /** * Created by zhangYB on 2016/7/8. * <p/> * 分享界面背景适配器 */ public class UIShowAdapter extends PagerAdapter { DBUtils dbUtils; private Context mContext; private List<String> mList=new ArrayList<>(); public UIShowAdapter(Context context) { dbUtils=DBUtils.getInstance(); this.mContext = context; } public void setDate(List<String> list){ if(list!=null) this.mList=list; } @Override public int getCount() { return mList.size(); } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public Object instantiateItem(ViewGroup container, int position) { View view = LayoutInflater.from(mContext).inflate(R.layout.item_breaker_layout, null); return view; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View)object); } }
1,336
0.683612
0.6783
55
22.963636
21.538095
94
false
false
0
0
0
0
0
0
0.472727
false
false
14
24979a04583329e83dac978f5d2106e8996b0d8e
7,172,595,404,199
bbde45a0bca036e1ef039b146a0855650e6cec19
/src/main/java/org/jahia/modules/visibility/filter/visibilityObjectList.java
27876cb0fee17918cdd4776f15c0e382c60e6436
[]
no_license
smonier/visibilityDashboard
https://github.com/smonier/visibilityDashboard
c87158312e4b36b8c486bd29be47f0d1e70c71fa
218bd4075f55b80938dca4bf89cc2df2ea460d12
refs/heads/master
2021-05-16T01:59:41.040000
2014-06-27T09:24:59
2014-06-27T09:24:59
20,476,327
0
0
null
false
2019-10-25T16:31:07
2014-06-04T08:47:26
2014-06-26T14:10:20
2019-10-25T15:18:10
40
0
0
0
CSS
false
false
package org.jahia.modules.visibility.filter; import org.jahia.services.content.JCRNodeWrapper; import org.jahia.services.content.JCRSessionFactory; import org.jahia.services.content.JCRSessionWrapper; import org.jahia.services.render.RenderContext; import org.jahia.services.render.Resource; import org.jahia.services.render.filter.AbstractFilter; import org.jahia.services.render.filter.RenderChain; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.i18n.LocaleContextHolder; import javax.jcr.NodeIterator; import javax.jcr.RepositoryException; import javax.jcr.query.Query; import javax.jcr.query.QueryManager; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.List; import java.util.Locale; /** * Created by smonier on 04/06/14. */ public class visibilityObjectList extends AbstractFilter { private JCRSessionWrapper getSession() throws RepositoryException { return getSession(LocaleContextHolder.getLocale()); } private JCRSessionWrapper getSession(Locale locale) throws RepositoryException { return JCRSessionFactory.getInstance().getCurrentUserSession("default", locale); } static final Logger logger = LoggerFactory.getLogger(visibilityObjectList.class); public String prepare(RenderContext renderContext, Resource resource, RenderChain chain) { // Get SitePath to execute query from it String sitePath = renderContext.getMainResource().getNode().getPath().toString(); final List<JCRNodeWrapper> visibilityContentList = new ArrayList<JCRNodeWrapper>(); logger.info("Visibility Dashboard for " + sitePath + " ... Listing all Objects"); try { QueryManager qm = getSession().getWorkspace().getQueryManager(); StringBuilder statement = new StringBuilder("select * from [jnt:conditionalVisibility] as visibilityContent where ISDESCENDANTNODE(visibilityContent,'" + sitePath + "') order by visibilityContent.['jcr:lastModified'] desc"); Query q = qm.createQuery(statement.toString(), Query.JCR_SQL2); NodeIterator ni = q.execute().getNodes(); while (ni.hasNext()) { JCRNodeWrapper nodeWrapper = (JCRNodeWrapper) ni.next(); if (nodeWrapper.isNodeType("jnt:conditionalVisibility")) { visibilityContentList.add(nodeWrapper); logger.info("adding Content to List"); } } // Save List in request HttpServletRequest request = renderContext.getRequest(); request.setAttribute("visibilityContentList", visibilityContentList); } catch (RepositoryException e) { logger.error("Missing information for Visibility Content list Retrieval"); e.printStackTrace(); } return null; } }
UTF-8
Java
2,909
java
visibilityObjectList.java
Java
[ { "context": ".List;\nimport java.util.Locale;\n\n/**\n * Created by smonier on 04/06/14.\n */\npublic class visibilityObjectLis", "end": 805, "score": 0.9995669722557068, "start": 798, "tag": "USERNAME", "value": "smonier" } ]
null
[]
package org.jahia.modules.visibility.filter; import org.jahia.services.content.JCRNodeWrapper; import org.jahia.services.content.JCRSessionFactory; import org.jahia.services.content.JCRSessionWrapper; import org.jahia.services.render.RenderContext; import org.jahia.services.render.Resource; import org.jahia.services.render.filter.AbstractFilter; import org.jahia.services.render.filter.RenderChain; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.i18n.LocaleContextHolder; import javax.jcr.NodeIterator; import javax.jcr.RepositoryException; import javax.jcr.query.Query; import javax.jcr.query.QueryManager; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.List; import java.util.Locale; /** * Created by smonier on 04/06/14. */ public class visibilityObjectList extends AbstractFilter { private JCRSessionWrapper getSession() throws RepositoryException { return getSession(LocaleContextHolder.getLocale()); } private JCRSessionWrapper getSession(Locale locale) throws RepositoryException { return JCRSessionFactory.getInstance().getCurrentUserSession("default", locale); } static final Logger logger = LoggerFactory.getLogger(visibilityObjectList.class); public String prepare(RenderContext renderContext, Resource resource, RenderChain chain) { // Get SitePath to execute query from it String sitePath = renderContext.getMainResource().getNode().getPath().toString(); final List<JCRNodeWrapper> visibilityContentList = new ArrayList<JCRNodeWrapper>(); logger.info("Visibility Dashboard for " + sitePath + " ... Listing all Objects"); try { QueryManager qm = getSession().getWorkspace().getQueryManager(); StringBuilder statement = new StringBuilder("select * from [jnt:conditionalVisibility] as visibilityContent where ISDESCENDANTNODE(visibilityContent,'" + sitePath + "') order by visibilityContent.['jcr:lastModified'] desc"); Query q = qm.createQuery(statement.toString(), Query.JCR_SQL2); NodeIterator ni = q.execute().getNodes(); while (ni.hasNext()) { JCRNodeWrapper nodeWrapper = (JCRNodeWrapper) ni.next(); if (nodeWrapper.isNodeType("jnt:conditionalVisibility")) { visibilityContentList.add(nodeWrapper); logger.info("adding Content to List"); } } // Save List in request HttpServletRequest request = renderContext.getRequest(); request.setAttribute("visibilityContentList", visibilityContentList); } catch (RepositoryException e) { logger.error("Missing information for Visibility Content list Retrieval"); e.printStackTrace(); } return null; } }
2,909
0.710553
0.706772
77
36.79221
38.276279
237
false
false
0
0
0
0
0
0
0.558442
false
false
14
f05c01e2e1c8fc772b74a10f5cf4629c6cea7d5c
18,708,877,565,060
7e973c3b81498a4c3129a1b8cb639ae389ba9d09
/src/Rectangle.java
56b5853fe1ad24b5b60f995772d3a6f46f58a786
[]
no_license
tomershay100/The-Coins-Game
https://github.com/tomershay100/The-Coins-Game
2a69a9ac1ef6b8e968c626276668a74be0a0cc7a
889ed019fc3c7b3223fe86e3c13df59587eb8af9
refs/heads/master
2023-03-12T06:34:21.440000
2021-02-26T17:52:21
2021-02-26T17:52:21
288,694,345
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
//323082701 import java.awt.*; /** * Geometries.Rectangle Object - each Geometries.Rectangle has a width, a height and a Geometries.Point. * * @author Tomer Shay <tomershay100@gmail.com> * @version 1.0 * @since 2020-04-24 */ public class Rectangle { private final double width; private final double height; private final Point upperLeft; /** * Create a new rectangle with location and width/height. * * @param upperLeft The upper Left point. * @param width the width of the rectangle. * @param height the height of the rectangle. */ public Rectangle(Point upperLeft, double width, double height) { this.upperLeft = upperLeft; this.width = width; this.height = height; } /** * Returns the width of the rectangle. * * @return the width of the rectangle. */ public double getWidth() { return this.width; } /** * Returns the height of the rectangle. * * @return the height of the rectangle. */ public double getHeight() { return this.height; } /** * Returns the upper-left point of the rectangle. * * @return the upper-left point of the rectangle. */ public Point getUpperLeft() { return this.upperLeft; } }
UTF-8
Java
1,381
java
Rectangle.java
Java
[ { "context": ", a height and a Geometries.Point.\r\n *\r\n * @author Tomer Shay <tomershay100@gmail.com>\r\n * @version 1.0\r\n * @si", "end": 173, "score": 0.9998713731765747, "start": 163, "tag": "NAME", "value": "Tomer Shay" }, { "context": "d a Geometries.Point.\r\n *\r\n * @author Tomer Shay <tomershay100@gmail.com>\r\n * @version 1.0\r\n * @since 2020-04-24\r\n */\r\npub", "end": 197, "score": 0.9999293088912964, "start": 175, "tag": "EMAIL", "value": "tomershay100@gmail.com" } ]
null
[]
//323082701 import java.awt.*; /** * Geometries.Rectangle Object - each Geometries.Rectangle has a width, a height and a Geometries.Point. * * @author <NAME> <<EMAIL>> * @version 1.0 * @since 2020-04-24 */ public class Rectangle { private final double width; private final double height; private final Point upperLeft; /** * Create a new rectangle with location and width/height. * * @param upperLeft The upper Left point. * @param width the width of the rectangle. * @param height the height of the rectangle. */ public Rectangle(Point upperLeft, double width, double height) { this.upperLeft = upperLeft; this.width = width; this.height = height; } /** * Returns the width of the rectangle. * * @return the width of the rectangle. */ public double getWidth() { return this.width; } /** * Returns the height of the rectangle. * * @return the height of the rectangle. */ public double getHeight() { return this.height; } /** * Returns the upper-left point of the rectangle. * * @return the upper-left point of the rectangle. */ public Point getUpperLeft() { return this.upperLeft; } }
1,362
0.583635
0.567705
59
21.440678
21.71641
104
false
false
0
0
0
0
0
0
0.220339
false
false
14