repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
RefineriaWeb/base_app_android | presentation/src/androidTest/java/presentation/sections/dashboard/DashboardTest.java | // Path: presentation/src/androidTest/java/presentation/common/BaseTest.java
// @RunWith(AndroidJUnit4.class)
// public abstract class BaseTest {
// public static final long SHORT_WAIT = 1000;
// public static final long MEDIUM_WAIT = 2500;
// public static final long LONG_WAIT = 5000;
//
// public static void shortWait() {
// waitTime(SHORT_WAIT);
// }
//
// public static void mediumWait() {
// waitTime(MEDIUM_WAIT);
// }
//
// public static void longWait() {
// waitTime(LONG_WAIT);
// }
//
// private static void waitTime(long time) {
// try {Thread.sleep(time);
// } catch (InterruptedException e) { e.printStackTrace();}
// }
//
// @Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class);
//
// @Before public void init() {}
//
// protected Activity getCurrentActivity() {
// BaseApp app = (BaseApp) InstrumentationRegistry.getTargetContext().getApplicationContext();
// return app.getLiveActivity();
// }
//
// protected void takeScreenShot(String name) {
// try {
// Spoon.screenshot(getCurrentActivity(), name);
// } catch (Exception ignore){}
// }
// }
//
// Path: presentation/src/androidTest/java/presentation/common/ViewActions.java
// public static ViewAction actionCloseDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "close drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).closeDrawer(GravityCompat.START);
// }
// };
// }
//
// Path: presentation/src/androidTest/java/presentation/common/ViewActions.java
// public static ViewAction actionOpenDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "open drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).openDrawer(GravityCompat.START);
// }
// };
// }
| import android.support.test.espresso.contrib.RecyclerViewActions;
import org.junit.Test;
import base.app.android.R;
import presentation.common.BaseTest;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static presentation.common.ViewActions.actionCloseDrawer;
import static presentation.common.ViewActions.actionOpenDrawer; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.sections.dashboard;
public class DashboardTest extends BaseTest {
@Test public void Open_And_Close_Users() { | // Path: presentation/src/androidTest/java/presentation/common/BaseTest.java
// @RunWith(AndroidJUnit4.class)
// public abstract class BaseTest {
// public static final long SHORT_WAIT = 1000;
// public static final long MEDIUM_WAIT = 2500;
// public static final long LONG_WAIT = 5000;
//
// public static void shortWait() {
// waitTime(SHORT_WAIT);
// }
//
// public static void mediumWait() {
// waitTime(MEDIUM_WAIT);
// }
//
// public static void longWait() {
// waitTime(LONG_WAIT);
// }
//
// private static void waitTime(long time) {
// try {Thread.sleep(time);
// } catch (InterruptedException e) { e.printStackTrace();}
// }
//
// @Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class);
//
// @Before public void init() {}
//
// protected Activity getCurrentActivity() {
// BaseApp app = (BaseApp) InstrumentationRegistry.getTargetContext().getApplicationContext();
// return app.getLiveActivity();
// }
//
// protected void takeScreenShot(String name) {
// try {
// Spoon.screenshot(getCurrentActivity(), name);
// } catch (Exception ignore){}
// }
// }
//
// Path: presentation/src/androidTest/java/presentation/common/ViewActions.java
// public static ViewAction actionCloseDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "close drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).closeDrawer(GravityCompat.START);
// }
// };
// }
//
// Path: presentation/src/androidTest/java/presentation/common/ViewActions.java
// public static ViewAction actionOpenDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "open drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).openDrawer(GravityCompat.START);
// }
// };
// }
// Path: presentation/src/androidTest/java/presentation/sections/dashboard/DashboardTest.java
import android.support.test.espresso.contrib.RecyclerViewActions;
import org.junit.Test;
import base.app.android.R;
import presentation.common.BaseTest;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static presentation.common.ViewActions.actionCloseDrawer;
import static presentation.common.ViewActions.actionOpenDrawer;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.sections.dashboard;
public class DashboardTest extends BaseTest {
@Test public void Open_And_Close_Users() { | onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer()); |
RefineriaWeb/base_app_android | presentation/src/androidTest/java/presentation/sections/dashboard/DashboardTest.java | // Path: presentation/src/androidTest/java/presentation/common/BaseTest.java
// @RunWith(AndroidJUnit4.class)
// public abstract class BaseTest {
// public static final long SHORT_WAIT = 1000;
// public static final long MEDIUM_WAIT = 2500;
// public static final long LONG_WAIT = 5000;
//
// public static void shortWait() {
// waitTime(SHORT_WAIT);
// }
//
// public static void mediumWait() {
// waitTime(MEDIUM_WAIT);
// }
//
// public static void longWait() {
// waitTime(LONG_WAIT);
// }
//
// private static void waitTime(long time) {
// try {Thread.sleep(time);
// } catch (InterruptedException e) { e.printStackTrace();}
// }
//
// @Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class);
//
// @Before public void init() {}
//
// protected Activity getCurrentActivity() {
// BaseApp app = (BaseApp) InstrumentationRegistry.getTargetContext().getApplicationContext();
// return app.getLiveActivity();
// }
//
// protected void takeScreenShot(String name) {
// try {
// Spoon.screenshot(getCurrentActivity(), name);
// } catch (Exception ignore){}
// }
// }
//
// Path: presentation/src/androidTest/java/presentation/common/ViewActions.java
// public static ViewAction actionCloseDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "close drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).closeDrawer(GravityCompat.START);
// }
// };
// }
//
// Path: presentation/src/androidTest/java/presentation/common/ViewActions.java
// public static ViewAction actionOpenDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "open drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).openDrawer(GravityCompat.START);
// }
// };
// }
| import android.support.test.espresso.contrib.RecyclerViewActions;
import org.junit.Test;
import base.app.android.R;
import presentation.common.BaseTest;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static presentation.common.ViewActions.actionCloseDrawer;
import static presentation.common.ViewActions.actionOpenDrawer; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.sections.dashboard;
public class DashboardTest extends BaseTest {
@Test public void Open_And_Close_Users() {
onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
mediumWait();
onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
takeScreenShot("Users"); | // Path: presentation/src/androidTest/java/presentation/common/BaseTest.java
// @RunWith(AndroidJUnit4.class)
// public abstract class BaseTest {
// public static final long SHORT_WAIT = 1000;
// public static final long MEDIUM_WAIT = 2500;
// public static final long LONG_WAIT = 5000;
//
// public static void shortWait() {
// waitTime(SHORT_WAIT);
// }
//
// public static void mediumWait() {
// waitTime(MEDIUM_WAIT);
// }
//
// public static void longWait() {
// waitTime(LONG_WAIT);
// }
//
// private static void waitTime(long time) {
// try {Thread.sleep(time);
// } catch (InterruptedException e) { e.printStackTrace();}
// }
//
// @Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class);
//
// @Before public void init() {}
//
// protected Activity getCurrentActivity() {
// BaseApp app = (BaseApp) InstrumentationRegistry.getTargetContext().getApplicationContext();
// return app.getLiveActivity();
// }
//
// protected void takeScreenShot(String name) {
// try {
// Spoon.screenshot(getCurrentActivity(), name);
// } catch (Exception ignore){}
// }
// }
//
// Path: presentation/src/androidTest/java/presentation/common/ViewActions.java
// public static ViewAction actionCloseDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "close drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).closeDrawer(GravityCompat.START);
// }
// };
// }
//
// Path: presentation/src/androidTest/java/presentation/common/ViewActions.java
// public static ViewAction actionOpenDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "open drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).openDrawer(GravityCompat.START);
// }
// };
// }
// Path: presentation/src/androidTest/java/presentation/sections/dashboard/DashboardTest.java
import android.support.test.espresso.contrib.RecyclerViewActions;
import org.junit.Test;
import base.app.android.R;
import presentation.common.BaseTest;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static presentation.common.ViewActions.actionCloseDrawer;
import static presentation.common.ViewActions.actionOpenDrawer;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.sections.dashboard;
public class DashboardTest extends BaseTest {
@Test public void Open_And_Close_Users() {
onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
mediumWait();
onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
takeScreenShot("Users"); | onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer()); |
RefineriaWeb/base_app_android | presentation/src/androidTest/java/presentation/common/BaseTest.java | // Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: presentation/src/main/java/presentation/sections/launch/LaunchActivity.java
// public class LaunchActivity extends BaseFragmentActivity implements LaunchView {
// @Inject protected LaunchPresenter launchPresenter;
//
// @Override protected void injectDagger() {
// getApplicationComponent().inject(this);
// }
//
// @Override protected void initViews() {
// super.initViews();
// launchPresenter.attachView(this);
// }
// }
| import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.squareup.spoon.Spoon;
import org.junit.Before;
import org.junit.Rule;
import org.junit.runner.RunWith;
import presentation.foundation.BaseApp;
import presentation.sections.launch.LaunchActivity; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.common;
@RunWith(AndroidJUnit4.class)
public abstract class BaseTest {
public static final long SHORT_WAIT = 1000;
public static final long MEDIUM_WAIT = 2500;
public static final long LONG_WAIT = 5000;
public static void shortWait() {
waitTime(SHORT_WAIT);
}
public static void mediumWait() {
waitTime(MEDIUM_WAIT);
}
public static void longWait() {
waitTime(LONG_WAIT);
}
private static void waitTime(long time) {
try {Thread.sleep(time);
} catch (InterruptedException e) { e.printStackTrace();}
}
| // Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: presentation/src/main/java/presentation/sections/launch/LaunchActivity.java
// public class LaunchActivity extends BaseFragmentActivity implements LaunchView {
// @Inject protected LaunchPresenter launchPresenter;
//
// @Override protected void injectDagger() {
// getApplicationComponent().inject(this);
// }
//
// @Override protected void initViews() {
// super.initViews();
// launchPresenter.attachView(this);
// }
// }
// Path: presentation/src/androidTest/java/presentation/common/BaseTest.java
import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.squareup.spoon.Spoon;
import org.junit.Before;
import org.junit.Rule;
import org.junit.runner.RunWith;
import presentation.foundation.BaseApp;
import presentation.sections.launch.LaunchActivity;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.common;
@RunWith(AndroidJUnit4.class)
public abstract class BaseTest {
public static final long SHORT_WAIT = 1000;
public static final long MEDIUM_WAIT = 2500;
public static final long LONG_WAIT = 5000;
public static void shortWait() {
waitTime(SHORT_WAIT);
}
public static void mediumWait() {
waitTime(MEDIUM_WAIT);
}
public static void longWait() {
waitTime(LONG_WAIT);
}
private static void waitTime(long time) {
try {Thread.sleep(time);
} catch (InterruptedException e) { e.printStackTrace();}
}
| @Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class); |
RefineriaWeb/base_app_android | presentation/src/androidTest/java/presentation/common/BaseTest.java | // Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: presentation/src/main/java/presentation/sections/launch/LaunchActivity.java
// public class LaunchActivity extends BaseFragmentActivity implements LaunchView {
// @Inject protected LaunchPresenter launchPresenter;
//
// @Override protected void injectDagger() {
// getApplicationComponent().inject(this);
// }
//
// @Override protected void initViews() {
// super.initViews();
// launchPresenter.attachView(this);
// }
// }
| import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.squareup.spoon.Spoon;
import org.junit.Before;
import org.junit.Rule;
import org.junit.runner.RunWith;
import presentation.foundation.BaseApp;
import presentation.sections.launch.LaunchActivity; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.common;
@RunWith(AndroidJUnit4.class)
public abstract class BaseTest {
public static final long SHORT_WAIT = 1000;
public static final long MEDIUM_WAIT = 2500;
public static final long LONG_WAIT = 5000;
public static void shortWait() {
waitTime(SHORT_WAIT);
}
public static void mediumWait() {
waitTime(MEDIUM_WAIT);
}
public static void longWait() {
waitTime(LONG_WAIT);
}
private static void waitTime(long time) {
try {Thread.sleep(time);
} catch (InterruptedException e) { e.printStackTrace();}
}
@Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class);
@Before public void init() {}
protected Activity getCurrentActivity() { | // Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: presentation/src/main/java/presentation/sections/launch/LaunchActivity.java
// public class LaunchActivity extends BaseFragmentActivity implements LaunchView {
// @Inject protected LaunchPresenter launchPresenter;
//
// @Override protected void injectDagger() {
// getApplicationComponent().inject(this);
// }
//
// @Override protected void initViews() {
// super.initViews();
// launchPresenter.attachView(this);
// }
// }
// Path: presentation/src/androidTest/java/presentation/common/BaseTest.java
import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.squareup.spoon.Spoon;
import org.junit.Before;
import org.junit.Rule;
import org.junit.runner.RunWith;
import presentation.foundation.BaseApp;
import presentation.sections.launch.LaunchActivity;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.common;
@RunWith(AndroidJUnit4.class)
public abstract class BaseTest {
public static final long SHORT_WAIT = 1000;
public static final long MEDIUM_WAIT = 2500;
public static final long LONG_WAIT = 5000;
public static void shortWait() {
waitTime(SHORT_WAIT);
}
public static void mediumWait() {
waitTime(MEDIUM_WAIT);
}
public static void longWait() {
waitTime(LONG_WAIT);
}
private static void waitTime(long time) {
try {Thread.sleep(time);
} catch (InterruptedException e) { e.printStackTrace();}
}
@Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class);
@Before public void init() {}
protected Activity getCurrentActivity() { | BaseApp app = (BaseApp) InstrumentationRegistry.getTargetContext().getApplicationContext(); |
RefineriaWeb/base_app_android | data/src/test/java/data/net/RestApiTest.java | // Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.util.List;
import domain.sections.user_demo.entities.UserDemoEntity;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.observers.TestSubscriber; | /*
* Copyright 2015 RefineriaWeb
*
* 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 data.net;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RestApiTest {
private static final String VALID_USERNAME = "RefineriaWeb", INVALID_USERNAME = "";
private RestApi restApiUT;
@Before public void setUp() {
restApiUT = new Retrofit.Builder()
.baseUrl(RestApi.URL_BASE)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(RestApi.class);
}
@Test public void _1_When_Get_User_With_Valid_User_Name_Then_Get_UserDemo() { | // Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: data/src/test/java/data/net/RestApiTest.java
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.util.List;
import domain.sections.user_demo.entities.UserDemoEntity;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.observers.TestSubscriber;
/*
* Copyright 2015 RefineriaWeb
*
* 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 data.net;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RestApiTest {
private static final String VALID_USERNAME = "RefineriaWeb", INVALID_USERNAME = "";
private RestApi restApiUT;
@Before public void setUp() {
restApiUT = new Retrofit.Builder()
.baseUrl(RestApi.URL_BASE)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(RestApi.class);
}
@Test public void _1_When_Get_User_With_Valid_User_Name_Then_Get_UserDemo() { | TestSubscriber<Response<UserDemoEntity>> subscriber = new TestSubscriber<>(); |
RefineriaWeb/base_app_android | domain/src/test/java/domain/sections/user_demo/list/SaveUserDemoSelectedListUseCaseTest.java | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import org.junit.Test;
import org.mockito.Mock;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.mockito.Mockito.when; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.list;
public class SaveUserDemoSelectedListUseCaseTest extends BaseTest {
private SaveUserDemoSelectedListUseCase saveUserDemoSelectedListUseCaseUT; | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: domain/src/test/java/domain/sections/user_demo/list/SaveUserDemoSelectedListUseCaseTest.java
import org.junit.Test;
import org.mockito.Mock;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.mockito.Mockito.when;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.list;
public class SaveUserDemoSelectedListUseCaseTest extends BaseTest {
private SaveUserDemoSelectedListUseCase saveUserDemoSelectedListUseCaseUT; | @Mock protected UserDemoRepository userDemoRepositoryMock; |
RefineriaWeb/base_app_android | domain/src/test/java/domain/sections/user_demo/list/SaveUserDemoSelectedListUseCaseTest.java | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import org.junit.Test;
import org.mockito.Mock;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.mockito.Mockito.when; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.list;
public class SaveUserDemoSelectedListUseCaseTest extends BaseTest {
private SaveUserDemoSelectedListUseCase saveUserDemoSelectedListUseCaseUT;
@Mock protected UserDemoRepository userDemoRepositoryMock; | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: domain/src/test/java/domain/sections/user_demo/list/SaveUserDemoSelectedListUseCaseTest.java
import org.junit.Test;
import org.mockito.Mock;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.mockito.Mockito.when;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.list;
public class SaveUserDemoSelectedListUseCaseTest extends BaseTest {
private SaveUserDemoSelectedListUseCase saveUserDemoSelectedListUseCaseUT;
@Mock protected UserDemoRepository userDemoRepositoryMock; | @Mock protected UserDemoEntity userDemoEntityMock; |
RefineriaWeb/base_app_android | presentation/src/androidTest/java/presentation/common/SuiteIntegration.java | // Path: presentation/src/androidTest/java/presentation/sections/dashboard/DashboardTest.java
// public class DashboardTest extends BaseTest {
//
// @Test public void Open_And_Close_Users() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
// onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
//
// takeScreenShot("Users");
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
//
// takeScreenShot("User");
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_Search_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(2, click()));
//
// takeScreenShot("SearchUser");
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// }
//
// Path: presentation/src/androidTest/java/presentation/sections/user_demo/UsersTest.java
// @FixMethodOrder(MethodSorters.NAME_ASCENDING)
// public class UsersTest extends BaseTest {
// private static final int ID_USER = 21, INDEX_LIST = 11, ID_USER_REFINERIA = 8580307;
// private static final String USERNAME = "technoweenie";
// private static final String USERNAME_REFINERIA = "RefineriaWeb";
//
// @Test public void _1_Get_Users() {
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
// takeScreenShot("Users");
// }
//
// @Test public void _2_Get_User() {
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
//
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));
// onView(withId(R.id.tv_name)).check(matches(withText(ID_USER + ":" + USERNAME)));
//
// takeScreenShot(USERNAME);
// }
//
// @Test public void _3_Search_User() {
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
//
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));
//
// onView(withId(R.id.bt_go_to_search_user)).perform(click());
//
// onView(withId(R.id.et_name)).perform(click(), replaceText(USERNAME_REFINERIA), closeSoftKeyboard());
// onView(withId(R.id.bt_find_user)).perform(click());
// mediumWait();
//
// onView(withId(R.id.tv_name)).check(matches(withText(ID_USER_REFINERIA + ":" + USERNAME_REFINERIA)));
// takeScreenShot(USERNAME_REFINERIA);
// }
//
// }
| import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import presentation.sections.dashboard.DashboardTest;
import presentation.sections.user_demo.UsersTest; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.common;
@RunWith(Suite.class)
@Suite.SuiteClasses({ | // Path: presentation/src/androidTest/java/presentation/sections/dashboard/DashboardTest.java
// public class DashboardTest extends BaseTest {
//
// @Test public void Open_And_Close_Users() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
// onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
//
// takeScreenShot("Users");
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
//
// takeScreenShot("User");
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_Search_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(2, click()));
//
// takeScreenShot("SearchUser");
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// }
//
// Path: presentation/src/androidTest/java/presentation/sections/user_demo/UsersTest.java
// @FixMethodOrder(MethodSorters.NAME_ASCENDING)
// public class UsersTest extends BaseTest {
// private static final int ID_USER = 21, INDEX_LIST = 11, ID_USER_REFINERIA = 8580307;
// private static final String USERNAME = "technoweenie";
// private static final String USERNAME_REFINERIA = "RefineriaWeb";
//
// @Test public void _1_Get_Users() {
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
// takeScreenShot("Users");
// }
//
// @Test public void _2_Get_User() {
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
//
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));
// onView(withId(R.id.tv_name)).check(matches(withText(ID_USER + ":" + USERNAME)));
//
// takeScreenShot(USERNAME);
// }
//
// @Test public void _3_Search_User() {
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
//
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));
//
// onView(withId(R.id.bt_go_to_search_user)).perform(click());
//
// onView(withId(R.id.et_name)).perform(click(), replaceText(USERNAME_REFINERIA), closeSoftKeyboard());
// onView(withId(R.id.bt_find_user)).perform(click());
// mediumWait();
//
// onView(withId(R.id.tv_name)).check(matches(withText(ID_USER_REFINERIA + ":" + USERNAME_REFINERIA)));
// takeScreenShot(USERNAME_REFINERIA);
// }
//
// }
// Path: presentation/src/androidTest/java/presentation/common/SuiteIntegration.java
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import presentation.sections.dashboard.DashboardTest;
import presentation.sections.user_demo.UsersTest;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.common;
@RunWith(Suite.class)
@Suite.SuiteClasses({ | DashboardTest.class, |
RefineriaWeb/base_app_android | presentation/src/androidTest/java/presentation/common/SuiteIntegration.java | // Path: presentation/src/androidTest/java/presentation/sections/dashboard/DashboardTest.java
// public class DashboardTest extends BaseTest {
//
// @Test public void Open_And_Close_Users() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
// onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
//
// takeScreenShot("Users");
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
//
// takeScreenShot("User");
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_Search_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(2, click()));
//
// takeScreenShot("SearchUser");
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// }
//
// Path: presentation/src/androidTest/java/presentation/sections/user_demo/UsersTest.java
// @FixMethodOrder(MethodSorters.NAME_ASCENDING)
// public class UsersTest extends BaseTest {
// private static final int ID_USER = 21, INDEX_LIST = 11, ID_USER_REFINERIA = 8580307;
// private static final String USERNAME = "technoweenie";
// private static final String USERNAME_REFINERIA = "RefineriaWeb";
//
// @Test public void _1_Get_Users() {
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
// takeScreenShot("Users");
// }
//
// @Test public void _2_Get_User() {
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
//
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));
// onView(withId(R.id.tv_name)).check(matches(withText(ID_USER + ":" + USERNAME)));
//
// takeScreenShot(USERNAME);
// }
//
// @Test public void _3_Search_User() {
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
//
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));
//
// onView(withId(R.id.bt_go_to_search_user)).perform(click());
//
// onView(withId(R.id.et_name)).perform(click(), replaceText(USERNAME_REFINERIA), closeSoftKeyboard());
// onView(withId(R.id.bt_find_user)).perform(click());
// mediumWait();
//
// onView(withId(R.id.tv_name)).check(matches(withText(ID_USER_REFINERIA + ":" + USERNAME_REFINERIA)));
// takeScreenShot(USERNAME_REFINERIA);
// }
//
// }
| import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import presentation.sections.dashboard.DashboardTest;
import presentation.sections.user_demo.UsersTest; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.common;
@RunWith(Suite.class)
@Suite.SuiteClasses({
DashboardTest.class, | // Path: presentation/src/androidTest/java/presentation/sections/dashboard/DashboardTest.java
// public class DashboardTest extends BaseTest {
//
// @Test public void Open_And_Close_Users() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
// onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
//
// takeScreenShot("Users");
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
//
// takeScreenShot("User");
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_Search_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(2, click()));
//
// takeScreenShot("SearchUser");
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// }
//
// Path: presentation/src/androidTest/java/presentation/sections/user_demo/UsersTest.java
// @FixMethodOrder(MethodSorters.NAME_ASCENDING)
// public class UsersTest extends BaseTest {
// private static final int ID_USER = 21, INDEX_LIST = 11, ID_USER_REFINERIA = 8580307;
// private static final String USERNAME = "technoweenie";
// private static final String USERNAME_REFINERIA = "RefineriaWeb";
//
// @Test public void _1_Get_Users() {
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
// takeScreenShot("Users");
// }
//
// @Test public void _2_Get_User() {
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
//
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));
// onView(withId(R.id.tv_name)).check(matches(withText(ID_USER + ":" + USERNAME)));
//
// takeScreenShot(USERNAME);
// }
//
// @Test public void _3_Search_User() {
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
//
// mediumWait();
// onView(withId(R.id.rv_users)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));
//
// onView(withId(R.id.bt_go_to_search_user)).perform(click());
//
// onView(withId(R.id.et_name)).perform(click(), replaceText(USERNAME_REFINERIA), closeSoftKeyboard());
// onView(withId(R.id.bt_find_user)).perform(click());
// mediumWait();
//
// onView(withId(R.id.tv_name)).check(matches(withText(ID_USER_REFINERIA + ":" + USERNAME_REFINERIA)));
// takeScreenShot(USERNAME_REFINERIA);
// }
//
// }
// Path: presentation/src/androidTest/java/presentation/common/SuiteIntegration.java
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import presentation.sections.dashboard.DashboardTest;
import presentation.sections.user_demo.UsersTest;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.common;
@RunWith(Suite.class)
@Suite.SuiteClasses({
DashboardTest.class, | UsersTest.class |
RefineriaWeb/base_app_android | data/src/main/java/data/net/RestApi.java | // Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import java.util.List;
import domain.sections.user_demo.entities.UserDemoEntity;
import retrofit2.Response;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.Path;
import rx.Observable; | /*
* Copyright 2015 RefineriaWeb
*
* 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 data.net;
/**
* Definition for Retrofit of every endpoint required by the Api.
* {@link #getUsers()} and {@link #getUser(String)} are both and example of endpoint}
*/
public interface RestApi {
String URL_BASE = "https://api.github.com";
String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
@Headers({HEADER_API_VERSION}) | // Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: data/src/main/java/data/net/RestApi.java
import java.util.List;
import domain.sections.user_demo.entities.UserDemoEntity;
import retrofit2.Response;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.Path;
import rx.Observable;
/*
* Copyright 2015 RefineriaWeb
*
* 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 data.net;
/**
* Definition for Retrofit of every endpoint required by the Api.
* {@link #getUsers()} and {@link #getUser(String)} are both and example of endpoint}
*/
public interface RestApi {
String URL_BASE = "https://api.github.com";
String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
@Headers({HEADER_API_VERSION}) | @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username); |
RefineriaWeb/base_app_android | domain/src/test/java/domain/sections/user_demo/list/GetUsersDemoUseCaseTest.java | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import static org.mockito.Mockito.when;
import org.junit.Test;
import org.mockito.Mock;
import java.util.Arrays;
import java.util.List;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.list;
public class GetUsersDemoUseCaseTest extends BaseTest {
private GetUsersDemoUseCase getUsersDemoUseCaseUT; | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: domain/src/test/java/domain/sections/user_demo/list/GetUsersDemoUseCaseTest.java
import static org.mockito.Mockito.when;
import org.junit.Test;
import org.mockito.Mock;
import java.util.Arrays;
import java.util.List;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.list;
public class GetUsersDemoUseCaseTest extends BaseTest {
private GetUsersDemoUseCase getUsersDemoUseCaseUT; | @Mock protected UserDemoRepository userDemoRepositoryMock; |
RefineriaWeb/base_app_android | domain/src/test/java/domain/sections/user_demo/list/GetUsersDemoUseCaseTest.java | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import static org.mockito.Mockito.when;
import org.junit.Test;
import org.mockito.Mock;
import java.util.Arrays;
import java.util.List;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.list;
public class GetUsersDemoUseCaseTest extends BaseTest {
private GetUsersDemoUseCase getUsersDemoUseCaseUT;
@Mock protected UserDemoRepository userDemoRepositoryMock; | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: domain/src/test/java/domain/sections/user_demo/list/GetUsersDemoUseCaseTest.java
import static org.mockito.Mockito.when;
import org.junit.Test;
import org.mockito.Mock;
import java.util.Arrays;
import java.util.List;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.list;
public class GetUsersDemoUseCaseTest extends BaseTest {
private GetUsersDemoUseCase getUsersDemoUseCaseUT;
@Mock protected UserDemoRepository userDemoRepositoryMock; | @Mock protected UserDemoEntity userDemoEntityMock; |
RefineriaWeb/base_app_android | domain/src/test/java/domain/sections/user_demo/search/SearchUserDemoUseCaseTest.java | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import org.junit.Test;
import org.mockito.Mock;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.search;
public class SearchUserDemoUseCaseTest extends BaseTest {
private SearchUserDemoUseCase searchUserDemoUseCaseUT; | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: domain/src/test/java/domain/sections/user_demo/search/SearchUserDemoUseCaseTest.java
import org.junit.Test;
import org.mockito.Mock;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.search;
public class SearchUserDemoUseCaseTest extends BaseTest {
private SearchUserDemoUseCase searchUserDemoUseCaseUT; | @Mock protected UserDemoRepository userDemoRepositoryMock; |
RefineriaWeb/base_app_android | domain/src/test/java/domain/sections/user_demo/search/SearchUserDemoUseCaseTest.java | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import org.junit.Test;
import org.mockito.Mock;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.search;
public class SearchUserDemoUseCaseTest extends BaseTest {
private SearchUserDemoUseCase searchUserDemoUseCaseUT;
@Mock protected UserDemoRepository userDemoRepositoryMock; | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: domain/src/test/java/domain/sections/user_demo/search/SearchUserDemoUseCaseTest.java
import org.junit.Test;
import org.mockito.Mock;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.search;
public class SearchUserDemoUseCaseTest extends BaseTest {
private SearchUserDemoUseCase searchUserDemoUseCaseUT;
@Mock protected UserDemoRepository userDemoRepositoryMock; | @Mock protected UserDemoEntity userDemoEntityMock; |
RefineriaWeb/base_app_android | domain/src/main/java/domain/sections/user_demo/detail/GetSelectedDemoUserListUseCase.java | // Path: domain/src/main/java/domain/foundation/UseCase.java
// public abstract class UseCase<D> {
// protected final UI ui;
//
// public UseCase(UI ui) {
// this.ui = ui;
// }
//
// /**
// * Observable built for every use case
// */
// public abstract Observable<D> react();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import javax.inject.Inject;
import domain.foundation.UseCase;
import domain.sections.UI;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.detail;
public class GetSelectedDemoUserListUseCase extends UseCase<UserDemoEntity> {
private final UserDemoRepository repository;
| // Path: domain/src/main/java/domain/foundation/UseCase.java
// public abstract class UseCase<D> {
// protected final UI ui;
//
// public UseCase(UI ui) {
// this.ui = ui;
// }
//
// /**
// * Observable built for every use case
// */
// public abstract Observable<D> react();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: domain/src/main/java/domain/sections/user_demo/detail/GetSelectedDemoUserListUseCase.java
import javax.inject.Inject;
import domain.foundation.UseCase;
import domain.sections.UI;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.detail;
public class GetSelectedDemoUserListUseCase extends UseCase<UserDemoEntity> {
private final UserDemoRepository repository;
| @Inject public GetSelectedDemoUserListUseCase(UI ui, UserDemoRepository repository) { |
RefineriaWeb/base_app_android | data/src/main/java/data/sections/DataRepository.java | // Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
// Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
//
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: domain/src/main/java/domain/foundation/Repository.java
// public interface Repository {
// }
| import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import java.io.IOException;
import data.cache.RxProviders;
import data.net.RestApi;
import domain.foundation.Repository;
import lombok.Data;
import retrofit2.Response;
import rx.Observable; | /*
* Copyright 2015 RefineriaWeb
*
* 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 data.sections;
public abstract class DataRepository implements Repository {
protected final RestApi restApi; | // Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
// Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
//
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: domain/src/main/java/domain/foundation/Repository.java
// public interface Repository {
// }
// Path: data/src/main/java/data/sections/DataRepository.java
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import java.io.IOException;
import data.cache.RxProviders;
import data.net.RestApi;
import domain.foundation.Repository;
import lombok.Data;
import retrofit2.Response;
import rx.Observable;
/*
* Copyright 2015 RefineriaWeb
*
* 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 data.sections;
public abstract class DataRepository implements Repository {
protected final RestApi restApi; | protected final RxProviders rxProviders; |
RefineriaWeb/base_app_android | domain/src/main/java/domain/foundation/helpers/ParserException.java | // Path: domain/src/main/java/domain/foundation/UseCase.java
// public abstract class UseCase<D> {
// protected final UI ui;
//
// public UseCase(UI ui) {
// this.ui = ui;
// }
//
// /**
// * Observable built for every use case
// */
// public abstract Observable<D> react();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
| import javax.inject.Inject;
import domain.foundation.UseCase;
import domain.sections.UI;
import rx.Observable;
import rx.exceptions.CompositeException; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.foundation.helpers;
/**
* Created by victor on 09/03/16.
*/
public class ParserException extends UseCase<String> {
private Throwable throwable;
| // Path: domain/src/main/java/domain/foundation/UseCase.java
// public abstract class UseCase<D> {
// protected final UI ui;
//
// public UseCase(UI ui) {
// this.ui = ui;
// }
//
// /**
// * Observable built for every use case
// */
// public abstract Observable<D> react();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
// Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
import javax.inject.Inject;
import domain.foundation.UseCase;
import domain.sections.UI;
import rx.Observable;
import rx.exceptions.CompositeException;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.foundation.helpers;
/**
* Created by victor on 09/03/16.
*/
public class ParserException extends UseCase<String> {
private Throwable throwable;
| @Inject public ParserException(UI ui) { |
RefineriaWeb/base_app_android | domain/src/test/java/domain/foundation/PresenterErrorsTest.java | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
// public class ParserException extends UseCase<String> {
// private Throwable throwable;
//
// @Inject public ParserException(UI ui) {
// super(ui);
// }
//
// public ParserException with(Throwable throwable) {
// this.throwable = throwable;
// return this;
// }
//
// @Override public Observable<String> react() {
// String message = throwable.getMessage();
//
// if (throwable instanceof CompositeException) {
// message += System.getProperty("line.separator");
// CompositeException compositeException = (CompositeException) throwable;
//
// for (Throwable exception : compositeException.getExceptions()) {
// String exceptionName = exception.getClass().getSimpleName();
// String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "";
// message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator");
// }
// }
//
// return Observable.just(message);
// }
// }
| import org.junit.Test;
import domain.common.BaseTest;
import domain.foundation.helpers.ParserException;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | when(UIMock.errorNonEmptyFields()).thenReturn(oFeedback);
TestSubscriber<String> subscriberMock = new TestSubscriber<>();
presenterUT.safety(useCaseFailureMock.react())
.disposable(oMock -> oMock.subscribe(subscriberMock));
subscriberMock.awaitTerminalEvent();
subscriberMock.assertNoErrors();
subscriberMock.assertNoValues();
verify(UIMock, times(0)).showFeedback(oFeedback);
}
@Test public void When_Subscribe_Safety_Report_Error_Observable_Failure_Nothing_Is_Emitted_And_UI_Show_Error_Is_Called() {
TestSubscriber<String> subscriberMock = new TestSubscriber<>();
presenterUT.safetyReportError(useCaseFailureMock.react())
.disposable(oMock -> oMock.subscribe(subscriberMock));
subscriberMock.awaitTerminalEvent();
subscriberMock.assertNoErrors();
subscriberMock.assertNoValues();
verify(UIMock, times(1)).showFeedback(any(Observable.class));
}
private class PresenterUnderTest extends Presenter<BaseView> {
final UseCaseSuccessMock useCaseSuccessMock;
final UseCaseFailureMock useCaseFailureMock;
public PresenterUnderTest() { | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
// public class ParserException extends UseCase<String> {
// private Throwable throwable;
//
// @Inject public ParserException(UI ui) {
// super(ui);
// }
//
// public ParserException with(Throwable throwable) {
// this.throwable = throwable;
// return this;
// }
//
// @Override public Observable<String> react() {
// String message = throwable.getMessage();
//
// if (throwable instanceof CompositeException) {
// message += System.getProperty("line.separator");
// CompositeException compositeException = (CompositeException) throwable;
//
// for (Throwable exception : compositeException.getExceptions()) {
// String exceptionName = exception.getClass().getSimpleName();
// String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "";
// message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator");
// }
// }
//
// return Observable.just(message);
// }
// }
// Path: domain/src/test/java/domain/foundation/PresenterErrorsTest.java
import org.junit.Test;
import domain.common.BaseTest;
import domain.foundation.helpers.ParserException;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
when(UIMock.errorNonEmptyFields()).thenReturn(oFeedback);
TestSubscriber<String> subscriberMock = new TestSubscriber<>();
presenterUT.safety(useCaseFailureMock.react())
.disposable(oMock -> oMock.subscribe(subscriberMock));
subscriberMock.awaitTerminalEvent();
subscriberMock.assertNoErrors();
subscriberMock.assertNoValues();
verify(UIMock, times(0)).showFeedback(oFeedback);
}
@Test public void When_Subscribe_Safety_Report_Error_Observable_Failure_Nothing_Is_Emitted_And_UI_Show_Error_Is_Called() {
TestSubscriber<String> subscriberMock = new TestSubscriber<>();
presenterUT.safetyReportError(useCaseFailureMock.react())
.disposable(oMock -> oMock.subscribe(subscriberMock));
subscriberMock.awaitTerminalEvent();
subscriberMock.assertNoErrors();
subscriberMock.assertNoValues();
verify(UIMock, times(1)).showFeedback(any(Observable.class));
}
private class PresenterUnderTest extends Presenter<BaseView> {
final UseCaseSuccessMock useCaseSuccessMock;
final UseCaseFailureMock useCaseFailureMock;
public PresenterUnderTest() { | super(null, subscribeOnMock, observeOnMock, new ParserException(UIMock), UIMock); |
RefineriaWeb/base_app_android | domain/src/main/java/domain/sections/user_demo/search/SearchUserDemoUseCase.java | // Path: domain/src/main/java/domain/foundation/UseCase.java
// public abstract class UseCase<D> {
// protected final UI ui;
//
// public UseCase(UI ui) {
// this.ui = ui;
// }
//
// /**
// * Observable built for every use case
// */
// public abstract Observable<D> react();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import javax.inject.Inject;
import domain.foundation.UseCase;
import domain.sections.UI;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.search;
public class SearchUserDemoUseCase extends UseCase<UserDemoEntity> {
private final UserDemoRepository repository;
private String name;
| // Path: domain/src/main/java/domain/foundation/UseCase.java
// public abstract class UseCase<D> {
// protected final UI ui;
//
// public UseCase(UI ui) {
// this.ui = ui;
// }
//
// /**
// * Observable built for every use case
// */
// public abstract Observable<D> react();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: domain/src/main/java/domain/sections/user_demo/search/SearchUserDemoUseCase.java
import javax.inject.Inject;
import domain.foundation.UseCase;
import domain.sections.UI;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.search;
public class SearchUserDemoUseCase extends UseCase<UserDemoEntity> {
private final UserDemoRepository repository;
private String name;
| @Inject public SearchUserDemoUseCase(UI ui, UserDemoRepository repository) { |
RefineriaWeb/base_app_android | domain/src/main/java/domain/sections/dashboard/GetMenuItemsUseCase.java | // Path: domain/src/main/java/domain/foundation/UseCase.java
// public abstract class UseCase<D> {
// protected final UI ui;
//
// public UseCase(UI ui) {
// this.ui = ui;
// }
//
// /**
// * Observable built for every use case
// */
// public abstract Observable<D> react();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
| import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;
import domain.foundation.UseCase;
import domain.sections.UI;
import rx.Observable; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.dashboard;
public class GetMenuItemsUseCase extends UseCase<List<ItemMenu>> {
public static final int ID_USERS = 1, ID_USER = 2, ID_SEARCH_USER = 3;
private final DashboardItemsMenu dashboardItemsMenu;
| // Path: domain/src/main/java/domain/foundation/UseCase.java
// public abstract class UseCase<D> {
// protected final UI ui;
//
// public UseCase(UI ui) {
// this.ui = ui;
// }
//
// /**
// * Observable built for every use case
// */
// public abstract Observable<D> react();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
// Path: domain/src/main/java/domain/sections/dashboard/GetMenuItemsUseCase.java
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;
import domain.foundation.UseCase;
import domain.sections.UI;
import rx.Observable;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.dashboard;
public class GetMenuItemsUseCase extends UseCase<List<ItemMenu>> {
public static final int ID_USERS = 1, ID_USER = 2, ID_SEARCH_USER = 3;
private final DashboardItemsMenu dashboardItemsMenu;
| @Inject GetMenuItemsUseCase(DashboardItemsMenu dashboardItemsMenu, UI ui) { |
RefineriaWeb/base_app_android | presentation/src/main/java/presentation/sections/dashboard/DashboardItemsMenuDomain.java | // Path: domain/src/main/java/domain/sections/dashboard/DashboardItemsMenu.java
// public interface DashboardItemsMenu {
// void configureUsers(ItemMenu itemMenu);
// void configureUser(ItemMenu itemMenu);
// void configureSearchUser(ItemMenu itemMenu);
// }
//
// Path: domain/src/main/java/domain/sections/dashboard/ItemMenu.java
// @Data
// public class ItemMenu {
// public final int id;
// public String title;
// public Object imageResource;
// }
//
// Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
| import base.app.android.R;
import domain.sections.dashboard.DashboardItemsMenu;
import domain.sections.dashboard.ItemMenu;
import presentation.foundation.BaseApp; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.sections.dashboard;
public class DashboardItemsMenuDomain implements DashboardItemsMenu {
private final BaseApp baseApp;
public DashboardItemsMenuDomain(BaseApp baseApp) {
this.baseApp = baseApp;
}
| // Path: domain/src/main/java/domain/sections/dashboard/DashboardItemsMenu.java
// public interface DashboardItemsMenu {
// void configureUsers(ItemMenu itemMenu);
// void configureUser(ItemMenu itemMenu);
// void configureSearchUser(ItemMenu itemMenu);
// }
//
// Path: domain/src/main/java/domain/sections/dashboard/ItemMenu.java
// @Data
// public class ItemMenu {
// public final int id;
// public String title;
// public Object imageResource;
// }
//
// Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
// Path: presentation/src/main/java/presentation/sections/dashboard/DashboardItemsMenuDomain.java
import base.app.android.R;
import domain.sections.dashboard.DashboardItemsMenu;
import domain.sections.dashboard.ItemMenu;
import presentation.foundation.BaseApp;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.sections.dashboard;
public class DashboardItemsMenuDomain implements DashboardItemsMenu {
private final BaseApp baseApp;
public DashboardItemsMenuDomain(BaseApp baseApp) {
this.baseApp = baseApp;
}
| @Override public void configureUsers(ItemMenu itemMenu) { |
RefineriaWeb/base_app_android | presentation/src/main/java/presentation/foundation/BaseApp.java | // Path: presentation/src/main/java/presentation/internal/di/ApplicationComponent.java
// @Singleton @Component(modules = {DomainPresentationModule.class, DataPresentationModule.class, ApplicationModule.class})
// public interface ApplicationComponent {
// void inject(LaunchActivity launchActivity);
//
// void inject(DashBoardActivity dashBoardActivity);
// void inject(UserFragment userFragment);
// void inject(UsersFragment usersFragment);
// void inject(SearchUserFragment searchUserFragment);
// }
//
// Path: presentation/src/main/java/presentation/internal/di/ApplicationModule.java
// @Module(includes = DataModule.class) public class ApplicationModule {
// private final BaseApp baseApp;
//
// public ApplicationModule(BaseApp baseApp) {
// this.baseApp = baseApp;
// }
//
// @Provides @Singleton BaseApp provideApplication() {
// return baseApp;
// }
//
// }
| import android.app.Application;
import android.support.annotation.Nullable;
import presentation.internal.di.ApplicationComponent;
import presentation.internal.di.ApplicationModule;
import presentation.internal.di.DaggerApplicationComponent; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.foundation;
/**
* Custom Application
*/
public class BaseApp extends Application {
private ApplicationComponent applicationComponent;
@Override public void onCreate() {
super.onCreate();
initInject();
AppCare.YesSir.takeCareOn(this);
}
private void initInject() {
applicationComponent = DaggerApplicationComponent.builder() | // Path: presentation/src/main/java/presentation/internal/di/ApplicationComponent.java
// @Singleton @Component(modules = {DomainPresentationModule.class, DataPresentationModule.class, ApplicationModule.class})
// public interface ApplicationComponent {
// void inject(LaunchActivity launchActivity);
//
// void inject(DashBoardActivity dashBoardActivity);
// void inject(UserFragment userFragment);
// void inject(UsersFragment usersFragment);
// void inject(SearchUserFragment searchUserFragment);
// }
//
// Path: presentation/src/main/java/presentation/internal/di/ApplicationModule.java
// @Module(includes = DataModule.class) public class ApplicationModule {
// private final BaseApp baseApp;
//
// public ApplicationModule(BaseApp baseApp) {
// this.baseApp = baseApp;
// }
//
// @Provides @Singleton BaseApp provideApplication() {
// return baseApp;
// }
//
// }
// Path: presentation/src/main/java/presentation/foundation/BaseApp.java
import android.app.Application;
import android.support.annotation.Nullable;
import presentation.internal.di.ApplicationComponent;
import presentation.internal.di.ApplicationModule;
import presentation.internal.di.DaggerApplicationComponent;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.foundation;
/**
* Custom Application
*/
public class BaseApp extends Application {
private ApplicationComponent applicationComponent;
@Override public void onCreate() {
super.onCreate();
initInject();
AppCare.YesSir.takeCareOn(this);
}
private void initInject() {
applicationComponent = DaggerApplicationComponent.builder() | .applicationModule(new ApplicationModule(this)) |
RefineriaWeb/base_app_android | domain/src/main/java/domain/sections/user_demo/list/GetUsersDemoUseCase.java | // Path: domain/src/main/java/domain/foundation/UseCase.java
// public abstract class UseCase<D> {
// protected final UI ui;
//
// public UseCase(UI ui) {
// this.ui = ui;
// }
//
// /**
// * Observable built for every use case
// */
// public abstract Observable<D> react();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import java.util.List;
import javax.inject.Inject;
import domain.foundation.UseCase;
import domain.sections.UI;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.list;
public class GetUsersDemoUseCase extends UseCase<List<UserDemoEntity>> {
private final UserDemoRepository repository;
| // Path: domain/src/main/java/domain/foundation/UseCase.java
// public abstract class UseCase<D> {
// protected final UI ui;
//
// public UseCase(UI ui) {
// this.ui = ui;
// }
//
// /**
// * Observable built for every use case
// */
// public abstract Observable<D> react();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: domain/src/main/java/domain/sections/user_demo/list/GetUsersDemoUseCase.java
import java.util.List;
import javax.inject.Inject;
import domain.foundation.UseCase;
import domain.sections.UI;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.user_demo.list;
public class GetUsersDemoUseCase extends UseCase<List<UserDemoEntity>> {
private final UserDemoRepository repository;
| @Inject public GetUsersDemoUseCase(UI ui, UserDemoRepository repository) { |
RefineriaWeb/base_app_android | data/src/test/java/data/user_demo/UserDemoDataRepositoryTest.java | // Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import data.net.RestApi;
import data.sections.UI;
import data.sections.user_demo.UserDemoDataRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import retrofit2.Response;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.CoreMatchers.is; | /*
* Copyright 2015 RefineriaWeb
*
* 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 data.user_demo;
public class UserDemoDataRepositoryTest {
@Mock private RestApi restApiMock; | // Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: data/src/test/java/data/user_demo/UserDemoDataRepositoryTest.java
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import data.net.RestApi;
import data.sections.UI;
import data.sections.user_demo.UserDemoDataRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import retrofit2.Response;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.CoreMatchers.is;
/*
* Copyright 2015 RefineriaWeb
*
* 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 data.user_demo;
public class UserDemoDataRepositoryTest {
@Mock private RestApi restApiMock; | @Mock private UI UIMock; |
RefineriaWeb/base_app_android | data/src/test/java/data/user_demo/UserDemoDataRepositoryTest.java | // Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import data.net.RestApi;
import data.sections.UI;
import data.sections.user_demo.UserDemoDataRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import retrofit2.Response;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.CoreMatchers.is; | /*
* Copyright 2015 RefineriaWeb
*
* 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 data.user_demo;
public class UserDemoDataRepositoryTest {
@Mock private RestApi restApiMock;
@Mock private UI UIMock; | // Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: data/src/test/java/data/user_demo/UserDemoDataRepositoryTest.java
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import data.net.RestApi;
import data.sections.UI;
import data.sections.user_demo.UserDemoDataRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import retrofit2.Response;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.CoreMatchers.is;
/*
* Copyright 2015 RefineriaWeb
*
* 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 data.user_demo;
public class UserDemoDataRepositoryTest {
@Mock private RestApi restApiMock;
@Mock private UI UIMock; | private UserDemoDataRepository userDemoDataRepositoryUT; |
RefineriaWeb/base_app_android | data/src/test/java/data/user_demo/UserDemoDataRepositoryTest.java | // Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import data.net.RestApi;
import data.sections.UI;
import data.sections.user_demo.UserDemoDataRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import retrofit2.Response;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.CoreMatchers.is; | /*
* Copyright 2015 RefineriaWeb
*
* 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 data.user_demo;
public class UserDemoDataRepositoryTest {
@Mock private RestApi restApiMock;
@Mock private UI UIMock;
private UserDemoDataRepository userDemoDataRepositoryUT;
@Before public void setUp() {
MockitoAnnotations.initMocks(this);
userDemoDataRepositoryUT = new UserDemoDataRepository(restApiMock, null, UIMock);
}
@Test public void When_Search_With_Valid_User_Name_Then_Get_Demo_User() { | // Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: data/src/test/java/data/user_demo/UserDemoDataRepositoryTest.java
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import data.net.RestApi;
import data.sections.UI;
import data.sections.user_demo.UserDemoDataRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import retrofit2.Response;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.CoreMatchers.is;
/*
* Copyright 2015 RefineriaWeb
*
* 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 data.user_demo;
public class UserDemoDataRepositoryTest {
@Mock private RestApi restApiMock;
@Mock private UI UIMock;
private UserDemoDataRepository userDemoDataRepositoryUT;
@Before public void setUp() {
MockitoAnnotations.initMocks(this);
userDemoDataRepositoryUT = new UserDemoDataRepository(restApiMock, null, UIMock);
}
@Test public void When_Search_With_Valid_User_Name_Then_Get_Demo_User() { | Response<UserDemoEntity> response = Response.success(mock(UserDemoEntity.class)); |
RefineriaWeb/base_app_android | domain/src/main/java/domain/foundation/Presenter.java | // Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
// public class ParserException extends UseCase<String> {
// private Throwable throwable;
//
// @Inject public ParserException(UI ui) {
// super(ui);
// }
//
// public ParserException with(Throwable throwable) {
// this.throwable = throwable;
// return this;
// }
//
// @Override public Observable<String> react() {
// String message = throwable.getMessage();
//
// if (throwable instanceof CompositeException) {
// message += System.getProperty("line.separator");
// CompositeException compositeException = (CompositeException) throwable;
//
// for (Throwable exception : compositeException.getExceptions()) {
// String exceptionName = exception.getClass().getSimpleName();
// String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "";
// message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator");
// }
// }
//
// return Observable.just(message);
// }
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/Wireframe.java
// public interface Wireframe {
// void dashboard();
// void searchUserScreen();
// void userScreen();
// void usersScreen();
// void popCurrentScreen();
// }
| import domain.foundation.helpers.ParserException;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import domain.sections.Wireframe;
import rx.Observable;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.foundation;
/**
* Base class for any Presenter.
* The presenter is responsible for linking the uses cases in order to create a logical unit
* which will be represented as a screen in the application.
* @param <V> The view interface attached to this presenter.
* @see BaseView
*/
public abstract class Presenter<V extends BaseView> {
protected V view; | // Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
// public class ParserException extends UseCase<String> {
// private Throwable throwable;
//
// @Inject public ParserException(UI ui) {
// super(ui);
// }
//
// public ParserException with(Throwable throwable) {
// this.throwable = throwable;
// return this;
// }
//
// @Override public Observable<String> react() {
// String message = throwable.getMessage();
//
// if (throwable instanceof CompositeException) {
// message += System.getProperty("line.separator");
// CompositeException compositeException = (CompositeException) throwable;
//
// for (Throwable exception : compositeException.getExceptions()) {
// String exceptionName = exception.getClass().getSimpleName();
// String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "";
// message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator");
// }
// }
//
// return Observable.just(message);
// }
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/Wireframe.java
// public interface Wireframe {
// void dashboard();
// void searchUserScreen();
// void userScreen();
// void usersScreen();
// void popCurrentScreen();
// }
// Path: domain/src/main/java/domain/foundation/Presenter.java
import domain.foundation.helpers.ParserException;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import domain.sections.Wireframe;
import rx.Observable;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.foundation;
/**
* Base class for any Presenter.
* The presenter is responsible for linking the uses cases in order to create a logical unit
* which will be represented as a screen in the application.
* @param <V> The view interface attached to this presenter.
* @see BaseView
*/
public abstract class Presenter<V extends BaseView> {
protected V view; | protected final Wireframe wireframe; |
RefineriaWeb/base_app_android | domain/src/main/java/domain/foundation/Presenter.java | // Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
// public class ParserException extends UseCase<String> {
// private Throwable throwable;
//
// @Inject public ParserException(UI ui) {
// super(ui);
// }
//
// public ParserException with(Throwable throwable) {
// this.throwable = throwable;
// return this;
// }
//
// @Override public Observable<String> react() {
// String message = throwable.getMessage();
//
// if (throwable instanceof CompositeException) {
// message += System.getProperty("line.separator");
// CompositeException compositeException = (CompositeException) throwable;
//
// for (Throwable exception : compositeException.getExceptions()) {
// String exceptionName = exception.getClass().getSimpleName();
// String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "";
// message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator");
// }
// }
//
// return Observable.just(message);
// }
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/Wireframe.java
// public interface Wireframe {
// void dashboard();
// void searchUserScreen();
// void userScreen();
// void usersScreen();
// void popCurrentScreen();
// }
| import domain.foundation.helpers.ParserException;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import domain.sections.Wireframe;
import rx.Observable;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.foundation;
/**
* Base class for any Presenter.
* The presenter is responsible for linking the uses cases in order to create a logical unit
* which will be represented as a screen in the application.
* @param <V> The view interface attached to this presenter.
* @see BaseView
*/
public abstract class Presenter<V extends BaseView> {
protected V view;
protected final Wireframe wireframe; | // Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
// public class ParserException extends UseCase<String> {
// private Throwable throwable;
//
// @Inject public ParserException(UI ui) {
// super(ui);
// }
//
// public ParserException with(Throwable throwable) {
// this.throwable = throwable;
// return this;
// }
//
// @Override public Observable<String> react() {
// String message = throwable.getMessage();
//
// if (throwable instanceof CompositeException) {
// message += System.getProperty("line.separator");
// CompositeException compositeException = (CompositeException) throwable;
//
// for (Throwable exception : compositeException.getExceptions()) {
// String exceptionName = exception.getClass().getSimpleName();
// String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "";
// message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator");
// }
// }
//
// return Observable.just(message);
// }
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/Wireframe.java
// public interface Wireframe {
// void dashboard();
// void searchUserScreen();
// void userScreen();
// void usersScreen();
// void popCurrentScreen();
// }
// Path: domain/src/main/java/domain/foundation/Presenter.java
import domain.foundation.helpers.ParserException;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import domain.sections.Wireframe;
import rx.Observable;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.foundation;
/**
* Base class for any Presenter.
* The presenter is responsible for linking the uses cases in order to create a logical unit
* which will be represented as a screen in the application.
* @param <V> The view interface attached to this presenter.
* @see BaseView
*/
public abstract class Presenter<V extends BaseView> {
protected V view;
protected final Wireframe wireframe; | private final SubscribeOn subscribeOn; |
RefineriaWeb/base_app_android | domain/src/main/java/domain/foundation/Presenter.java | // Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
// public class ParserException extends UseCase<String> {
// private Throwable throwable;
//
// @Inject public ParserException(UI ui) {
// super(ui);
// }
//
// public ParserException with(Throwable throwable) {
// this.throwable = throwable;
// return this;
// }
//
// @Override public Observable<String> react() {
// String message = throwable.getMessage();
//
// if (throwable instanceof CompositeException) {
// message += System.getProperty("line.separator");
// CompositeException compositeException = (CompositeException) throwable;
//
// for (Throwable exception : compositeException.getExceptions()) {
// String exceptionName = exception.getClass().getSimpleName();
// String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "";
// message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator");
// }
// }
//
// return Observable.just(message);
// }
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/Wireframe.java
// public interface Wireframe {
// void dashboard();
// void searchUserScreen();
// void userScreen();
// void usersScreen();
// void popCurrentScreen();
// }
| import domain.foundation.helpers.ParserException;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import domain.sections.Wireframe;
import rx.Observable;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.foundation;
/**
* Base class for any Presenter.
* The presenter is responsible for linking the uses cases in order to create a logical unit
* which will be represented as a screen in the application.
* @param <V> The view interface attached to this presenter.
* @see BaseView
*/
public abstract class Presenter<V extends BaseView> {
protected V view;
protected final Wireframe wireframe;
private final SubscribeOn subscribeOn; | // Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
// public class ParserException extends UseCase<String> {
// private Throwable throwable;
//
// @Inject public ParserException(UI ui) {
// super(ui);
// }
//
// public ParserException with(Throwable throwable) {
// this.throwable = throwable;
// return this;
// }
//
// @Override public Observable<String> react() {
// String message = throwable.getMessage();
//
// if (throwable instanceof CompositeException) {
// message += System.getProperty("line.separator");
// CompositeException compositeException = (CompositeException) throwable;
//
// for (Throwable exception : compositeException.getExceptions()) {
// String exceptionName = exception.getClass().getSimpleName();
// String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "";
// message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator");
// }
// }
//
// return Observable.just(message);
// }
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/Wireframe.java
// public interface Wireframe {
// void dashboard();
// void searchUserScreen();
// void userScreen();
// void usersScreen();
// void popCurrentScreen();
// }
// Path: domain/src/main/java/domain/foundation/Presenter.java
import domain.foundation.helpers.ParserException;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import domain.sections.Wireframe;
import rx.Observable;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.foundation;
/**
* Base class for any Presenter.
* The presenter is responsible for linking the uses cases in order to create a logical unit
* which will be represented as a screen in the application.
* @param <V> The view interface attached to this presenter.
* @see BaseView
*/
public abstract class Presenter<V extends BaseView> {
protected V view;
protected final Wireframe wireframe;
private final SubscribeOn subscribeOn; | private final ObserveOn observeOn; |
RefineriaWeb/base_app_android | domain/src/main/java/domain/foundation/Presenter.java | // Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
// public class ParserException extends UseCase<String> {
// private Throwable throwable;
//
// @Inject public ParserException(UI ui) {
// super(ui);
// }
//
// public ParserException with(Throwable throwable) {
// this.throwable = throwable;
// return this;
// }
//
// @Override public Observable<String> react() {
// String message = throwable.getMessage();
//
// if (throwable instanceof CompositeException) {
// message += System.getProperty("line.separator");
// CompositeException compositeException = (CompositeException) throwable;
//
// for (Throwable exception : compositeException.getExceptions()) {
// String exceptionName = exception.getClass().getSimpleName();
// String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "";
// message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator");
// }
// }
//
// return Observable.just(message);
// }
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/Wireframe.java
// public interface Wireframe {
// void dashboard();
// void searchUserScreen();
// void userScreen();
// void usersScreen();
// void popCurrentScreen();
// }
| import domain.foundation.helpers.ParserException;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import domain.sections.Wireframe;
import rx.Observable;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.foundation;
/**
* Base class for any Presenter.
* The presenter is responsible for linking the uses cases in order to create a logical unit
* which will be represented as a screen in the application.
* @param <V> The view interface attached to this presenter.
* @see BaseView
*/
public abstract class Presenter<V extends BaseView> {
protected V view;
protected final Wireframe wireframe;
private final SubscribeOn subscribeOn;
private final ObserveOn observeOn; | // Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
// public class ParserException extends UseCase<String> {
// private Throwable throwable;
//
// @Inject public ParserException(UI ui) {
// super(ui);
// }
//
// public ParserException with(Throwable throwable) {
// this.throwable = throwable;
// return this;
// }
//
// @Override public Observable<String> react() {
// String message = throwable.getMessage();
//
// if (throwable instanceof CompositeException) {
// message += System.getProperty("line.separator");
// CompositeException compositeException = (CompositeException) throwable;
//
// for (Throwable exception : compositeException.getExceptions()) {
// String exceptionName = exception.getClass().getSimpleName();
// String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "";
// message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator");
// }
// }
//
// return Observable.just(message);
// }
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/Wireframe.java
// public interface Wireframe {
// void dashboard();
// void searchUserScreen();
// void userScreen();
// void usersScreen();
// void popCurrentScreen();
// }
// Path: domain/src/main/java/domain/foundation/Presenter.java
import domain.foundation.helpers.ParserException;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import domain.sections.Wireframe;
import rx.Observable;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.foundation;
/**
* Base class for any Presenter.
* The presenter is responsible for linking the uses cases in order to create a logical unit
* which will be represented as a screen in the application.
* @param <V> The view interface attached to this presenter.
* @see BaseView
*/
public abstract class Presenter<V extends BaseView> {
protected V view;
protected final Wireframe wireframe;
private final SubscribeOn subscribeOn;
private final ObserveOn observeOn; | private final ParserException parserException; |
RefineriaWeb/base_app_android | domain/src/main/java/domain/foundation/Presenter.java | // Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
// public class ParserException extends UseCase<String> {
// private Throwable throwable;
//
// @Inject public ParserException(UI ui) {
// super(ui);
// }
//
// public ParserException with(Throwable throwable) {
// this.throwable = throwable;
// return this;
// }
//
// @Override public Observable<String> react() {
// String message = throwable.getMessage();
//
// if (throwable instanceof CompositeException) {
// message += System.getProperty("line.separator");
// CompositeException compositeException = (CompositeException) throwable;
//
// for (Throwable exception : compositeException.getExceptions()) {
// String exceptionName = exception.getClass().getSimpleName();
// String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "";
// message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator");
// }
// }
//
// return Observable.just(message);
// }
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/Wireframe.java
// public interface Wireframe {
// void dashboard();
// void searchUserScreen();
// void userScreen();
// void usersScreen();
// void popCurrentScreen();
// }
| import domain.foundation.helpers.ParserException;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import domain.sections.Wireframe;
import rx.Observable;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.foundation;
/**
* Base class for any Presenter.
* The presenter is responsible for linking the uses cases in order to create a logical unit
* which will be represented as a screen in the application.
* @param <V> The view interface attached to this presenter.
* @see BaseView
*/
public abstract class Presenter<V extends BaseView> {
protected V view;
protected final Wireframe wireframe;
private final SubscribeOn subscribeOn;
private final ObserveOn observeOn;
private final ParserException parserException; | // Path: domain/src/main/java/domain/foundation/helpers/ParserException.java
// public class ParserException extends UseCase<String> {
// private Throwable throwable;
//
// @Inject public ParserException(UI ui) {
// super(ui);
// }
//
// public ParserException with(Throwable throwable) {
// this.throwable = throwable;
// return this;
// }
//
// @Override public Observable<String> react() {
// String message = throwable.getMessage();
//
// if (throwable instanceof CompositeException) {
// message += System.getProperty("line.separator");
// CompositeException compositeException = (CompositeException) throwable;
//
// for (Throwable exception : compositeException.getExceptions()) {
// String exceptionName = exception.getClass().getSimpleName();
// String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : "";
// message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator");
// }
// }
//
// return Observable.just(message);
// }
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
//
// Path: domain/src/main/java/domain/sections/Wireframe.java
// public interface Wireframe {
// void dashboard();
// void searchUserScreen();
// void userScreen();
// void usersScreen();
// void popCurrentScreen();
// }
// Path: domain/src/main/java/domain/foundation/Presenter.java
import domain.foundation.helpers.ParserException;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import domain.sections.Wireframe;
import rx.Observable;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.foundation;
/**
* Base class for any Presenter.
* The presenter is responsible for linking the uses cases in order to create a logical unit
* which will be represented as a screen in the application.
* @param <V> The view interface attached to this presenter.
* @see BaseView
*/
public abstract class Presenter<V extends BaseView> {
protected V view;
protected final Wireframe wireframe;
private final SubscribeOn subscribeOn;
private final ObserveOn observeOn;
private final ParserException parserException; | protected final UI ui; |
RefineriaWeb/base_app_android | domain/src/test/java/domain/sections/dashboard/GetMenuItemsUseCaseTest.java | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import org.junit.Test;
import org.mockito.Mock;
import java.util.List;
import domain.common.BaseTest;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.observers.TestSubscriber;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.dashboard;
public class GetMenuItemsUseCaseTest extends BaseTest {
private GetMenuItemsUseCase getMenuItemsUseCase;
@Mock protected DashboardItemsMenu dashboardItemsMenuMock; | // Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
// protected final static int WAIT = 50;
// @Mock protected UI UIMock;
// @Mock protected ObserveOn observeOnMock;
// @Mock protected SubscribeOn subscribeOnMock;
//
// @Before public void setUp() {
// MockitoAnnotations.initMocks(this);
// when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
// }
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
// private final int id;
// private final String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: domain/src/test/java/domain/sections/dashboard/GetMenuItemsUseCaseTest.java
import org.junit.Test;
import org.mockito.Mock;
import java.util.List;
import domain.common.BaseTest;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.observers.TestSubscriber;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.sections.dashboard;
public class GetMenuItemsUseCaseTest extends BaseTest {
private GetMenuItemsUseCase getMenuItemsUseCase;
@Mock protected DashboardItemsMenu dashboardItemsMenuMock; | @Mock protected UserDemoEntity userDemoEntityMock; |
RefineriaWeb/base_app_android | data/src/main/java/data/internal/di/DataModule.java | // Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
// Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
//
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
| import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.cache.RxProviders;
import data.net.RestApi;
import data.sections.user_demo.UserDemoDataRepository;
import data.storage.RepositoryAdapter;
import domain.sections.user_demo.UserDemoRepository;
import io.rx_cache.internal.RxCache;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory; | /*
* Copyright 2015 RefineriaWeb
*
* 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 data.internal.di;
/**
* Dagger module for data layer. {@link #provideRestApi} define the interface used by retrofit in order
* to generate every endpoint required
*
* {@link #provideUserDemoDataRepository} is an example of repository. UserDemoDataRepository implements the interface defined
* in the domain layer, it required to be able to launch the application.
*/
@Module
public class DataModule {
| // Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
// Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
//
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
// Path: data/src/main/java/data/internal/di/DataModule.java
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.cache.RxProviders;
import data.net.RestApi;
import data.sections.user_demo.UserDemoDataRepository;
import data.storage.RepositoryAdapter;
import domain.sections.user_demo.UserDemoRepository;
import io.rx_cache.internal.RxCache;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
/*
* Copyright 2015 RefineriaWeb
*
* 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 data.internal.di;
/**
* Dagger module for data layer. {@link #provideRestApi} define the interface used by retrofit in order
* to generate every endpoint required
*
* {@link #provideUserDemoDataRepository} is an example of repository. UserDemoDataRepository implements the interface defined
* in the domain layer, it required to be able to launch the application.
*/
@Module
public class DataModule {
| @Singleton @Provides RestApi provideRestApi() { |
RefineriaWeb/base_app_android | data/src/main/java/data/internal/di/DataModule.java | // Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
// Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
//
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
| import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.cache.RxProviders;
import data.net.RestApi;
import data.sections.user_demo.UserDemoDataRepository;
import data.storage.RepositoryAdapter;
import domain.sections.user_demo.UserDemoRepository;
import io.rx_cache.internal.RxCache;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory; | /*
* Copyright 2015 RefineriaWeb
*
* 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 data.internal.di;
/**
* Dagger module for data layer. {@link #provideRestApi} define the interface used by retrofit in order
* to generate every endpoint required
*
* {@link #provideUserDemoDataRepository} is an example of repository. UserDemoDataRepository implements the interface defined
* in the domain layer, it required to be able to launch the application.
*/
@Module
public class DataModule {
@Singleton @Provides RestApi provideRestApi() {
return new Retrofit.Builder()
.baseUrl(RestApi.URL_BASE)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(RestApi.class);
}
| // Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
// Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
//
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
// Path: data/src/main/java/data/internal/di/DataModule.java
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.cache.RxProviders;
import data.net.RestApi;
import data.sections.user_demo.UserDemoDataRepository;
import data.storage.RepositoryAdapter;
import domain.sections.user_demo.UserDemoRepository;
import io.rx_cache.internal.RxCache;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
/*
* Copyright 2015 RefineriaWeb
*
* 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 data.internal.di;
/**
* Dagger module for data layer. {@link #provideRestApi} define the interface used by retrofit in order
* to generate every endpoint required
*
* {@link #provideUserDemoDataRepository} is an example of repository. UserDemoDataRepository implements the interface defined
* in the domain layer, it required to be able to launch the application.
*/
@Module
public class DataModule {
@Singleton @Provides RestApi provideRestApi() {
return new Retrofit.Builder()
.baseUrl(RestApi.URL_BASE)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(RestApi.class);
}
| @Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) { |
RefineriaWeb/base_app_android | data/src/main/java/data/internal/di/DataModule.java | // Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
// Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
//
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
| import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.cache.RxProviders;
import data.net.RestApi;
import data.sections.user_demo.UserDemoDataRepository;
import data.storage.RepositoryAdapter;
import domain.sections.user_demo.UserDemoRepository;
import io.rx_cache.internal.RxCache;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory; | /*
* Copyright 2015 RefineriaWeb
*
* 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 data.internal.di;
/**
* Dagger module for data layer. {@link #provideRestApi} define the interface used by retrofit in order
* to generate every endpoint required
*
* {@link #provideUserDemoDataRepository} is an example of repository. UserDemoDataRepository implements the interface defined
* in the domain layer, it required to be able to launch the application.
*/
@Module
public class DataModule {
@Singleton @Provides RestApi provideRestApi() {
return new Retrofit.Builder()
.baseUrl(RestApi.URL_BASE)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(RestApi.class);
}
| // Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
// Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
//
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
// Path: data/src/main/java/data/internal/di/DataModule.java
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.cache.RxProviders;
import data.net.RestApi;
import data.sections.user_demo.UserDemoDataRepository;
import data.storage.RepositoryAdapter;
import domain.sections.user_demo.UserDemoRepository;
import io.rx_cache.internal.RxCache;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
/*
* Copyright 2015 RefineriaWeb
*
* 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 data.internal.di;
/**
* Dagger module for data layer. {@link #provideRestApi} define the interface used by retrofit in order
* to generate every endpoint required
*
* {@link #provideUserDemoDataRepository} is an example of repository. UserDemoDataRepository implements the interface defined
* in the domain layer, it required to be able to launch the application.
*/
@Module
public class DataModule {
@Singleton @Provides RestApi provideRestApi() {
return new Retrofit.Builder()
.baseUrl(RestApi.URL_BASE)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(RestApi.class);
}
| @Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) { |
RefineriaWeb/base_app_android | data/src/main/java/data/internal/di/DataModule.java | // Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
// Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
//
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
| import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.cache.RxProviders;
import data.net.RestApi;
import data.sections.user_demo.UserDemoDataRepository;
import data.storage.RepositoryAdapter;
import domain.sections.user_demo.UserDemoRepository;
import io.rx_cache.internal.RxCache;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory; | /*
* Copyright 2015 RefineriaWeb
*
* 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 data.internal.di;
/**
* Dagger module for data layer. {@link #provideRestApi} define the interface used by retrofit in order
* to generate every endpoint required
*
* {@link #provideUserDemoDataRepository} is an example of repository. UserDemoDataRepository implements the interface defined
* in the domain layer, it required to be able to launch the application.
*/
@Module
public class DataModule {
@Singleton @Provides RestApi provideRestApi() {
return new Retrofit.Builder()
.baseUrl(RestApi.URL_BASE)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(RestApi.class);
}
@Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
return new RxCache.Builder()
.persistence(repositoryAdapter.cacheDirectory())
.using(RxProviders.class);
}
| // Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
// Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
//
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
// Path: data/src/main/java/data/internal/di/DataModule.java
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.cache.RxProviders;
import data.net.RestApi;
import data.sections.user_demo.UserDemoDataRepository;
import data.storage.RepositoryAdapter;
import domain.sections.user_demo.UserDemoRepository;
import io.rx_cache.internal.RxCache;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
/*
* Copyright 2015 RefineriaWeb
*
* 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 data.internal.di;
/**
* Dagger module for data layer. {@link #provideRestApi} define the interface used by retrofit in order
* to generate every endpoint required
*
* {@link #provideUserDemoDataRepository} is an example of repository. UserDemoDataRepository implements the interface defined
* in the domain layer, it required to be able to launch the application.
*/
@Module
public class DataModule {
@Singleton @Provides RestApi provideRestApi() {
return new Retrofit.Builder()
.baseUrl(RestApi.URL_BASE)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(RestApi.class);
}
@Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
return new RxCache.Builder()
.persistence(repositoryAdapter.cacheDirectory())
.using(RxProviders.class);
}
| @Provides @Singleton public UserDemoRepository provideUserDemoDataRepository(UserDemoDataRepository userDemoDataRepository) { |
RefineriaWeb/base_app_android | data/src/main/java/data/internal/di/DataModule.java | // Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
// Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
//
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
| import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.cache.RxProviders;
import data.net.RestApi;
import data.sections.user_demo.UserDemoDataRepository;
import data.storage.RepositoryAdapter;
import domain.sections.user_demo.UserDemoRepository;
import io.rx_cache.internal.RxCache;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory; | /*
* Copyright 2015 RefineriaWeb
*
* 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 data.internal.di;
/**
* Dagger module for data layer. {@link #provideRestApi} define the interface used by retrofit in order
* to generate every endpoint required
*
* {@link #provideUserDemoDataRepository} is an example of repository. UserDemoDataRepository implements the interface defined
* in the domain layer, it required to be able to launch the application.
*/
@Module
public class DataModule {
@Singleton @Provides RestApi provideRestApi() {
return new Retrofit.Builder()
.baseUrl(RestApi.URL_BASE)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(RestApi.class);
}
@Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
return new RxCache.Builder()
.persistence(repositoryAdapter.cacheDirectory())
.using(RxProviders.class);
}
| // Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
// Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
//
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
//
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
//
// @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
// super(restApi, rxProviders, ui);
// }
//
// @Override public Observable<UserDemoEntity> searchByUserName(final String username) {
// return restApi.getUser(username).map(response -> {
// handleError(response);
// final UserDemoEntity user = response.body();
// return user;
// });
// }
//
// @Override public Observable<List<UserDemoEntity>> askForUsers() {
// return restApi.getUsers().map(response -> {
// handleError(response);
// return response.body();
// });
// }
//
// @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
// return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
// }
//
// @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
// return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
// .map(user-> true);
// }
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
// Observable<UserDemoEntity> searchByUserName(String nameUser);
// Observable<List<UserDemoEntity>> askForUsers();
// Observable<UserDemoEntity> getSelectedUserDemoList();
// Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
// Path: data/src/main/java/data/internal/di/DataModule.java
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.cache.RxProviders;
import data.net.RestApi;
import data.sections.user_demo.UserDemoDataRepository;
import data.storage.RepositoryAdapter;
import domain.sections.user_demo.UserDemoRepository;
import io.rx_cache.internal.RxCache;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
/*
* Copyright 2015 RefineriaWeb
*
* 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 data.internal.di;
/**
* Dagger module for data layer. {@link #provideRestApi} define the interface used by retrofit in order
* to generate every endpoint required
*
* {@link #provideUserDemoDataRepository} is an example of repository. UserDemoDataRepository implements the interface defined
* in the domain layer, it required to be able to launch the application.
*/
@Module
public class DataModule {
@Singleton @Provides RestApi provideRestApi() {
return new Retrofit.Builder()
.baseUrl(RestApi.URL_BASE)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(RestApi.class);
}
@Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
return new RxCache.Builder()
.persistence(repositoryAdapter.cacheDirectory())
.using(RxProviders.class);
}
| @Provides @Singleton public UserDemoRepository provideUserDemoDataRepository(UserDemoDataRepository userDemoDataRepository) { |
RefineriaWeb/base_app_android | presentation/src/main/java/presentation/internal/di/DataPresentationModule.java | // Path: data/src/main/java/data/internal/di/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides RestApi provideRestApi() {
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
// return new RxCache.Builder()
// .persistence(repositoryAdapter.cacheDirectory())
// .using(RxProviders.class);
// }
//
// @Provides @Singleton public UserDemoRepository provideUserDemoDataRepository(UserDemoDataRepository userDemoDataRepository) {
// return userDemoDataRepository;
// }
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: presentation/src/main/java/presentation/sections/UIData.java
// public class UIData implements UI {
// private final BaseApp baseApp;
//
// public UIData(BaseApp baseApp) {
// this.baseApp = baseApp;
// }
//
// @Override public Observable<String> genericError() {
// return Observable.just(baseApp.getString(R.string.generic_error));
// }
// }
| import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.internal.di.DataModule;
import data.sections.UI;
import data.storage.RepositoryAdapter;
import presentation.foundation.BaseApp;
import presentation.sections.UIData; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.internal.di;
/**
* Dependencies required by the data layer need to be provided in this dagger module
*/
@Module(includes = {DataModule.class, ApplicationModule.class})
public class DataPresentationModule {
/**
* Provides the file system for the data layer
* @see RepositoryAdapter
*/ | // Path: data/src/main/java/data/internal/di/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides RestApi provideRestApi() {
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
// return new RxCache.Builder()
// .persistence(repositoryAdapter.cacheDirectory())
// .using(RxProviders.class);
// }
//
// @Provides @Singleton public UserDemoRepository provideUserDemoDataRepository(UserDemoDataRepository userDemoDataRepository) {
// return userDemoDataRepository;
// }
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: presentation/src/main/java/presentation/sections/UIData.java
// public class UIData implements UI {
// private final BaseApp baseApp;
//
// public UIData(BaseApp baseApp) {
// this.baseApp = baseApp;
// }
//
// @Override public Observable<String> genericError() {
// return Observable.just(baseApp.getString(R.string.generic_error));
// }
// }
// Path: presentation/src/main/java/presentation/internal/di/DataPresentationModule.java
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.internal.di.DataModule;
import data.sections.UI;
import data.storage.RepositoryAdapter;
import presentation.foundation.BaseApp;
import presentation.sections.UIData;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.internal.di;
/**
* Dependencies required by the data layer need to be provided in this dagger module
*/
@Module(includes = {DataModule.class, ApplicationModule.class})
public class DataPresentationModule {
/**
* Provides the file system for the data layer
* @see RepositoryAdapter
*/ | @Singleton @Provides RepositoryAdapter provideRepositoryAdapter(BaseApp baseApp) { |
RefineriaWeb/base_app_android | presentation/src/main/java/presentation/internal/di/DataPresentationModule.java | // Path: data/src/main/java/data/internal/di/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides RestApi provideRestApi() {
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
// return new RxCache.Builder()
// .persistence(repositoryAdapter.cacheDirectory())
// .using(RxProviders.class);
// }
//
// @Provides @Singleton public UserDemoRepository provideUserDemoDataRepository(UserDemoDataRepository userDemoDataRepository) {
// return userDemoDataRepository;
// }
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: presentation/src/main/java/presentation/sections/UIData.java
// public class UIData implements UI {
// private final BaseApp baseApp;
//
// public UIData(BaseApp baseApp) {
// this.baseApp = baseApp;
// }
//
// @Override public Observable<String> genericError() {
// return Observable.just(baseApp.getString(R.string.generic_error));
// }
// }
| import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.internal.di.DataModule;
import data.sections.UI;
import data.storage.RepositoryAdapter;
import presentation.foundation.BaseApp;
import presentation.sections.UIData; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.internal.di;
/**
* Dependencies required by the data layer need to be provided in this dagger module
*/
@Module(includes = {DataModule.class, ApplicationModule.class})
public class DataPresentationModule {
/**
* Provides the file system for the data layer
* @see RepositoryAdapter
*/ | // Path: data/src/main/java/data/internal/di/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides RestApi provideRestApi() {
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
// return new RxCache.Builder()
// .persistence(repositoryAdapter.cacheDirectory())
// .using(RxProviders.class);
// }
//
// @Provides @Singleton public UserDemoRepository provideUserDemoDataRepository(UserDemoDataRepository userDemoDataRepository) {
// return userDemoDataRepository;
// }
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: presentation/src/main/java/presentation/sections/UIData.java
// public class UIData implements UI {
// private final BaseApp baseApp;
//
// public UIData(BaseApp baseApp) {
// this.baseApp = baseApp;
// }
//
// @Override public Observable<String> genericError() {
// return Observable.just(baseApp.getString(R.string.generic_error));
// }
// }
// Path: presentation/src/main/java/presentation/internal/di/DataPresentationModule.java
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.internal.di.DataModule;
import data.sections.UI;
import data.storage.RepositoryAdapter;
import presentation.foundation.BaseApp;
import presentation.sections.UIData;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.internal.di;
/**
* Dependencies required by the data layer need to be provided in this dagger module
*/
@Module(includes = {DataModule.class, ApplicationModule.class})
public class DataPresentationModule {
/**
* Provides the file system for the data layer
* @see RepositoryAdapter
*/ | @Singleton @Provides RepositoryAdapter provideRepositoryAdapter(BaseApp baseApp) { |
RefineriaWeb/base_app_android | presentation/src/main/java/presentation/internal/di/DataPresentationModule.java | // Path: data/src/main/java/data/internal/di/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides RestApi provideRestApi() {
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
// return new RxCache.Builder()
// .persistence(repositoryAdapter.cacheDirectory())
// .using(RxProviders.class);
// }
//
// @Provides @Singleton public UserDemoRepository provideUserDemoDataRepository(UserDemoDataRepository userDemoDataRepository) {
// return userDemoDataRepository;
// }
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: presentation/src/main/java/presentation/sections/UIData.java
// public class UIData implements UI {
// private final BaseApp baseApp;
//
// public UIData(BaseApp baseApp) {
// this.baseApp = baseApp;
// }
//
// @Override public Observable<String> genericError() {
// return Observable.just(baseApp.getString(R.string.generic_error));
// }
// }
| import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.internal.di.DataModule;
import data.sections.UI;
import data.storage.RepositoryAdapter;
import presentation.foundation.BaseApp;
import presentation.sections.UIData; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.internal.di;
/**
* Dependencies required by the data layer need to be provided in this dagger module
*/
@Module(includes = {DataModule.class, ApplicationModule.class})
public class DataPresentationModule {
/**
* Provides the file system for the data layer
* @see RepositoryAdapter
*/
@Singleton @Provides RepositoryAdapter provideRepositoryAdapter(BaseApp baseApp) {
return () -> baseApp.getFilesDir();
}
/**
* Provides the locale for the data layer
* @see UI
*/
@Singleton @Provides | // Path: data/src/main/java/data/internal/di/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides RestApi provideRestApi() {
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
// return new RxCache.Builder()
// .persistence(repositoryAdapter.cacheDirectory())
// .using(RxProviders.class);
// }
//
// @Provides @Singleton public UserDemoRepository provideUserDemoDataRepository(UserDemoDataRepository userDemoDataRepository) {
// return userDemoDataRepository;
// }
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: presentation/src/main/java/presentation/sections/UIData.java
// public class UIData implements UI {
// private final BaseApp baseApp;
//
// public UIData(BaseApp baseApp) {
// this.baseApp = baseApp;
// }
//
// @Override public Observable<String> genericError() {
// return Observable.just(baseApp.getString(R.string.generic_error));
// }
// }
// Path: presentation/src/main/java/presentation/internal/di/DataPresentationModule.java
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.internal.di.DataModule;
import data.sections.UI;
import data.storage.RepositoryAdapter;
import presentation.foundation.BaseApp;
import presentation.sections.UIData;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.internal.di;
/**
* Dependencies required by the data layer need to be provided in this dagger module
*/
@Module(includes = {DataModule.class, ApplicationModule.class})
public class DataPresentationModule {
/**
* Provides the file system for the data layer
* @see RepositoryAdapter
*/
@Singleton @Provides RepositoryAdapter provideRepositoryAdapter(BaseApp baseApp) {
return () -> baseApp.getFilesDir();
}
/**
* Provides the locale for the data layer
* @see UI
*/
@Singleton @Provides | UI provideLocale(BaseApp baseApp) { |
RefineriaWeb/base_app_android | presentation/src/main/java/presentation/internal/di/DataPresentationModule.java | // Path: data/src/main/java/data/internal/di/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides RestApi provideRestApi() {
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
// return new RxCache.Builder()
// .persistence(repositoryAdapter.cacheDirectory())
// .using(RxProviders.class);
// }
//
// @Provides @Singleton public UserDemoRepository provideUserDemoDataRepository(UserDemoDataRepository userDemoDataRepository) {
// return userDemoDataRepository;
// }
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: presentation/src/main/java/presentation/sections/UIData.java
// public class UIData implements UI {
// private final BaseApp baseApp;
//
// public UIData(BaseApp baseApp) {
// this.baseApp = baseApp;
// }
//
// @Override public Observable<String> genericError() {
// return Observable.just(baseApp.getString(R.string.generic_error));
// }
// }
| import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.internal.di.DataModule;
import data.sections.UI;
import data.storage.RepositoryAdapter;
import presentation.foundation.BaseApp;
import presentation.sections.UIData; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.internal.di;
/**
* Dependencies required by the data layer need to be provided in this dagger module
*/
@Module(includes = {DataModule.class, ApplicationModule.class})
public class DataPresentationModule {
/**
* Provides the file system for the data layer
* @see RepositoryAdapter
*/
@Singleton @Provides RepositoryAdapter provideRepositoryAdapter(BaseApp baseApp) {
return () -> baseApp.getFilesDir();
}
/**
* Provides the locale for the data layer
* @see UI
*/
@Singleton @Provides
UI provideLocale(BaseApp baseApp) { | // Path: data/src/main/java/data/internal/di/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides RestApi provideRestApi() {
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
// return new RxCache.Builder()
// .persistence(repositoryAdapter.cacheDirectory())
// .using(RxProviders.class);
// }
//
// @Provides @Singleton public UserDemoRepository provideUserDemoDataRepository(UserDemoDataRepository userDemoDataRepository) {
// return userDemoDataRepository;
// }
// }
//
// Path: data/src/main/java/data/sections/UI.java
// public interface UI {
// Observable<String> genericError();
// }
//
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
// File cacheDirectory();
// }
//
// Path: presentation/src/main/java/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private ApplicationComponent applicationComponent;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// }
//
// private void initInject() {
// applicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
//
// public ApplicationComponent getApplicationComponent() {
// return applicationComponent;
// }
//
// @Nullable public BaseFragmentActivity getLiveActivity(){
// return (BaseFragmentActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: presentation/src/main/java/presentation/sections/UIData.java
// public class UIData implements UI {
// private final BaseApp baseApp;
//
// public UIData(BaseApp baseApp) {
// this.baseApp = baseApp;
// }
//
// @Override public Observable<String> genericError() {
// return Observable.just(baseApp.getString(R.string.generic_error));
// }
// }
// Path: presentation/src/main/java/presentation/internal/di/DataPresentationModule.java
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.internal.di.DataModule;
import data.sections.UI;
import data.storage.RepositoryAdapter;
import presentation.foundation.BaseApp;
import presentation.sections.UIData;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.internal.di;
/**
* Dependencies required by the data layer need to be provided in this dagger module
*/
@Module(includes = {DataModule.class, ApplicationModule.class})
public class DataPresentationModule {
/**
* Provides the file system for the data layer
* @see RepositoryAdapter
*/
@Singleton @Provides RepositoryAdapter provideRepositoryAdapter(BaseApp baseApp) {
return () -> baseApp.getFilesDir();
}
/**
* Provides the locale for the data layer
* @see UI
*/
@Singleton @Provides
UI provideLocale(BaseApp baseApp) { | return new UIData(baseApp); |
RefineriaWeb/base_app_android | presentation/src/main/java/presentation/foundation/BaseFragmentActivity.java | // Path: presentation/src/main/java/presentation/internal/di/ApplicationComponent.java
// @Singleton @Component(modules = {DomainPresentationModule.class, DataPresentationModule.class, ApplicationModule.class})
// public interface ApplicationComponent {
// void inject(LaunchActivity launchActivity);
//
// void inject(DashBoardActivity dashBoardActivity);
// void inject(UserFragment userFragment);
// void inject(UsersFragment usersFragment);
// void inject(SearchUserFragment searchUserFragment);
// }
| import java.io.Serializable;
import base.app.android.R;
import butterknife.Bind;
import butterknife.ButterKnife;
import presentation.internal.di.ApplicationComponent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import com.afollestad.materialdialogs.MaterialDialog; | /*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.foundation;
public abstract class BaseFragmentActivity extends AppCompatActivity {
@Nullable @Bind(R.id.app_bar) protected AppBarLayout app_bar;
@Nullable @Bind(R.id.toolbar) protected Toolbar toolbar;
protected String app_name;
private MaterialDialog materialDialog;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app_name = getString(R.string.app_name);
if (layoutRes() != null) setContentView(layoutRes());
ButterKnife.bind(this);
injectDagger();
configureToolbar(toolbar, app_bar);
initViews();
configureFragment();
}
protected void initViews() {}
private Integer layoutRes() {
LayoutResActivity layoutRes = this.getClass().getAnnotation(LayoutResActivity.class);
return layoutRes != null ? layoutRes.value() : null;
}
protected abstract void injectDagger();
public BaseApp getBaseApp() {
return ((BaseApp)getApplication());
}
| // Path: presentation/src/main/java/presentation/internal/di/ApplicationComponent.java
// @Singleton @Component(modules = {DomainPresentationModule.class, DataPresentationModule.class, ApplicationModule.class})
// public interface ApplicationComponent {
// void inject(LaunchActivity launchActivity);
//
// void inject(DashBoardActivity dashBoardActivity);
// void inject(UserFragment userFragment);
// void inject(UsersFragment usersFragment);
// void inject(SearchUserFragment searchUserFragment);
// }
// Path: presentation/src/main/java/presentation/foundation/BaseFragmentActivity.java
import java.io.Serializable;
import base.app.android.R;
import butterknife.Bind;
import butterknife.ButterKnife;
import presentation.internal.di.ApplicationComponent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import com.afollestad.materialdialogs.MaterialDialog;
/*
* Copyright 2015 RefineriaWeb
*
* 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 presentation.foundation;
public abstract class BaseFragmentActivity extends AppCompatActivity {
@Nullable @Bind(R.id.app_bar) protected AppBarLayout app_bar;
@Nullable @Bind(R.id.toolbar) protected Toolbar toolbar;
protected String app_name;
private MaterialDialog materialDialog;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app_name = getString(R.string.app_name);
if (layoutRes() != null) setContentView(layoutRes());
ButterKnife.bind(this);
injectDagger();
configureToolbar(toolbar, app_bar);
initViews();
configureFragment();
}
protected void initViews() {}
private Integer layoutRes() {
LayoutResActivity layoutRes = this.getClass().getAnnotation(LayoutResActivity.class);
return layoutRes != null ? layoutRes.value() : null;
}
protected abstract void injectDagger();
public BaseApp getBaseApp() {
return ((BaseApp)getApplication());
}
| public ApplicationComponent getApplicationComponent() { |
RefineriaWeb/base_app_android | domain/src/test/java/domain/common/BaseTest.java | // Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
| import org.junit.Before;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import rx.schedulers.Schedulers;
import static org.mockito.Mockito.when; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.common;
public abstract class BaseTest {
protected final static int WAIT = 50; | // Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
// Path: domain/src/test/java/domain/common/BaseTest.java
import org.junit.Before;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import rx.schedulers.Schedulers;
import static org.mockito.Mockito.when;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.common;
public abstract class BaseTest {
protected final static int WAIT = 50; | @Mock protected UI UIMock; |
RefineriaWeb/base_app_android | domain/src/test/java/domain/common/BaseTest.java | // Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
| import org.junit.Before;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import rx.schedulers.Schedulers;
import static org.mockito.Mockito.when; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.common;
public abstract class BaseTest {
protected final static int WAIT = 50;
@Mock protected UI UIMock; | // Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
// Path: domain/src/test/java/domain/common/BaseTest.java
import org.junit.Before;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import rx.schedulers.Schedulers;
import static org.mockito.Mockito.when;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.common;
public abstract class BaseTest {
protected final static int WAIT = 50;
@Mock protected UI UIMock; | @Mock protected ObserveOn observeOnMock; |
RefineriaWeb/base_app_android | domain/src/test/java/domain/common/BaseTest.java | // Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
| import org.junit.Before;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import rx.schedulers.Schedulers;
import static org.mockito.Mockito.when; | /*
* Copyright 2015 RefineriaWeb
*
* 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 domain.common;
public abstract class BaseTest {
protected final static int WAIT = 50;
@Mock protected UI UIMock;
@Mock protected ObserveOn observeOnMock; | // Path: domain/src/main/java/domain/foundation/schedulers/ObserveOn.java
// public interface ObserveOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/foundation/schedulers/SubscribeOn.java
// public interface SubscribeOn {
// Scheduler getScheduler();
// }
//
// Path: domain/src/main/java/domain/sections/UI.java
// public interface UI {
// Observable<String> errorNonEmptyFields();
// Subscription showFeedback(Observable<String> oFeedback);
// Subscription showAnchoredScreenFeedback(Observable<String> oFeedback);
//
// void showLoading();
// void hideLoading();
// }
// Path: domain/src/test/java/domain/common/BaseTest.java
import org.junit.Before;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import domain.foundation.schedulers.ObserveOn;
import domain.foundation.schedulers.SubscribeOn;
import domain.sections.UI;
import rx.schedulers.Schedulers;
import static org.mockito.Mockito.when;
/*
* Copyright 2015 RefineriaWeb
*
* 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 domain.common;
public abstract class BaseTest {
protected final static int WAIT = 50;
@Mock protected UI UIMock;
@Mock protected ObserveOn observeOnMock; | @Mock protected SubscribeOn subscribeOnMock; |
zeroturnaround/zt-exec | src/main/java/org/zeroturnaround/exec/close/StandardProcessCloser.java | // Path: src/main/java/org/zeroturnaround/exec/stream/ExecuteStreamHandler.java
// public interface ExecuteStreamHandler {
//
// /**
// * Install a handler for the input stream of the subprocess.
// *
// * @param os
// * output stream to write to the standard input stream of the
// * subprocess
// * @throws IOException throws a IO exception in case of IO issues of the underlying stream
// */
// void setProcessInputStream(OutputStream os) throws IOException;
//
// /**
// * Install a handler for the error stream of the subprocess.
// *
// * @param is
// * input stream to read from the error stream from the subprocess
// * @throws IOException throws a IO exception in case of IO issues of the underlying stream
// */
// void setProcessErrorStream(InputStream is) throws IOException;
//
// /**
// * Install a handler for the output stream of the subprocess.
// *
// * @param is
// * input stream to read from the error stream from the subprocess
// * @throws IOException throws a IO exception in case of IO issues of the underlying stream
// */
// void setProcessOutputStream(InputStream is) throws IOException;
//
// /**
// * Start handling of the streams.
// *
// * @throws IOException throws a IO exception in case of IO issues of the underlying stream
// */
// void start() throws IOException;
//
// /**
// * Stop handling of the streams - will not be restarted.
// * Will wait for pump threads to complete.
// */
// void stop();
// }
| import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zeroturnaround.exec.stream.ExecuteStreamHandler; | /*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec.close;
/**
* Stops {@link ExecuteStreamHandler} from pumping the streams and closes them.
*/
public class StandardProcessCloser implements ProcessCloser {
private static final Logger log = LoggerFactory.getLogger(StandardProcessCloser.class);
| // Path: src/main/java/org/zeroturnaround/exec/stream/ExecuteStreamHandler.java
// public interface ExecuteStreamHandler {
//
// /**
// * Install a handler for the input stream of the subprocess.
// *
// * @param os
// * output stream to write to the standard input stream of the
// * subprocess
// * @throws IOException throws a IO exception in case of IO issues of the underlying stream
// */
// void setProcessInputStream(OutputStream os) throws IOException;
//
// /**
// * Install a handler for the error stream of the subprocess.
// *
// * @param is
// * input stream to read from the error stream from the subprocess
// * @throws IOException throws a IO exception in case of IO issues of the underlying stream
// */
// void setProcessErrorStream(InputStream is) throws IOException;
//
// /**
// * Install a handler for the output stream of the subprocess.
// *
// * @param is
// * input stream to read from the error stream from the subprocess
// * @throws IOException throws a IO exception in case of IO issues of the underlying stream
// */
// void setProcessOutputStream(InputStream is) throws IOException;
//
// /**
// * Start handling of the streams.
// *
// * @throws IOException throws a IO exception in case of IO issues of the underlying stream
// */
// void start() throws IOException;
//
// /**
// * Stop handling of the streams - will not be restarted.
// * Will wait for pump threads to complete.
// */
// void stop();
// }
// Path: src/main/java/org/zeroturnaround/exec/close/StandardProcessCloser.java
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zeroturnaround.exec.stream.ExecuteStreamHandler;
/*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec.close;
/**
* Stops {@link ExecuteStreamHandler} from pumping the streams and closes them.
*/
public class StandardProcessCloser implements ProcessCloser {
private static final Logger log = LoggerFactory.getLogger(StandardProcessCloser.class);
| protected final ExecuteStreamHandler streams; |
zeroturnaround/zt-exec | src/test/java/org/zeroturnaround/exec/test/LogOutputStreamTest.java | // Path: src/main/java/org/zeroturnaround/exec/stream/LogOutputStream.java
// public abstract class LogOutputStream extends OutputStream {
//
// /** Initial buffer size. */
// private static final int INTIAL_SIZE = 132;
//
// /** Carriage return */
// private static final int CR = 0x0d;
//
// /** Linefeed */
// private static final int LF = 0x0a;
//
// /** the internal buffer */
// private final ByteArrayOutputStream buffer = new ByteArrayOutputStream(
// INTIAL_SIZE);
//
// byte lastReceivedByte;
//
// private String outputCharset;
//
// public LogOutputStream setOutputCharset(final String outputCharset) {
// this.outputCharset = outputCharset;
// return this;
// }
//
// /**
// * Write the data to the buffer and flush the buffer, if a line separator is
// * detected.
// *
// * @param cc data to log (byte).
// * @see java.io.OutputStream#write(int)
// */
// public void write(final int cc) throws IOException {
// final byte c = (byte) cc;
// if ((c == '\n') || (c == '\r')) {
// // new line is started in case of
// // - CR (regardless of previous character)
// // - LF if previous character was not CR and not LF
// if (c == '\r' || (c == '\n' && (lastReceivedByte != '\r' && lastReceivedByte != '\n'))) {
// processBuffer();
// }
// } else {
// buffer.write(cc);
// }
// lastReceivedByte = c;
// }
//
// /**
// * Flush this log stream.
// *
// * @see java.io.OutputStream#flush()
// */
// public void flush() {
// if (buffer.size() > 0) {
// processBuffer();
// }
// }
//
// /**
// * Writes all remaining data from the buffer.
// *
// * @see java.io.OutputStream#close()
// */
// public void close() throws IOException {
// if (buffer.size() > 0) {
// processBuffer();
// }
// super.close();
// }
//
// /**
// * Write a block of characters to the output stream
// *
// * @param b the array containing the data
// * @param off the offset into the array where data starts
// * @param len the length of block
// * @throws java.io.IOException if the data cannot be written into the stream.
// * @see java.io.OutputStream#write(byte[], int, int)
// */
// public void write(final byte[] b, final int off, final int len)
// throws IOException {
// // find the line breaks and pass other chars through in blocks
// int offset = off;
// int blockStartOffset = offset;
// int remaining = len;
// while (remaining > 0) {
// while (remaining > 0 && b[offset] != LF && b[offset] != CR) {
// offset++;
// remaining--;
// }
// // either end of buffer or a line separator char
// int blockLength = offset - blockStartOffset;
// if (blockLength > 0) {
// buffer.write(b, blockStartOffset, blockLength);
// lastReceivedByte = 0;
// }
// while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) {
// write(b[offset]);
// offset++;
// remaining--;
// }
// blockStartOffset = offset;
// }
// }
//
// /**
// * Converts the buffer to a string and sends it to <code>processLine</code>.
// */
// protected void processBuffer() {
// final String line;
// if (outputCharset == null) {
// line = buffer.toString();
// } else {
// try {
// line = buffer.toString(outputCharset);
// } catch (UnsupportedEncodingException e) {
// throw new IllegalArgumentException(e);
// }
// }
// processLine(line);
// buffer.reset();
// }
//
// /**
// * Logs a line to the log system of the user.
// *
// * @param line
// * the line to log.
// */
// protected abstract void processLine(String line);
//
// }
| import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.zeroturnaround.exec.stream.LogOutputStream; | package org.zeroturnaround.exec.test;
public class LogOutputStreamTest {
private void testLogOutputStream(String multiLineString, String... expectedLines) throws UnsupportedEncodingException, IOException {
final List<String> processedLines = new ArrayList<String>(); | // Path: src/main/java/org/zeroturnaround/exec/stream/LogOutputStream.java
// public abstract class LogOutputStream extends OutputStream {
//
// /** Initial buffer size. */
// private static final int INTIAL_SIZE = 132;
//
// /** Carriage return */
// private static final int CR = 0x0d;
//
// /** Linefeed */
// private static final int LF = 0x0a;
//
// /** the internal buffer */
// private final ByteArrayOutputStream buffer = new ByteArrayOutputStream(
// INTIAL_SIZE);
//
// byte lastReceivedByte;
//
// private String outputCharset;
//
// public LogOutputStream setOutputCharset(final String outputCharset) {
// this.outputCharset = outputCharset;
// return this;
// }
//
// /**
// * Write the data to the buffer and flush the buffer, if a line separator is
// * detected.
// *
// * @param cc data to log (byte).
// * @see java.io.OutputStream#write(int)
// */
// public void write(final int cc) throws IOException {
// final byte c = (byte) cc;
// if ((c == '\n') || (c == '\r')) {
// // new line is started in case of
// // - CR (regardless of previous character)
// // - LF if previous character was not CR and not LF
// if (c == '\r' || (c == '\n' && (lastReceivedByte != '\r' && lastReceivedByte != '\n'))) {
// processBuffer();
// }
// } else {
// buffer.write(cc);
// }
// lastReceivedByte = c;
// }
//
// /**
// * Flush this log stream.
// *
// * @see java.io.OutputStream#flush()
// */
// public void flush() {
// if (buffer.size() > 0) {
// processBuffer();
// }
// }
//
// /**
// * Writes all remaining data from the buffer.
// *
// * @see java.io.OutputStream#close()
// */
// public void close() throws IOException {
// if (buffer.size() > 0) {
// processBuffer();
// }
// super.close();
// }
//
// /**
// * Write a block of characters to the output stream
// *
// * @param b the array containing the data
// * @param off the offset into the array where data starts
// * @param len the length of block
// * @throws java.io.IOException if the data cannot be written into the stream.
// * @see java.io.OutputStream#write(byte[], int, int)
// */
// public void write(final byte[] b, final int off, final int len)
// throws IOException {
// // find the line breaks and pass other chars through in blocks
// int offset = off;
// int blockStartOffset = offset;
// int remaining = len;
// while (remaining > 0) {
// while (remaining > 0 && b[offset] != LF && b[offset] != CR) {
// offset++;
// remaining--;
// }
// // either end of buffer or a line separator char
// int blockLength = offset - blockStartOffset;
// if (blockLength > 0) {
// buffer.write(b, blockStartOffset, blockLength);
// lastReceivedByte = 0;
// }
// while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) {
// write(b[offset]);
// offset++;
// remaining--;
// }
// blockStartOffset = offset;
// }
// }
//
// /**
// * Converts the buffer to a string and sends it to <code>processLine</code>.
// */
// protected void processBuffer() {
// final String line;
// if (outputCharset == null) {
// line = buffer.toString();
// } else {
// try {
// line = buffer.toString(outputCharset);
// } catch (UnsupportedEncodingException e) {
// throw new IllegalArgumentException(e);
// }
// }
// processLine(line);
// buffer.reset();
// }
//
// /**
// * Logs a line to the log system of the user.
// *
// * @param line
// * the line to log.
// */
// protected abstract void processLine(String line);
//
// }
// Path: src/test/java/org/zeroturnaround/exec/test/LogOutputStreamTest.java
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.zeroturnaround.exec.stream.LogOutputStream;
package org.zeroturnaround.exec.test;
public class LogOutputStreamTest {
private void testLogOutputStream(String multiLineString, String... expectedLines) throws UnsupportedEncodingException, IOException {
final List<String> processedLines = new ArrayList<String>(); | LogOutputStream logOutputStream = new LogOutputStream() { |
zeroturnaround/zt-exec | src/main/java/org/zeroturnaround/exec/WaitForProcess.java | // Path: src/main/java/org/zeroturnaround/exec/close/ProcessCloser.java
// public interface ProcessCloser {
//
// /**
// * Closes standard streams of a given sub process.
// *
// * @param process sub process (not <code>null</code>).
// * @throws IOException if I/O errors occur while closing the underlying stream
// * @throws InterruptedException if underlying throws a InterruptedException
// */
// void close(Process process) throws IOException, InterruptedException;
//
// }
//
// Path: src/main/java/org/zeroturnaround/exec/listener/ProcessListener.java
// public abstract class ProcessListener {
//
// /**
// * Invoked before a process is started.
// *
// * @param executor executor used for starting a process.
// * Any changes made here apply to the starting process.
// * Once the process has started it is not affected by the {@link ProcessExecutor} any more.
// */
// public void beforeStart(ProcessExecutor executor) {
// // do nothing
// }
//
// /**
// * Invoked after a process has started.
// *
// * @param process the process started.
// * @param executor executor used for starting the process.
// * Modifying the {@link ProcessExecutor} only affects the following processes
// * not the one just started.
// */
// public void afterStart(Process process, ProcessExecutor executor) {
// // do nothing
// }
//
// /**
// * Invoked after a process has finished successfully.
// *
// * @param process process just finished.
// * @param result result of the finished process.
// * @since 1.8
// */
// public void afterFinish(Process process, ProcessResult result) {
// // do nothing
// }
//
// /**
// * Invoked after a process has exited (whether finished or cancelled).
// *
// * @param process process just stopped.
// */
// public void afterStop(Process process) {
// // do nothing
// }
//
// }
//
// Path: src/main/java/org/zeroturnaround/exec/stop/ProcessStopper.java
// public interface ProcessStopper {
//
// /**
// * Stops a given sub process.
// * It does not wait for the process to actually stop and it has no guarantee that the process terminates.
// *
// * @param process sub process being stopped (not <code>null</code>).
// */
// void stop(Process process);
//
// }
| import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zeroturnaround.exec.close.ProcessCloser;
import org.zeroturnaround.exec.listener.ProcessListener;
import org.zeroturnaround.exec.stop.ProcessStopper; | /*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec;
/**
* Handles the executed process.
*
* @author Rein Raudjärv
*/
class WaitForProcess implements Callable<ProcessResult> {
private static final Logger log = LoggerFactory.getLogger(WaitForProcess.class);
private final Process process;
/**
* Set of main attributes used to start the process.
*/
private final ProcessAttributes attributes;
/**
* Helper for stopping the process in case of interruption.
*/ | // Path: src/main/java/org/zeroturnaround/exec/close/ProcessCloser.java
// public interface ProcessCloser {
//
// /**
// * Closes standard streams of a given sub process.
// *
// * @param process sub process (not <code>null</code>).
// * @throws IOException if I/O errors occur while closing the underlying stream
// * @throws InterruptedException if underlying throws a InterruptedException
// */
// void close(Process process) throws IOException, InterruptedException;
//
// }
//
// Path: src/main/java/org/zeroturnaround/exec/listener/ProcessListener.java
// public abstract class ProcessListener {
//
// /**
// * Invoked before a process is started.
// *
// * @param executor executor used for starting a process.
// * Any changes made here apply to the starting process.
// * Once the process has started it is not affected by the {@link ProcessExecutor} any more.
// */
// public void beforeStart(ProcessExecutor executor) {
// // do nothing
// }
//
// /**
// * Invoked after a process has started.
// *
// * @param process the process started.
// * @param executor executor used for starting the process.
// * Modifying the {@link ProcessExecutor} only affects the following processes
// * not the one just started.
// */
// public void afterStart(Process process, ProcessExecutor executor) {
// // do nothing
// }
//
// /**
// * Invoked after a process has finished successfully.
// *
// * @param process process just finished.
// * @param result result of the finished process.
// * @since 1.8
// */
// public void afterFinish(Process process, ProcessResult result) {
// // do nothing
// }
//
// /**
// * Invoked after a process has exited (whether finished or cancelled).
// *
// * @param process process just stopped.
// */
// public void afterStop(Process process) {
// // do nothing
// }
//
// }
//
// Path: src/main/java/org/zeroturnaround/exec/stop/ProcessStopper.java
// public interface ProcessStopper {
//
// /**
// * Stops a given sub process.
// * It does not wait for the process to actually stop and it has no guarantee that the process terminates.
// *
// * @param process sub process being stopped (not <code>null</code>).
// */
// void stop(Process process);
//
// }
// Path: src/main/java/org/zeroturnaround/exec/WaitForProcess.java
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zeroturnaround.exec.close.ProcessCloser;
import org.zeroturnaround.exec.listener.ProcessListener;
import org.zeroturnaround.exec.stop.ProcessStopper;
/*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec;
/**
* Handles the executed process.
*
* @author Rein Raudjärv
*/
class WaitForProcess implements Callable<ProcessResult> {
private static final Logger log = LoggerFactory.getLogger(WaitForProcess.class);
private final Process process;
/**
* Set of main attributes used to start the process.
*/
private final ProcessAttributes attributes;
/**
* Helper for stopping the process in case of interruption.
*/ | private final ProcessStopper stopper; |
zeroturnaround/zt-exec | src/main/java/org/zeroturnaround/exec/WaitForProcess.java | // Path: src/main/java/org/zeroturnaround/exec/close/ProcessCloser.java
// public interface ProcessCloser {
//
// /**
// * Closes standard streams of a given sub process.
// *
// * @param process sub process (not <code>null</code>).
// * @throws IOException if I/O errors occur while closing the underlying stream
// * @throws InterruptedException if underlying throws a InterruptedException
// */
// void close(Process process) throws IOException, InterruptedException;
//
// }
//
// Path: src/main/java/org/zeroturnaround/exec/listener/ProcessListener.java
// public abstract class ProcessListener {
//
// /**
// * Invoked before a process is started.
// *
// * @param executor executor used for starting a process.
// * Any changes made here apply to the starting process.
// * Once the process has started it is not affected by the {@link ProcessExecutor} any more.
// */
// public void beforeStart(ProcessExecutor executor) {
// // do nothing
// }
//
// /**
// * Invoked after a process has started.
// *
// * @param process the process started.
// * @param executor executor used for starting the process.
// * Modifying the {@link ProcessExecutor} only affects the following processes
// * not the one just started.
// */
// public void afterStart(Process process, ProcessExecutor executor) {
// // do nothing
// }
//
// /**
// * Invoked after a process has finished successfully.
// *
// * @param process process just finished.
// * @param result result of the finished process.
// * @since 1.8
// */
// public void afterFinish(Process process, ProcessResult result) {
// // do nothing
// }
//
// /**
// * Invoked after a process has exited (whether finished or cancelled).
// *
// * @param process process just stopped.
// */
// public void afterStop(Process process) {
// // do nothing
// }
//
// }
//
// Path: src/main/java/org/zeroturnaround/exec/stop/ProcessStopper.java
// public interface ProcessStopper {
//
// /**
// * Stops a given sub process.
// * It does not wait for the process to actually stop and it has no guarantee that the process terminates.
// *
// * @param process sub process being stopped (not <code>null</code>).
// */
// void stop(Process process);
//
// }
| import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zeroturnaround.exec.close.ProcessCloser;
import org.zeroturnaround.exec.listener.ProcessListener;
import org.zeroturnaround.exec.stop.ProcessStopper; | /*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec;
/**
* Handles the executed process.
*
* @author Rein Raudjärv
*/
class WaitForProcess implements Callable<ProcessResult> {
private static final Logger log = LoggerFactory.getLogger(WaitForProcess.class);
private final Process process;
/**
* Set of main attributes used to start the process.
*/
private final ProcessAttributes attributes;
/**
* Helper for stopping the process in case of interruption.
*/
private final ProcessStopper stopper;
/**
* Helper for closing the process' standard streams.
*/ | // Path: src/main/java/org/zeroturnaround/exec/close/ProcessCloser.java
// public interface ProcessCloser {
//
// /**
// * Closes standard streams of a given sub process.
// *
// * @param process sub process (not <code>null</code>).
// * @throws IOException if I/O errors occur while closing the underlying stream
// * @throws InterruptedException if underlying throws a InterruptedException
// */
// void close(Process process) throws IOException, InterruptedException;
//
// }
//
// Path: src/main/java/org/zeroturnaround/exec/listener/ProcessListener.java
// public abstract class ProcessListener {
//
// /**
// * Invoked before a process is started.
// *
// * @param executor executor used for starting a process.
// * Any changes made here apply to the starting process.
// * Once the process has started it is not affected by the {@link ProcessExecutor} any more.
// */
// public void beforeStart(ProcessExecutor executor) {
// // do nothing
// }
//
// /**
// * Invoked after a process has started.
// *
// * @param process the process started.
// * @param executor executor used for starting the process.
// * Modifying the {@link ProcessExecutor} only affects the following processes
// * not the one just started.
// */
// public void afterStart(Process process, ProcessExecutor executor) {
// // do nothing
// }
//
// /**
// * Invoked after a process has finished successfully.
// *
// * @param process process just finished.
// * @param result result of the finished process.
// * @since 1.8
// */
// public void afterFinish(Process process, ProcessResult result) {
// // do nothing
// }
//
// /**
// * Invoked after a process has exited (whether finished or cancelled).
// *
// * @param process process just stopped.
// */
// public void afterStop(Process process) {
// // do nothing
// }
//
// }
//
// Path: src/main/java/org/zeroturnaround/exec/stop/ProcessStopper.java
// public interface ProcessStopper {
//
// /**
// * Stops a given sub process.
// * It does not wait for the process to actually stop and it has no guarantee that the process terminates.
// *
// * @param process sub process being stopped (not <code>null</code>).
// */
// void stop(Process process);
//
// }
// Path: src/main/java/org/zeroturnaround/exec/WaitForProcess.java
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zeroturnaround.exec.close.ProcessCloser;
import org.zeroturnaround.exec.listener.ProcessListener;
import org.zeroturnaround.exec.stop.ProcessStopper;
/*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec;
/**
* Handles the executed process.
*
* @author Rein Raudjärv
*/
class WaitForProcess implements Callable<ProcessResult> {
private static final Logger log = LoggerFactory.getLogger(WaitForProcess.class);
private final Process process;
/**
* Set of main attributes used to start the process.
*/
private final ProcessAttributes attributes;
/**
* Helper for stopping the process in case of interruption.
*/
private final ProcessStopper stopper;
/**
* Helper for closing the process' standard streams.
*/ | private final ProcessCloser closer; |
zeroturnaround/zt-exec | src/main/java/org/zeroturnaround/exec/WaitForProcess.java | // Path: src/main/java/org/zeroturnaround/exec/close/ProcessCloser.java
// public interface ProcessCloser {
//
// /**
// * Closes standard streams of a given sub process.
// *
// * @param process sub process (not <code>null</code>).
// * @throws IOException if I/O errors occur while closing the underlying stream
// * @throws InterruptedException if underlying throws a InterruptedException
// */
// void close(Process process) throws IOException, InterruptedException;
//
// }
//
// Path: src/main/java/org/zeroturnaround/exec/listener/ProcessListener.java
// public abstract class ProcessListener {
//
// /**
// * Invoked before a process is started.
// *
// * @param executor executor used for starting a process.
// * Any changes made here apply to the starting process.
// * Once the process has started it is not affected by the {@link ProcessExecutor} any more.
// */
// public void beforeStart(ProcessExecutor executor) {
// // do nothing
// }
//
// /**
// * Invoked after a process has started.
// *
// * @param process the process started.
// * @param executor executor used for starting the process.
// * Modifying the {@link ProcessExecutor} only affects the following processes
// * not the one just started.
// */
// public void afterStart(Process process, ProcessExecutor executor) {
// // do nothing
// }
//
// /**
// * Invoked after a process has finished successfully.
// *
// * @param process process just finished.
// * @param result result of the finished process.
// * @since 1.8
// */
// public void afterFinish(Process process, ProcessResult result) {
// // do nothing
// }
//
// /**
// * Invoked after a process has exited (whether finished or cancelled).
// *
// * @param process process just stopped.
// */
// public void afterStop(Process process) {
// // do nothing
// }
//
// }
//
// Path: src/main/java/org/zeroturnaround/exec/stop/ProcessStopper.java
// public interface ProcessStopper {
//
// /**
// * Stops a given sub process.
// * It does not wait for the process to actually stop and it has no guarantee that the process terminates.
// *
// * @param process sub process being stopped (not <code>null</code>).
// */
// void stop(Process process);
//
// }
| import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zeroturnaround.exec.close.ProcessCloser;
import org.zeroturnaround.exec.listener.ProcessListener;
import org.zeroturnaround.exec.stop.ProcessStopper; | /*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec;
/**
* Handles the executed process.
*
* @author Rein Raudjärv
*/
class WaitForProcess implements Callable<ProcessResult> {
private static final Logger log = LoggerFactory.getLogger(WaitForProcess.class);
private final Process process;
/**
* Set of main attributes used to start the process.
*/
private final ProcessAttributes attributes;
/**
* Helper for stopping the process in case of interruption.
*/
private final ProcessStopper stopper;
/**
* Helper for closing the process' standard streams.
*/
private final ProcessCloser closer;
/**
* Buffer where the process output is redirected to or <code>null</code> if it's not used.
*/
private final ByteArrayOutputStream out;
/**
* Process event listener (not <code>null</code>).
*/ | // Path: src/main/java/org/zeroturnaround/exec/close/ProcessCloser.java
// public interface ProcessCloser {
//
// /**
// * Closes standard streams of a given sub process.
// *
// * @param process sub process (not <code>null</code>).
// * @throws IOException if I/O errors occur while closing the underlying stream
// * @throws InterruptedException if underlying throws a InterruptedException
// */
// void close(Process process) throws IOException, InterruptedException;
//
// }
//
// Path: src/main/java/org/zeroturnaround/exec/listener/ProcessListener.java
// public abstract class ProcessListener {
//
// /**
// * Invoked before a process is started.
// *
// * @param executor executor used for starting a process.
// * Any changes made here apply to the starting process.
// * Once the process has started it is not affected by the {@link ProcessExecutor} any more.
// */
// public void beforeStart(ProcessExecutor executor) {
// // do nothing
// }
//
// /**
// * Invoked after a process has started.
// *
// * @param process the process started.
// * @param executor executor used for starting the process.
// * Modifying the {@link ProcessExecutor} only affects the following processes
// * not the one just started.
// */
// public void afterStart(Process process, ProcessExecutor executor) {
// // do nothing
// }
//
// /**
// * Invoked after a process has finished successfully.
// *
// * @param process process just finished.
// * @param result result of the finished process.
// * @since 1.8
// */
// public void afterFinish(Process process, ProcessResult result) {
// // do nothing
// }
//
// /**
// * Invoked after a process has exited (whether finished or cancelled).
// *
// * @param process process just stopped.
// */
// public void afterStop(Process process) {
// // do nothing
// }
//
// }
//
// Path: src/main/java/org/zeroturnaround/exec/stop/ProcessStopper.java
// public interface ProcessStopper {
//
// /**
// * Stops a given sub process.
// * It does not wait for the process to actually stop and it has no guarantee that the process terminates.
// *
// * @param process sub process being stopped (not <code>null</code>).
// */
// void stop(Process process);
//
// }
// Path: src/main/java/org/zeroturnaround/exec/WaitForProcess.java
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zeroturnaround.exec.close.ProcessCloser;
import org.zeroturnaround.exec.listener.ProcessListener;
import org.zeroturnaround.exec.stop.ProcessStopper;
/*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec;
/**
* Handles the executed process.
*
* @author Rein Raudjärv
*/
class WaitForProcess implements Callable<ProcessResult> {
private static final Logger log = LoggerFactory.getLogger(WaitForProcess.class);
private final Process process;
/**
* Set of main attributes used to start the process.
*/
private final ProcessAttributes attributes;
/**
* Helper for stopping the process in case of interruption.
*/
private final ProcessStopper stopper;
/**
* Helper for closing the process' standard streams.
*/
private final ProcessCloser closer;
/**
* Buffer where the process output is redirected to or <code>null</code> if it's not used.
*/
private final ByteArrayOutputStream out;
/**
* Process event listener (not <code>null</code>).
*/ | private final ProcessListener listener; |
zeroturnaround/zt-exec | src/main/java/org/zeroturnaround/exec/stream/PumpStreamHandler.java | // Path: src/main/java/org/zeroturnaround/exec/MDCRunnableAdapter.java
// public class MDCRunnableAdapter implements Runnable {
//
// private final Runnable target;
//
// private final Map contextMap;
//
// public MDCRunnableAdapter(Runnable target, Map contextMap) {
// this.target = target;
// this.contextMap = contextMap;
// }
//
// public void run() {
// MDC.setContextMap(contextMap);
// try {
// target.run();
// }
// finally {
// MDC.clear();
// }
// }
//
// }
| import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.zeroturnaround.exec.MDCRunnableAdapter; | * @param os the output stream to copy into
* @return the stream pumper thread
*/
protected Thread createSystemInPump(InputStream is, OutputStream os) {
inputStreamPumper = new InputStreamPumper(is, os);
return newThread(inputStreamPumper);
}
/**
* Override this to customize how the background task is created.
*
* @param task the task to be run in the background
* @return the thread of the task
*/
protected Thread newThread(Runnable task) {
Thread result = new Thread(wrapTask(task));
result.setDaemon(true);
return result;
}
/**
* Override this to customize how the background task is created.
*
* @param task the task to be run in the background
* @return the runnable of the wrapped task
*/
protected Runnable wrapTask(Runnable task) {
// Preserve the MDC context of the caller thread.
Map contextMap = MDC.getCopyOfContextMap();
if (contextMap != null) { | // Path: src/main/java/org/zeroturnaround/exec/MDCRunnableAdapter.java
// public class MDCRunnableAdapter implements Runnable {
//
// private final Runnable target;
//
// private final Map contextMap;
//
// public MDCRunnableAdapter(Runnable target, Map contextMap) {
// this.target = target;
// this.contextMap = contextMap;
// }
//
// public void run() {
// MDC.setContextMap(contextMap);
// try {
// target.run();
// }
// finally {
// MDC.clear();
// }
// }
//
// }
// Path: src/main/java/org/zeroturnaround/exec/stream/PumpStreamHandler.java
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.zeroturnaround.exec.MDCRunnableAdapter;
* @param os the output stream to copy into
* @return the stream pumper thread
*/
protected Thread createSystemInPump(InputStream is, OutputStream os) {
inputStreamPumper = new InputStreamPumper(is, os);
return newThread(inputStreamPumper);
}
/**
* Override this to customize how the background task is created.
*
* @param task the task to be run in the background
* @return the thread of the task
*/
protected Thread newThread(Runnable task) {
Thread result = new Thread(wrapTask(task));
result.setDaemon(true);
return result;
}
/**
* Override this to customize how the background task is created.
*
* @param task the task to be run in the background
* @return the runnable of the wrapped task
*/
protected Runnable wrapTask(Runnable task) {
// Preserve the MDC context of the caller thread.
Map contextMap = MDC.getCopyOfContextMap();
if (contextMap != null) { | return new MDCRunnableAdapter(task, contextMap); |
zeroturnaround/zt-exec | src/test/java/org/zeroturnaround/exec/test/ProcessInitExceptionTest.java | // Path: src/main/java/org/zeroturnaround/exec/ProcessInitException.java
// public class ProcessInitException extends IOException {
//
// private static final String BEFORE_CODE = " error=";
// private static final String AFTER_CODE = ", ";
// private static final String NEW_INFIX = " Error=";
//
// private final int errorCode;
//
// public ProcessInitException(String message, Throwable cause, int errorCode) {
// super(message, cause);
// this.errorCode = errorCode;
// }
//
// /**
// * @return error code raised when a process failed to start.
// */
// public int getErrorCode() {
// return errorCode;
// }
//
// /**
// * Try to wrap a given {@link IOException} into a {@link ProcessInitException}.
// *
// * @param prefix prefix to be added in the message.
// * @param e existing exception possibly containing an error code in its message.
// * @return new exception containing the prefix, error code and its description in the message plus the error code value as a field,
// * <code>null</code> if we were unable to find an error code from the original message.
// */
// public static ProcessInitException newInstance(String prefix, IOException e) {
// String m = e.getMessage();
// if (m == null) {
// return null;
// }
// int i = m.lastIndexOf(BEFORE_CODE);
// if (i == -1) {
// return null;
// }
// int j = m.indexOf(AFTER_CODE, i);
// if (j == -1) {
// return null;
// }
// int code;
// try {
// code = Integer.parseInt(m.substring(i + BEFORE_CODE.length(), j));
// }
// catch (NumberFormatException n) {
// return null;
// }
// return new ProcessInitException(prefix + NEW_INFIX + m.substring(i + BEFORE_CODE.length()), e, code);
// }
//
// }
| import java.io.IOException;
import org.junit.Assert;
import org.junit.Test;
import org.zeroturnaround.exec.ProcessInitException; | /*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec.test;
public class ProcessInitExceptionTest {
@Test
public void testNull() throws Exception { | // Path: src/main/java/org/zeroturnaround/exec/ProcessInitException.java
// public class ProcessInitException extends IOException {
//
// private static final String BEFORE_CODE = " error=";
// private static final String AFTER_CODE = ", ";
// private static final String NEW_INFIX = " Error=";
//
// private final int errorCode;
//
// public ProcessInitException(String message, Throwable cause, int errorCode) {
// super(message, cause);
// this.errorCode = errorCode;
// }
//
// /**
// * @return error code raised when a process failed to start.
// */
// public int getErrorCode() {
// return errorCode;
// }
//
// /**
// * Try to wrap a given {@link IOException} into a {@link ProcessInitException}.
// *
// * @param prefix prefix to be added in the message.
// * @param e existing exception possibly containing an error code in its message.
// * @return new exception containing the prefix, error code and its description in the message plus the error code value as a field,
// * <code>null</code> if we were unable to find an error code from the original message.
// */
// public static ProcessInitException newInstance(String prefix, IOException e) {
// String m = e.getMessage();
// if (m == null) {
// return null;
// }
// int i = m.lastIndexOf(BEFORE_CODE);
// if (i == -1) {
// return null;
// }
// int j = m.indexOf(AFTER_CODE, i);
// if (j == -1) {
// return null;
// }
// int code;
// try {
// code = Integer.parseInt(m.substring(i + BEFORE_CODE.length(), j));
// }
// catch (NumberFormatException n) {
// return null;
// }
// return new ProcessInitException(prefix + NEW_INFIX + m.substring(i + BEFORE_CODE.length()), e, code);
// }
//
// }
// Path: src/test/java/org/zeroturnaround/exec/test/ProcessInitExceptionTest.java
import java.io.IOException;
import org.junit.Assert;
import org.junit.Test;
import org.zeroturnaround.exec.ProcessInitException;
/*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec.test;
public class ProcessInitExceptionTest {
@Test
public void testNull() throws Exception { | Assert.assertNull(ProcessInitException.newInstance(null, new IOException())); |
zeroturnaround/zt-exec | src/test/java/org/zeroturnaround/exec/test/CallerLoggerUtilTest.java | // Path: src/main/java/org/zeroturnaround/exec/stream/CallerLoggerUtil.java
// public abstract class CallerLoggerUtil {
//
// /**
// * Returns full name for the caller class' logger.
// *
// * @param name name of the logger. In case of full name (it contains dots) same value is just returned.
// * In case of short names (no dots) the given name is prefixed by caller's class name and a dot.
// * In case of <code>null</code> the caller's class name is just returned.
// * @return full name for the caller class' logger.
// */
// public static String getName(String name) {
// return getName(name, 1);
// }
//
// /**
// * Returns full name for the caller class' logger.
// *
// * @param name name of the logger. In case of full name (it contains dots) same value is just returned.
// * In case of short names (no dots) the given name is prefixed by caller's class name and a dot.
// * In case of <code>null</code> the caller's class name is just returned.
// * @param level no of call stack levels to get the caller (0 means the caller of this method).
// * @return full name for the caller class' logger.
// */
// public static String getName(String name, int level) {
// level++;
// String fullName;
// if (name == null)
// fullName = getCallerClassName(level);
// else if (name.contains("."))
// fullName = name;
// else
// fullName = getCallerClassName(level) + "." + name;
// return fullName;
// }
//
// /**
// * @return caller class name of the given level.
// */
// private static String getCallerClassName(int level) {
// return Thread.currentThread().getStackTrace()[level + 2].getClassName();
// }
//
// }
| import org.junit.Assert;
import org.junit.Test;
import org.zeroturnaround.exec.stream.CallerLoggerUtil; | /*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec.test;
public class CallerLoggerUtilTest {
@Test
public void testFullName() throws Exception {
String fullName = "my.full.Logger"; | // Path: src/main/java/org/zeroturnaround/exec/stream/CallerLoggerUtil.java
// public abstract class CallerLoggerUtil {
//
// /**
// * Returns full name for the caller class' logger.
// *
// * @param name name of the logger. In case of full name (it contains dots) same value is just returned.
// * In case of short names (no dots) the given name is prefixed by caller's class name and a dot.
// * In case of <code>null</code> the caller's class name is just returned.
// * @return full name for the caller class' logger.
// */
// public static String getName(String name) {
// return getName(name, 1);
// }
//
// /**
// * Returns full name for the caller class' logger.
// *
// * @param name name of the logger. In case of full name (it contains dots) same value is just returned.
// * In case of short names (no dots) the given name is prefixed by caller's class name and a dot.
// * In case of <code>null</code> the caller's class name is just returned.
// * @param level no of call stack levels to get the caller (0 means the caller of this method).
// * @return full name for the caller class' logger.
// */
// public static String getName(String name, int level) {
// level++;
// String fullName;
// if (name == null)
// fullName = getCallerClassName(level);
// else if (name.contains("."))
// fullName = name;
// else
// fullName = getCallerClassName(level) + "." + name;
// return fullName;
// }
//
// /**
// * @return caller class name of the given level.
// */
// private static String getCallerClassName(int level) {
// return Thread.currentThread().getStackTrace()[level + 2].getClassName();
// }
//
// }
// Path: src/test/java/org/zeroturnaround/exec/test/CallerLoggerUtilTest.java
import org.junit.Assert;
import org.junit.Test;
import org.zeroturnaround.exec.stream.CallerLoggerUtil;
/*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec.test;
public class CallerLoggerUtilTest {
@Test
public void testFullName() throws Exception {
String fullName = "my.full.Logger"; | Assert.assertEquals(fullName, CallerLoggerUtil.getName(fullName)); |
zeroturnaround/zt-exec | src/main/java/org/zeroturnaround/exec/stream/slf4j/Slf4jStream.java | // Path: src/main/java/org/zeroturnaround/exec/stream/CallerLoggerUtil.java
// public abstract class CallerLoggerUtil {
//
// /**
// * Returns full name for the caller class' logger.
// *
// * @param name name of the logger. In case of full name (it contains dots) same value is just returned.
// * In case of short names (no dots) the given name is prefixed by caller's class name and a dot.
// * In case of <code>null</code> the caller's class name is just returned.
// * @return full name for the caller class' logger.
// */
// public static String getName(String name) {
// return getName(name, 1);
// }
//
// /**
// * Returns full name for the caller class' logger.
// *
// * @param name name of the logger. In case of full name (it contains dots) same value is just returned.
// * In case of short names (no dots) the given name is prefixed by caller's class name and a dot.
// * In case of <code>null</code> the caller's class name is just returned.
// * @param level no of call stack levels to get the caller (0 means the caller of this method).
// * @return full name for the caller class' logger.
// */
// public static String getName(String name, int level) {
// level++;
// String fullName;
// if (name == null)
// fullName = getCallerClassName(level);
// else if (name.contains("."))
// fullName = name;
// else
// fullName = getCallerClassName(level) + "." + name;
// return fullName;
// }
//
// /**
// * @return caller class name of the given level.
// */
// private static String getCallerClassName(int level) {
// return Thread.currentThread().getStackTrace()[level + 2].getClassName();
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zeroturnaround.exec.stream.CallerLoggerUtil; | /*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec.stream.slf4j;
/**
* Creates output streams that write to {@link Logger}s.
*
* @author Rein Raudjärv
*/
public class Slf4jStream {
private final Logger log;
private Slf4jStream(Logger log) {
this.log = log;
}
/**
* @param log logger which an output stream redirects to.
* @return Slf4jStream with the given logger.
*/
public static Slf4jStream of(Logger log) {
return new Slf4jStream(log);
}
/**
* @param klass class which is used to get the logger's name.
* @return Slf4jStream with a logger named after the given class.
*/
public static Slf4jStream of(Class<?> klass) {
return of(LoggerFactory.getLogger(klass));
}
/**
* Constructs a logger from a class name and an additional name,
* appended to the end. So the final logger name will be:
* <blockquote><code>klass.getName() + "." + name</code></blockquote>
*
* @param klass class which is used to get the logger's name.
* @param name logger's name, appended to the class name.
* @return Slf4jStream with a logger named after the given class.
*
* @since 1.8
*/
public static Slf4jStream of(Class<?> klass, String name) {
if (name == null) {
return of(klass);
} else {
return of(LoggerFactory.getLogger(klass.getName() + "." + name));
}
}
/**
* @param name logger's name (full or short).
* In case of short name (no dots) the given name is prefixed by caller's class name and a dot.
* @return Slf4jStream with the given logger.
*/
public static Slf4jStream of(String name) { | // Path: src/main/java/org/zeroturnaround/exec/stream/CallerLoggerUtil.java
// public abstract class CallerLoggerUtil {
//
// /**
// * Returns full name for the caller class' logger.
// *
// * @param name name of the logger. In case of full name (it contains dots) same value is just returned.
// * In case of short names (no dots) the given name is prefixed by caller's class name and a dot.
// * In case of <code>null</code> the caller's class name is just returned.
// * @return full name for the caller class' logger.
// */
// public static String getName(String name) {
// return getName(name, 1);
// }
//
// /**
// * Returns full name for the caller class' logger.
// *
// * @param name name of the logger. In case of full name (it contains dots) same value is just returned.
// * In case of short names (no dots) the given name is prefixed by caller's class name and a dot.
// * In case of <code>null</code> the caller's class name is just returned.
// * @param level no of call stack levels to get the caller (0 means the caller of this method).
// * @return full name for the caller class' logger.
// */
// public static String getName(String name, int level) {
// level++;
// String fullName;
// if (name == null)
// fullName = getCallerClassName(level);
// else if (name.contains("."))
// fullName = name;
// else
// fullName = getCallerClassName(level) + "." + name;
// return fullName;
// }
//
// /**
// * @return caller class name of the given level.
// */
// private static String getCallerClassName(int level) {
// return Thread.currentThread().getStackTrace()[level + 2].getClassName();
// }
//
// }
// Path: src/main/java/org/zeroturnaround/exec/stream/slf4j/Slf4jStream.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zeroturnaround.exec.stream.CallerLoggerUtil;
/*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec.stream.slf4j;
/**
* Creates output streams that write to {@link Logger}s.
*
* @author Rein Raudjärv
*/
public class Slf4jStream {
private final Logger log;
private Slf4jStream(Logger log) {
this.log = log;
}
/**
* @param log logger which an output stream redirects to.
* @return Slf4jStream with the given logger.
*/
public static Slf4jStream of(Logger log) {
return new Slf4jStream(log);
}
/**
* @param klass class which is used to get the logger's name.
* @return Slf4jStream with a logger named after the given class.
*/
public static Slf4jStream of(Class<?> klass) {
return of(LoggerFactory.getLogger(klass));
}
/**
* Constructs a logger from a class name and an additional name,
* appended to the end. So the final logger name will be:
* <blockquote><code>klass.getName() + "." + name</code></blockquote>
*
* @param klass class which is used to get the logger's name.
* @param name logger's name, appended to the class name.
* @return Slf4jStream with a logger named after the given class.
*
* @since 1.8
*/
public static Slf4jStream of(Class<?> klass, String name) {
if (name == null) {
return of(klass);
} else {
return of(LoggerFactory.getLogger(klass.getName() + "." + name));
}
}
/**
* @param name logger's name (full or short).
* In case of short name (no dots) the given name is prefixed by caller's class name and a dot.
* @return Slf4jStream with the given logger.
*/
public static Slf4jStream of(String name) { | return of(LoggerFactory.getLogger(CallerLoggerUtil.getName(name, 1))); |
zeroturnaround/zt-exec | src/main/java/org/zeroturnaround/exec/MessageLoggers.java | // Path: src/main/java/org/zeroturnaround/exec/stream/slf4j/Level.java
// public enum Level {
//
// TRACE,
// DEBUG,
// INFO,
// WARN,
// ERROR
//
// }
| import org.slf4j.Logger;
import org.zeroturnaround.exec.stream.slf4j.Level; | /*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec;
/**
* Contains {@link MessageLogger} instances for various log levels.
*/
public class MessageLoggers {
public static final MessageLogger NOP = new MessageLogger() {
public void message(Logger log, String format, Object... arguments) {
// do nothing
}
};
public static final MessageLogger TRACE = new MessageLogger() {
public void message(Logger log, String format, Object... arguments) {
log.trace(format, arguments);
}
};
public static final MessageLogger DEBUG = new MessageLogger() {
public void message(Logger log, String format, Object... arguments) {
log.debug(format, arguments);
}
};
public static final MessageLogger INFO = new MessageLogger() {
public void message(Logger log, String format, Object... arguments) {
log.info(format, arguments);
}
};
| // Path: src/main/java/org/zeroturnaround/exec/stream/slf4j/Level.java
// public enum Level {
//
// TRACE,
// DEBUG,
// INFO,
// WARN,
// ERROR
//
// }
// Path: src/main/java/org/zeroturnaround/exec/MessageLoggers.java
import org.slf4j.Logger;
import org.zeroturnaround.exec.stream.slf4j.Level;
/*
* Copyright (C) 2014 ZeroTurnaround <[email protected]>
* Contains fragments of code from Apache Commons Exec, rights owned
* by Apache Software Foundation (ASF).
*
* 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.zeroturnaround.exec;
/**
* Contains {@link MessageLogger} instances for various log levels.
*/
public class MessageLoggers {
public static final MessageLogger NOP = new MessageLogger() {
public void message(Logger log, String format, Object... arguments) {
// do nothing
}
};
public static final MessageLogger TRACE = new MessageLogger() {
public void message(Logger log, String format, Object... arguments) {
log.trace(format, arguments);
}
};
public static final MessageLogger DEBUG = new MessageLogger() {
public void message(Logger log, String format, Object... arguments) {
log.debug(format, arguments);
}
};
public static final MessageLogger INFO = new MessageLogger() {
public void message(Logger log, String format, Object... arguments) {
log.info(format, arguments);
}
};
| public static final MessageLogger get(Level level) { |
twothe/DaVincing | src/main/java/two/davincing/utils/ExpirablePool.java | // Path: src/main/java/two/davincing/DaVincing.java
// @Mod(modid = DaVincing.MOD_ID, name = DaVincing.MOD_NAME, version = DaVincing.MOD_VERSION)
// public class DaVincing {
//
// /* Global logger that uses string format type logging */
// public static final Logger log = LogManager.getLogger(DaVincing.class.getSimpleName(), new StringFormatterMessageFactory());
// /* Task scheduler for background task. Will run at lowest thread priority to not interfere with FPS/ticks */
// public static final ScheduledExecutorService backgroundTasks = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), new PriorityThreadFactory(DaVincing.class.getSimpleName() + " Worker", Thread.MIN_PRIORITY, true));
// public static final ConcurrentLinkedQueue<Runnable> glTasks = new ConcurrentLinkedQueue<Runnable>();
//
// public static final String MOD_NAME = "DaVincing";
// public static final String MOD_ID = "davincing";
// public static final String MOD_VERSION = "1710.1.8"; // Make sure to keep this version in sync with the build.gradle file!
//
// @Mod.Instance(MOD_ID)
// public static DaVincing instance; // this will point to the actual instance of this class once running
//
// @SidedProxy(clientSide = "two.davincing.ProxyClient", serverSide = "two.davincing.ProxyServer")
// public static ProxyBase proxy; // will load the appropriate proxy class depending whether this is running on a client or on a server
//
// public static final Config config = new Config();
// public static final CreativeTabs tabDaVincing = new DaVincingCreativeTab();
// public static final SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel("minepainter");
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// config.initialize(event.getSuggestedConfigurationFile());
// proxy.onPreInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent e) {
// config.load();
// proxy.onInit();
//
// Crafting.instance.registerRecipes();
//
// network.registerMessage(SculptureOperationMessage.SculptureOperationHandler.class, SculptureOperationMessage.class, 0, Side.SERVER);
// network.registerMessage(PaintingOperationHandler.class, PaintingOperationMessage.class, 1, Side.SERVER);
// config.save();
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event) {
// proxy.onPostInit();
// }
//
// @Mod.EventHandler
// public void serverLoad(final FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandImportPainting());
// }
//
// @Mod.EventHandler
// public void serverStopped(final FMLServerStoppedEvent event) {
// }
// }
| import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import two.davincing.DaVincing; | package two.davincing.utils;
public abstract class ExpirablePool<K, V> implements Runnable {
static final long DEFAULT_CHECK_INTERVAL_MS = 80;
static final long DEFAULT_EXPIRY_TIME_MS = 60 * 1000;
protected final class MapEntry<V> {
final V value;
long expireDate = 0;
public MapEntry(final V value) {
this.value = value;
}
public void updateExpiry() {
this.expireDate = System.currentTimeMillis() + DEFAULT_EXPIRY_TIME_MS;
}
}
protected final ConcurrentHashMap<K, MapEntry<V>> items = new ConcurrentHashMap<K, MapEntry<V>>();
protected ScheduledFuture<?> cleanupTask = null;
public ExpirablePool() {
}
protected abstract void release(final V value);
protected abstract V create(final K key);
public void start() {
if (cleanupTask == null) { | // Path: src/main/java/two/davincing/DaVincing.java
// @Mod(modid = DaVincing.MOD_ID, name = DaVincing.MOD_NAME, version = DaVincing.MOD_VERSION)
// public class DaVincing {
//
// /* Global logger that uses string format type logging */
// public static final Logger log = LogManager.getLogger(DaVincing.class.getSimpleName(), new StringFormatterMessageFactory());
// /* Task scheduler for background task. Will run at lowest thread priority to not interfere with FPS/ticks */
// public static final ScheduledExecutorService backgroundTasks = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), new PriorityThreadFactory(DaVincing.class.getSimpleName() + " Worker", Thread.MIN_PRIORITY, true));
// public static final ConcurrentLinkedQueue<Runnable> glTasks = new ConcurrentLinkedQueue<Runnable>();
//
// public static final String MOD_NAME = "DaVincing";
// public static final String MOD_ID = "davincing";
// public static final String MOD_VERSION = "1710.1.8"; // Make sure to keep this version in sync with the build.gradle file!
//
// @Mod.Instance(MOD_ID)
// public static DaVincing instance; // this will point to the actual instance of this class once running
//
// @SidedProxy(clientSide = "two.davincing.ProxyClient", serverSide = "two.davincing.ProxyServer")
// public static ProxyBase proxy; // will load the appropriate proxy class depending whether this is running on a client or on a server
//
// public static final Config config = new Config();
// public static final CreativeTabs tabDaVincing = new DaVincingCreativeTab();
// public static final SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel("minepainter");
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// config.initialize(event.getSuggestedConfigurationFile());
// proxy.onPreInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent e) {
// config.load();
// proxy.onInit();
//
// Crafting.instance.registerRecipes();
//
// network.registerMessage(SculptureOperationMessage.SculptureOperationHandler.class, SculptureOperationMessage.class, 0, Side.SERVER);
// network.registerMessage(PaintingOperationHandler.class, PaintingOperationMessage.class, 1, Side.SERVER);
// config.save();
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event) {
// proxy.onPostInit();
// }
//
// @Mod.EventHandler
// public void serverLoad(final FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandImportPainting());
// }
//
// @Mod.EventHandler
// public void serverStopped(final FMLServerStoppedEvent event) {
// }
// }
// Path: src/main/java/two/davincing/utils/ExpirablePool.java
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import two.davincing.DaVincing;
package two.davincing.utils;
public abstract class ExpirablePool<K, V> implements Runnable {
static final long DEFAULT_CHECK_INTERVAL_MS = 80;
static final long DEFAULT_EXPIRY_TIME_MS = 60 * 1000;
protected final class MapEntry<V> {
final V value;
long expireDate = 0;
public MapEntry(final V value) {
this.value = value;
}
public void updateExpiry() {
this.expireDate = System.currentTimeMillis() + DEFAULT_EXPIRY_TIME_MS;
}
}
protected final ConcurrentHashMap<K, MapEntry<V>> items = new ConcurrentHashMap<K, MapEntry<V>>();
protected ScheduledFuture<?> cleanupTask = null;
public ExpirablePool() {
}
protected abstract void release(final V value);
protected abstract V create(final K key);
public void start() {
if (cleanupTask == null) { | cleanupTask = DaVincing.backgroundTasks.scheduleAtFixedRate(this, 0, DEFAULT_CHECK_INTERVAL_MS, TimeUnit.MILLISECONDS); |
twothe/DaVincing | src/main/java/two/davincing/Config.java | // Path: src/main/java/two/davincing/utils/Utils.java
// public class Utils {
//
// public static void forEachInv(IInventory inv, IInvTraversal traversal) {
// int size = inv.getSizeInventory();
// for (int i = 0; i < size; i++) {
// ItemStack is = inv.getStackInSlot(i);
// if (traversal.visit(i, is)) {
// return;
// }
// }
// }
//
// public static interface IInvTraversal {
//
// public boolean visit(int i, ItemStack is);
// }
//
// public static String getClassName(final Object o) {
// return o == null ? "null" : o.getClass().getName();
// }
//
// public static String getSimpleClassName(final Object o) {
// return o == null ? "null" : o.getClass().getSimpleName();
// }
//
// public static String blockToString(final Block block) {
// if (block == null) {
// return "null";
// }
// final String blockIDName = GameData.getBlockRegistry().getNameForObject(block);
// return blockIDName == null ? block.getUnlocalizedName() : blockIDName;
// }
//
// public static String itemToString(final Item item) {
// if (item == null) {
// return "null";
// } else {
// final String itemIDName = GameData.getItemRegistry().getNameForObject(item);
// return itemIDName == null ? item.getUnlocalizedName() : itemIDName;
// }
// }
// }
| import cpw.mods.fml.common.registry.GameData;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import two.davincing.utils.Utils; | final Property property = configuration.get(CATEGORY_VARIOUS_SETTINGS, key, defaultValue.toArray(new String[defaultValue.size()]), comment);
return Arrays.asList(property.getStringList());
}
public List<Block> getMiscBlocks(final String key, final List<Block> defaultValue) {
return getMiscBlocks(key, defaultValue, null);
}
public List<Block> getMiscBlocks(final String key, final List<Block> defaultValue, final String comment) {
final String[] defaultValueStrings = blockListToBlockNames(defaultValue);
final Property property = configuration.get(CATEGORY_VARIOUS_SETTINGS, key, defaultValueStrings, comment);
return blockNamesToBlockList(property.getStringList());
}
public Configuration getConfiguration() {
return configuration;
}
protected String[] blockListToBlockNames(final List<Block> blockList) {
if ((blockList == null) || blockList.isEmpty()) {
return new String[0];
} else {
final String[] result = new String[blockList.size()];
int index = 0;
for (final Block block : blockList) {
final String blockname = GameData.getBlockRegistry().getNameForObject(block);
if (blockname != null) {
result[index] = blockname;
++index;
} else { | // Path: src/main/java/two/davincing/utils/Utils.java
// public class Utils {
//
// public static void forEachInv(IInventory inv, IInvTraversal traversal) {
// int size = inv.getSizeInventory();
// for (int i = 0; i < size; i++) {
// ItemStack is = inv.getStackInSlot(i);
// if (traversal.visit(i, is)) {
// return;
// }
// }
// }
//
// public static interface IInvTraversal {
//
// public boolean visit(int i, ItemStack is);
// }
//
// public static String getClassName(final Object o) {
// return o == null ? "null" : o.getClass().getName();
// }
//
// public static String getSimpleClassName(final Object o) {
// return o == null ? "null" : o.getClass().getSimpleName();
// }
//
// public static String blockToString(final Block block) {
// if (block == null) {
// return "null";
// }
// final String blockIDName = GameData.getBlockRegistry().getNameForObject(block);
// return blockIDName == null ? block.getUnlocalizedName() : blockIDName;
// }
//
// public static String itemToString(final Item item) {
// if (item == null) {
// return "null";
// } else {
// final String itemIDName = GameData.getItemRegistry().getNameForObject(item);
// return itemIDName == null ? item.getUnlocalizedName() : itemIDName;
// }
// }
// }
// Path: src/main/java/two/davincing/Config.java
import cpw.mods.fml.common.registry.GameData;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import two.davincing.utils.Utils;
final Property property = configuration.get(CATEGORY_VARIOUS_SETTINGS, key, defaultValue.toArray(new String[defaultValue.size()]), comment);
return Arrays.asList(property.getStringList());
}
public List<Block> getMiscBlocks(final String key, final List<Block> defaultValue) {
return getMiscBlocks(key, defaultValue, null);
}
public List<Block> getMiscBlocks(final String key, final List<Block> defaultValue, final String comment) {
final String[] defaultValueStrings = blockListToBlockNames(defaultValue);
final Property property = configuration.get(CATEGORY_VARIOUS_SETTINGS, key, defaultValueStrings, comment);
return blockNamesToBlockList(property.getStringList());
}
public Configuration getConfiguration() {
return configuration;
}
protected String[] blockListToBlockNames(final List<Block> blockList) {
if ((blockList == null) || blockList.isEmpty()) {
return new String[0];
} else {
final String[] result = new String[blockList.size()];
int index = 0;
for (final Block block : blockList) {
final String blockname = GameData.getBlockRegistry().getNameForObject(block);
if (blockname != null) {
result[index] = blockname;
++index;
} else { | DaVincing.log.warn("Ignoring invalid block configuration entry: %s", Utils.blockToString(block)); |
twothe/DaVincing | src/main/java/two/davincing/utils/Texture.java | // Path: src/main/java/two/davincing/DaVincing.java
// @Mod(modid = DaVincing.MOD_ID, name = DaVincing.MOD_NAME, version = DaVincing.MOD_VERSION)
// public class DaVincing {
//
// /* Global logger that uses string format type logging */
// public static final Logger log = LogManager.getLogger(DaVincing.class.getSimpleName(), new StringFormatterMessageFactory());
// /* Task scheduler for background task. Will run at lowest thread priority to not interfere with FPS/ticks */
// public static final ScheduledExecutorService backgroundTasks = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), new PriorityThreadFactory(DaVincing.class.getSimpleName() + " Worker", Thread.MIN_PRIORITY, true));
// public static final ConcurrentLinkedQueue<Runnable> glTasks = new ConcurrentLinkedQueue<Runnable>();
//
// public static final String MOD_NAME = "DaVincing";
// public static final String MOD_ID = "davincing";
// public static final String MOD_VERSION = "1710.1.8"; // Make sure to keep this version in sync with the build.gradle file!
//
// @Mod.Instance(MOD_ID)
// public static DaVincing instance; // this will point to the actual instance of this class once running
//
// @SidedProxy(clientSide = "two.davincing.ProxyClient", serverSide = "two.davincing.ProxyServer")
// public static ProxyBase proxy; // will load the appropriate proxy class depending whether this is running on a client or on a server
//
// public static final Config config = new Config();
// public static final CreativeTabs tabDaVincing = new DaVincingCreativeTab();
// public static final SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel("minepainter");
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// config.initialize(event.getSuggestedConfigurationFile());
// proxy.onPreInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent e) {
// config.load();
// proxy.onInit();
//
// Crafting.instance.registerRecipes();
//
// network.registerMessage(SculptureOperationMessage.SculptureOperationHandler.class, SculptureOperationMessage.class, 0, Side.SERVER);
// network.registerMessage(PaintingOperationHandler.class, PaintingOperationMessage.class, 1, Side.SERVER);
// config.save();
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event) {
// proxy.onPostInit();
// }
//
// @Mod.EventHandler
// public void serverLoad(final FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandImportPainting());
// }
//
// @Mod.EventHandler
// public void serverStopped(final FMLServerStoppedEvent event) {
// }
// }
| import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import net.minecraft.util.IIcon;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import two.davincing.DaVincing; | package two.davincing.utils;
public abstract class Texture extends PixelData implements IIcon {
protected final IntBuffer pixelBuf;
protected int id;
protected boolean initialized;
public Texture(final int width, final int height) {
this(width, height, -1);
}
protected Texture(final int width, final int height, final int id) {
super(width, height);
this.id = id;
this.initialized = (id > 0);
this.pixelBuf = ByteBuffer.allocateDirect(width * height * Integer.SIZE / 8).order(ByteOrder.nativeOrder()).asIntBuffer();
}
@SideOnly(Side.CLIENT)
public void initializeGL() {
if (this.initialized == false) {
if (id < 0) {
this.id = GL11.glGenTextures();
if (this.id <= 0) { | // Path: src/main/java/two/davincing/DaVincing.java
// @Mod(modid = DaVincing.MOD_ID, name = DaVincing.MOD_NAME, version = DaVincing.MOD_VERSION)
// public class DaVincing {
//
// /* Global logger that uses string format type logging */
// public static final Logger log = LogManager.getLogger(DaVincing.class.getSimpleName(), new StringFormatterMessageFactory());
// /* Task scheduler for background task. Will run at lowest thread priority to not interfere with FPS/ticks */
// public static final ScheduledExecutorService backgroundTasks = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), new PriorityThreadFactory(DaVincing.class.getSimpleName() + " Worker", Thread.MIN_PRIORITY, true));
// public static final ConcurrentLinkedQueue<Runnable> glTasks = new ConcurrentLinkedQueue<Runnable>();
//
// public static final String MOD_NAME = "DaVincing";
// public static final String MOD_ID = "davincing";
// public static final String MOD_VERSION = "1710.1.8"; // Make sure to keep this version in sync with the build.gradle file!
//
// @Mod.Instance(MOD_ID)
// public static DaVincing instance; // this will point to the actual instance of this class once running
//
// @SidedProxy(clientSide = "two.davincing.ProxyClient", serverSide = "two.davincing.ProxyServer")
// public static ProxyBase proxy; // will load the appropriate proxy class depending whether this is running on a client or on a server
//
// public static final Config config = new Config();
// public static final CreativeTabs tabDaVincing = new DaVincingCreativeTab();
// public static final SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel("minepainter");
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// config.initialize(event.getSuggestedConfigurationFile());
// proxy.onPreInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent e) {
// config.load();
// proxy.onInit();
//
// Crafting.instance.registerRecipes();
//
// network.registerMessage(SculptureOperationMessage.SculptureOperationHandler.class, SculptureOperationMessage.class, 0, Side.SERVER);
// network.registerMessage(PaintingOperationHandler.class, PaintingOperationMessage.class, 1, Side.SERVER);
// config.save();
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event) {
// proxy.onPostInit();
// }
//
// @Mod.EventHandler
// public void serverLoad(final FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandImportPainting());
// }
//
// @Mod.EventHandler
// public void serverStopped(final FMLServerStoppedEvent event) {
// }
// }
// Path: src/main/java/two/davincing/utils/Texture.java
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import net.minecraft.util.IIcon;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import two.davincing.DaVincing;
package two.davincing.utils;
public abstract class Texture extends PixelData implements IIcon {
protected final IntBuffer pixelBuf;
protected int id;
protected boolean initialized;
public Texture(final int width, final int height) {
this(width, height, -1);
}
protected Texture(final int width, final int height, final int id) {
super(width, height);
this.id = id;
this.initialized = (id > 0);
this.pixelBuf = ByteBuffer.allocateDirect(width * height * Integer.SIZE / 8).order(ByteOrder.nativeOrder()).asIntBuffer();
}
@SideOnly(Side.CLIENT)
public void initializeGL() {
if (this.initialized == false) {
if (id < 0) {
this.id = GL11.glGenTextures();
if (this.id <= 0) { | DaVincing.log.error("Unable to generate new texture"); |
twothe/DaVincing | src/main/java/two/davincing/sculpture/SculptureEntityRenderer.java | // Path: src/main/java/two/davincing/DaVincing.java
// @Mod(modid = DaVincing.MOD_ID, name = DaVincing.MOD_NAME, version = DaVincing.MOD_VERSION)
// public class DaVincing {
//
// /* Global logger that uses string format type logging */
// public static final Logger log = LogManager.getLogger(DaVincing.class.getSimpleName(), new StringFormatterMessageFactory());
// /* Task scheduler for background task. Will run at lowest thread priority to not interfere with FPS/ticks */
// public static final ScheduledExecutorService backgroundTasks = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), new PriorityThreadFactory(DaVincing.class.getSimpleName() + " Worker", Thread.MIN_PRIORITY, true));
// public static final ConcurrentLinkedQueue<Runnable> glTasks = new ConcurrentLinkedQueue<Runnable>();
//
// public static final String MOD_NAME = "DaVincing";
// public static final String MOD_ID = "davincing";
// public static final String MOD_VERSION = "1710.1.8"; // Make sure to keep this version in sync with the build.gradle file!
//
// @Mod.Instance(MOD_ID)
// public static DaVincing instance; // this will point to the actual instance of this class once running
//
// @SidedProxy(clientSide = "two.davincing.ProxyClient", serverSide = "two.davincing.ProxyServer")
// public static ProxyBase proxy; // will load the appropriate proxy class depending whether this is running on a client or on a server
//
// public static final Config config = new Config();
// public static final CreativeTabs tabDaVincing = new DaVincingCreativeTab();
// public static final SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel("minepainter");
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// config.initialize(event.getSuggestedConfigurationFile());
// proxy.onPreInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent e) {
// config.load();
// proxy.onInit();
//
// Crafting.instance.registerRecipes();
//
// network.registerMessage(SculptureOperationMessage.SculptureOperationHandler.class, SculptureOperationMessage.class, 0, Side.SERVER);
// network.registerMessage(PaintingOperationHandler.class, PaintingOperationMessage.class, 1, Side.SERVER);
// config.save();
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event) {
// proxy.onPostInit();
// }
//
// @Mod.EventHandler
// public void serverLoad(final FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandImportPainting());
// }
//
// @Mod.EventHandler
// public void serverStopped(final FMLServerStoppedEvent event) {
// }
// }
| import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import two.davincing.DaVincing; | int light = lightY * 65536 + lightX;
se.getRender().initFromSculptureAndLight(se.sculpture(), light);
} else {
se.updateRender();
}
RenderHelper.disableStandardItemLighting();
GL11.glPushMatrix();
GL11.glTranslated(xd, yd, zd);
int displayList = se.getRender().glDisplayList[0];
if (displayList > 0) {
GL11.glCallList(displayList);
}
displayList = se.getRender().glDisplayList[1];
if (displayList > 0) {
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f);
GL11.glCallList(displayList);
GL11.glDisable(GL11.GL_BLEND);
}
GL11.glPopMatrix();
// GL11.glEnable(GL11.GL_ALPHA_TEST);
RenderHelper.enableStandardItemLighting();
} else { | // Path: src/main/java/two/davincing/DaVincing.java
// @Mod(modid = DaVincing.MOD_ID, name = DaVincing.MOD_NAME, version = DaVincing.MOD_VERSION)
// public class DaVincing {
//
// /* Global logger that uses string format type logging */
// public static final Logger log = LogManager.getLogger(DaVincing.class.getSimpleName(), new StringFormatterMessageFactory());
// /* Task scheduler for background task. Will run at lowest thread priority to not interfere with FPS/ticks */
// public static final ScheduledExecutorService backgroundTasks = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), new PriorityThreadFactory(DaVincing.class.getSimpleName() + " Worker", Thread.MIN_PRIORITY, true));
// public static final ConcurrentLinkedQueue<Runnable> glTasks = new ConcurrentLinkedQueue<Runnable>();
//
// public static final String MOD_NAME = "DaVincing";
// public static final String MOD_ID = "davincing";
// public static final String MOD_VERSION = "1710.1.8"; // Make sure to keep this version in sync with the build.gradle file!
//
// @Mod.Instance(MOD_ID)
// public static DaVincing instance; // this will point to the actual instance of this class once running
//
// @SidedProxy(clientSide = "two.davincing.ProxyClient", serverSide = "two.davincing.ProxyServer")
// public static ProxyBase proxy; // will load the appropriate proxy class depending whether this is running on a client or on a server
//
// public static final Config config = new Config();
// public static final CreativeTabs tabDaVincing = new DaVincingCreativeTab();
// public static final SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel("minepainter");
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// config.initialize(event.getSuggestedConfigurationFile());
// proxy.onPreInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent e) {
// config.load();
// proxy.onInit();
//
// Crafting.instance.registerRecipes();
//
// network.registerMessage(SculptureOperationMessage.SculptureOperationHandler.class, SculptureOperationMessage.class, 0, Side.SERVER);
// network.registerMessage(PaintingOperationHandler.class, PaintingOperationMessage.class, 1, Side.SERVER);
// config.save();
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event) {
// proxy.onPostInit();
// }
//
// @Mod.EventHandler
// public void serverLoad(final FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandImportPainting());
// }
//
// @Mod.EventHandler
// public void serverStopped(final FMLServerStoppedEvent event) {
// }
// }
// Path: src/main/java/two/davincing/sculpture/SculptureEntityRenderer.java
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import two.davincing.DaVincing;
int light = lightY * 65536 + lightX;
se.getRender().initFromSculptureAndLight(se.sculpture(), light);
} else {
se.updateRender();
}
RenderHelper.disableStandardItemLighting();
GL11.glPushMatrix();
GL11.glTranslated(xd, yd, zd);
int displayList = se.getRender().glDisplayList[0];
if (displayList > 0) {
GL11.glCallList(displayList);
}
displayList = se.getRender().glDisplayList[1];
if (displayList > 0) {
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f);
GL11.glCallList(displayList);
GL11.glDisable(GL11.GL_BLEND);
}
GL11.glPopMatrix();
// GL11.glEnable(GL11.GL_ALPHA_TEST);
RenderHelper.enableStandardItemLighting();
} else { | DaVincing.log.error("[SculptureEntityRenderer.renderTileEntityAt]: expected SculptureEntity at %f, %f, %f, but got %s", xd, yd, zd, (tileEntity == null ? "null" : tileEntity.getClass().getName())); |
twothe/DaVincing | src/main/java/two/davincing/item/ItemBase.java | // Path: src/main/java/two/davincing/DaVincing.java
// @Mod(modid = DaVincing.MOD_ID, name = DaVincing.MOD_NAME, version = DaVincing.MOD_VERSION)
// public class DaVincing {
//
// /* Global logger that uses string format type logging */
// public static final Logger log = LogManager.getLogger(DaVincing.class.getSimpleName(), new StringFormatterMessageFactory());
// /* Task scheduler for background task. Will run at lowest thread priority to not interfere with FPS/ticks */
// public static final ScheduledExecutorService backgroundTasks = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), new PriorityThreadFactory(DaVincing.class.getSimpleName() + " Worker", Thread.MIN_PRIORITY, true));
// public static final ConcurrentLinkedQueue<Runnable> glTasks = new ConcurrentLinkedQueue<Runnable>();
//
// public static final String MOD_NAME = "DaVincing";
// public static final String MOD_ID = "davincing";
// public static final String MOD_VERSION = "1710.1.8"; // Make sure to keep this version in sync with the build.gradle file!
//
// @Mod.Instance(MOD_ID)
// public static DaVincing instance; // this will point to the actual instance of this class once running
//
// @SidedProxy(clientSide = "two.davincing.ProxyClient", serverSide = "two.davincing.ProxyServer")
// public static ProxyBase proxy; // will load the appropriate proxy class depending whether this is running on a client or on a server
//
// public static final Config config = new Config();
// public static final CreativeTabs tabDaVincing = new DaVincingCreativeTab();
// public static final SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel("minepainter");
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// config.initialize(event.getSuggestedConfigurationFile());
// proxy.onPreInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent e) {
// config.load();
// proxy.onInit();
//
// Crafting.instance.registerRecipes();
//
// network.registerMessage(SculptureOperationMessage.SculptureOperationHandler.class, SculptureOperationMessage.class, 0, Side.SERVER);
// network.registerMessage(PaintingOperationHandler.class, PaintingOperationMessage.class, 1, Side.SERVER);
// config.save();
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event) {
// proxy.onPostInit();
// }
//
// @Mod.EventHandler
// public void serverLoad(final FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandImportPainting());
// }
//
// @Mod.EventHandler
// public void serverStopped(final FMLServerStoppedEvent event) {
// }
// }
//
// Path: src/main/java/two/davincing/InitializableModContent.java
// public interface InitializableModContent {
// public void initialize();
// }
| import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.Item;
import two.davincing.DaVincing;
import two.davincing.InitializableModContent; | /*
*/
package two.davincing.item;
/**
* @author Two
*/
public class ItemBase extends Item implements InitializableModContent {
public ItemBase() { | // Path: src/main/java/two/davincing/DaVincing.java
// @Mod(modid = DaVincing.MOD_ID, name = DaVincing.MOD_NAME, version = DaVincing.MOD_VERSION)
// public class DaVincing {
//
// /* Global logger that uses string format type logging */
// public static final Logger log = LogManager.getLogger(DaVincing.class.getSimpleName(), new StringFormatterMessageFactory());
// /* Task scheduler for background task. Will run at lowest thread priority to not interfere with FPS/ticks */
// public static final ScheduledExecutorService backgroundTasks = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), new PriorityThreadFactory(DaVincing.class.getSimpleName() + " Worker", Thread.MIN_PRIORITY, true));
// public static final ConcurrentLinkedQueue<Runnable> glTasks = new ConcurrentLinkedQueue<Runnable>();
//
// public static final String MOD_NAME = "DaVincing";
// public static final String MOD_ID = "davincing";
// public static final String MOD_VERSION = "1710.1.8"; // Make sure to keep this version in sync with the build.gradle file!
//
// @Mod.Instance(MOD_ID)
// public static DaVincing instance; // this will point to the actual instance of this class once running
//
// @SidedProxy(clientSide = "two.davincing.ProxyClient", serverSide = "two.davincing.ProxyServer")
// public static ProxyBase proxy; // will load the appropriate proxy class depending whether this is running on a client or on a server
//
// public static final Config config = new Config();
// public static final CreativeTabs tabDaVincing = new DaVincingCreativeTab();
// public static final SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel("minepainter");
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// config.initialize(event.getSuggestedConfigurationFile());
// proxy.onPreInit();
// }
//
// @Mod.EventHandler
// public void init(FMLInitializationEvent e) {
// config.load();
// proxy.onInit();
//
// Crafting.instance.registerRecipes();
//
// network.registerMessage(SculptureOperationMessage.SculptureOperationHandler.class, SculptureOperationMessage.class, 0, Side.SERVER);
// network.registerMessage(PaintingOperationHandler.class, PaintingOperationMessage.class, 1, Side.SERVER);
// config.save();
// }
//
// @Mod.EventHandler
// public void postInit(final FMLPostInitializationEvent event) {
// proxy.onPostInit();
// }
//
// @Mod.EventHandler
// public void serverLoad(final FMLServerStartingEvent event) {
// event.registerServerCommand(new CommandImportPainting());
// }
//
// @Mod.EventHandler
// public void serverStopped(final FMLServerStoppedEvent event) {
// }
// }
//
// Path: src/main/java/two/davincing/InitializableModContent.java
// public interface InitializableModContent {
// public void initialize();
// }
// Path: src/main/java/two/davincing/item/ItemBase.java
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.Item;
import two.davincing.DaVincing;
import two.davincing.InitializableModContent;
/*
*/
package two.davincing.item;
/**
* @author Two
*/
public class ItemBase extends Item implements InitializableModContent {
public ItemBase() { | this.setCreativeTab(DaVincing.tabDaVincing); |
twothe/DaVincing | src/main/java/two/davincing/sculpture/Sculpture.java | // Path: src/main/java/two/davincing/utils/Debug.java
// public class Debug {
//
// public static <T> void log(T... thing) {
// StringBuilder sb = new StringBuilder();
// for (T i : thing) {
// sb.append(i + ", ");
// }
// System.err.println(sb.toString());
// }
//
// }
| import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import two.davincing.utils.Debug; |
r.apply(x, y, z);
for (int l = 0; l < layers.length; l++) {
if ((index & (1 << l)) > 0) {
layers[l][r.x * 8 + r.y] |= (1 << r.z);
} else {
layers[l][r.x * 8 + r.y] &= ~(1 << r.z);
}
}
}
public static boolean contains(int x, int y, int z) {
return x >= 0 && y >= 0 && z >= 0 && x < 8 && y < 8 && z < 8;
}
private boolean check() {
if (block_ids == null) {
return false;
}
if (block_metas == null) {
return false;
}
if (layers == null) {
return false;
}
if (r.r == null) {
return false;
}
for (int i = 0; i < layers.length; i++) {
if (layers[i] == null) { | // Path: src/main/java/two/davincing/utils/Debug.java
// public class Debug {
//
// public static <T> void log(T... thing) {
// StringBuilder sb = new StringBuilder();
// for (T i : thing) {
// sb.append(i + ", ");
// }
// System.err.println(sb.toString());
// }
//
// }
// Path: src/main/java/two/davincing/sculpture/Sculpture.java
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import two.davincing.utils.Debug;
r.apply(x, y, z);
for (int l = 0; l < layers.length; l++) {
if ((index & (1 << l)) > 0) {
layers[l][r.x * 8 + r.y] |= (1 << r.z);
} else {
layers[l][r.x * 8 + r.y] &= ~(1 << r.z);
}
}
}
public static boolean contains(int x, int y, int z) {
return x >= 0 && y >= 0 && z >= 0 && x < 8 && y < 8 && z < 8;
}
private boolean check() {
if (block_ids == null) {
return false;
}
if (block_metas == null) {
return false;
}
if (layers == null) {
return false;
}
if (r.r == null) {
return false;
}
for (int i = 0; i < layers.length; i++) {
if (layers[i] == null) { | Debug.log("layer " + i + " is null!"); |
twothe/DaVincing | src/main/java/two/davincing/renderer/CanvasRenderer.java | // Path: src/main/java/two/davincing/ProxyBase.java
// public class ProxyBase {
//
// public static final BlockLoader<SculptureBlock> blockSculpture = new BlockLoader(new SculptureBlock(), SculptureEntity.class);
// public static final BlockLoader<PaintingBlock> blockPainting = new BlockLoader(new PaintingBlock(), PaintingEntity.class);
//
// public static ItemHandle itemHandle;
// public static ChiselItem itemChisel;
// public static ChiselItem itemBarcutter;
// public static ChiselItem itemSaw;
// public static PaintTool itemEraser;
// public static PaintTool itemBucket;
// public static PaintTool itemMixerbrush;
// public static PaintTool itemMinibrush;
// public static CopygunItem itemCopygun;
// public static Palette itemPalette;
// /* Items with special renderer */
// public static PieceItem itemBar;
// public static DroppedSculptureItem itemDroppedSculpture;
// public static PieceItem itemCover;
// public static CanvasItem itemCanvas;
// public static PieceItem itemPiece;
// /* Initialization list for content that needs post-initialization. */
// protected LinkedList<InitializableModContent> pendingInitialization = new LinkedList<InitializableModContent>();
// /* Global Config vars */
// public boolean doAmbientOcclusion; // whether or not to do ambient occlusion during rendering
// public final ArrayList<Block> blockBlacklist = new ArrayList<Block>();
//
// public ProxyBase() {
// }
//
// protected void loadGlobalConfigValues() {
// doAmbientOcclusion = DaVincing.config.getMiscBoolean("Render with Ambient Occlusion", false);
// final List<Block> defaultBlackList = Arrays.asList(new Block[]{
// Blocks.bedrock, Blocks.cactus, Blocks.glass, Blocks.grass, Blocks.leaves, Blocks.stained_glass
// });
//
// blockBlacklist.clear();
// blockBlacklist.addAll(DaVincing.config.getMiscBlocks("Chisel blacklist", defaultBlackList, "A list of blocks that cannot be chiseled. Note that all blocks with a tile entity or blocks that are not full blocks cannot be chiseled in general."));
// }
//
// protected void registerBlocks() {
// blockSculpture.load();
// blockPainting.load();
// }
//
// protected void registerItems() {
// itemHandle = new ItemHandle();
// pendingInitialization.add(itemHandle);
// itemChisel = new ChiselItem();
// pendingInitialization.add(itemChisel);
// itemBarcutter = new ChiselItem.Barcutter();
// pendingInitialization.add(itemBarcutter);
// itemSaw = new ChiselItem.Saw();
// pendingInitialization.add(itemSaw);
// itemCopygun = new CopygunItem();
// pendingInitialization.add(itemCopygun);
// itemMinibrush = new PaintTool.Mini();
// pendingInitialization.add(itemMinibrush);
// itemMixerbrush = new PaintTool.Mixer();
// pendingInitialization.add(itemMixerbrush);
// itemBucket = new PaintTool.Bucket();
// pendingInitialization.add(itemBucket);
// itemEraser = new PaintTool.Eraser();
// pendingInitialization.add(itemEraser);
// itemPalette = new Palette();
// pendingInitialization.add(itemPalette);
//
// itemCanvas = new CanvasItem();
// pendingInitialization.add(itemCanvas);
// itemPiece = new PieceItem();
// pendingInitialization.add(itemPiece);
// itemBar = new PieceItem.Bar();
// pendingInitialization.add(itemBar);
// itemCover = new PieceItem.Cover();
// pendingInitialization.add(itemCover);
// itemDroppedSculpture = new DroppedSculptureItem();
// pendingInitialization.add(itemDroppedSculpture);
// }
//
// protected void registerRenderers() {
// }
//
// public void onPreInit() {
// MinecraftForge.EVENT_BUS.register(this);
// }
//
// public void onInit() {
// loadGlobalConfigValues();
// registerBlocks();
// registerItems();
// registerRenderers();
//
// InitializableModContent content;
// while ((content = pendingInitialization.poll()) != null) {
// content.initialize();
// }
// }
//
// public void onPostInit() {
// }
// }
| import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.IItemRenderer.ItemRendererHelper;
import org.lwjgl.opengl.GL11;
import two.davincing.ProxyBase; | package two.davincing.renderer;
@SideOnly(Side.CLIENT)
public class CanvasRenderer implements IItemRenderer {
public static boolean overrideUseRenderHelper = false;
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type == ItemRenderType.INVENTORY
|| type == ItemRenderType.EQUIPPED
|| type == ItemRenderType.EQUIPPED_FIRST_PERSON
|| type == ItemRenderType.ENTITY;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
if (overrideUseRenderHelper) {
return true;
}
if (type == ItemRenderType.ENTITY) {
return helper == ItemRendererHelper.ENTITY_ROTATION
|| helper == ItemRendererHelper.ENTITY_BOBBING;
}
return false;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
IIcon icon;
if (item.hasTagCompound()) {
final PaintingTexture paintingTexture = ItemTextureCache.instance.get(item);
paintingTexture.bind();
icon = paintingTexture;
} else { | // Path: src/main/java/two/davincing/ProxyBase.java
// public class ProxyBase {
//
// public static final BlockLoader<SculptureBlock> blockSculpture = new BlockLoader(new SculptureBlock(), SculptureEntity.class);
// public static final BlockLoader<PaintingBlock> blockPainting = new BlockLoader(new PaintingBlock(), PaintingEntity.class);
//
// public static ItemHandle itemHandle;
// public static ChiselItem itemChisel;
// public static ChiselItem itemBarcutter;
// public static ChiselItem itemSaw;
// public static PaintTool itemEraser;
// public static PaintTool itemBucket;
// public static PaintTool itemMixerbrush;
// public static PaintTool itemMinibrush;
// public static CopygunItem itemCopygun;
// public static Palette itemPalette;
// /* Items with special renderer */
// public static PieceItem itemBar;
// public static DroppedSculptureItem itemDroppedSculpture;
// public static PieceItem itemCover;
// public static CanvasItem itemCanvas;
// public static PieceItem itemPiece;
// /* Initialization list for content that needs post-initialization. */
// protected LinkedList<InitializableModContent> pendingInitialization = new LinkedList<InitializableModContent>();
// /* Global Config vars */
// public boolean doAmbientOcclusion; // whether or not to do ambient occlusion during rendering
// public final ArrayList<Block> blockBlacklist = new ArrayList<Block>();
//
// public ProxyBase() {
// }
//
// protected void loadGlobalConfigValues() {
// doAmbientOcclusion = DaVincing.config.getMiscBoolean("Render with Ambient Occlusion", false);
// final List<Block> defaultBlackList = Arrays.asList(new Block[]{
// Blocks.bedrock, Blocks.cactus, Blocks.glass, Blocks.grass, Blocks.leaves, Blocks.stained_glass
// });
//
// blockBlacklist.clear();
// blockBlacklist.addAll(DaVincing.config.getMiscBlocks("Chisel blacklist", defaultBlackList, "A list of blocks that cannot be chiseled. Note that all blocks with a tile entity or blocks that are not full blocks cannot be chiseled in general."));
// }
//
// protected void registerBlocks() {
// blockSculpture.load();
// blockPainting.load();
// }
//
// protected void registerItems() {
// itemHandle = new ItemHandle();
// pendingInitialization.add(itemHandle);
// itemChisel = new ChiselItem();
// pendingInitialization.add(itemChisel);
// itemBarcutter = new ChiselItem.Barcutter();
// pendingInitialization.add(itemBarcutter);
// itemSaw = new ChiselItem.Saw();
// pendingInitialization.add(itemSaw);
// itemCopygun = new CopygunItem();
// pendingInitialization.add(itemCopygun);
// itemMinibrush = new PaintTool.Mini();
// pendingInitialization.add(itemMinibrush);
// itemMixerbrush = new PaintTool.Mixer();
// pendingInitialization.add(itemMixerbrush);
// itemBucket = new PaintTool.Bucket();
// pendingInitialization.add(itemBucket);
// itemEraser = new PaintTool.Eraser();
// pendingInitialization.add(itemEraser);
// itemPalette = new Palette();
// pendingInitialization.add(itemPalette);
//
// itemCanvas = new CanvasItem();
// pendingInitialization.add(itemCanvas);
// itemPiece = new PieceItem();
// pendingInitialization.add(itemPiece);
// itemBar = new PieceItem.Bar();
// pendingInitialization.add(itemBar);
// itemCover = new PieceItem.Cover();
// pendingInitialization.add(itemCover);
// itemDroppedSculpture = new DroppedSculptureItem();
// pendingInitialization.add(itemDroppedSculpture);
// }
//
// protected void registerRenderers() {
// }
//
// public void onPreInit() {
// MinecraftForge.EVENT_BUS.register(this);
// }
//
// public void onInit() {
// loadGlobalConfigValues();
// registerBlocks();
// registerItems();
// registerRenderers();
//
// InitializableModContent content;
// while ((content = pendingInitialization.poll()) != null) {
// content.initialize();
// }
// }
//
// public void onPostInit() {
// }
// }
// Path: src/main/java/two/davincing/renderer/CanvasRenderer.java
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.IItemRenderer.ItemRendererHelper;
import org.lwjgl.opengl.GL11;
import two.davincing.ProxyBase;
package two.davincing.renderer;
@SideOnly(Side.CLIENT)
public class CanvasRenderer implements IItemRenderer {
public static boolean overrideUseRenderHelper = false;
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type == ItemRenderType.INVENTORY
|| type == ItemRenderType.EQUIPPED
|| type == ItemRenderType.EQUIPPED_FIRST_PERSON
|| type == ItemRenderType.ENTITY;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
if (overrideUseRenderHelper) {
return true;
}
if (type == ItemRenderType.ENTITY) {
return helper == ItemRendererHelper.ENTITY_ROTATION
|| helper == ItemRendererHelper.ENTITY_BOBBING;
}
return false;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
IIcon icon;
if (item.hasTagCompound()) {
final PaintingTexture paintingTexture = ItemTextureCache.instance.get(item);
paintingTexture.bind();
icon = paintingTexture;
} else { | icon = ProxyBase.itemCanvas.getIconFromDamage(0); |
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/FieldExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class FieldExtractor extends AbstractContentExtractor {
public FieldExtractor(Element document, String source) {
super.document = document;
super.source = source;
}
@Override
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/FieldExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class FieldExtractor extends AbstractContentExtractor {
public FieldExtractor(Element document, String source) {
super.document = document;
super.source = source;
}
@Override
| protected List run(List<ScrapableField> fields, FIELD_TYPE type) {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/FieldExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class FieldExtractor extends AbstractContentExtractor {
public FieldExtractor(Element document, String source) {
super.document = document;
super.source = source;
}
@Override
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/FieldExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class FieldExtractor extends AbstractContentExtractor {
public FieldExtractor(Element document, String source) {
super.document = document;
super.source = source;
}
@Override
| protected List run(List<ScrapableField> fields, FIELD_TYPE type) {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/FieldExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class FieldExtractor extends AbstractContentExtractor {
public FieldExtractor(Element document, String source) {
super.document = document;
super.source = source;
}
@Override
protected List run(List<ScrapableField> fields, FIELD_TYPE type) {
ArrayList extractedFields = new ArrayList();
Document temp_company = new Document();
if (document != null) {
for (int i = 0; i < fields.size(); i++) {
try {
Document extracted_content = getSelectedElement(fields.get(i), document);
if (!extracted_content.getString("name").equals("") && !extracted_content.get("value").toString().equals("") && extracted_content.get("value") != null) {
if (type.equals(FIELD_TYPE.COMPANY_INFO)) {
temp_company.append(extracted_content.getString("name"), extracted_content.getString("value"));
} else {
extracted_content.append("source", source);
extractedFields.add(extracted_content);
}
}
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/FieldExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class FieldExtractor extends AbstractContentExtractor {
public FieldExtractor(Element document, String source) {
super.document = document;
super.source = source;
}
@Override
protected List run(List<ScrapableField> fields, FIELD_TYPE type) {
ArrayList extractedFields = new ArrayList();
Document temp_company = new Document();
if (document != null) {
for (int i = 0; i < fields.size(); i++) {
try {
Document extracted_content = getSelectedElement(fields.get(i), document);
if (!extracted_content.getString("name").equals("") && !extracted_content.get("value").toString().equals("") && extracted_content.get("value") != null) {
if (type.equals(FIELD_TYPE.COMPANY_INFO)) {
temp_company.append(extracted_content.getString("name"), extracted_content.getString("value"));
} else {
extracted_content.append("source", source);
extractedFields.add(extracted_content);
}
}
| } catch (PostProcessingException ex) {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public abstract class AbstractContentExtractor {
protected Element document;
protected String source;
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public abstract class AbstractContentExtractor {
protected Element document;
protected String source;
| abstract protected List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException;
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public abstract class AbstractContentExtractor {
protected Element document;
protected String source;
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public abstract class AbstractContentExtractor {
protected Element document;
protected String source;
| abstract protected List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException;
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public abstract class AbstractContentExtractor {
protected Element document;
protected String source;
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public abstract class AbstractContentExtractor {
protected Element document;
protected String source;
| abstract protected List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException;
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public abstract class AbstractContentExtractor {
protected Element document;
protected String source;
abstract protected List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException;
public List getExtractedFields(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException {
return run(fields, type);
}
/**
* Returns the content of a specific field in the document
*
* @param field
* @return a Pair of String, Object that corresponds to field name and field
* value accordingly
*/
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public abstract class AbstractContentExtractor {
protected Element document;
protected String source;
abstract protected List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException;
public List getExtractedFields(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException {
return run(fields, type);
}
/**
* Returns the content of a specific field in the document
*
* @param field
* @return a Pair of String, Object that corresponds to field name and field
* value accordingly
*/
| protected Document getSelectedElement(ScrapableField field, Object e) throws PostProcessingException {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public abstract class AbstractContentExtractor {
protected Element document;
protected String source;
abstract protected List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException;
public List getExtractedFields(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException {
return run(fields, type);
}
/**
* Returns the content of a specific field in the document
*
* @param field
* @return a Pair of String, Object that corresponds to field name and field
* value accordingly
*/
protected Document getSelectedElement(ScrapableField field, Object e) throws PostProcessingException {
Element element = (Element) e;
String field_name;
Object field_value;
Integer field_citeyear;
if (field.label instanceof String) {
field_name = (String) field.label;
} else {
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public abstract class AbstractContentExtractor {
protected Element document;
protected String source;
abstract protected List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException;
public List getExtractedFields(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException {
return run(fields, type);
}
/**
* Returns the content of a specific field in the document
*
* @param field
* @return a Pair of String, Object that corresponds to field name and field
* value accordingly
*/
protected Document getSelectedElement(ScrapableField field, Object e) throws PostProcessingException {
Element element = (Element) e;
String field_name;
Object field_value;
Integer field_citeyear;
if (field.label instanceof String) {
field_name = (String) field.label;
} else {
| field_name = extractContent((ExtractionProperties) field.label, element).toString();
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
| extracted_content = element.select(extraction_properties.selector).attr("href");
if (extracted_content.equals("")) {
extracted_content = element.select(extraction_properties.selector).attr("data-tab-content");
if (!extracted_content.equals("")) {
extracted_content = source + "#" + extracted_content;
}
}
} else if (extraction_properties.type.equals("image")) {
extracted_content = element.select(extraction_properties.selector).attr("src");
} else if (extraction_properties.type.equals("html")) {
extracted_content = element.select(extraction_properties.selector).html();
} else if (extraction_properties.type.equals("list")) {
extracted_content = extractList(element, extraction_properties.selector);
} else {
extracted_content = element.select(extraction_properties.selector).attr(extraction_properties.type);
}
if (extracted_content.equals("")) {
System.out.println("WARNING: No content found in the specified element:|" + element.cssSelector() + " " + extraction_properties.selector + "| Please check the correction of the defined extraction rule or for possible changes in the source!");
}
if (extracted_content instanceof String && extraction_properties.replace != null) {
extracted_content = processContent(
(String) extracted_content,
extraction_properties.replace
);
}
return extracted_content;
}
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
extracted_content = element.select(extraction_properties.selector).attr("href");
if (extracted_content.equals("")) {
extracted_content = element.select(extraction_properties.selector).attr("data-tab-content");
if (!extracted_content.equals("")) {
extracted_content = source + "#" + extracted_content;
}
}
} else if (extraction_properties.type.equals("image")) {
extracted_content = element.select(extraction_properties.selector).attr("src");
} else if (extraction_properties.type.equals("html")) {
extracted_content = element.select(extraction_properties.selector).html();
} else if (extraction_properties.type.equals("list")) {
extracted_content = extractList(element, extraction_properties.selector);
} else {
extracted_content = element.select(extraction_properties.selector).attr(extraction_properties.type);
}
if (extracted_content.equals("")) {
System.out.println("WARNING: No content found in the specified element:|" + element.cssSelector() + " " + extraction_properties.selector + "| Please check the correction of the defined extraction rule or for possible changes in the source!");
}
if (extracted_content instanceof String && extraction_properties.replace != null) {
extracted_content = processContent(
(String) extracted_content,
extraction_properties.replace
);
}
return extracted_content;
}
| protected String processContent(String content, ReplaceField replace_properties) throws PostProcessingException {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/dynamicpages/SingleDynamicPageExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
| import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import java.util.List;
import java.util.concurrent.Callable;
import org.jsoup.HttpStatusException;
import org.jsoup.nodes.Document;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors.dynamicpages;
/**
*
* @author vasgat
*/
public class SingleDynamicPageExtractor implements Callable {
public String page;
private String tableSelector;
| // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/dynamicpages/SingleDynamicPageExtractor.java
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import java.util.List;
import java.util.concurrent.Callable;
import org.jsoup.HttpStatusException;
import org.jsoup.nodes.Document;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors.dynamicpages;
/**
*
* @author vasgat
*/
public class SingleDynamicPageExtractor implements Callable {
public String page;
private String tableSelector;
| private List<ScrapableField> cfields;
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/configuration/JSONConfigurationDeserializer.java | // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public final class Configuration {
//
// public URL url;
//
// public HashSet<String> group_of_urls;
//
// public String source_name;
//
// public String entity_name;
//
// public String table_selector;
//
// public ArrayList<ScrapableField> metrics;
//
// public ArrayList<ScrapableField> entity_info;
//
// public String next_page_selector;
//
// public boolean dynamic_page;
//
// public Object events;
//
// public Store store;
//
// public Configuration crawl;
//
// public void setEvents(ArrayList<Event> events) {
// this.events = events;
// }
//
// public void setEvents(Event events) {
// this.events = events;
// }
//
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// public static class URL {
//
// public String base_url;
//
// public String relative_url;
// }
//
// public class Store {
//
// public String format;
//
// public String database;
//
// public String hd_path;
//
// public String companies_collection;
//
// public String metrics_collection;
//
// public DBCreadentials db_credentials;
//
// public String wikirate_metric_designer;
// }
//
// public class DBCreadentials {
//
// public String username;
//
// public String password;
//
// public String server_address;
//
// public String db;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
| import certh.iti.mklab.easie.configuration.Configuration;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.internal.LinkedTreeMap;
import certh.iti.mklab.easie.configuration.Configuration.Event;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import java.lang.reflect.Type;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONObject;
| package certh.iti.mklab.easie.configuration;
/**
* JSONConfigurationDeserializer extends JsonDeserializer and is responsible of
* the deserialization of a JSON formated file into Configuration Object.
* Required fields can be set through registerRequiredField method.
*
* @author vasgat
*/
public class JSONConfigurationDeserializer implements JsonDeserializer<Configuration> {
@Override
public Configuration deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
Configuration configuration = new Gson().fromJson(json, Configuration.class);
configuration.metrics = transform_metrics(configuration.metrics);
configuration.entity_info = transform_CompanyInfo(configuration.entity_info);
Configuration crawl = configuration.crawl;
while (crawl != null) {
crawl.metrics = transform_metrics(crawl.metrics);
crawl.entity_info = transform_CompanyInfo(crawl.entity_info);
crawl = crawl.crawl;
}
if (configuration.dynamic_page) {
Object events = configuration.events;
if (configuration.events != null) {
if (events instanceof ArrayList) {
| // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public final class Configuration {
//
// public URL url;
//
// public HashSet<String> group_of_urls;
//
// public String source_name;
//
// public String entity_name;
//
// public String table_selector;
//
// public ArrayList<ScrapableField> metrics;
//
// public ArrayList<ScrapableField> entity_info;
//
// public String next_page_selector;
//
// public boolean dynamic_page;
//
// public Object events;
//
// public Store store;
//
// public Configuration crawl;
//
// public void setEvents(ArrayList<Event> events) {
// this.events = events;
// }
//
// public void setEvents(Event events) {
// this.events = events;
// }
//
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// public static class URL {
//
// public String base_url;
//
// public String relative_url;
// }
//
// public class Store {
//
// public String format;
//
// public String database;
//
// public String hd_path;
//
// public String companies_collection;
//
// public String metrics_collection;
//
// public DBCreadentials db_credentials;
//
// public String wikirate_metric_designer;
// }
//
// public class DBCreadentials {
//
// public String username;
//
// public String password;
//
// public String server_address;
//
// public String db;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/configuration/JSONConfigurationDeserializer.java
import certh.iti.mklab.easie.configuration.Configuration;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.internal.LinkedTreeMap;
import certh.iti.mklab.easie.configuration.Configuration.Event;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import java.lang.reflect.Type;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONObject;
package certh.iti.mklab.easie.configuration;
/**
* JSONConfigurationDeserializer extends JsonDeserializer and is responsible of
* the deserialization of a JSON formated file into Configuration Object.
* Required fields can be set through registerRequiredField method.
*
* @author vasgat
*/
public class JSONConfigurationDeserializer implements JsonDeserializer<Configuration> {
@Override
public Configuration deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
Configuration configuration = new Gson().fromJson(json, Configuration.class);
configuration.metrics = transform_metrics(configuration.metrics);
configuration.entity_info = transform_CompanyInfo(configuration.entity_info);
Configuration crawl = configuration.crawl;
while (crawl != null) {
crawl.metrics = transform_metrics(crawl.metrics);
crawl.entity_info = transform_CompanyInfo(crawl.entity_info);
crawl = crawl.crawl;
}
if (configuration.dynamic_page) {
Object events = configuration.events;
if (configuration.events != null) {
if (events instanceof ArrayList) {
| ArrayList<Event> evnts = new Gson().fromJson(
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/configuration/JSONConfigurationDeserializer.java | // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public final class Configuration {
//
// public URL url;
//
// public HashSet<String> group_of_urls;
//
// public String source_name;
//
// public String entity_name;
//
// public String table_selector;
//
// public ArrayList<ScrapableField> metrics;
//
// public ArrayList<ScrapableField> entity_info;
//
// public String next_page_selector;
//
// public boolean dynamic_page;
//
// public Object events;
//
// public Store store;
//
// public Configuration crawl;
//
// public void setEvents(ArrayList<Event> events) {
// this.events = events;
// }
//
// public void setEvents(Event events) {
// this.events = events;
// }
//
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// public static class URL {
//
// public String base_url;
//
// public String relative_url;
// }
//
// public class Store {
//
// public String format;
//
// public String database;
//
// public String hd_path;
//
// public String companies_collection;
//
// public String metrics_collection;
//
// public DBCreadentials db_credentials;
//
// public String wikirate_metric_designer;
// }
//
// public class DBCreadentials {
//
// public String username;
//
// public String password;
//
// public String server_address;
//
// public String db;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
| import certh.iti.mklab.easie.configuration.Configuration;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.internal.LinkedTreeMap;
import certh.iti.mklab.easie.configuration.Configuration.Event;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import java.lang.reflect.Type;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONObject;
|
configuration.entity_info = transform_CompanyInfo(configuration.entity_info);
Configuration crawl = configuration.crawl;
while (crawl != null) {
crawl.metrics = transform_metrics(crawl.metrics);
crawl.entity_info = transform_CompanyInfo(crawl.entity_info);
crawl = crawl.crawl;
}
if (configuration.dynamic_page) {
Object events = configuration.events;
if (configuration.events != null) {
if (events instanceof ArrayList) {
ArrayList<Event> evnts = new Gson().fromJson(
(new JSONArray((ArrayList<LinkedTreeMap>) events)).toString(),
new TypeToken<ArrayList<Event>>() {
}.getType());
configuration.setEvents(evnts);
} else {
Event evnts = new Gson().fromJson(
(new JSONObject((LinkedTreeMap) events)).toString(), new TypeToken<Event>() {
}.getType());
configuration.setEvents(evnts);
}
}
}
return configuration;
}
| // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public final class Configuration {
//
// public URL url;
//
// public HashSet<String> group_of_urls;
//
// public String source_name;
//
// public String entity_name;
//
// public String table_selector;
//
// public ArrayList<ScrapableField> metrics;
//
// public ArrayList<ScrapableField> entity_info;
//
// public String next_page_selector;
//
// public boolean dynamic_page;
//
// public Object events;
//
// public Store store;
//
// public Configuration crawl;
//
// public void setEvents(ArrayList<Event> events) {
// this.events = events;
// }
//
// public void setEvents(Event events) {
// this.events = events;
// }
//
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// public static class URL {
//
// public String base_url;
//
// public String relative_url;
// }
//
// public class Store {
//
// public String format;
//
// public String database;
//
// public String hd_path;
//
// public String companies_collection;
//
// public String metrics_collection;
//
// public DBCreadentials db_credentials;
//
// public String wikirate_metric_designer;
// }
//
// public class DBCreadentials {
//
// public String username;
//
// public String password;
//
// public String server_address;
//
// public String db;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/configuration/JSONConfigurationDeserializer.java
import certh.iti.mklab.easie.configuration.Configuration;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.internal.LinkedTreeMap;
import certh.iti.mklab.easie.configuration.Configuration.Event;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import java.lang.reflect.Type;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONObject;
configuration.entity_info = transform_CompanyInfo(configuration.entity_info);
Configuration crawl = configuration.crawl;
while (crawl != null) {
crawl.metrics = transform_metrics(crawl.metrics);
crawl.entity_info = transform_CompanyInfo(crawl.entity_info);
crawl = crawl.crawl;
}
if (configuration.dynamic_page) {
Object events = configuration.events;
if (configuration.events != null) {
if (events instanceof ArrayList) {
ArrayList<Event> evnts = new Gson().fromJson(
(new JSONArray((ArrayList<LinkedTreeMap>) events)).toString(),
new TypeToken<ArrayList<Event>>() {
}.getType());
configuration.setEvents(evnts);
} else {
Event evnts = new Gson().fromJson(
(new JSONObject((LinkedTreeMap) events)).toString(), new TypeToken<Event>() {
}.getType());
configuration.setEvents(evnts);
}
}
}
return configuration;
}
| private ArrayList<ScrapableField> transform_metrics(ArrayList<ScrapableField> metrics) {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/configuration/JSONConfigurationDeserializer.java | // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public final class Configuration {
//
// public URL url;
//
// public HashSet<String> group_of_urls;
//
// public String source_name;
//
// public String entity_name;
//
// public String table_selector;
//
// public ArrayList<ScrapableField> metrics;
//
// public ArrayList<ScrapableField> entity_info;
//
// public String next_page_selector;
//
// public boolean dynamic_page;
//
// public Object events;
//
// public Store store;
//
// public Configuration crawl;
//
// public void setEvents(ArrayList<Event> events) {
// this.events = events;
// }
//
// public void setEvents(Event events) {
// this.events = events;
// }
//
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// public static class URL {
//
// public String base_url;
//
// public String relative_url;
// }
//
// public class Store {
//
// public String format;
//
// public String database;
//
// public String hd_path;
//
// public String companies_collection;
//
// public String metrics_collection;
//
// public DBCreadentials db_credentials;
//
// public String wikirate_metric_designer;
// }
//
// public class DBCreadentials {
//
// public String username;
//
// public String password;
//
// public String server_address;
//
// public String db;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
| import certh.iti.mklab.easie.configuration.Configuration;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.internal.LinkedTreeMap;
import certh.iti.mklab.easie.configuration.Configuration.Event;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import java.lang.reflect.Type;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONObject;
| crawl = crawl.crawl;
}
if (configuration.dynamic_page) {
Object events = configuration.events;
if (configuration.events != null) {
if (events instanceof ArrayList) {
ArrayList<Event> evnts = new Gson().fromJson(
(new JSONArray((ArrayList<LinkedTreeMap>) events)).toString(),
new TypeToken<ArrayList<Event>>() {
}.getType());
configuration.setEvents(evnts);
} else {
Event evnts = new Gson().fromJson(
(new JSONObject((LinkedTreeMap) events)).toString(), new TypeToken<Event>() {
}.getType());
configuration.setEvents(evnts);
}
}
}
return configuration;
}
private ArrayList<ScrapableField> transform_metrics(ArrayList<ScrapableField> metrics) {
for (int i = 0; i < metrics.size(); i++) {
Object label = metrics.get(i).label;
Object value = metrics.get(i).value;
Object citeyear = metrics.get(i).citeyear;
if (!(label instanceof String)) {
| // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public final class Configuration {
//
// public URL url;
//
// public HashSet<String> group_of_urls;
//
// public String source_name;
//
// public String entity_name;
//
// public String table_selector;
//
// public ArrayList<ScrapableField> metrics;
//
// public ArrayList<ScrapableField> entity_info;
//
// public String next_page_selector;
//
// public boolean dynamic_page;
//
// public Object events;
//
// public Store store;
//
// public Configuration crawl;
//
// public void setEvents(ArrayList<Event> events) {
// this.events = events;
// }
//
// public void setEvents(Event events) {
// this.events = events;
// }
//
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// public static class URL {
//
// public String base_url;
//
// public String relative_url;
// }
//
// public class Store {
//
// public String format;
//
// public String database;
//
// public String hd_path;
//
// public String companies_collection;
//
// public String metrics_collection;
//
// public DBCreadentials db_credentials;
//
// public String wikirate_metric_designer;
// }
//
// public class DBCreadentials {
//
// public String username;
//
// public String password;
//
// public String server_address;
//
// public String db;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/configuration/JSONConfigurationDeserializer.java
import certh.iti.mklab.easie.configuration.Configuration;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.internal.LinkedTreeMap;
import certh.iti.mklab.easie.configuration.Configuration.Event;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import java.lang.reflect.Type;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONObject;
crawl = crawl.crawl;
}
if (configuration.dynamic_page) {
Object events = configuration.events;
if (configuration.events != null) {
if (events instanceof ArrayList) {
ArrayList<Event> evnts = new Gson().fromJson(
(new JSONArray((ArrayList<LinkedTreeMap>) events)).toString(),
new TypeToken<ArrayList<Event>>() {
}.getType());
configuration.setEvents(evnts);
} else {
Event evnts = new Gson().fromJson(
(new JSONObject((LinkedTreeMap) events)).toString(), new TypeToken<Event>() {
}.getType());
configuration.setEvents(evnts);
}
}
}
return configuration;
}
private ArrayList<ScrapableField> transform_metrics(ArrayList<ScrapableField> metrics) {
for (int i = 0; i < metrics.size(); i++) {
Object label = metrics.get(i).label;
Object value = metrics.get(i).value;
Object citeyear = metrics.get(i).citeyear;
if (!(label instanceof String)) {
| ExtractionProperties label_value = new Gson().fromJson(
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/TableFieldExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class TableFieldExtractor extends AbstractContentExtractor {
private String table_selector;
public TableFieldExtractor(Element document, String table_selector, String source) {
super.document = document;
this.table_selector = table_selector;
super.source = source;
}
@Override
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/TableFieldExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class TableFieldExtractor extends AbstractContentExtractor {
private String table_selector;
public TableFieldExtractor(Element document, String table_selector, String source) {
super.document = document;
this.table_selector = table_selector;
super.source = source;
}
@Override
| public List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/TableFieldExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class TableFieldExtractor extends AbstractContentExtractor {
private String table_selector;
public TableFieldExtractor(Element document, String table_selector, String source) {
super.document = document;
this.table_selector = table_selector;
super.source = source;
}
@Override
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/TableFieldExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class TableFieldExtractor extends AbstractContentExtractor {
private String table_selector;
public TableFieldExtractor(Element document, String table_selector, String source) {
super.document = document;
this.table_selector = table_selector;
super.source = source;
}
@Override
| public List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/TableFieldExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class TableFieldExtractor extends AbstractContentExtractor {
private String table_selector;
public TableFieldExtractor(Element document, String table_selector, String source) {
super.document = document;
this.table_selector = table_selector;
super.source = source;
}
@Override
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/TableFieldExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class TableFieldExtractor extends AbstractContentExtractor {
private String table_selector;
public TableFieldExtractor(Element document, String table_selector, String source) {
super.document = document;
this.table_selector = table_selector;
super.source = source;
}
@Override
| public List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/TableFieldExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class TableFieldExtractor extends AbstractContentExtractor {
private String table_selector;
public TableFieldExtractor(Element document, String table_selector, String source) {
super.document = document;
this.table_selector = table_selector;
super.source = source;
}
@Override
public List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException {
ArrayList extractedContent = new ArrayList();
if (document != null) {
Elements table = document.select(table_selector);
if (table.size() == 0) {
throw new HTMLElementNotFoundException("WARNING: The defined table element was not found. Check the correctness of your table selector |" + table_selector + "| or for possible changes in the structure of your source.");
}
for (int i = 0; i < table.size(); i++) {
try {
ArrayList temp = new ArrayList();
if (type.equals(type.COMPANY_INFO)) {
extractedContent.add(extractTableFields(fields, table.get(i), type));
} else {
temp.addAll((List) extractTableFields(fields, table.get(i), type));
extractedContent.add(temp);
}
| // Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
// METRIC,
// COMPANY_INFO
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
//
// public HTMLElementNotFoundException() {
// }
//
// public HTMLElementNotFoundException(String message) {
// super(message);
// }
//
// public HTMLElementNotFoundException(Throwable cause) {
// super(cause);
// }
//
// public HTMLElementNotFoundException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
// public PostProcessingException(){
//
// }
//
// public PostProcessingException(String message){
// super(message);
// }
//
// public PostProcessingException(Throwable cause){
// super(cause);
// }
//
// public PostProcessingException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/TableFieldExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors;
/**
*
* @author vasgat
*/
public class TableFieldExtractor extends AbstractContentExtractor {
private String table_selector;
public TableFieldExtractor(Element document, String table_selector, String source) {
super.document = document;
this.table_selector = table_selector;
super.source = source;
}
@Override
public List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException {
ArrayList extractedContent = new ArrayList();
if (document != null) {
Elements table = document.select(table_selector);
if (table.size() == 0) {
throw new HTMLElementNotFoundException("WARNING: The defined table element was not found. Check the correctness of your table selector |" + table_selector + "| or for possible changes in the structure of your source.");
}
for (int i = 0; i < table.size(); i++) {
try {
ArrayList temp = new ArrayList();
if (type.equals(type.COMPANY_INFO)) {
extractedContent.add(extractTableFields(fields, table.get(i), type));
} else {
temp.addAll((List) extractTableFields(fields, table.get(i), type));
extractedContent.add(temp);
}
| } catch (PostProcessingException ex) {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/configuration/validator/ConfigurationValidator.java | // Path: src/main/java/certh/iti/mklab/easie/exception/IllegalSchemaException.java
// public class IllegalSchemaException extends Exception {
// public IllegalSchemaException(){
//
// }
//
// public IllegalSchemaException(String message){
// super(message);
// }
//
// public IllegalSchemaException(Throwable cause){
// super(cause);
// }
//
// public IllegalSchemaException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.exception.IllegalSchemaException;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.report.ProcessingMessage;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
import com.github.fge.jsonschema.main.JsonValidator;
import org.json.JSONObject;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.configuration.validator;
/**
* @author vasgat
*/
public class ConfigurationValidator {
private JsonValidator VALIDATOR;
private JsonNode ConfigurationSchema;
public ConfigurationValidator(String path) throws IOException {
this.VALIDATOR = JsonSchemaFactory.byDefault().getValidator();
this.ConfigurationSchema = JsonLoader.fromFile(
new File(path + "/ConfigurationSchema.json")
);
}
public ConfigurationValidator() throws IOException {
this.VALIDATOR = JsonSchemaFactory.byDefault().getValidator();
this.ConfigurationSchema = JsonLoader.fromFile(
new File("ConfigurationSchema.json")
);
}
| // Path: src/main/java/certh/iti/mklab/easie/exception/IllegalSchemaException.java
// public class IllegalSchemaException extends Exception {
// public IllegalSchemaException(){
//
// }
//
// public IllegalSchemaException(String message){
// super(message);
// }
//
// public IllegalSchemaException(Throwable cause){
// super(cause);
// }
//
// public IllegalSchemaException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/configuration/validator/ConfigurationValidator.java
import certh.iti.mklab.easie.exception.IllegalSchemaException;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.report.ProcessingMessage;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
import com.github.fge.jsonschema.main.JsonValidator;
import org.json.JSONObject;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.configuration.validator;
/**
* @author vasgat
*/
public class ConfigurationValidator {
private JsonValidator VALIDATOR;
private JsonNode ConfigurationSchema;
public ConfigurationValidator(String path) throws IOException {
this.VALIDATOR = JsonSchemaFactory.byDefault().getValidator();
this.ConfigurationSchema = JsonLoader.fromFile(
new File(path + "/ConfigurationSchema.json")
);
}
public ConfigurationValidator() throws IOException {
this.VALIDATOR = JsonSchemaFactory.byDefault().getValidator();
this.ConfigurationSchema = JsonLoader.fromFile(
new File("ConfigurationSchema.json")
);
}
| public void validate(File ConfigurationFile) throws IOException, ProcessingException, IllegalSchemaException {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/executor/handlers/DataHandler.java | // Path: src/main/java/certh/iti/mklab/easie/MongoUtils.java
// public final class MongoUtils {
//
// /**
// * Creates new mongodb client
// *
// * @param username
// * @param password
// * @param db
// * @return
// */
// public static MongoClient newClient(String server_address, String username, String password, String db) {
// List<ServerAddress> seeds = new ArrayList<ServerAddress>();
// seeds.add(new ServerAddress(server_address));
// List<MongoCredential> credentials = new ArrayList<MongoCredential>();
// credentials.add(
// MongoCredential.createScramSha1Credential(
// username,
// db,
// password.toCharArray()
// )
// );
//
// return new MongoClient(seeds, credentials);
// }
//
// /**
// * Creates new mongodb client
// *
// * @return
// */
// public static MongoClient newClient() {
// return new MongoClient();
// }
//
// /**
// * Connects to mongoDB and returns a specified collection
// *
// * @param mongoDB name
// * @param Collection collection
// * @return DBCollection object
// */
// public static MongoCollection connect(MongoClient client, String dbname, String cname) {
// MongoDatabase db = client.getDatabase(dbname);
// MongoCollection collection = db.getCollection(cname);
// return collection;
// }
//
// /**
// * Inserts a document in mongoDB
// *
// * @param mongoDB name
// * @param Collection name
// * @param document
// */
// public static ObjectId insertDoc(MongoClient mongoClient, String dbname, String cname, Document document) {
// MongoCollection collection = connect(mongoClient, dbname, cname);
// collection.insertOne(document);
// return (ObjectId) document.get("_id");
// }
//
// public static ObjectId insertDoc(MongoCollection collection, Document document) {
// collection.insertOne(document);
// return (ObjectId) document.get("_id");
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public class Store {
//
// public String format;
//
// public String database;
//
// public String hd_path;
//
// public String companies_collection;
//
// public String metrics_collection;
//
// public DBCreadentials db_credentials;
//
// public String wikirate_metric_designer;
// }
| import com.mongodb.MongoClient;
import certh.iti.mklab.easie.MongoUtils;
import certh.iti.mklab.easie.configuration.Configuration.Store;
import com.mongodb.client.MongoCollection;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.executor.handlers;
/**
* DataHandler transforms the extracted data into Snippet Objects and stores
* them into a mongodb or in the drive
*
* @author vasgat
*/
public class DataHandler {
private List<Document> extracted_company_info;
private List<ArrayList<Document>> extracted_metrics;
private StoreUtils storeUtils;
private String entity_name;
/**
* Creates SnippetHandler Object
*
* @param extracted_company_info: extracted company fields
* @param extracted_metrics: extracted snippet fields
* @throws Exception
*/
public DataHandler(List<Document> extracted_company_info, List<ArrayList<Document>> extracted_metrics, String entity_name) {
this.extracted_company_info = extracted_company_info;
this.extracted_metrics = extracted_metrics;
this.entity_name = entity_name;
storeUtils = new StoreUtils(extracted_company_info, extracted_metrics, entity_name);
}
/**
* Stores the extracted data (companies_fields and extracted_metrics) into
* mongodb or drive
*
* @param store contains information about where the data are going to be
* stored
* @param source_name
* @throws UnknownHostException
* @throws FileNotFoundException
* @throws Exception
*/
| // Path: src/main/java/certh/iti/mklab/easie/MongoUtils.java
// public final class MongoUtils {
//
// /**
// * Creates new mongodb client
// *
// * @param username
// * @param password
// * @param db
// * @return
// */
// public static MongoClient newClient(String server_address, String username, String password, String db) {
// List<ServerAddress> seeds = new ArrayList<ServerAddress>();
// seeds.add(new ServerAddress(server_address));
// List<MongoCredential> credentials = new ArrayList<MongoCredential>();
// credentials.add(
// MongoCredential.createScramSha1Credential(
// username,
// db,
// password.toCharArray()
// )
// );
//
// return new MongoClient(seeds, credentials);
// }
//
// /**
// * Creates new mongodb client
// *
// * @return
// */
// public static MongoClient newClient() {
// return new MongoClient();
// }
//
// /**
// * Connects to mongoDB and returns a specified collection
// *
// * @param mongoDB name
// * @param Collection collection
// * @return DBCollection object
// */
// public static MongoCollection connect(MongoClient client, String dbname, String cname) {
// MongoDatabase db = client.getDatabase(dbname);
// MongoCollection collection = db.getCollection(cname);
// return collection;
// }
//
// /**
// * Inserts a document in mongoDB
// *
// * @param mongoDB name
// * @param Collection name
// * @param document
// */
// public static ObjectId insertDoc(MongoClient mongoClient, String dbname, String cname, Document document) {
// MongoCollection collection = connect(mongoClient, dbname, cname);
// collection.insertOne(document);
// return (ObjectId) document.get("_id");
// }
//
// public static ObjectId insertDoc(MongoCollection collection, Document document) {
// collection.insertOne(document);
// return (ObjectId) document.get("_id");
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public class Store {
//
// public String format;
//
// public String database;
//
// public String hd_path;
//
// public String companies_collection;
//
// public String metrics_collection;
//
// public DBCreadentials db_credentials;
//
// public String wikirate_metric_designer;
// }
// Path: src/main/java/certh/iti/mklab/easie/executor/handlers/DataHandler.java
import com.mongodb.MongoClient;
import certh.iti.mklab.easie.MongoUtils;
import certh.iti.mklab.easie.configuration.Configuration.Store;
import com.mongodb.client.MongoCollection;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.executor.handlers;
/**
* DataHandler transforms the extracted data into Snippet Objects and stores
* them into a mongodb or in the drive
*
* @author vasgat
*/
public class DataHandler {
private List<Document> extracted_company_info;
private List<ArrayList<Document>> extracted_metrics;
private StoreUtils storeUtils;
private String entity_name;
/**
* Creates SnippetHandler Object
*
* @param extracted_company_info: extracted company fields
* @param extracted_metrics: extracted snippet fields
* @throws Exception
*/
public DataHandler(List<Document> extracted_company_info, List<ArrayList<Document>> extracted_metrics, String entity_name) {
this.extracted_company_info = extracted_company_info;
this.extracted_metrics = extracted_metrics;
this.entity_name = entity_name;
storeUtils = new StoreUtils(extracted_company_info, extracted_metrics, entity_name);
}
/**
* Stores the extracted data (companies_fields and extracted_metrics) into
* mongodb or drive
*
* @param store contains information about where the data are going to be
* stored
* @param source_name
* @throws UnknownHostException
* @throws FileNotFoundException
* @throws Exception
*/
| public void store(Store store, String source_name) throws UnknownHostException, FileNotFoundException, IOException {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/executor/handlers/DataHandler.java | // Path: src/main/java/certh/iti/mklab/easie/MongoUtils.java
// public final class MongoUtils {
//
// /**
// * Creates new mongodb client
// *
// * @param username
// * @param password
// * @param db
// * @return
// */
// public static MongoClient newClient(String server_address, String username, String password, String db) {
// List<ServerAddress> seeds = new ArrayList<ServerAddress>();
// seeds.add(new ServerAddress(server_address));
// List<MongoCredential> credentials = new ArrayList<MongoCredential>();
// credentials.add(
// MongoCredential.createScramSha1Credential(
// username,
// db,
// password.toCharArray()
// )
// );
//
// return new MongoClient(seeds, credentials);
// }
//
// /**
// * Creates new mongodb client
// *
// * @return
// */
// public static MongoClient newClient() {
// return new MongoClient();
// }
//
// /**
// * Connects to mongoDB and returns a specified collection
// *
// * @param mongoDB name
// * @param Collection collection
// * @return DBCollection object
// */
// public static MongoCollection connect(MongoClient client, String dbname, String cname) {
// MongoDatabase db = client.getDatabase(dbname);
// MongoCollection collection = db.getCollection(cname);
// return collection;
// }
//
// /**
// * Inserts a document in mongoDB
// *
// * @param mongoDB name
// * @param Collection name
// * @param document
// */
// public static ObjectId insertDoc(MongoClient mongoClient, String dbname, String cname, Document document) {
// MongoCollection collection = connect(mongoClient, dbname, cname);
// collection.insertOne(document);
// return (ObjectId) document.get("_id");
// }
//
// public static ObjectId insertDoc(MongoCollection collection, Document document) {
// collection.insertOne(document);
// return (ObjectId) document.get("_id");
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public class Store {
//
// public String format;
//
// public String database;
//
// public String hd_path;
//
// public String companies_collection;
//
// public String metrics_collection;
//
// public DBCreadentials db_credentials;
//
// public String wikirate_metric_designer;
// }
| import com.mongodb.MongoClient;
import certh.iti.mklab.easie.MongoUtils;
import certh.iti.mklab.easie.configuration.Configuration.Store;
import com.mongodb.client.MongoCollection;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.executor.handlers;
/**
* DataHandler transforms the extracted data into Snippet Objects and stores
* them into a mongodb or in the drive
*
* @author vasgat
*/
public class DataHandler {
private List<Document> extracted_company_info;
private List<ArrayList<Document>> extracted_metrics;
private StoreUtils storeUtils;
private String entity_name;
/**
* Creates SnippetHandler Object
*
* @param extracted_company_info: extracted company fields
* @param extracted_metrics: extracted snippet fields
* @throws Exception
*/
public DataHandler(List<Document> extracted_company_info, List<ArrayList<Document>> extracted_metrics, String entity_name) {
this.extracted_company_info = extracted_company_info;
this.extracted_metrics = extracted_metrics;
this.entity_name = entity_name;
storeUtils = new StoreUtils(extracted_company_info, extracted_metrics, entity_name);
}
/**
* Stores the extracted data (companies_fields and extracted_metrics) into
* mongodb or drive
*
* @param store contains information about where the data are going to be
* stored
* @param source_name
* @throws UnknownHostException
* @throws FileNotFoundException
* @throws Exception
*/
public void store(Store store, String source_name) throws UnknownHostException, FileNotFoundException, IOException {
if (store.companies_collection != null && extracted_company_info != null) {
MongoClient client;
if (store.db_credentials != null) {
| // Path: src/main/java/certh/iti/mklab/easie/MongoUtils.java
// public final class MongoUtils {
//
// /**
// * Creates new mongodb client
// *
// * @param username
// * @param password
// * @param db
// * @return
// */
// public static MongoClient newClient(String server_address, String username, String password, String db) {
// List<ServerAddress> seeds = new ArrayList<ServerAddress>();
// seeds.add(new ServerAddress(server_address));
// List<MongoCredential> credentials = new ArrayList<MongoCredential>();
// credentials.add(
// MongoCredential.createScramSha1Credential(
// username,
// db,
// password.toCharArray()
// )
// );
//
// return new MongoClient(seeds, credentials);
// }
//
// /**
// * Creates new mongodb client
// *
// * @return
// */
// public static MongoClient newClient() {
// return new MongoClient();
// }
//
// /**
// * Connects to mongoDB and returns a specified collection
// *
// * @param mongoDB name
// * @param Collection collection
// * @return DBCollection object
// */
// public static MongoCollection connect(MongoClient client, String dbname, String cname) {
// MongoDatabase db = client.getDatabase(dbname);
// MongoCollection collection = db.getCollection(cname);
// return collection;
// }
//
// /**
// * Inserts a document in mongoDB
// *
// * @param mongoDB name
// * @param Collection name
// * @param document
// */
// public static ObjectId insertDoc(MongoClient mongoClient, String dbname, String cname, Document document) {
// MongoCollection collection = connect(mongoClient, dbname, cname);
// collection.insertOne(document);
// return (ObjectId) document.get("_id");
// }
//
// public static ObjectId insertDoc(MongoCollection collection, Document document) {
// collection.insertOne(document);
// return (ObjectId) document.get("_id");
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public class Store {
//
// public String format;
//
// public String database;
//
// public String hd_path;
//
// public String companies_collection;
//
// public String metrics_collection;
//
// public DBCreadentials db_credentials;
//
// public String wikirate_metric_designer;
// }
// Path: src/main/java/certh/iti/mklab/easie/executor/handlers/DataHandler.java
import com.mongodb.MongoClient;
import certh.iti.mklab.easie.MongoUtils;
import certh.iti.mklab.easie.configuration.Configuration.Store;
import com.mongodb.client.MongoCollection;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import org.bson.Document;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.executor.handlers;
/**
* DataHandler transforms the extracted data into Snippet Objects and stores
* them into a mongodb or in the drive
*
* @author vasgat
*/
public class DataHandler {
private List<Document> extracted_company_info;
private List<ArrayList<Document>> extracted_metrics;
private StoreUtils storeUtils;
private String entity_name;
/**
* Creates SnippetHandler Object
*
* @param extracted_company_info: extracted company fields
* @param extracted_metrics: extracted snippet fields
* @throws Exception
*/
public DataHandler(List<Document> extracted_company_info, List<ArrayList<Document>> extracted_metrics, String entity_name) {
this.extracted_company_info = extracted_company_info;
this.extracted_metrics = extracted_metrics;
this.entity_name = entity_name;
storeUtils = new StoreUtils(extracted_company_info, extracted_metrics, entity_name);
}
/**
* Stores the extracted data (companies_fields and extracted_metrics) into
* mongodb or drive
*
* @param store contains information about where the data are going to be
* stored
* @param source_name
* @throws UnknownHostException
* @throws FileNotFoundException
* @throws Exception
*/
public void store(Store store, String source_name) throws UnknownHostException, FileNotFoundException, IOException {
if (store.companies_collection != null && extracted_company_info != null) {
MongoClient client;
if (store.db_credentials != null) {
| client = MongoUtils.newClient(
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/staticpages/GroupHTMLExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/extractors/AbstractHTMLExtractor.java
// public abstract class AbstractHTMLExtractor {
//
// public abstract List extractFields(List<ScrapableField> fields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
//
// public abstract List extractTable(String tableSelector, List<ScrapableField> fields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
//
// public abstract Pair extractFields(List<ScrapableField> cfields, List<ScrapableField> sfields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
//
// public abstract Pair extractTable(String tableSelector, List<ScrapableField> cfields, List<ScrapableField> sfields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
// }
| import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.lang3.tuple.Pair;
import org.bson.Document;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.extractors.AbstractHTMLExtractor;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors.staticpages;
/**
* BunchWrapper object extends AbstractWrapper and is responsible for extracting
* data from a set of links - webpages with the same structure
*
* @author vasgat
*/
public class GroupHTMLExtractor extends AbstractHTMLExtractor {
private HashSet<String> group_of_urls;
private String base_url;
private int numThreads;
/**
* Creates a new BunchWrapper
*
* @param group_of_urls a set of webpages
*/
public GroupHTMLExtractor(HashSet<String> group_of_urls) {
this.base_url = "";
this.group_of_urls = group_of_urls;
this.numThreads = 10;
}
public GroupHTMLExtractor(HashSet<String> group_of_urls, String base_url) {
this.base_url = base_url;
this.group_of_urls = group_of_urls;
this.numThreads = 10;
}
/**
* Extracts specified field for each webpage
*
* @param fields set of fields
* @return the extracted Fields
* @throws URISyntaxException
* @throws IOException
* @throws Exception
*/
@Override
| // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/extractors/AbstractHTMLExtractor.java
// public abstract class AbstractHTMLExtractor {
//
// public abstract List extractFields(List<ScrapableField> fields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
//
// public abstract List extractTable(String tableSelector, List<ScrapableField> fields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
//
// public abstract Pair extractFields(List<ScrapableField> cfields, List<ScrapableField> sfields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
//
// public abstract Pair extractTable(String tableSelector, List<ScrapableField> cfields, List<ScrapableField> sfields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/staticpages/GroupHTMLExtractor.java
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.lang3.tuple.Pair;
import org.bson.Document;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.extractors.AbstractHTMLExtractor;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors.staticpages;
/**
* BunchWrapper object extends AbstractWrapper and is responsible for extracting
* data from a set of links - webpages with the same structure
*
* @author vasgat
*/
public class GroupHTMLExtractor extends AbstractHTMLExtractor {
private HashSet<String> group_of_urls;
private String base_url;
private int numThreads;
/**
* Creates a new BunchWrapper
*
* @param group_of_urls a set of webpages
*/
public GroupHTMLExtractor(HashSet<String> group_of_urls) {
this.base_url = "";
this.group_of_urls = group_of_urls;
this.numThreads = 10;
}
public GroupHTMLExtractor(HashSet<String> group_of_urls, String base_url) {
this.base_url = base_url;
this.group_of_urls = group_of_urls;
this.numThreads = 10;
}
/**
* Extracts specified field for each webpage
*
* @param fields set of fields
* @return the extracted Fields
* @throws URISyntaxException
* @throws IOException
* @throws Exception
*/
@Override
| public List<Document> extractFields(List<ScrapableField> fields) throws URISyntaxException, IOException {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/companymatching/CompanyMatcher.java | // Path: src/main/java/certh/iti/mklab/easie/MongoUtils.java
// public final class MongoUtils {
//
// /**
// * Creates new mongodb client
// *
// * @param username
// * @param password
// * @param db
// * @return
// */
// public static MongoClient newClient(String server_address, String username, String password, String db) {
// List<ServerAddress> seeds = new ArrayList<ServerAddress>();
// seeds.add(new ServerAddress(server_address));
// List<MongoCredential> credentials = new ArrayList<MongoCredential>();
// credentials.add(
// MongoCredential.createScramSha1Credential(
// username,
// db,
// password.toCharArray()
// )
// );
//
// return new MongoClient(seeds, credentials);
// }
//
// /**
// * Creates new mongodb client
// *
// * @return
// */
// public static MongoClient newClient() {
// return new MongoClient();
// }
//
// /**
// * Connects to mongoDB and returns a specified collection
// *
// * @param mongoDB name
// * @param Collection collection
// * @return DBCollection object
// */
// public static MongoCollection connect(MongoClient client, String dbname, String cname) {
// MongoDatabase db = client.getDatabase(dbname);
// MongoCollection collection = db.getCollection(cname);
// return collection;
// }
//
// /**
// * Inserts a document in mongoDB
// *
// * @param mongoDB name
// * @param Collection name
// * @param document
// */
// public static ObjectId insertDoc(MongoClient mongoClient, String dbname, String cname, Document document) {
// MongoCollection collection = connect(mongoClient, dbname, cname);
// collection.insertOne(document);
// return (ObjectId) document.get("_id");
// }
//
// public static ObjectId insertDoc(MongoCollection collection, Document document) {
// collection.insertOne(document);
// return (ObjectId) document.get("_id");
// }
// }
| import certh.iti.mklab.easie.MongoUtils;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import java.net.UnknownHostException;
import java.util.ArrayList;
import org.bson.Document;
import org.bson.types.ObjectId;
| /**
* @returns Company's name
*/
public String getCompanyName() {
return company_name;
}
/**
* @returns Company's website
*/
public String getWebsite() {
return website;
}
/**
* Inserts Company to the database based on the available company name and
* website
*
* @return company's id
*/
private ObjectId insertCompany() {
Document object = new Document();
object.append("company_name", company_name.trim());
if (website != null) {
object.append("website", website.toLowerCase());
}
ArrayList list = new ArrayList();
list.add(company_name.trim());
object.append("aliases", list);
| // Path: src/main/java/certh/iti/mklab/easie/MongoUtils.java
// public final class MongoUtils {
//
// /**
// * Creates new mongodb client
// *
// * @param username
// * @param password
// * @param db
// * @return
// */
// public static MongoClient newClient(String server_address, String username, String password, String db) {
// List<ServerAddress> seeds = new ArrayList<ServerAddress>();
// seeds.add(new ServerAddress(server_address));
// List<MongoCredential> credentials = new ArrayList<MongoCredential>();
// credentials.add(
// MongoCredential.createScramSha1Credential(
// username,
// db,
// password.toCharArray()
// )
// );
//
// return new MongoClient(seeds, credentials);
// }
//
// /**
// * Creates new mongodb client
// *
// * @return
// */
// public static MongoClient newClient() {
// return new MongoClient();
// }
//
// /**
// * Connects to mongoDB and returns a specified collection
// *
// * @param mongoDB name
// * @param Collection collection
// * @return DBCollection object
// */
// public static MongoCollection connect(MongoClient client, String dbname, String cname) {
// MongoDatabase db = client.getDatabase(dbname);
// MongoCollection collection = db.getCollection(cname);
// return collection;
// }
//
// /**
// * Inserts a document in mongoDB
// *
// * @param mongoDB name
// * @param Collection name
// * @param document
// */
// public static ObjectId insertDoc(MongoClient mongoClient, String dbname, String cname, Document document) {
// MongoCollection collection = connect(mongoClient, dbname, cname);
// collection.insertOne(document);
// return (ObjectId) document.get("_id");
// }
//
// public static ObjectId insertDoc(MongoCollection collection, Document document) {
// collection.insertOne(document);
// return (ObjectId) document.get("_id");
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/companymatching/CompanyMatcher.java
import certh.iti.mklab.easie.MongoUtils;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import java.net.UnknownHostException;
import java.util.ArrayList;
import org.bson.Document;
import org.bson.types.ObjectId;
/**
* @returns Company's name
*/
public String getCompanyName() {
return company_name;
}
/**
* @returns Company's website
*/
public String getWebsite() {
return website;
}
/**
* Inserts Company to the database based on the available company name and
* website
*
* @return company's id
*/
private ObjectId insertCompany() {
Document object = new Document();
object.append("company_name", company_name.trim());
if (website != null) {
object.append("website", website.toLowerCase());
}
ArrayList list = new ArrayList();
list.add(company_name.trim());
object.append("aliases", list);
| ObjectId id = MongoUtils.insertDoc(companies, object);
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/configuration/ConfigurationReader.java | // Path: src/main/java/certh/iti/mklab/easie/configuration/validator/ConfigurationValidator.java
// public class ConfigurationValidator {
//
// private JsonValidator VALIDATOR;
// private JsonNode ConfigurationSchema;
//
// public ConfigurationValidator(String path) throws IOException {
// this.VALIDATOR = JsonSchemaFactory.byDefault().getValidator();
// this.ConfigurationSchema = JsonLoader.fromFile(
// new File(path + "/ConfigurationSchema.json")
// );
// }
//
// public ConfigurationValidator() throws IOException {
// this.VALIDATOR = JsonSchemaFactory.byDefault().getValidator();
// this.ConfigurationSchema = JsonLoader.fromFile(
// new File("ConfigurationSchema.json")
// );
// }
//
// public void validate(File ConfigurationFile) throws IOException, ProcessingException, IllegalSchemaException {
// JsonNode Configuration = JsonLoader.fromFile(ConfigurationFile);
//
// ProcessingReport r1 = VALIDATOR.validate(
// ConfigurationSchema,
// Configuration
// );
//
// if (!r1.isSuccess()) {
// Iterator<ProcessingMessage> it = r1.iterator();
// ProcessingMessage pm = it.next();
// JSONObject o = new JSONObject(pm.asJson().toString());
// throw new IllegalSchemaException(o.toString(4));
// }
// }
//
// public void validate(String ConfigurationFile) throws IOException, ProcessingException, IllegalSchemaException {
// JsonNode Configuration = JsonLoader.fromString(ConfigurationFile);
//
// ProcessingReport r1 = VALIDATOR.validate(
// ConfigurationSchema,
// Configuration
// );
//
// if (!r1.isSuccess()) {
// Iterator<ProcessingMessage> it = r1.iterator();
// ProcessingMessage pm = it.next();
// JSONObject o = new JSONObject(pm.asJson().toString());
// throw new IllegalSchemaException(o.toString(4));
// }
// }
//
// public void setConfigurationSchema(File ConfigurationSchemaFile) throws IOException {
// this.ConfigurationSchema = JsonLoader.fromFile(ConfigurationSchemaFile);
// }
//
// public void setConfigurationSchema(String ConfigurationSchema) throws IOException {
// this.ConfigurationSchema = JsonLoader.fromString(ConfigurationSchema);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/IllegalSchemaException.java
// public class IllegalSchemaException extends Exception {
// public IllegalSchemaException(){
//
// }
//
// public IllegalSchemaException(String message){
// super(message);
// }
//
// public IllegalSchemaException(Throwable cause){
// super(cause);
// }
//
// public IllegalSchemaException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.configuration.validator.ConfigurationValidator;
import certh.iti.mklab.easie.exception.IllegalSchemaException;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.configuration;
/**
* ConfigurationFileReader Object reads a JSON file or a String and transforms
* it to Configuration Object and validates it
*
* @author vasgat
*/
public class ConfigurationReader {
private String content;
public Configuration config;
private File ConfigurationFile;
/**
* ConfigurationFileReader Object constructor that created Configuration
* Object from a JSON file and validates it.
*
* @param configurationFile: Configuration
* @throws FileNotFoundException in case of not valid file path
* @throws IllegalConfigurationException in case of invalid Configuration
* schema
*/
| // Path: src/main/java/certh/iti/mklab/easie/configuration/validator/ConfigurationValidator.java
// public class ConfigurationValidator {
//
// private JsonValidator VALIDATOR;
// private JsonNode ConfigurationSchema;
//
// public ConfigurationValidator(String path) throws IOException {
// this.VALIDATOR = JsonSchemaFactory.byDefault().getValidator();
// this.ConfigurationSchema = JsonLoader.fromFile(
// new File(path + "/ConfigurationSchema.json")
// );
// }
//
// public ConfigurationValidator() throws IOException {
// this.VALIDATOR = JsonSchemaFactory.byDefault().getValidator();
// this.ConfigurationSchema = JsonLoader.fromFile(
// new File("ConfigurationSchema.json")
// );
// }
//
// public void validate(File ConfigurationFile) throws IOException, ProcessingException, IllegalSchemaException {
// JsonNode Configuration = JsonLoader.fromFile(ConfigurationFile);
//
// ProcessingReport r1 = VALIDATOR.validate(
// ConfigurationSchema,
// Configuration
// );
//
// if (!r1.isSuccess()) {
// Iterator<ProcessingMessage> it = r1.iterator();
// ProcessingMessage pm = it.next();
// JSONObject o = new JSONObject(pm.asJson().toString());
// throw new IllegalSchemaException(o.toString(4));
// }
// }
//
// public void validate(String ConfigurationFile) throws IOException, ProcessingException, IllegalSchemaException {
// JsonNode Configuration = JsonLoader.fromString(ConfigurationFile);
//
// ProcessingReport r1 = VALIDATOR.validate(
// ConfigurationSchema,
// Configuration
// );
//
// if (!r1.isSuccess()) {
// Iterator<ProcessingMessage> it = r1.iterator();
// ProcessingMessage pm = it.next();
// JSONObject o = new JSONObject(pm.asJson().toString());
// throw new IllegalSchemaException(o.toString(4));
// }
// }
//
// public void setConfigurationSchema(File ConfigurationSchemaFile) throws IOException {
// this.ConfigurationSchema = JsonLoader.fromFile(ConfigurationSchemaFile);
// }
//
// public void setConfigurationSchema(String ConfigurationSchema) throws IOException {
// this.ConfigurationSchema = JsonLoader.fromString(ConfigurationSchema);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/IllegalSchemaException.java
// public class IllegalSchemaException extends Exception {
// public IllegalSchemaException(){
//
// }
//
// public IllegalSchemaException(String message){
// super(message);
// }
//
// public IllegalSchemaException(Throwable cause){
// super(cause);
// }
//
// public IllegalSchemaException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/configuration/ConfigurationReader.java
import certh.iti.mklab.easie.configuration.validator.ConfigurationValidator;
import certh.iti.mklab.easie.exception.IllegalSchemaException;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.configuration;
/**
* ConfigurationFileReader Object reads a JSON file or a String and transforms
* it to Configuration Object and validates it
*
* @author vasgat
*/
public class ConfigurationReader {
private String content;
public Configuration config;
private File ConfigurationFile;
/**
* ConfigurationFileReader Object constructor that created Configuration
* Object from a JSON file and validates it.
*
* @param configurationFile: Configuration
* @throws FileNotFoundException in case of not valid file path
* @throws IllegalConfigurationException in case of invalid Configuration
* schema
*/
| public ConfigurationReader(String FilePath, String SchemaPath) throws FileNotFoundException, IOException, ProcessingException, IllegalSchemaException {
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/configuration/ConfigurationReader.java | // Path: src/main/java/certh/iti/mklab/easie/configuration/validator/ConfigurationValidator.java
// public class ConfigurationValidator {
//
// private JsonValidator VALIDATOR;
// private JsonNode ConfigurationSchema;
//
// public ConfigurationValidator(String path) throws IOException {
// this.VALIDATOR = JsonSchemaFactory.byDefault().getValidator();
// this.ConfigurationSchema = JsonLoader.fromFile(
// new File(path + "/ConfigurationSchema.json")
// );
// }
//
// public ConfigurationValidator() throws IOException {
// this.VALIDATOR = JsonSchemaFactory.byDefault().getValidator();
// this.ConfigurationSchema = JsonLoader.fromFile(
// new File("ConfigurationSchema.json")
// );
// }
//
// public void validate(File ConfigurationFile) throws IOException, ProcessingException, IllegalSchemaException {
// JsonNode Configuration = JsonLoader.fromFile(ConfigurationFile);
//
// ProcessingReport r1 = VALIDATOR.validate(
// ConfigurationSchema,
// Configuration
// );
//
// if (!r1.isSuccess()) {
// Iterator<ProcessingMessage> it = r1.iterator();
// ProcessingMessage pm = it.next();
// JSONObject o = new JSONObject(pm.asJson().toString());
// throw new IllegalSchemaException(o.toString(4));
// }
// }
//
// public void validate(String ConfigurationFile) throws IOException, ProcessingException, IllegalSchemaException {
// JsonNode Configuration = JsonLoader.fromString(ConfigurationFile);
//
// ProcessingReport r1 = VALIDATOR.validate(
// ConfigurationSchema,
// Configuration
// );
//
// if (!r1.isSuccess()) {
// Iterator<ProcessingMessage> it = r1.iterator();
// ProcessingMessage pm = it.next();
// JSONObject o = new JSONObject(pm.asJson().toString());
// throw new IllegalSchemaException(o.toString(4));
// }
// }
//
// public void setConfigurationSchema(File ConfigurationSchemaFile) throws IOException {
// this.ConfigurationSchema = JsonLoader.fromFile(ConfigurationSchemaFile);
// }
//
// public void setConfigurationSchema(String ConfigurationSchema) throws IOException {
// this.ConfigurationSchema = JsonLoader.fromString(ConfigurationSchema);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/IllegalSchemaException.java
// public class IllegalSchemaException extends Exception {
// public IllegalSchemaException(){
//
// }
//
// public IllegalSchemaException(String message){
// super(message);
// }
//
// public IllegalSchemaException(Throwable cause){
// super(cause);
// }
//
// public IllegalSchemaException(String message, Throwable cause){
// super(message, cause);
// }
// }
| import certh.iti.mklab.easie.configuration.validator.ConfigurationValidator;
import certh.iti.mklab.easie.exception.IllegalSchemaException;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.configuration;
/**
* ConfigurationFileReader Object reads a JSON file or a String and transforms
* it to Configuration Object and validates it
*
* @author vasgat
*/
public class ConfigurationReader {
private String content;
public Configuration config;
private File ConfigurationFile;
/**
* ConfigurationFileReader Object constructor that created Configuration
* Object from a JSON file and validates it.
*
* @param configurationFile: Configuration
* @throws FileNotFoundException in case of not valid file path
* @throws IllegalConfigurationException in case of invalid Configuration
* schema
*/
public ConfigurationReader(String FilePath, String SchemaPath) throws FileNotFoundException, IOException, ProcessingException, IllegalSchemaException {
content = IOUtils.toString(new FileInputStream(new File(FilePath)), "UTF-8");
this.ConfigurationFile = new File(FilePath);
deserialize(SchemaPath);
}
public ConfigurationReader(String config_content) throws IOException, ProcessingException, IllegalSchemaException{
content = config_content;
deserialize();
}
private void deserialize(String SchemaPath) throws IOException, ProcessingException, IllegalSchemaException {
| // Path: src/main/java/certh/iti/mklab/easie/configuration/validator/ConfigurationValidator.java
// public class ConfigurationValidator {
//
// private JsonValidator VALIDATOR;
// private JsonNode ConfigurationSchema;
//
// public ConfigurationValidator(String path) throws IOException {
// this.VALIDATOR = JsonSchemaFactory.byDefault().getValidator();
// this.ConfigurationSchema = JsonLoader.fromFile(
// new File(path + "/ConfigurationSchema.json")
// );
// }
//
// public ConfigurationValidator() throws IOException {
// this.VALIDATOR = JsonSchemaFactory.byDefault().getValidator();
// this.ConfigurationSchema = JsonLoader.fromFile(
// new File("ConfigurationSchema.json")
// );
// }
//
// public void validate(File ConfigurationFile) throws IOException, ProcessingException, IllegalSchemaException {
// JsonNode Configuration = JsonLoader.fromFile(ConfigurationFile);
//
// ProcessingReport r1 = VALIDATOR.validate(
// ConfigurationSchema,
// Configuration
// );
//
// if (!r1.isSuccess()) {
// Iterator<ProcessingMessage> it = r1.iterator();
// ProcessingMessage pm = it.next();
// JSONObject o = new JSONObject(pm.asJson().toString());
// throw new IllegalSchemaException(o.toString(4));
// }
// }
//
// public void validate(String ConfigurationFile) throws IOException, ProcessingException, IllegalSchemaException {
// JsonNode Configuration = JsonLoader.fromString(ConfigurationFile);
//
// ProcessingReport r1 = VALIDATOR.validate(
// ConfigurationSchema,
// Configuration
// );
//
// if (!r1.isSuccess()) {
// Iterator<ProcessingMessage> it = r1.iterator();
// ProcessingMessage pm = it.next();
// JSONObject o = new JSONObject(pm.asJson().toString());
// throw new IllegalSchemaException(o.toString(4));
// }
// }
//
// public void setConfigurationSchema(File ConfigurationSchemaFile) throws IOException {
// this.ConfigurationSchema = JsonLoader.fromFile(ConfigurationSchemaFile);
// }
//
// public void setConfigurationSchema(String ConfigurationSchema) throws IOException {
// this.ConfigurationSchema = JsonLoader.fromString(ConfigurationSchema);
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/exception/IllegalSchemaException.java
// public class IllegalSchemaException extends Exception {
// public IllegalSchemaException(){
//
// }
//
// public IllegalSchemaException(String message){
// super(message);
// }
//
// public IllegalSchemaException(Throwable cause){
// super(cause);
// }
//
// public IllegalSchemaException(String message, Throwable cause){
// super(message, cause);
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/configuration/ConfigurationReader.java
import certh.iti.mklab.easie.configuration.validator.ConfigurationValidator;
import certh.iti.mklab.easie.exception.IllegalSchemaException;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.configuration;
/**
* ConfigurationFileReader Object reads a JSON file or a String and transforms
* it to Configuration Object and validates it
*
* @author vasgat
*/
public class ConfigurationReader {
private String content;
public Configuration config;
private File ConfigurationFile;
/**
* ConfigurationFileReader Object constructor that created Configuration
* Object from a JSON file and validates it.
*
* @param configurationFile: Configuration
* @throws FileNotFoundException in case of not valid file path
* @throws IllegalConfigurationException in case of invalid Configuration
* schema
*/
public ConfigurationReader(String FilePath, String SchemaPath) throws FileNotFoundException, IOException, ProcessingException, IllegalSchemaException {
content = IOUtils.toString(new FileInputStream(new File(FilePath)), "UTF-8");
this.ConfigurationFile = new File(FilePath);
deserialize(SchemaPath);
}
public ConfigurationReader(String config_content) throws IOException, ProcessingException, IllegalSchemaException{
content = config_content;
deserialize();
}
private void deserialize(String SchemaPath) throws IOException, ProcessingException, IllegalSchemaException {
| ConfigurationValidator validator = new ConfigurationValidator(SchemaPath);
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/companymatching/CompanySearcher.java | // Path: src/main/java/certh/iti/mklab/easie/MapFunctionsUtils.java
// public final class MapFunctionsUtils {
//
// /**
// * Sorts a Map object by value
// *
// * @returns the ordered HashMap
// */
// public static <K, V extends Comparable<? super V>> Map<K, String>
// sortByValue(Map<K, V> map) {
// List<Map.Entry<K, V>> list
// = new LinkedList<Map.Entry<K, V>>(map.entrySet());
// Collections.sort(list, new Comparator<Map.Entry<K, V>>() {
// public int compare(Map.Entry<K, V> o1, Map.Entry<K, V> o2) {
// return (o2.getValue()).compareTo(o1.getValue());
// }
// });
//
// Map<K, String> result = new LinkedHashMap<K, String>();
// for (Map.Entry<K, V> entry : list) {
// result.put(entry.getKey(), "\"" + entry.getValue() + "\"");
// }
// return result;
// }
//
// /**
// * Selects the top-k (key,value) pairs of a Map based on value of the value
// */
// public static Map getTopValues(Map unsortMap, Integer selectTop) {
// List list = new LinkedList(unsortMap.entrySet());
//
// Collections.sort(list, new Comparator() {
// public int compare(Object o1, Object o2) {
// return ((Comparable) ((Map.Entry) (o1)).getValue())
// .compareTo(((Map.Entry) (o2)).getValue());
// }
// });
//
// Map sortedMap = new LinkedHashMap();
// int counter = 0;
// for (Iterator it = list.iterator(); it.hasNext();) {
// Map.Entry entry = (Map.Entry) it.next();
// sortedMap.put(entry.getKey(), entry.getValue());
// counter++;
// if (counter == selectTop) {
// break;
// }
// }
// return sortedMap;
// }
//
// public static Map getTopValues2(Map unsortMap, Integer selectTop) {
// List list = new LinkedList(unsortMap.entrySet());
//
// Collections.sort(list, new Comparator() {
// public int compare(Object o1, Object o2) {
// return ((Comparable) ((Map.Entry) (o2)).getValue())
// .compareTo(((Map.Entry) (o1)).getValue());
// }
// });
//
// Map sortedMap = new LinkedHashMap();
// int counter = 0;
// for (Iterator it = list.iterator(); it.hasNext();) {
// Map.Entry entry = (Map.Entry) it.next();
// sortedMap.put(entry.getKey(), entry.getValue());
// counter++;
// if (counter == selectTop) {
// break;
// }
// }
// return sortedMap;
// }
//
// /**
// * Returns a sub-TreeMap from index i to j.
// *
// * @param startIndex
// * @param endIndex
// * @param treeMap
// * @returns the sub-TreeMap
// */
// public static TreeMap subTreeMap(int startIndex, int endIndex, TreeMap treeMap) {
// Iterator it = treeMap.entrySet().iterator();
// TreeMap newMap = new TreeMap();
// ArrayList list = new ArrayList<Map.Entry>(treeMap.entrySet());
// for (int i = startIndex; i <= endIndex; i++) {
// Map.Entry entry = (Map.Entry) list.get(i);
// newMap.put(entry.getKey(), entry.getValue());
// }
//
// return newMap;
// }
// }
| import certh.iti.mklab.easie.MapFunctionsUtils;
import certh.iti.mklab.jSimilarity.documentUtils.CompanyDocument;
import certh.iti.mklab.jSimilarity.documentUtils.Corpus;
import certh.iti.mklab.jSimilarity.stringsimilarities.CosineSimilarity;
import certh.iti.mklab.jSimilarity.tfidf.TFIDF;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.apache.commons.collections4.Predicate;
import org.bson.Document;
import org.bson.types.ObjectId;
| HashMap<String, Double> candidates = new HashMap();
Predicate predicate = new Predicate<CompanyDocument>() {
@Override
public boolean evaluate(CompanyDocument object) {
if (country == null && object.country == null) {
return true;
}
if (object.country == null) {
return false;
}
return object.country.equals(country);
}
};
Iterator<CompanyDocument> it = corpus.iterator(predicate);
int i = 0;
while (it.hasNext()) {
CompanyDocument company = it.next();
double similarity = tfidf.similarity("candidate", company.id);
if (similarity >= threshold && !company.equals(document)) {
candidates.put(company.id, similarity);
}
}
if (candidates.size() > 0) {
| // Path: src/main/java/certh/iti/mklab/easie/MapFunctionsUtils.java
// public final class MapFunctionsUtils {
//
// /**
// * Sorts a Map object by value
// *
// * @returns the ordered HashMap
// */
// public static <K, V extends Comparable<? super V>> Map<K, String>
// sortByValue(Map<K, V> map) {
// List<Map.Entry<K, V>> list
// = new LinkedList<Map.Entry<K, V>>(map.entrySet());
// Collections.sort(list, new Comparator<Map.Entry<K, V>>() {
// public int compare(Map.Entry<K, V> o1, Map.Entry<K, V> o2) {
// return (o2.getValue()).compareTo(o1.getValue());
// }
// });
//
// Map<K, String> result = new LinkedHashMap<K, String>();
// for (Map.Entry<K, V> entry : list) {
// result.put(entry.getKey(), "\"" + entry.getValue() + "\"");
// }
// return result;
// }
//
// /**
// * Selects the top-k (key,value) pairs of a Map based on value of the value
// */
// public static Map getTopValues(Map unsortMap, Integer selectTop) {
// List list = new LinkedList(unsortMap.entrySet());
//
// Collections.sort(list, new Comparator() {
// public int compare(Object o1, Object o2) {
// return ((Comparable) ((Map.Entry) (o1)).getValue())
// .compareTo(((Map.Entry) (o2)).getValue());
// }
// });
//
// Map sortedMap = new LinkedHashMap();
// int counter = 0;
// for (Iterator it = list.iterator(); it.hasNext();) {
// Map.Entry entry = (Map.Entry) it.next();
// sortedMap.put(entry.getKey(), entry.getValue());
// counter++;
// if (counter == selectTop) {
// break;
// }
// }
// return sortedMap;
// }
//
// public static Map getTopValues2(Map unsortMap, Integer selectTop) {
// List list = new LinkedList(unsortMap.entrySet());
//
// Collections.sort(list, new Comparator() {
// public int compare(Object o1, Object o2) {
// return ((Comparable) ((Map.Entry) (o2)).getValue())
// .compareTo(((Map.Entry) (o1)).getValue());
// }
// });
//
// Map sortedMap = new LinkedHashMap();
// int counter = 0;
// for (Iterator it = list.iterator(); it.hasNext();) {
// Map.Entry entry = (Map.Entry) it.next();
// sortedMap.put(entry.getKey(), entry.getValue());
// counter++;
// if (counter == selectTop) {
// break;
// }
// }
// return sortedMap;
// }
//
// /**
// * Returns a sub-TreeMap from index i to j.
// *
// * @param startIndex
// * @param endIndex
// * @param treeMap
// * @returns the sub-TreeMap
// */
// public static TreeMap subTreeMap(int startIndex, int endIndex, TreeMap treeMap) {
// Iterator it = treeMap.entrySet().iterator();
// TreeMap newMap = new TreeMap();
// ArrayList list = new ArrayList<Map.Entry>(treeMap.entrySet());
// for (int i = startIndex; i <= endIndex; i++) {
// Map.Entry entry = (Map.Entry) list.get(i);
// newMap.put(entry.getKey(), entry.getValue());
// }
//
// return newMap;
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/companymatching/CompanySearcher.java
import certh.iti.mklab.easie.MapFunctionsUtils;
import certh.iti.mklab.jSimilarity.documentUtils.CompanyDocument;
import certh.iti.mklab.jSimilarity.documentUtils.Corpus;
import certh.iti.mklab.jSimilarity.stringsimilarities.CosineSimilarity;
import certh.iti.mklab.jSimilarity.tfidf.TFIDF;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.apache.commons.collections4.Predicate;
import org.bson.Document;
import org.bson.types.ObjectId;
HashMap<String, Double> candidates = new HashMap();
Predicate predicate = new Predicate<CompanyDocument>() {
@Override
public boolean evaluate(CompanyDocument object) {
if (country == null && object.country == null) {
return true;
}
if (object.country == null) {
return false;
}
return object.country.equals(country);
}
};
Iterator<CompanyDocument> it = corpus.iterator(predicate);
int i = 0;
while (it.hasNext()) {
CompanyDocument company = it.next();
double similarity = tfidf.similarity("candidate", company.id);
if (similarity >= threshold && !company.equals(document)) {
candidates.put(company.id, similarity);
}
}
if (candidates.size() > 0) {
| String id = (String) MapFunctionsUtils.getTopValues2(candidates, 1).keySet().iterator().next();
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/extractors/staticpages/SingleStaticPageExtractor.java | // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
| import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.concurrent.Callable;
import org.jsoup.HttpStatusException;
import org.jsoup.nodes.Document;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors.staticpages;
/**
* @author vasgat
*/
public class SingleStaticPageExtractor implements Callable {
public String page;
private String tableSelector;
| // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
// Path: src/main/java/certh/iti/mklab/easie/extractors/staticpages/SingleStaticPageExtractor.java
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.concurrent.Callable;
import org.jsoup.HttpStatusException;
import org.jsoup.nodes.Document;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.extractors.staticpages;
/**
* @author vasgat
*/
public class SingleStaticPageExtractor implements Callable {
public String page;
private String tableSelector;
| private List<ScrapableField> cfields;
|
MKLab-ITI/easIE | src/main/java/certh/iti/mklab/easie/executor/handlers/ExtractionHandler.java | // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public final class Configuration {
//
// public URL url;
//
// public HashSet<String> group_of_urls;
//
// public String source_name;
//
// public String entity_name;
//
// public String table_selector;
//
// public ArrayList<ScrapableField> metrics;
//
// public ArrayList<ScrapableField> entity_info;
//
// public String next_page_selector;
//
// public boolean dynamic_page;
//
// public Object events;
//
// public Store store;
//
// public Configuration crawl;
//
// public void setEvents(ArrayList<Event> events) {
// this.events = events;
// }
//
// public void setEvents(Event events) {
// this.events = events;
// }
//
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// public static class URL {
//
// public String base_url;
//
// public String relative_url;
// }
//
// public class Store {
//
// public String format;
//
// public String database;
//
// public String hd_path;
//
// public String companies_collection;
//
// public String metrics_collection;
//
// public DBCreadentials db_credentials;
//
// public String wikirate_metric_designer;
// }
//
// public class DBCreadentials {
//
// public String username;
//
// public String password;
//
// public String server_address;
//
// public String db;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/extractors/AbstractHTMLExtractor.java
// public abstract class AbstractHTMLExtractor {
//
// public abstract List extractFields(List<ScrapableField> fields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
//
// public abstract List extractTable(String tableSelector, List<ScrapableField> fields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
//
// public abstract Pair extractFields(List<ScrapableField> cfields, List<ScrapableField> sfields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
//
// public abstract Pair extractTable(String tableSelector, List<ScrapableField> cfields, List<ScrapableField> sfields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
// }
| import certh.iti.mklab.easie.configuration.Configuration;
import certh.iti.mklab.easie.extractors.AbstractHTMLExtractor;
import org.apache.commons.lang3.tuple.Pair;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.KeyManagementException;
import java.util.ArrayList;
import java.util.HashMap;
| /*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.executor.handlers;
/**
*
* @author vasgat
*/
public class ExtractionHandler {
private AbstractHTMLExtractor wrapper;
| // Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public final class Configuration {
//
// public URL url;
//
// public HashSet<String> group_of_urls;
//
// public String source_name;
//
// public String entity_name;
//
// public String table_selector;
//
// public ArrayList<ScrapableField> metrics;
//
// public ArrayList<ScrapableField> entity_info;
//
// public String next_page_selector;
//
// public boolean dynamic_page;
//
// public Object events;
//
// public Store store;
//
// public Configuration crawl;
//
// public void setEvents(ArrayList<Event> events) {
// this.events = events;
// }
//
// public void setEvents(Event events) {
// this.events = events;
// }
//
// public static class ScrapableField {
//
// public Object label;
//
// public Object value;
//
// public Object citeyear;
//
// public void setLabel(ExtractionProperties ep) {
// label = ep;
// }
//
// public void setValue(ExtractionProperties ep) {
// value = ep;
// }
//
// public void setCiteyear(ExtractionProperties ep) {
// citeyear = ep;
// }
// }
//
// public static class ExtractionProperties {
//
// public String selector;
//
// public String type;
//
// public Object citeyear;
//
// public ReplaceField replace;
//
// }
//
// public static class ReplaceField {
//
// public List<String> regex;
//
// public List<String> with;
// }
//
// public static class Event {
//
// public String type;
//
// public String selector;
//
// public Integer times_to_repeat;
//
// public String extraction_type;
// }
//
// public static class URL {
//
// public String base_url;
//
// public String relative_url;
// }
//
// public class Store {
//
// public String format;
//
// public String database;
//
// public String hd_path;
//
// public String companies_collection;
//
// public String metrics_collection;
//
// public DBCreadentials db_credentials;
//
// public String wikirate_metric_designer;
// }
//
// public class DBCreadentials {
//
// public String username;
//
// public String password;
//
// public String server_address;
//
// public String db;
// }
// }
//
// Path: src/main/java/certh/iti/mklab/easie/extractors/AbstractHTMLExtractor.java
// public abstract class AbstractHTMLExtractor {
//
// public abstract List extractFields(List<ScrapableField> fields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
//
// public abstract List extractTable(String tableSelector, List<ScrapableField> fields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
//
// public abstract Pair extractFields(List<ScrapableField> cfields, List<ScrapableField> sfields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
//
// public abstract Pair extractTable(String tableSelector, List<ScrapableField> cfields, List<ScrapableField> sfields) throws URISyntaxException, IOException, InterruptedException, KeyManagementException;
// }
// Path: src/main/java/certh/iti/mklab/easie/executor/handlers/ExtractionHandler.java
import certh.iti.mklab.easie.configuration.Configuration;
import certh.iti.mklab.easie.extractors.AbstractHTMLExtractor;
import org.apache.commons.lang3.tuple.Pair;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.KeyManagementException;
import java.util.ArrayList;
import java.util.HashMap;
/*
* Copyright 2016 vasgat.
*
* 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 certh.iti.mklab.easie.executor.handlers;
/**
*
* @author vasgat
*/
public class ExtractionHandler {
private AbstractHTMLExtractor wrapper;
| private Configuration configuration;
|
jchampemont/notedown | src/main/java/com/jeanchampemont/notedown/security/AuthenticationService.java | // Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
// User findByEmailIgnoreCase(String email);
// }
| import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service; | /*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.security;
@Service
public class AuthenticationService { | // Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
// User findByEmailIgnoreCase(String email);
// }
// Path: src/main/java/com/jeanchampemont/notedown/security/AuthenticationService.java
import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
/*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.security;
@Service
public class AuthenticationService { | private UserRepository userRepository; |
jchampemont/notedown | src/main/java/com/jeanchampemont/notedown/security/AuthenticationService.java | // Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
// User findByEmailIgnoreCase(String email);
// }
| import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service; | /*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.security;
@Service
public class AuthenticationService {
private UserRepository userRepository;
private AuthenticationManager authenticationManager;
@Autowired
public AuthenticationService(UserRepository userRepository, AuthenticationManager authenticationManager) {
this.userRepository = userRepository;
this.authenticationManager = authenticationManager;
}
| // Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
// User findByEmailIgnoreCase(String email);
// }
// Path: src/main/java/com/jeanchampemont/notedown/security/AuthenticationService.java
import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
/*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.security;
@Service
public class AuthenticationService {
private UserRepository userRepository;
private AuthenticationManager authenticationManager;
@Autowired
public AuthenticationService(UserRepository userRepository, AuthenticationManager authenticationManager) {
this.userRepository = userRepository;
this.authenticationManager = authenticationManager;
}
| public User getCurrentUser() { |
jchampemont/notedown | src/main/java/com/jeanchampemont/notedown/note/persistence/NoteEvent.java | // Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
| import com.jeanchampemont.notedown.user.persistence.User;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.Date; | /*
* Copyright (C) 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.note.persistence;
@Entity
@Table(name = "note_event")
public class NoteEvent {
@Id
private NoteEventId id;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "note_id", referencedColumnName = "id", insertable = false, updatable = false)
private Note note;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "user_id", nullable = false) | // Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
// Path: src/main/java/com/jeanchampemont/notedown/note/persistence/NoteEvent.java
import com.jeanchampemont.notedown.user.persistence.User;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.Date;
/*
* Copyright (C) 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.note.persistence;
@Entity
@Table(name = "note_event")
public class NoteEvent {
@Id
private NoteEventId id;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "note_id", referencedColumnName = "id", insertable = false, updatable = false)
private Note note;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "user_id", nullable = false) | private User user; |
jchampemont/notedown | src/main/java/com/jeanchampemont/notedown/security/NoteDownUserDetailsService.java | // Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
// User findByEmailIgnoreCase(String email);
// }
| import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collections; | /*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.security;
@Service("userDetailsService")
public class NoteDownUserDetailsService implements UserDetailsService {
| // Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
// User findByEmailIgnoreCase(String email);
// }
// Path: src/main/java/com/jeanchampemont/notedown/security/NoteDownUserDetailsService.java
import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
/*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.security;
@Service("userDetailsService")
public class NoteDownUserDetailsService implements UserDetailsService {
| private UserRepository userRepository; |
jchampemont/notedown | src/main/java/com/jeanchampemont/notedown/security/NoteDownUserDetailsService.java | // Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
// User findByEmailIgnoreCase(String email);
// }
| import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collections; | /*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.security;
@Service("userDetailsService")
public class NoteDownUserDetailsService implements UserDetailsService {
private UserRepository userRepository;
@Autowired
public NoteDownUserDetailsService(UserRepository userRepository) {
this.userRepository = userRepository;
}
@Transactional(readOnly = true)
@Override
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException { | // Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
// User findByEmailIgnoreCase(String email);
// }
// Path: src/main/java/com/jeanchampemont/notedown/security/NoteDownUserDetailsService.java
import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
/*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.security;
@Service("userDetailsService")
public class NoteDownUserDetailsService implements UserDetailsService {
private UserRepository userRepository;
@Autowired
public NoteDownUserDetailsService(UserRepository userRepository) {
this.userRepository = userRepository;
}
@Transactional(readOnly = true)
@Override
public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException { | User user = userRepository.findByEmailIgnoreCase(s); |
jchampemont/notedown | src/main/java/com/jeanchampemont/notedown/config/WebSecurityConfiguration.java | // Path: src/main/java/com/jeanchampemont/notedown/utils/SecurityInterceptor.java
// @Component
// public class SecurityInterceptor extends HandlerInterceptorAdapter {
// @Override
// public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
// if (modelAndView != null) {
// FilterInvocation filterInvocation = new FilterInvocation(request, response, new FilterChain() {
// public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
// throw new UnsupportedOperationException();
// }
// });
//
// Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// if (authentication != null) {
// WebSecurityExpressionRoot sec = new WebSecurityExpressionRoot(authentication, filterInvocation);
// sec.setTrustResolver(new AuthenticationTrustResolverImpl());
// modelAndView.getModel().put("sec", sec);
// }
// }
// }
// }
| import com.jeanchampemont.notedown.utils.SecurityInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.rememberme.JdbcTokenRepositoryImpl;
import org.springframework.security.web.authentication.rememberme.PersistentTokenRepository;
import org.springframework.security.web.servlet.support.csrf.CsrfRequestDataValueProcessor;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.support.RequestDataValueProcessor;
import javax.sql.DataSource; | .formLogin().loginPage("/login").failureUrl("/login?error")
.usernameParameter("email").passwordParameter("password")
.defaultSuccessUrl("/app")
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout", "GET")).logoutSuccessUrl("/login?logout")
.and()
.rememberMe().tokenRepository(persistentTokenRepository()).tokenValiditySeconds(tokenValiditySeconds)
.and()
.csrf();
}
@Bean
public PersistentTokenRepository persistentTokenRepository() {
JdbcTokenRepositoryImpl repo = new JdbcTokenRepositoryImpl();
repo.setDataSource(dataSource);
return repo;
}
@Bean
public PasswordEncoder passwordEncoder() {
PasswordEncoder encoder = new BCryptPasswordEncoder();
return encoder;
}
@Bean
public RequestDataValueProcessor requestDataValueProcessor() {
return new CsrfRequestDataValueProcessor();
}
@Bean | // Path: src/main/java/com/jeanchampemont/notedown/utils/SecurityInterceptor.java
// @Component
// public class SecurityInterceptor extends HandlerInterceptorAdapter {
// @Override
// public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
// if (modelAndView != null) {
// FilterInvocation filterInvocation = new FilterInvocation(request, response, new FilterChain() {
// public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
// throw new UnsupportedOperationException();
// }
// });
//
// Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// if (authentication != null) {
// WebSecurityExpressionRoot sec = new WebSecurityExpressionRoot(authentication, filterInvocation);
// sec.setTrustResolver(new AuthenticationTrustResolverImpl());
// modelAndView.getModel().put("sec", sec);
// }
// }
// }
// }
// Path: src/main/java/com/jeanchampemont/notedown/config/WebSecurityConfiguration.java
import com.jeanchampemont.notedown.utils.SecurityInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.rememberme.JdbcTokenRepositoryImpl;
import org.springframework.security.web.authentication.rememberme.PersistentTokenRepository;
import org.springframework.security.web.servlet.support.csrf.CsrfRequestDataValueProcessor;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.support.RequestDataValueProcessor;
import javax.sql.DataSource;
.formLogin().loginPage("/login").failureUrl("/login?error")
.usernameParameter("email").passwordParameter("password")
.defaultSuccessUrl("/app")
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout", "GET")).logoutSuccessUrl("/login?logout")
.and()
.rememberMe().tokenRepository(persistentTokenRepository()).tokenValiditySeconds(tokenValiditySeconds)
.and()
.csrf();
}
@Bean
public PersistentTokenRepository persistentTokenRepository() {
JdbcTokenRepositoryImpl repo = new JdbcTokenRepositoryImpl();
repo.setDataSource(dataSource);
return repo;
}
@Bean
public PasswordEncoder passwordEncoder() {
PasswordEncoder encoder = new BCryptPasswordEncoder();
return encoder;
}
@Bean
public RequestDataValueProcessor requestDataValueProcessor() {
return new CsrfRequestDataValueProcessor();
}
@Bean | public RequestMappingHandlerMapping requestMappingHandlerMapping(SecurityInterceptor securityInterceptor) { |
jchampemont/notedown | src/main/java/com/jeanchampemont/notedown/user/persistence/User.java | // Path: src/main/java/com/jeanchampemont/notedown/note/persistence/Note.java
// @Entity
// @Table(name = "note")
// public class Note {
// @Id
// @Type(type = "uuid-char")
// private UUID id;
//
// @Column(name = "title", length = 64, nullable = false)
// private String title;
//
// @Column(name = "content", nullable = false)
// @Lob
// @Type(type = "org.hibernate.type.StringClobType")
// private String content;
//
// @Column(name = "last_modification", nullable = false)
// @Temporal(TemporalType.TIMESTAMP)
// private Date lastModification;
//
// @ManyToOne(fetch = FetchType.EAGER)
// @JoinColumn(name = "user_id", nullable = false)
// private User user;
//
// @OneToMany(mappedBy = "note", cascade = CascadeType.REMOVE)
// @OrderBy("version DESC")
// private List<NoteEvent> events = new ArrayList<>();
//
// public Note() {
// id = UUID.randomUUID();
// }
//
// public Note(String title, String content, User user) {
// id = UUID.randomUUID();
// this.title = title;
// this.content = content;
// this.user = user;
// }
//
// public UUID getId() {
// return id;
// }
//
// public void setId(UUID id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// public Date getLastModification() {
// return lastModification;
// }
//
// public void setLastModification(Date lastModification) {
// this.lastModification = lastModification;
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
//
// public List<NoteEvent> getEvents() {
// return events;
// }
//
// public void setEvents(List<NoteEvent> events) {
// this.events = events;
// }
//
// @Transient
// public Long getFirstAvailableVersion() {
// if (events == null || events.size() == 0) {
// return 0L;
// } else {
// return events.get(events.size() - 1).getId().getVersion();
// }
// }
//
// @Transient
// public Long getLastVersion() {
// if (events == null || events.size() == 0) {
// return 0L;
// } else {
// return events.get(0).getId().getVersion();
// }
// }
// }
| import com.jeanchampemont.notedown.note.persistence.Note;
import javax.persistence.*;
import java.util.HashSet;
import java.util.Set; | /*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.user.persistence;
@Entity
@Table(name = "user_account")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private long id;
@Column(name = "email", unique = true, length = 64)
private String email;
@Column(name = "password", length = 60)
private String password;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user") | // Path: src/main/java/com/jeanchampemont/notedown/note/persistence/Note.java
// @Entity
// @Table(name = "note")
// public class Note {
// @Id
// @Type(type = "uuid-char")
// private UUID id;
//
// @Column(name = "title", length = 64, nullable = false)
// private String title;
//
// @Column(name = "content", nullable = false)
// @Lob
// @Type(type = "org.hibernate.type.StringClobType")
// private String content;
//
// @Column(name = "last_modification", nullable = false)
// @Temporal(TemporalType.TIMESTAMP)
// private Date lastModification;
//
// @ManyToOne(fetch = FetchType.EAGER)
// @JoinColumn(name = "user_id", nullable = false)
// private User user;
//
// @OneToMany(mappedBy = "note", cascade = CascadeType.REMOVE)
// @OrderBy("version DESC")
// private List<NoteEvent> events = new ArrayList<>();
//
// public Note() {
// id = UUID.randomUUID();
// }
//
// public Note(String title, String content, User user) {
// id = UUID.randomUUID();
// this.title = title;
// this.content = content;
// this.user = user;
// }
//
// public UUID getId() {
// return id;
// }
//
// public void setId(UUID id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// public Date getLastModification() {
// return lastModification;
// }
//
// public void setLastModification(Date lastModification) {
// this.lastModification = lastModification;
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
//
// public List<NoteEvent> getEvents() {
// return events;
// }
//
// public void setEvents(List<NoteEvent> events) {
// this.events = events;
// }
//
// @Transient
// public Long getFirstAvailableVersion() {
// if (events == null || events.size() == 0) {
// return 0L;
// } else {
// return events.get(events.size() - 1).getId().getVersion();
// }
// }
//
// @Transient
// public Long getLastVersion() {
// if (events == null || events.size() == 0) {
// return 0L;
// } else {
// return events.get(0).getId().getVersion();
// }
// }
// }
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
import com.jeanchampemont.notedown.note.persistence.Note;
import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;
/*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.user.persistence;
@Entity
@Table(name = "user_account")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private long id;
@Column(name = "email", unique = true, length = 64)
private String email;
@Column(name = "password", length = 60)
private String password;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user") | private Set<Note> notes = new HashSet<>(); |
jchampemont/notedown | src/main/java/com/jeanchampemont/notedown/ApplicationStartup.java | // Path: src/main/java/com/jeanchampemont/notedown/note/persistence/repository/NoteRepository.java
// public interface NoteRepository extends CrudRepository<Note, UUID> {
// List<Note> findByUserOrderByLastModificationDesc(User user);
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/UserService.java
// @Service
// public class UserService {
//
// private AuthenticationService authenticationService;
//
// private UserRepository repo;
//
// private PasswordEncoder encoder;
//
// @Autowired
// public UserService(AuthenticationService authenticationService, UserRepository repo, PasswordEncoder encoder) {
// this.authenticationService = authenticationService;
// this.repo = repo;
// this.encoder = encoder;
// }
//
// /**
// * @return whether or not the application has at least one registered user.
// */
// @Transactional(readOnly = true)
// public boolean hasRegisteredUser() {
// return repo.findAll().iterator().hasNext();
// }
//
// /**
// * Create the user.
// * The password is encoded.
// *
// * @param user
// * @return persisted user with encoded password
// */
// @Transactional
// public User create(User user) {
// user.setPassword(encoder.encode(user.getPassword()));
// user.setEmail(user.getEmail().toLowerCase());
// user.setDisplayName(user.getEmail().toLowerCase());
// user = repo.save(user);
// return user;
// }
//
// /**
// * Find a user for this email if it exists
// *
// * @param email
// * @return
// */
// @Transactional(readOnly = true)
// @Cacheable("user")
// public Optional<User> getUserByEmail(String email) {
// return Optional.ofNullable(repo.findByEmailIgnoreCase(email));
// }
//
// /**
// * Update user
// * This method does not update email or password.
// * Use changeEmail or changePassword instead.
// *
// * @param user
// * @return updated user
// */
// @Transactional
// @CacheEvict(value = "user", key = "#user.email")
// public User update(User user) {
// User originalUser = repo.findByEmailIgnoreCase(user.getEmail());
// User currentUser = authenticationService.getCurrentUser();
// if (hasWriteAccess(currentUser, originalUser)) {
// originalUser.setLocale(user.getLocale());
// originalUser.setDisplayName(user.getDisplayName());
// return repo.save(originalUser);
// }
// throw new OperationNotAllowedException();
// }
//
// /**
// * Change user's email
// *
// * @param user
// * @param email
// * @param password
// * @return whether or not the change wass sucessfull
// */
// @Transactional
// @CacheEvict(value = "user", key = "#user.email")
// public boolean changeEmail(User user, String email, String password) {
// User originalUser = repo.findByEmailIgnoreCase(user.getEmail());
// User currentUser = authenticationService.getCurrentUser();
// if (hasWriteAccess(currentUser, originalUser) && encoder.matches(password, currentUser.getPassword())) {
// originalUser.setEmail(email);
// repo.save(originalUser);
// return true;
// } else {
// return false;
// }
// }
//
// /**
// * Change user's password
// *
// * @param user
// * @param oldPassword
// * @param newPassword
// * @return whether or not the change was sucessfull
// */
// @Transactional
// @CacheEvict(value = "user", key = "#user.email")
// public boolean changePassword(User user, String oldPassword, String newPassword) {
// User originalUser = repo.findByEmailIgnoreCase(user.getEmail());
// User currentUser = authenticationService.getCurrentUser();
// if (hasWriteAccess(currentUser, originalUser) && encoder.matches(oldPassword, currentUser.getPassword())) {
// originalUser.setPassword(encoder.encode(newPassword));
// repo.save(originalUser);
// return true;
// } else {
// return false;
// }
// }
//
// /**
// * @param currentUser
// * @param targetUser
// * @return whether or not the currentUser has write access to the targetUser
// */
// private boolean hasWriteAccess(User currentUser, User targetUser) {
// return currentUser.getId() == targetUser.getId();
// }
// }
| import com.jeanchampemont.notedown.note.persistence.repository.NoteRepository;
import com.jeanchampemont.notedown.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component; | /*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown;
@Component
public class ApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {
| // Path: src/main/java/com/jeanchampemont/notedown/note/persistence/repository/NoteRepository.java
// public interface NoteRepository extends CrudRepository<Note, UUID> {
// List<Note> findByUserOrderByLastModificationDesc(User user);
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/UserService.java
// @Service
// public class UserService {
//
// private AuthenticationService authenticationService;
//
// private UserRepository repo;
//
// private PasswordEncoder encoder;
//
// @Autowired
// public UserService(AuthenticationService authenticationService, UserRepository repo, PasswordEncoder encoder) {
// this.authenticationService = authenticationService;
// this.repo = repo;
// this.encoder = encoder;
// }
//
// /**
// * @return whether or not the application has at least one registered user.
// */
// @Transactional(readOnly = true)
// public boolean hasRegisteredUser() {
// return repo.findAll().iterator().hasNext();
// }
//
// /**
// * Create the user.
// * The password is encoded.
// *
// * @param user
// * @return persisted user with encoded password
// */
// @Transactional
// public User create(User user) {
// user.setPassword(encoder.encode(user.getPassword()));
// user.setEmail(user.getEmail().toLowerCase());
// user.setDisplayName(user.getEmail().toLowerCase());
// user = repo.save(user);
// return user;
// }
//
// /**
// * Find a user for this email if it exists
// *
// * @param email
// * @return
// */
// @Transactional(readOnly = true)
// @Cacheable("user")
// public Optional<User> getUserByEmail(String email) {
// return Optional.ofNullable(repo.findByEmailIgnoreCase(email));
// }
//
// /**
// * Update user
// * This method does not update email or password.
// * Use changeEmail or changePassword instead.
// *
// * @param user
// * @return updated user
// */
// @Transactional
// @CacheEvict(value = "user", key = "#user.email")
// public User update(User user) {
// User originalUser = repo.findByEmailIgnoreCase(user.getEmail());
// User currentUser = authenticationService.getCurrentUser();
// if (hasWriteAccess(currentUser, originalUser)) {
// originalUser.setLocale(user.getLocale());
// originalUser.setDisplayName(user.getDisplayName());
// return repo.save(originalUser);
// }
// throw new OperationNotAllowedException();
// }
//
// /**
// * Change user's email
// *
// * @param user
// * @param email
// * @param password
// * @return whether or not the change wass sucessfull
// */
// @Transactional
// @CacheEvict(value = "user", key = "#user.email")
// public boolean changeEmail(User user, String email, String password) {
// User originalUser = repo.findByEmailIgnoreCase(user.getEmail());
// User currentUser = authenticationService.getCurrentUser();
// if (hasWriteAccess(currentUser, originalUser) && encoder.matches(password, currentUser.getPassword())) {
// originalUser.setEmail(email);
// repo.save(originalUser);
// return true;
// } else {
// return false;
// }
// }
//
// /**
// * Change user's password
// *
// * @param user
// * @param oldPassword
// * @param newPassword
// * @return whether or not the change was sucessfull
// */
// @Transactional
// @CacheEvict(value = "user", key = "#user.email")
// public boolean changePassword(User user, String oldPassword, String newPassword) {
// User originalUser = repo.findByEmailIgnoreCase(user.getEmail());
// User currentUser = authenticationService.getCurrentUser();
// if (hasWriteAccess(currentUser, originalUser) && encoder.matches(oldPassword, currentUser.getPassword())) {
// originalUser.setPassword(encoder.encode(newPassword));
// repo.save(originalUser);
// return true;
// } else {
// return false;
// }
// }
//
// /**
// * @param currentUser
// * @param targetUser
// * @return whether or not the currentUser has write access to the targetUser
// */
// private boolean hasWriteAccess(User currentUser, User targetUser) {
// return currentUser.getId() == targetUser.getId();
// }
// }
// Path: src/main/java/com/jeanchampemont/notedown/ApplicationStartup.java
import com.jeanchampemont.notedown.note.persistence.repository.NoteRepository;
import com.jeanchampemont.notedown.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
/*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown;
@Component
public class ApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {
| private NoteRepository noteRepository; |
jchampemont/notedown | src/main/java/com/jeanchampemont/notedown/ApplicationStartup.java | // Path: src/main/java/com/jeanchampemont/notedown/note/persistence/repository/NoteRepository.java
// public interface NoteRepository extends CrudRepository<Note, UUID> {
// List<Note> findByUserOrderByLastModificationDesc(User user);
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/UserService.java
// @Service
// public class UserService {
//
// private AuthenticationService authenticationService;
//
// private UserRepository repo;
//
// private PasswordEncoder encoder;
//
// @Autowired
// public UserService(AuthenticationService authenticationService, UserRepository repo, PasswordEncoder encoder) {
// this.authenticationService = authenticationService;
// this.repo = repo;
// this.encoder = encoder;
// }
//
// /**
// * @return whether or not the application has at least one registered user.
// */
// @Transactional(readOnly = true)
// public boolean hasRegisteredUser() {
// return repo.findAll().iterator().hasNext();
// }
//
// /**
// * Create the user.
// * The password is encoded.
// *
// * @param user
// * @return persisted user with encoded password
// */
// @Transactional
// public User create(User user) {
// user.setPassword(encoder.encode(user.getPassword()));
// user.setEmail(user.getEmail().toLowerCase());
// user.setDisplayName(user.getEmail().toLowerCase());
// user = repo.save(user);
// return user;
// }
//
// /**
// * Find a user for this email if it exists
// *
// * @param email
// * @return
// */
// @Transactional(readOnly = true)
// @Cacheable("user")
// public Optional<User> getUserByEmail(String email) {
// return Optional.ofNullable(repo.findByEmailIgnoreCase(email));
// }
//
// /**
// * Update user
// * This method does not update email or password.
// * Use changeEmail or changePassword instead.
// *
// * @param user
// * @return updated user
// */
// @Transactional
// @CacheEvict(value = "user", key = "#user.email")
// public User update(User user) {
// User originalUser = repo.findByEmailIgnoreCase(user.getEmail());
// User currentUser = authenticationService.getCurrentUser();
// if (hasWriteAccess(currentUser, originalUser)) {
// originalUser.setLocale(user.getLocale());
// originalUser.setDisplayName(user.getDisplayName());
// return repo.save(originalUser);
// }
// throw new OperationNotAllowedException();
// }
//
// /**
// * Change user's email
// *
// * @param user
// * @param email
// * @param password
// * @return whether or not the change wass sucessfull
// */
// @Transactional
// @CacheEvict(value = "user", key = "#user.email")
// public boolean changeEmail(User user, String email, String password) {
// User originalUser = repo.findByEmailIgnoreCase(user.getEmail());
// User currentUser = authenticationService.getCurrentUser();
// if (hasWriteAccess(currentUser, originalUser) && encoder.matches(password, currentUser.getPassword())) {
// originalUser.setEmail(email);
// repo.save(originalUser);
// return true;
// } else {
// return false;
// }
// }
//
// /**
// * Change user's password
// *
// * @param user
// * @param oldPassword
// * @param newPassword
// * @return whether or not the change was sucessfull
// */
// @Transactional
// @CacheEvict(value = "user", key = "#user.email")
// public boolean changePassword(User user, String oldPassword, String newPassword) {
// User originalUser = repo.findByEmailIgnoreCase(user.getEmail());
// User currentUser = authenticationService.getCurrentUser();
// if (hasWriteAccess(currentUser, originalUser) && encoder.matches(oldPassword, currentUser.getPassword())) {
// originalUser.setPassword(encoder.encode(newPassword));
// repo.save(originalUser);
// return true;
// } else {
// return false;
// }
// }
//
// /**
// * @param currentUser
// * @param targetUser
// * @return whether or not the currentUser has write access to the targetUser
// */
// private boolean hasWriteAccess(User currentUser, User targetUser) {
// return currentUser.getId() == targetUser.getId();
// }
// }
| import com.jeanchampemont.notedown.note.persistence.repository.NoteRepository;
import com.jeanchampemont.notedown.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component; | /*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown;
@Component
public class ApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {
private NoteRepository noteRepository;
| // Path: src/main/java/com/jeanchampemont/notedown/note/persistence/repository/NoteRepository.java
// public interface NoteRepository extends CrudRepository<Note, UUID> {
// List<Note> findByUserOrderByLastModificationDesc(User user);
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/UserService.java
// @Service
// public class UserService {
//
// private AuthenticationService authenticationService;
//
// private UserRepository repo;
//
// private PasswordEncoder encoder;
//
// @Autowired
// public UserService(AuthenticationService authenticationService, UserRepository repo, PasswordEncoder encoder) {
// this.authenticationService = authenticationService;
// this.repo = repo;
// this.encoder = encoder;
// }
//
// /**
// * @return whether or not the application has at least one registered user.
// */
// @Transactional(readOnly = true)
// public boolean hasRegisteredUser() {
// return repo.findAll().iterator().hasNext();
// }
//
// /**
// * Create the user.
// * The password is encoded.
// *
// * @param user
// * @return persisted user with encoded password
// */
// @Transactional
// public User create(User user) {
// user.setPassword(encoder.encode(user.getPassword()));
// user.setEmail(user.getEmail().toLowerCase());
// user.setDisplayName(user.getEmail().toLowerCase());
// user = repo.save(user);
// return user;
// }
//
// /**
// * Find a user for this email if it exists
// *
// * @param email
// * @return
// */
// @Transactional(readOnly = true)
// @Cacheable("user")
// public Optional<User> getUserByEmail(String email) {
// return Optional.ofNullable(repo.findByEmailIgnoreCase(email));
// }
//
// /**
// * Update user
// * This method does not update email or password.
// * Use changeEmail or changePassword instead.
// *
// * @param user
// * @return updated user
// */
// @Transactional
// @CacheEvict(value = "user", key = "#user.email")
// public User update(User user) {
// User originalUser = repo.findByEmailIgnoreCase(user.getEmail());
// User currentUser = authenticationService.getCurrentUser();
// if (hasWriteAccess(currentUser, originalUser)) {
// originalUser.setLocale(user.getLocale());
// originalUser.setDisplayName(user.getDisplayName());
// return repo.save(originalUser);
// }
// throw new OperationNotAllowedException();
// }
//
// /**
// * Change user's email
// *
// * @param user
// * @param email
// * @param password
// * @return whether or not the change wass sucessfull
// */
// @Transactional
// @CacheEvict(value = "user", key = "#user.email")
// public boolean changeEmail(User user, String email, String password) {
// User originalUser = repo.findByEmailIgnoreCase(user.getEmail());
// User currentUser = authenticationService.getCurrentUser();
// if (hasWriteAccess(currentUser, originalUser) && encoder.matches(password, currentUser.getPassword())) {
// originalUser.setEmail(email);
// repo.save(originalUser);
// return true;
// } else {
// return false;
// }
// }
//
// /**
// * Change user's password
// *
// * @param user
// * @param oldPassword
// * @param newPassword
// * @return whether or not the change was sucessfull
// */
// @Transactional
// @CacheEvict(value = "user", key = "#user.email")
// public boolean changePassword(User user, String oldPassword, String newPassword) {
// User originalUser = repo.findByEmailIgnoreCase(user.getEmail());
// User currentUser = authenticationService.getCurrentUser();
// if (hasWriteAccess(currentUser, originalUser) && encoder.matches(oldPassword, currentUser.getPassword())) {
// originalUser.setPassword(encoder.encode(newPassword));
// repo.save(originalUser);
// return true;
// } else {
// return false;
// }
// }
//
// /**
// * @param currentUser
// * @param targetUser
// * @return whether or not the currentUser has write access to the targetUser
// */
// private boolean hasWriteAccess(User currentUser, User targetUser) {
// return currentUser.getId() == targetUser.getId();
// }
// }
// Path: src/main/java/com/jeanchampemont/notedown/ApplicationStartup.java
import com.jeanchampemont.notedown.note.persistence.repository.NoteRepository;
import com.jeanchampemont.notedown.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
/*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown;
@Component
public class ApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {
private NoteRepository noteRepository;
| private UserService userService; |
jchampemont/notedown | src/main/java/com/jeanchampemont/notedown/user/UserService.java | // Path: src/main/java/com/jeanchampemont/notedown/security/AuthenticationService.java
// @Service
// public class AuthenticationService {
// private UserRepository userRepository;
//
// private AuthenticationManager authenticationManager;
//
// @Autowired
// public AuthenticationService(UserRepository userRepository, AuthenticationManager authenticationManager) {
// this.userRepository = userRepository;
// this.authenticationManager = authenticationManager;
// }
//
// public User getCurrentUser() {
// String email = SecurityContextHolder.getContext().getAuthentication().getName();
// return userRepository.findByEmailIgnoreCase(email);
// }
//
// public boolean isAuthenticated() {
// return (SecurityContextHolder.getContext().getAuthentication() != null);
// }
//
// public void newAuthentication(String email, String password) {
// Authentication request = new UsernamePasswordAuthenticationToken(email, password);
// Authentication result = authenticationManager.authenticate(request);
// SecurityContextHolder.getContext().setAuthentication(result);
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
// User findByEmailIgnoreCase(String email);
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/utils/exception/OperationNotAllowedException.java
// public class OperationNotAllowedException extends RuntimeException {
//
// }
| import com.jeanchampemont.notedown.security.AuthenticationService;
import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import com.jeanchampemont.notedown.utils.exception.OperationNotAllowedException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional; | /*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.user;
/**
* This service manages users of the application.
*
* @author Jean Champémont
*/
@Service
public class UserService {
| // Path: src/main/java/com/jeanchampemont/notedown/security/AuthenticationService.java
// @Service
// public class AuthenticationService {
// private UserRepository userRepository;
//
// private AuthenticationManager authenticationManager;
//
// @Autowired
// public AuthenticationService(UserRepository userRepository, AuthenticationManager authenticationManager) {
// this.userRepository = userRepository;
// this.authenticationManager = authenticationManager;
// }
//
// public User getCurrentUser() {
// String email = SecurityContextHolder.getContext().getAuthentication().getName();
// return userRepository.findByEmailIgnoreCase(email);
// }
//
// public boolean isAuthenticated() {
// return (SecurityContextHolder.getContext().getAuthentication() != null);
// }
//
// public void newAuthentication(String email, String password) {
// Authentication request = new UsernamePasswordAuthenticationToken(email, password);
// Authentication result = authenticationManager.authenticate(request);
// SecurityContextHolder.getContext().setAuthentication(result);
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
// User findByEmailIgnoreCase(String email);
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/utils/exception/OperationNotAllowedException.java
// public class OperationNotAllowedException extends RuntimeException {
//
// }
// Path: src/main/java/com/jeanchampemont/notedown/user/UserService.java
import com.jeanchampemont.notedown.security.AuthenticationService;
import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import com.jeanchampemont.notedown.utils.exception.OperationNotAllowedException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.user;
/**
* This service manages users of the application.
*
* @author Jean Champémont
*/
@Service
public class UserService {
| private AuthenticationService authenticationService; |
jchampemont/notedown | src/main/java/com/jeanchampemont/notedown/user/UserService.java | // Path: src/main/java/com/jeanchampemont/notedown/security/AuthenticationService.java
// @Service
// public class AuthenticationService {
// private UserRepository userRepository;
//
// private AuthenticationManager authenticationManager;
//
// @Autowired
// public AuthenticationService(UserRepository userRepository, AuthenticationManager authenticationManager) {
// this.userRepository = userRepository;
// this.authenticationManager = authenticationManager;
// }
//
// public User getCurrentUser() {
// String email = SecurityContextHolder.getContext().getAuthentication().getName();
// return userRepository.findByEmailIgnoreCase(email);
// }
//
// public boolean isAuthenticated() {
// return (SecurityContextHolder.getContext().getAuthentication() != null);
// }
//
// public void newAuthentication(String email, String password) {
// Authentication request = new UsernamePasswordAuthenticationToken(email, password);
// Authentication result = authenticationManager.authenticate(request);
// SecurityContextHolder.getContext().setAuthentication(result);
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
// User findByEmailIgnoreCase(String email);
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/utils/exception/OperationNotAllowedException.java
// public class OperationNotAllowedException extends RuntimeException {
//
// }
| import com.jeanchampemont.notedown.security.AuthenticationService;
import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import com.jeanchampemont.notedown.utils.exception.OperationNotAllowedException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional; | /*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.user;
/**
* This service manages users of the application.
*
* @author Jean Champémont
*/
@Service
public class UserService {
private AuthenticationService authenticationService;
| // Path: src/main/java/com/jeanchampemont/notedown/security/AuthenticationService.java
// @Service
// public class AuthenticationService {
// private UserRepository userRepository;
//
// private AuthenticationManager authenticationManager;
//
// @Autowired
// public AuthenticationService(UserRepository userRepository, AuthenticationManager authenticationManager) {
// this.userRepository = userRepository;
// this.authenticationManager = authenticationManager;
// }
//
// public User getCurrentUser() {
// String email = SecurityContextHolder.getContext().getAuthentication().getName();
// return userRepository.findByEmailIgnoreCase(email);
// }
//
// public boolean isAuthenticated() {
// return (SecurityContextHolder.getContext().getAuthentication() != null);
// }
//
// public void newAuthentication(String email, String password) {
// Authentication request = new UsernamePasswordAuthenticationToken(email, password);
// Authentication result = authenticationManager.authenticate(request);
// SecurityContextHolder.getContext().setAuthentication(result);
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
// @Id
// @GeneratedValue(strategy = GenerationType.TABLE)
// private long id;
//
// @Column(name = "email", unique = true, length = 64)
// private String email;
//
// @Column(name = "password", length = 60)
// private String password;
//
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
// private Set<Note> notes = new HashSet<>();
//
// @Column(name = "locale", length = 2)
// private String locale;
//
// @Column(name = "display_name", length = 64)
// private String displayName;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Set<Note> getNotes() {
// return notes;
// }
//
// public void setNotes(Set<Note> notes) {
// this.notes = notes;
// }
//
// public String getLocale() {
// return locale;
// }
//
// public void setLocale(String locale) {
// this.locale = locale;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public void setDisplayName(String displayName) {
// this.displayName = displayName;
// }
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
// User findByEmailIgnoreCase(String email);
// }
//
// Path: src/main/java/com/jeanchampemont/notedown/utils/exception/OperationNotAllowedException.java
// public class OperationNotAllowedException extends RuntimeException {
//
// }
// Path: src/main/java/com/jeanchampemont/notedown/user/UserService.java
import com.jeanchampemont.notedown.security.AuthenticationService;
import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import com.jeanchampemont.notedown.utils.exception.OperationNotAllowedException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/*
* Copyright (C) 2014, 2015 NoteDown
*
* This file is part of the NoteDown project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeanchampemont.notedown.user;
/**
* This service manages users of the application.
*
* @author Jean Champémont
*/
@Service
public class UserService {
private AuthenticationService authenticationService;
| private UserRepository repo; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.