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
|
---|---|---|---|---|---|---|
Consoar/zhangshangwuda | src/zq/whu/zhangshangwuda/ui/SettingActivity.java | // Path: src/zq/whu/zhangshangwuda/base/BaseThemeSherlockPreferenceActivity.java
// public class BaseThemeSherlockPreferenceActivity extends
// SherlockPreferenceActivity {
// public int mTheme = R.style.MyLightTheme;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// if (savedInstanceState == null) {
// mTheme = PreferenceHelper.getTheme(this);
// } else {
// mTheme = savedInstanceState.getInt("theme");
// }
// setTheme(mTheme);
// getWindow().setBackgroundDrawable(null);
// super.onCreate(savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// if (mTheme != PreferenceHelper.getTheme(this)) {
// reload();
// }
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// outState.putInt("theme", mTheme);
// }
//
// protected void reload() {
// Intent intent = getIntent();
// overridePendingTransition(0, 0);
// intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
// finish();
// overridePendingTransition(0, 0);
// startActivity(intent);
// }
// }
//
// Path: src/zq/whu/zhangshangwuda/base/PreferenceHelper.java
// public class PreferenceHelper {
//
// public static final String KEY_THEME = "theme";
//
// private static SharedPreferences.Editor mEditor = null;
// private static SharedPreferences mdPreferences = null;
//
// public PreferenceHelper(Context context) {
// }
//
// private static SharedPreferences.Editor getEditor(Context paramContext) {
// if (mEditor == null)
// mEditor = paramContext.getSharedPreferences(
// Constants.PREFS_NAME_USER_DATA, 0).edit();
// return mEditor;
// }
//
// private static SharedPreferences getSharedPreferences(Context paramContext) {
// if (mdPreferences == null)
// mdPreferences = paramContext.getSharedPreferences(
// Constants.PREFS_NAME_USER_DATA, 0);
// return mdPreferences;
// }
//
// public static int getTheme(Context context) {
// return PreferenceHelper.getSharedPreferences(context).getInt(KEY_THEME,
// R.style.MyLightTheme);
// }
//
// public static void setTheme(Context context, int theme) {
// getEditor(context).putInt(KEY_THEME, theme).commit();
// }
//
// }
//
// Path: src/zq/whu/zhangshangwuda/tools/LessonsSharedPreferencesTool.java
// public class LessonsSharedPreferencesTool {
// public static boolean getLessonsHave(Context c) {
// SharedPreferences Mysettings = c.getSharedPreferences("User_Data", 0);
// return Mysettings.getBoolean("Lessons_Have", false);
// }
//
// public static void setLessonsHave(Context c, boolean x) {
// SharedPreferences.Editor localEditor = c.getSharedPreferences(
// "User_Data", 0).edit();
// localEditor.putBoolean("Lessons_Have", x).commit();
// }
//
// public static String getTermFirstDay(Context c) {
// SharedPreferences Mysettings = c.getSharedPreferences("User_Data", 0);
// return Mysettings.getString("Lessons_TermFirstDay", "2012-8-31");
// }
//
// public static void setTermFirstDay(Context c, String x) {
// SharedPreferences.Editor localEditor = c.getSharedPreferences(
// "User_Data", 0).edit();
// localEditor.putString("Lessons_TermFirstDay", x).commit();
// }
//
// public static Integer getLessonsId(Context c) {
// SharedPreferences Mysettings = c.getSharedPreferences("User_Data", 0);
// return Mysettings.getInt("Lessons_Id", 0);
// }
//
// public static void setLessonsId(Context c, Integer x) {
// SharedPreferences.Editor localEditor = c.getSharedPreferences(
// "User_Data", 0).edit();
// localEditor.putInt("Lessons_Id", x).commit();
// }
// }
| import zq.whu.zhangshangwuda.base.BaseThemeSherlockPreferenceActivity;
import zq.whu.zhangshangwuda.base.PreferenceHelper;
import zq.whu.zhangshangwuda.tools.LessonsSharedPreferencesTool;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import com.actionbarsherlock.view.MenuItem;
import com.umeng.analytics.MobclickAgent;
import com.umeng.update.UmengUpdateAgent;
import com.umeng.update.UmengUpdateListener;
import com.umeng.update.UpdateResponse; | package zq.whu.zhangshangwuda.ui;
public class SettingActivity extends BaseThemeSherlockPreferenceActivity
implements Preference.OnPreferenceChangeListener {
private EditTextPreference number_editPreference;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
getWindow().setFormat(PixelFormat.RGBA_8888);
addPreferencesFromResource(R.xml.settings);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
number_editPreference = (EditTextPreference) findPreference("lessons_TermFirstDay"); | // Path: src/zq/whu/zhangshangwuda/base/BaseThemeSherlockPreferenceActivity.java
// public class BaseThemeSherlockPreferenceActivity extends
// SherlockPreferenceActivity {
// public int mTheme = R.style.MyLightTheme;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// if (savedInstanceState == null) {
// mTheme = PreferenceHelper.getTheme(this);
// } else {
// mTheme = savedInstanceState.getInt("theme");
// }
// setTheme(mTheme);
// getWindow().setBackgroundDrawable(null);
// super.onCreate(savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// if (mTheme != PreferenceHelper.getTheme(this)) {
// reload();
// }
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// outState.putInt("theme", mTheme);
// }
//
// protected void reload() {
// Intent intent = getIntent();
// overridePendingTransition(0, 0);
// intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
// finish();
// overridePendingTransition(0, 0);
// startActivity(intent);
// }
// }
//
// Path: src/zq/whu/zhangshangwuda/base/PreferenceHelper.java
// public class PreferenceHelper {
//
// public static final String KEY_THEME = "theme";
//
// private static SharedPreferences.Editor mEditor = null;
// private static SharedPreferences mdPreferences = null;
//
// public PreferenceHelper(Context context) {
// }
//
// private static SharedPreferences.Editor getEditor(Context paramContext) {
// if (mEditor == null)
// mEditor = paramContext.getSharedPreferences(
// Constants.PREFS_NAME_USER_DATA, 0).edit();
// return mEditor;
// }
//
// private static SharedPreferences getSharedPreferences(Context paramContext) {
// if (mdPreferences == null)
// mdPreferences = paramContext.getSharedPreferences(
// Constants.PREFS_NAME_USER_DATA, 0);
// return mdPreferences;
// }
//
// public static int getTheme(Context context) {
// return PreferenceHelper.getSharedPreferences(context).getInt(KEY_THEME,
// R.style.MyLightTheme);
// }
//
// public static void setTheme(Context context, int theme) {
// getEditor(context).putInt(KEY_THEME, theme).commit();
// }
//
// }
//
// Path: src/zq/whu/zhangshangwuda/tools/LessonsSharedPreferencesTool.java
// public class LessonsSharedPreferencesTool {
// public static boolean getLessonsHave(Context c) {
// SharedPreferences Mysettings = c.getSharedPreferences("User_Data", 0);
// return Mysettings.getBoolean("Lessons_Have", false);
// }
//
// public static void setLessonsHave(Context c, boolean x) {
// SharedPreferences.Editor localEditor = c.getSharedPreferences(
// "User_Data", 0).edit();
// localEditor.putBoolean("Lessons_Have", x).commit();
// }
//
// public static String getTermFirstDay(Context c) {
// SharedPreferences Mysettings = c.getSharedPreferences("User_Data", 0);
// return Mysettings.getString("Lessons_TermFirstDay", "2012-8-31");
// }
//
// public static void setTermFirstDay(Context c, String x) {
// SharedPreferences.Editor localEditor = c.getSharedPreferences(
// "User_Data", 0).edit();
// localEditor.putString("Lessons_TermFirstDay", x).commit();
// }
//
// public static Integer getLessonsId(Context c) {
// SharedPreferences Mysettings = c.getSharedPreferences("User_Data", 0);
// return Mysettings.getInt("Lessons_Id", 0);
// }
//
// public static void setLessonsId(Context c, Integer x) {
// SharedPreferences.Editor localEditor = c.getSharedPreferences(
// "User_Data", 0).edit();
// localEditor.putInt("Lessons_Id", x).commit();
// }
// }
// Path: src/zq/whu/zhangshangwuda/ui/SettingActivity.java
import zq.whu.zhangshangwuda.base.BaseThemeSherlockPreferenceActivity;
import zq.whu.zhangshangwuda.base.PreferenceHelper;
import zq.whu.zhangshangwuda.tools.LessonsSharedPreferencesTool;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import com.actionbarsherlock.view.MenuItem;
import com.umeng.analytics.MobclickAgent;
import com.umeng.update.UmengUpdateAgent;
import com.umeng.update.UmengUpdateListener;
import com.umeng.update.UpdateResponse;
package zq.whu.zhangshangwuda.ui;
public class SettingActivity extends BaseThemeSherlockPreferenceActivity
implements Preference.OnPreferenceChangeListener {
private EditTextPreference number_editPreference;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
getWindow().setFormat(PixelFormat.RGBA_8888);
addPreferencesFromResource(R.xml.settings);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
number_editPreference = (EditTextPreference) findPreference("lessons_TermFirstDay"); | number_editPreference.setText(LessonsSharedPreferencesTool |
Consoar/zhangshangwuda | src/zq/whu/zhangshangwuda/ui/SettingActivity.java | // Path: src/zq/whu/zhangshangwuda/base/BaseThemeSherlockPreferenceActivity.java
// public class BaseThemeSherlockPreferenceActivity extends
// SherlockPreferenceActivity {
// public int mTheme = R.style.MyLightTheme;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// if (savedInstanceState == null) {
// mTheme = PreferenceHelper.getTheme(this);
// } else {
// mTheme = savedInstanceState.getInt("theme");
// }
// setTheme(mTheme);
// getWindow().setBackgroundDrawable(null);
// super.onCreate(savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// if (mTheme != PreferenceHelper.getTheme(this)) {
// reload();
// }
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// outState.putInt("theme", mTheme);
// }
//
// protected void reload() {
// Intent intent = getIntent();
// overridePendingTransition(0, 0);
// intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
// finish();
// overridePendingTransition(0, 0);
// startActivity(intent);
// }
// }
//
// Path: src/zq/whu/zhangshangwuda/base/PreferenceHelper.java
// public class PreferenceHelper {
//
// public static final String KEY_THEME = "theme";
//
// private static SharedPreferences.Editor mEditor = null;
// private static SharedPreferences mdPreferences = null;
//
// public PreferenceHelper(Context context) {
// }
//
// private static SharedPreferences.Editor getEditor(Context paramContext) {
// if (mEditor == null)
// mEditor = paramContext.getSharedPreferences(
// Constants.PREFS_NAME_USER_DATA, 0).edit();
// return mEditor;
// }
//
// private static SharedPreferences getSharedPreferences(Context paramContext) {
// if (mdPreferences == null)
// mdPreferences = paramContext.getSharedPreferences(
// Constants.PREFS_NAME_USER_DATA, 0);
// return mdPreferences;
// }
//
// public static int getTheme(Context context) {
// return PreferenceHelper.getSharedPreferences(context).getInt(KEY_THEME,
// R.style.MyLightTheme);
// }
//
// public static void setTheme(Context context, int theme) {
// getEditor(context).putInt(KEY_THEME, theme).commit();
// }
//
// }
//
// Path: src/zq/whu/zhangshangwuda/tools/LessonsSharedPreferencesTool.java
// public class LessonsSharedPreferencesTool {
// public static boolean getLessonsHave(Context c) {
// SharedPreferences Mysettings = c.getSharedPreferences("User_Data", 0);
// return Mysettings.getBoolean("Lessons_Have", false);
// }
//
// public static void setLessonsHave(Context c, boolean x) {
// SharedPreferences.Editor localEditor = c.getSharedPreferences(
// "User_Data", 0).edit();
// localEditor.putBoolean("Lessons_Have", x).commit();
// }
//
// public static String getTermFirstDay(Context c) {
// SharedPreferences Mysettings = c.getSharedPreferences("User_Data", 0);
// return Mysettings.getString("Lessons_TermFirstDay", "2012-8-31");
// }
//
// public static void setTermFirstDay(Context c, String x) {
// SharedPreferences.Editor localEditor = c.getSharedPreferences(
// "User_Data", 0).edit();
// localEditor.putString("Lessons_TermFirstDay", x).commit();
// }
//
// public static Integer getLessonsId(Context c) {
// SharedPreferences Mysettings = c.getSharedPreferences("User_Data", 0);
// return Mysettings.getInt("Lessons_Id", 0);
// }
//
// public static void setLessonsId(Context c, Integer x) {
// SharedPreferences.Editor localEditor = c.getSharedPreferences(
// "User_Data", 0).edit();
// localEditor.putInt("Lessons_Id", x).commit();
// }
// }
| import zq.whu.zhangshangwuda.base.BaseThemeSherlockPreferenceActivity;
import zq.whu.zhangshangwuda.base.PreferenceHelper;
import zq.whu.zhangshangwuda.tools.LessonsSharedPreferencesTool;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import com.actionbarsherlock.view.MenuItem;
import com.umeng.analytics.MobclickAgent;
import com.umeng.update.UmengUpdateAgent;
import com.umeng.update.UmengUpdateListener;
import com.umeng.update.UpdateResponse; | package zq.whu.zhangshangwuda.ui;
public class SettingActivity extends BaseThemeSherlockPreferenceActivity
implements Preference.OnPreferenceChangeListener {
private EditTextPreference number_editPreference;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
getWindow().setFormat(PixelFormat.RGBA_8888);
addPreferencesFromResource(R.xml.settings);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
number_editPreference = (EditTextPreference) findPreference("lessons_TermFirstDay");
number_editPreference.setText(LessonsSharedPreferencesTool
.getTermFirstDay(getApplicationContext()));
number_editPreference.setOnPreferenceChangeListener(this);
ListPreference listPreferencePicsizes = (ListPreference) findPreference("common_theme");
listPreferencePicsizes
.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference,
Object newValue) {
// TODO Auto-generated method stub
if (String.valueOf(newValue).equals("light")) | // Path: src/zq/whu/zhangshangwuda/base/BaseThemeSherlockPreferenceActivity.java
// public class BaseThemeSherlockPreferenceActivity extends
// SherlockPreferenceActivity {
// public int mTheme = R.style.MyLightTheme;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// if (savedInstanceState == null) {
// mTheme = PreferenceHelper.getTheme(this);
// } else {
// mTheme = savedInstanceState.getInt("theme");
// }
// setTheme(mTheme);
// getWindow().setBackgroundDrawable(null);
// super.onCreate(savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// if (mTheme != PreferenceHelper.getTheme(this)) {
// reload();
// }
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// outState.putInt("theme", mTheme);
// }
//
// protected void reload() {
// Intent intent = getIntent();
// overridePendingTransition(0, 0);
// intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
// finish();
// overridePendingTransition(0, 0);
// startActivity(intent);
// }
// }
//
// Path: src/zq/whu/zhangshangwuda/base/PreferenceHelper.java
// public class PreferenceHelper {
//
// public static final String KEY_THEME = "theme";
//
// private static SharedPreferences.Editor mEditor = null;
// private static SharedPreferences mdPreferences = null;
//
// public PreferenceHelper(Context context) {
// }
//
// private static SharedPreferences.Editor getEditor(Context paramContext) {
// if (mEditor == null)
// mEditor = paramContext.getSharedPreferences(
// Constants.PREFS_NAME_USER_DATA, 0).edit();
// return mEditor;
// }
//
// private static SharedPreferences getSharedPreferences(Context paramContext) {
// if (mdPreferences == null)
// mdPreferences = paramContext.getSharedPreferences(
// Constants.PREFS_NAME_USER_DATA, 0);
// return mdPreferences;
// }
//
// public static int getTheme(Context context) {
// return PreferenceHelper.getSharedPreferences(context).getInt(KEY_THEME,
// R.style.MyLightTheme);
// }
//
// public static void setTheme(Context context, int theme) {
// getEditor(context).putInt(KEY_THEME, theme).commit();
// }
//
// }
//
// Path: src/zq/whu/zhangshangwuda/tools/LessonsSharedPreferencesTool.java
// public class LessonsSharedPreferencesTool {
// public static boolean getLessonsHave(Context c) {
// SharedPreferences Mysettings = c.getSharedPreferences("User_Data", 0);
// return Mysettings.getBoolean("Lessons_Have", false);
// }
//
// public static void setLessonsHave(Context c, boolean x) {
// SharedPreferences.Editor localEditor = c.getSharedPreferences(
// "User_Data", 0).edit();
// localEditor.putBoolean("Lessons_Have", x).commit();
// }
//
// public static String getTermFirstDay(Context c) {
// SharedPreferences Mysettings = c.getSharedPreferences("User_Data", 0);
// return Mysettings.getString("Lessons_TermFirstDay", "2012-8-31");
// }
//
// public static void setTermFirstDay(Context c, String x) {
// SharedPreferences.Editor localEditor = c.getSharedPreferences(
// "User_Data", 0).edit();
// localEditor.putString("Lessons_TermFirstDay", x).commit();
// }
//
// public static Integer getLessonsId(Context c) {
// SharedPreferences Mysettings = c.getSharedPreferences("User_Data", 0);
// return Mysettings.getInt("Lessons_Id", 0);
// }
//
// public static void setLessonsId(Context c, Integer x) {
// SharedPreferences.Editor localEditor = c.getSharedPreferences(
// "User_Data", 0).edit();
// localEditor.putInt("Lessons_Id", x).commit();
// }
// }
// Path: src/zq/whu/zhangshangwuda/ui/SettingActivity.java
import zq.whu.zhangshangwuda.base.BaseThemeSherlockPreferenceActivity;
import zq.whu.zhangshangwuda.base.PreferenceHelper;
import zq.whu.zhangshangwuda.tools.LessonsSharedPreferencesTool;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import com.actionbarsherlock.view.MenuItem;
import com.umeng.analytics.MobclickAgent;
import com.umeng.update.UmengUpdateAgent;
import com.umeng.update.UmengUpdateListener;
import com.umeng.update.UpdateResponse;
package zq.whu.zhangshangwuda.ui;
public class SettingActivity extends BaseThemeSherlockPreferenceActivity
implements Preference.OnPreferenceChangeListener {
private EditTextPreference number_editPreference;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
getWindow().setFormat(PixelFormat.RGBA_8888);
addPreferencesFromResource(R.xml.settings);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
number_editPreference = (EditTextPreference) findPreference("lessons_TermFirstDay");
number_editPreference.setText(LessonsSharedPreferencesTool
.getTermFirstDay(getApplicationContext()));
number_editPreference.setOnPreferenceChangeListener(this);
ListPreference listPreferencePicsizes = (ListPreference) findPreference("common_theme");
listPreferencePicsizes
.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference,
Object newValue) {
// TODO Auto-generated method stub
if (String.valueOf(newValue).equals("light")) | PreferenceHelper.setTheme(getApplicationContext(), |
Consoar/zhangshangwuda | src/zq/whu/zhangshangwuda/db/WifiDb.java | // Path: src/zq/whu/zhangshangwuda/entity/WifiAccount.java
// public class WifiAccount {
//
// private int id;
// private String username;
// private String password;
//
// public WifiAccount(int id, String username, String password) {
// super();
// this.id = id;
// this.username = username;
// this.password = password;
// }
//
// public WifiAccount(String username, String password) {
// super();
// this.id = -1;
// this.username = username;
// this.password = password;
// }
//
// public WifiAccount() {
// super();
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
//
// Path: src/zq/whu/zhangshangwuda/entity/Lessons.java
// public class Lessons {
// /**
// * 课程Id
// */
// private String id;
// /**
// * 课程名称
// */
// private String name;
// /**
// * 星期几上课
// */
// private String day;
// /**
// * 起止星期
// */
// private String ste;
// /**
// * 每几星期
// */
// private String mjz;
// /**
// * 第几节
// */
// private String time;
// /**
// * 上课地点
// */
// private String place;
// /**
// * 教师姓名
// */
// private String teacher;
// /**
// * 备注信息
// */
// private String other;
//
// public Lessons() {
// }
//
// public Lessons(String id, String name, String day, String ste, String mjz,
// String time, String place, String teacher, String other) {
// this.id = id;
// this.name = name;
// this.day = day;
// this.ste = ste;
// this.mjz = mjz;
// this.time = time;
// this.place = place;
// this.teacher = teacher;
// this.other = other;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDay() {
// return day;
// }
//
// public void setDay(String day) {
// this.day = day;
// }
//
// public String getSte() {
// return ste;
// }
//
// public void setSte(String ste) {
// this.ste = ste;
// }
//
// public String getMjz() {
// return mjz;
// }
//
// public void setMjz(String mjz) {
// this.mjz = mjz;
// }
//
// public String getTime() {
// return time;
// }
//
// public void setTime(String time) {
// this.time = time;
// }
//
// public String getPlace() {
// return place;
// }
//
// public void setPlace(String place) {
// this.place = place;
// }
//
// public String getTeacher() {
// return teacher;
// }
//
// public void setTeacher(String teacher) {
// this.teacher = teacher;
// }
//
// public String getOther() {
// return other;
// }
//
// public void setOther(String other) {
// this.other = other;
// }
// }
| import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import zq.whu.zhangshangwuda.entity.WifiAccount;
import zq.whu.zhangshangwuda.entity.Lessons;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory; | package zq.whu.zhangshangwuda.db;
public class WifiDb extends WifiDBUtil {
private static final String TABLE_NAME = "wifi";
private static WifiDb service = null;
public static WifiDb getInstance(Context context) {
if (service == null) {
service = new WifiDb(context);
}
return service;
}
public WifiDb(Context context, String name, CursorFactory factory,
int version) {
super(context, name, factory, version);
}
public WifiDb(Context context) {
super(context);
}
/**
* 插入一条数据
*
* @param WifiAccount
* @return
*/ | // Path: src/zq/whu/zhangshangwuda/entity/WifiAccount.java
// public class WifiAccount {
//
// private int id;
// private String username;
// private String password;
//
// public WifiAccount(int id, String username, String password) {
// super();
// this.id = id;
// this.username = username;
// this.password = password;
// }
//
// public WifiAccount(String username, String password) {
// super();
// this.id = -1;
// this.username = username;
// this.password = password;
// }
//
// public WifiAccount() {
// super();
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
// }
//
// Path: src/zq/whu/zhangshangwuda/entity/Lessons.java
// public class Lessons {
// /**
// * 课程Id
// */
// private String id;
// /**
// * 课程名称
// */
// private String name;
// /**
// * 星期几上课
// */
// private String day;
// /**
// * 起止星期
// */
// private String ste;
// /**
// * 每几星期
// */
// private String mjz;
// /**
// * 第几节
// */
// private String time;
// /**
// * 上课地点
// */
// private String place;
// /**
// * 教师姓名
// */
// private String teacher;
// /**
// * 备注信息
// */
// private String other;
//
// public Lessons() {
// }
//
// public Lessons(String id, String name, String day, String ste, String mjz,
// String time, String place, String teacher, String other) {
// this.id = id;
// this.name = name;
// this.day = day;
// this.ste = ste;
// this.mjz = mjz;
// this.time = time;
// this.place = place;
// this.teacher = teacher;
// this.other = other;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDay() {
// return day;
// }
//
// public void setDay(String day) {
// this.day = day;
// }
//
// public String getSte() {
// return ste;
// }
//
// public void setSte(String ste) {
// this.ste = ste;
// }
//
// public String getMjz() {
// return mjz;
// }
//
// public void setMjz(String mjz) {
// this.mjz = mjz;
// }
//
// public String getTime() {
// return time;
// }
//
// public void setTime(String time) {
// this.time = time;
// }
//
// public String getPlace() {
// return place;
// }
//
// public void setPlace(String place) {
// this.place = place;
// }
//
// public String getTeacher() {
// return teacher;
// }
//
// public void setTeacher(String teacher) {
// this.teacher = teacher;
// }
//
// public String getOther() {
// return other;
// }
//
// public void setOther(String other) {
// this.other = other;
// }
// }
// Path: src/zq/whu/zhangshangwuda/db/WifiDb.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import zq.whu.zhangshangwuda.entity.WifiAccount;
import zq.whu.zhangshangwuda.entity.Lessons;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
package zq.whu.zhangshangwuda.db;
public class WifiDb extends WifiDBUtil {
private static final String TABLE_NAME = "wifi";
private static WifiDb service = null;
public static WifiDb getInstance(Context context) {
if (service == null) {
service = new WifiDb(context);
}
return service;
}
public WifiDb(Context context, String name, CursorFactory factory,
int version) {
super(context, name, factory, version);
}
public WifiDb(Context context) {
super(context);
}
/**
* 插入一条数据
*
* @param WifiAccount
* @return
*/ | public boolean insert(WifiAccount account) { |
Consoar/zhangshangwuda | src/org/taptwo/android/widget/FlowIndicator.java | // Path: src/org/taptwo/android/widget/ViewFlow.java
// public static interface ViewSwitchListener {
//
// /**
// * This method is called when a new View has been scrolled to.
// *
// * @param view
// * the {@link View} currently in focus.
// * @param position
// * The position in the adapter of the {@link View} currently
// * in focus.
// */
// void onSwitched(View view, int position);
//
// }
| import org.taptwo.android.widget.ViewFlow.ViewSwitchListener; | /*
* Copyright (C) 2011 Patrik 乲erfeldt
*
* 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.taptwo.android.widget;
/**
* An interface which defines the contract between a ViewFlow and a
* FlowIndicator.<br/>
* A FlowIndicator is responsible to show an visual indicator on the total views
* number and the current visible view.<br/>
*
*/ | // Path: src/org/taptwo/android/widget/ViewFlow.java
// public static interface ViewSwitchListener {
//
// /**
// * This method is called when a new View has been scrolled to.
// *
// * @param view
// * the {@link View} currently in focus.
// * @param position
// * The position in the adapter of the {@link View} currently
// * in focus.
// */
// void onSwitched(View view, int position);
//
// }
// Path: src/org/taptwo/android/widget/FlowIndicator.java
import org.taptwo.android.widget.ViewFlow.ViewSwitchListener;
/*
* Copyright (C) 2011 Patrik 乲erfeldt
*
* 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.taptwo.android.widget;
/**
* An interface which defines the contract between a ViewFlow and a
* FlowIndicator.<br/>
* A FlowIndicator is responsible to show an visual indicator on the total views
* number and the current visible view.<br/>
*
*/ | public interface FlowIndicator extends ViewSwitchListener { |
Consoar/zhangshangwuda | src/zq/whu/zhangshangwuda/db/LessonsDb.java | // Path: src/zq/whu/zhangshangwuda/entity/Lessons.java
// public class Lessons {
// /**
// * 课程Id
// */
// private String id;
// /**
// * 课程名称
// */
// private String name;
// /**
// * 星期几上课
// */
// private String day;
// /**
// * 起止星期
// */
// private String ste;
// /**
// * 每几星期
// */
// private String mjz;
// /**
// * 第几节
// */
// private String time;
// /**
// * 上课地点
// */
// private String place;
// /**
// * 教师姓名
// */
// private String teacher;
// /**
// * 备注信息
// */
// private String other;
//
// public Lessons() {
// }
//
// public Lessons(String id, String name, String day, String ste, String mjz,
// String time, String place, String teacher, String other) {
// this.id = id;
// this.name = name;
// this.day = day;
// this.ste = ste;
// this.mjz = mjz;
// this.time = time;
// this.place = place;
// this.teacher = teacher;
// this.other = other;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDay() {
// return day;
// }
//
// public void setDay(String day) {
// this.day = day;
// }
//
// public String getSte() {
// return ste;
// }
//
// public void setSte(String ste) {
// this.ste = ste;
// }
//
// public String getMjz() {
// return mjz;
// }
//
// public void setMjz(String mjz) {
// this.mjz = mjz;
// }
//
// public String getTime() {
// return time;
// }
//
// public void setTime(String time) {
// this.time = time;
// }
//
// public String getPlace() {
// return place;
// }
//
// public void setPlace(String place) {
// this.place = place;
// }
//
// public String getTeacher() {
// return teacher;
// }
//
// public void setTeacher(String teacher) {
// this.teacher = teacher;
// }
//
// public String getOther() {
// return other;
// }
//
// public void setOther(String other) {
// this.other = other;
// }
// }
| import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import zq.whu.zhangshangwuda.entity.Lessons;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory; | package zq.whu.zhangshangwuda.db;
public class LessonsDb extends LessonsDBUtil {
private static final String TABLE_NAME = "lessons";
private static LessonsDb service = null;
public static LessonsDb getInstance(Context context) {
if (service == null) {
service = new LessonsDb(context);
}
return service;
}
public LessonsDb(Context context, String name, CursorFactory factory,
int version) {
super(context, name, factory, version);
}
public LessonsDb(Context context) {
super(context);
}
/**
* 插入一条数据
*
* @param lessons
* @return
*/ | // Path: src/zq/whu/zhangshangwuda/entity/Lessons.java
// public class Lessons {
// /**
// * 课程Id
// */
// private String id;
// /**
// * 课程名称
// */
// private String name;
// /**
// * 星期几上课
// */
// private String day;
// /**
// * 起止星期
// */
// private String ste;
// /**
// * 每几星期
// */
// private String mjz;
// /**
// * 第几节
// */
// private String time;
// /**
// * 上课地点
// */
// private String place;
// /**
// * 教师姓名
// */
// private String teacher;
// /**
// * 备注信息
// */
// private String other;
//
// public Lessons() {
// }
//
// public Lessons(String id, String name, String day, String ste, String mjz,
// String time, String place, String teacher, String other) {
// this.id = id;
// this.name = name;
// this.day = day;
// this.ste = ste;
// this.mjz = mjz;
// this.time = time;
// this.place = place;
// this.teacher = teacher;
// this.other = other;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDay() {
// return day;
// }
//
// public void setDay(String day) {
// this.day = day;
// }
//
// public String getSte() {
// return ste;
// }
//
// public void setSte(String ste) {
// this.ste = ste;
// }
//
// public String getMjz() {
// return mjz;
// }
//
// public void setMjz(String mjz) {
// this.mjz = mjz;
// }
//
// public String getTime() {
// return time;
// }
//
// public void setTime(String time) {
// this.time = time;
// }
//
// public String getPlace() {
// return place;
// }
//
// public void setPlace(String place) {
// this.place = place;
// }
//
// public String getTeacher() {
// return teacher;
// }
//
// public void setTeacher(String teacher) {
// this.teacher = teacher;
// }
//
// public String getOther() {
// return other;
// }
//
// public void setOther(String other) {
// this.other = other;
// }
// }
// Path: src/zq/whu/zhangshangwuda/db/LessonsDb.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import zq.whu.zhangshangwuda.entity.Lessons;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
package zq.whu.zhangshangwuda.db;
public class LessonsDb extends LessonsDBUtil {
private static final String TABLE_NAME = "lessons";
private static LessonsDb service = null;
public static LessonsDb getInstance(Context context) {
if (service == null) {
service = new LessonsDb(context);
}
return service;
}
public LessonsDb(Context context, String name, CursorFactory factory,
int version) {
super(context, name, factory, version);
}
public LessonsDb(Context context) {
super(context);
}
/**
* 插入一条数据
*
* @param lessons
* @return
*/ | public boolean insert(Lessons lessons) { |
Consoar/zhangshangwuda | src/zq/whu/zhangshangwuda/tools/gif/PlayGifTask.java | // Path: src/zq/whu/zhangshangwuda/tools/gif/GifHelper.java
// public static class GifFrame {
// // to access image & delay w/o interface
// public Bitmap image;
// public int delay;
//
// public GifFrame(Bitmap im, int del) {
// image = im;
// delay = del;
// }
//
// }
| import zq.whu.zhangshangwuda.tools.gif.GifHelper.GifFrame;
import android.widget.ImageView; | package zq.whu.zhangshangwuda.tools.gif;
public class PlayGifTask implements Runnable {
int i = 0;
ImageView iv; | // Path: src/zq/whu/zhangshangwuda/tools/gif/GifHelper.java
// public static class GifFrame {
// // to access image & delay w/o interface
// public Bitmap image;
// public int delay;
//
// public GifFrame(Bitmap im, int del) {
// image = im;
// delay = del;
// }
//
// }
// Path: src/zq/whu/zhangshangwuda/tools/gif/PlayGifTask.java
import zq.whu.zhangshangwuda.tools.gif.GifHelper.GifFrame;
import android.widget.ImageView;
package zq.whu.zhangshangwuda.tools.gif;
public class PlayGifTask implements Runnable {
int i = 0;
ImageView iv; | GifFrame[] frames; |
Consoar/zhangshangwuda | src/zq/whu/zhangshangwuda/views/PullToRefreshListView.java | // Path: src/zq/whu/zhangshangwuda/tools/LogUtils.java
// public class LogUtils {
// private static final String LOG_PREFIX = "ZSWD_";
// private static final int LOG_PREFIX_LENGTH = LOG_PREFIX.length();
// private static final int MAX_LOG_TAG_LENGTH = 23;
// private static final boolean DEBUG = BuildConfig.DEBUG;
//
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
//
// /**
// * WARNING: Don't use this when obfuscating class names with Proguard!
// */
// public static String makeLogTag(Class cls) {
// return makeLogTag(cls.getSimpleName());
// }
//
// public static void D(final String tag, String message) {
// if (DEBUG) {
// Log.d(tag, message);
// }
// }
//
// public static void D(final String tag, String message, Throwable cause) {
// if (DEBUG) {
// Log.d(tag, message, cause);
// }
// }
//
// public static void V(final String tag, String message) {
// // noinspection PointlessBooleanExpression,ConstantConditions
// if (DEBUG) {
// Log.v(tag, message);
// }
// }
//
// public static void V(final String tag, String message, Throwable cause) {
// // noinspection PointlessBooleanExpression,ConstantConditions
// if (DEBUG) {
// Log.v(tag, message, cause);
// }
// }
//
// public static void I(final String tag, String message) {
// if (DEBUG) {
// Log.i(tag, message);
// }
// }
//
// public static void I(final String tag, String message, Throwable cause) {
// if (DEBUG) {
// Log.i(tag, message, cause);
// }
// }
//
// public static void W(final String tag, String message) {
// if (DEBUG) {
// Log.w(tag, message);
// }
// }
//
// public static void W(final String tag, String message, Throwable cause) {
// if (DEBUG) {
// Log.w(tag, message, cause);
// }
// }
//
// public static void E(final String tag, String message) {
// if (DEBUG) {
// Log.e(tag, message);
// }
// }
//
// public static void E(final String tag, String message, Throwable cause) {
// if (DEBUG) {
// Log.e(tag, message, cause);
// }
// }
//
// private LogUtils() {
// }
// }
| import java.util.Date;
import zq.whu.zhangshangwuda.tools.LogUtils;
import zq.whu.zhangshangwuda.ui.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView; | package zq.whu.zhangshangwuda.views;
public class PullToRefreshListView extends ListView implements OnScrollListener {
private final static String TAG = "PullToRefreshListView"; | // Path: src/zq/whu/zhangshangwuda/tools/LogUtils.java
// public class LogUtils {
// private static final String LOG_PREFIX = "ZSWD_";
// private static final int LOG_PREFIX_LENGTH = LOG_PREFIX.length();
// private static final int MAX_LOG_TAG_LENGTH = 23;
// private static final boolean DEBUG = BuildConfig.DEBUG;
//
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
//
// /**
// * WARNING: Don't use this when obfuscating class names with Proguard!
// */
// public static String makeLogTag(Class cls) {
// return makeLogTag(cls.getSimpleName());
// }
//
// public static void D(final String tag, String message) {
// if (DEBUG) {
// Log.d(tag, message);
// }
// }
//
// public static void D(final String tag, String message, Throwable cause) {
// if (DEBUG) {
// Log.d(tag, message, cause);
// }
// }
//
// public static void V(final String tag, String message) {
// // noinspection PointlessBooleanExpression,ConstantConditions
// if (DEBUG) {
// Log.v(tag, message);
// }
// }
//
// public static void V(final String tag, String message, Throwable cause) {
// // noinspection PointlessBooleanExpression,ConstantConditions
// if (DEBUG) {
// Log.v(tag, message, cause);
// }
// }
//
// public static void I(final String tag, String message) {
// if (DEBUG) {
// Log.i(tag, message);
// }
// }
//
// public static void I(final String tag, String message, Throwable cause) {
// if (DEBUG) {
// Log.i(tag, message, cause);
// }
// }
//
// public static void W(final String tag, String message) {
// if (DEBUG) {
// Log.w(tag, message);
// }
// }
//
// public static void W(final String tag, String message, Throwable cause) {
// if (DEBUG) {
// Log.w(tag, message, cause);
// }
// }
//
// public static void E(final String tag, String message) {
// if (DEBUG) {
// Log.e(tag, message);
// }
// }
//
// public static void E(final String tag, String message, Throwable cause) {
// if (DEBUG) {
// Log.e(tag, message, cause);
// }
// }
//
// private LogUtils() {
// }
// }
// Path: src/zq/whu/zhangshangwuda/views/PullToRefreshListView.java
import java.util.Date;
import zq.whu.zhangshangwuda.tools.LogUtils;
import zq.whu.zhangshangwuda.ui.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
package zq.whu.zhangshangwuda.views;
public class PullToRefreshListView extends ListView implements OnScrollListener {
private final static String TAG = "PullToRefreshListView"; | private LogUtils LOG; |
Consoar/zhangshangwuda | src/zq/whu/zhangshangwuda/tools/FileCache.java | // Path: src/zq/whu/zhangshangwuda/tools/LogUtils.java
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
| import static zq.whu.zhangshangwuda.tools.LogUtils.makeLogTag;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.util.Log; | package zq.whu.zhangshangwuda.tools;
public class FileCache {
private static LogUtils LOG; | // Path: src/zq/whu/zhangshangwuda/tools/LogUtils.java
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
// Path: src/zq/whu/zhangshangwuda/tools/FileCache.java
import static zq.whu.zhangshangwuda.tools.LogUtils.makeLogTag;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.util.Log;
package zq.whu.zhangshangwuda.tools;
public class FileCache {
private static LogUtils LOG; | private static final String TAG = makeLogTag(FileCache.class); |
Consoar/zhangshangwuda | src/zq/whu/zhangshangwuda/base/PreferenceHelper.java | // Path: src/zq/whu/zhangshangwuda/tools/Constants.java
// public final class Constants {
// public static final String PREFS_NAME_APP_SETTING = "zq.whu.zhangshangwuda.ui_preferences";
// public static final String PREFS_NAME_USER_DATA = "User_Data";
// public static final int DISPLAY_LDPI_WIDTH = 240; // ldpi屏幕的宽度
// public static final int DISPLAY_MDPI_WIDTH = 320; // mdpi屏幕的宽度
// public static final int DISPLAY_HDPI_WIDTH = 480; // hdpi屏幕的宽度
// public static final int DISPLAY_XHDPI_WIDTH = 640; // xhdpi屏幕的宽度
// }
| import zq.whu.zhangshangwuda.tools.Constants;
import zq.whu.zhangshangwuda.ui.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager; | package zq.whu.zhangshangwuda.base;
public class PreferenceHelper {
public static final String KEY_THEME = "theme";
private static SharedPreferences.Editor mEditor = null;
private static SharedPreferences mdPreferences = null;
public PreferenceHelper(Context context) {
}
private static SharedPreferences.Editor getEditor(Context paramContext) {
if (mEditor == null)
mEditor = paramContext.getSharedPreferences( | // Path: src/zq/whu/zhangshangwuda/tools/Constants.java
// public final class Constants {
// public static final String PREFS_NAME_APP_SETTING = "zq.whu.zhangshangwuda.ui_preferences";
// public static final String PREFS_NAME_USER_DATA = "User_Data";
// public static final int DISPLAY_LDPI_WIDTH = 240; // ldpi屏幕的宽度
// public static final int DISPLAY_MDPI_WIDTH = 320; // mdpi屏幕的宽度
// public static final int DISPLAY_HDPI_WIDTH = 480; // hdpi屏幕的宽度
// public static final int DISPLAY_XHDPI_WIDTH = 640; // xhdpi屏幕的宽度
// }
// Path: src/zq/whu/zhangshangwuda/base/PreferenceHelper.java
import zq.whu.zhangshangwuda.tools.Constants;
import zq.whu.zhangshangwuda.ui.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
package zq.whu.zhangshangwuda.base;
public class PreferenceHelper {
public static final String KEY_THEME = "theme";
private static SharedPreferences.Editor mEditor = null;
private static SharedPreferences mdPreferences = null;
public PreferenceHelper(Context context) {
}
private static SharedPreferences.Editor getEditor(Context paramContext) {
if (mEditor == null)
mEditor = paramContext.getSharedPreferences( | Constants.PREFS_NAME_USER_DATA, 0).edit(); |
NitorCreations/DomainReverseMapper | drm-core/src/main/java/com/nitorcreations/scanners/FieldScanner.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static Edge createEdge(Class<?> sourceClass, Class<?> field, EdgeType type, String name) {
// DomainObject source = new DomainObject(sourceClass, name);
// DomainObject target = new DomainObject(field);
// return new Edge(source, target, type, UNI_DIRECTIONAL);
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static List<Edge> mergeBiDirectionals(List<Edge> edges) {
// Collection<List<Edge>> groupedEdges = groupEdges(edges);
// List<Edge> uniDirectionals = takeSingleItemsGroups(groupedEdges);
// List<Edge> biDirectionals = mergeNonSingleGroups(groupedEdges);
// List<Edge> mergedEdges = Lists.newArrayList();
// mergedEdges.addAll(uniDirectionals);
// mergedEdges.addAll(biDirectionals);
// return mergedEdges;
// }
| import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static com.nitorcreations.scanners.EdgeOperations.createEdge;
import static com.nitorcreations.scanners.EdgeOperations.mergeBiDirectionals;
import static java.util.Optional.empty;
import static java.util.Optional.of; | package com.nitorcreations.scanners;
public class FieldScanner extends AbstractScanner {
private static final String NAME_FOR_INNERCLASS = null;
private static final String innerClassFieldReferenceInBytecode = "this$0";
private final Logger logger = LoggerFactory.getLogger(FieldScanner.class);
public FieldScanner(final List<Class<?>> classes) {
super(classes);
}
| // Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static Edge createEdge(Class<?> sourceClass, Class<?> field, EdgeType type, String name) {
// DomainObject source = new DomainObject(sourceClass, name);
// DomainObject target = new DomainObject(field);
// return new Edge(source, target, type, UNI_DIRECTIONAL);
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static List<Edge> mergeBiDirectionals(List<Edge> edges) {
// Collection<List<Edge>> groupedEdges = groupEdges(edges);
// List<Edge> uniDirectionals = takeSingleItemsGroups(groupedEdges);
// List<Edge> biDirectionals = mergeNonSingleGroups(groupedEdges);
// List<Edge> mergedEdges = Lists.newArrayList();
// mergedEdges.addAll(uniDirectionals);
// mergedEdges.addAll(biDirectionals);
// return mergedEdges;
// }
// Path: drm-core/src/main/java/com/nitorcreations/scanners/FieldScanner.java
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static com.nitorcreations.scanners.EdgeOperations.createEdge;
import static com.nitorcreations.scanners.EdgeOperations.mergeBiDirectionals;
import static java.util.Optional.empty;
import static java.util.Optional.of;
package com.nitorcreations.scanners;
public class FieldScanner extends AbstractScanner {
private static final String NAME_FOR_INNERCLASS = null;
private static final String innerClassFieldReferenceInBytecode = "this$0";
private final Logger logger = LoggerFactory.getLogger(FieldScanner.class);
public FieldScanner(final List<Class<?>> classes) {
super(classes);
}
| public List<Edge> getEdges() { |
NitorCreations/DomainReverseMapper | drm-core/src/main/java/com/nitorcreations/scanners/FieldScanner.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static Edge createEdge(Class<?> sourceClass, Class<?> field, EdgeType type, String name) {
// DomainObject source = new DomainObject(sourceClass, name);
// DomainObject target = new DomainObject(field);
// return new Edge(source, target, type, UNI_DIRECTIONAL);
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static List<Edge> mergeBiDirectionals(List<Edge> edges) {
// Collection<List<Edge>> groupedEdges = groupEdges(edges);
// List<Edge> uniDirectionals = takeSingleItemsGroups(groupedEdges);
// List<Edge> biDirectionals = mergeNonSingleGroups(groupedEdges);
// List<Edge> mergedEdges = Lists.newArrayList();
// mergedEdges.addAll(uniDirectionals);
// mergedEdges.addAll(biDirectionals);
// return mergedEdges;
// }
| import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static com.nitorcreations.scanners.EdgeOperations.createEdge;
import static com.nitorcreations.scanners.EdgeOperations.mergeBiDirectionals;
import static java.util.Optional.empty;
import static java.util.Optional.of; | package com.nitorcreations.scanners;
public class FieldScanner extends AbstractScanner {
private static final String NAME_FOR_INNERCLASS = null;
private static final String innerClassFieldReferenceInBytecode = "this$0";
private final Logger logger = LoggerFactory.getLogger(FieldScanner.class);
public FieldScanner(final List<Class<?>> classes) {
super(classes);
}
public List<Edge> getEdges() {
List<Edge> edges = new ArrayList<>();
for (Class<?> clazz : classes) {
edges.addAll(extractFieldEdges(clazz));
} | // Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static Edge createEdge(Class<?> sourceClass, Class<?> field, EdgeType type, String name) {
// DomainObject source = new DomainObject(sourceClass, name);
// DomainObject target = new DomainObject(field);
// return new Edge(source, target, type, UNI_DIRECTIONAL);
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static List<Edge> mergeBiDirectionals(List<Edge> edges) {
// Collection<List<Edge>> groupedEdges = groupEdges(edges);
// List<Edge> uniDirectionals = takeSingleItemsGroups(groupedEdges);
// List<Edge> biDirectionals = mergeNonSingleGroups(groupedEdges);
// List<Edge> mergedEdges = Lists.newArrayList();
// mergedEdges.addAll(uniDirectionals);
// mergedEdges.addAll(biDirectionals);
// return mergedEdges;
// }
// Path: drm-core/src/main/java/com/nitorcreations/scanners/FieldScanner.java
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static com.nitorcreations.scanners.EdgeOperations.createEdge;
import static com.nitorcreations.scanners.EdgeOperations.mergeBiDirectionals;
import static java.util.Optional.empty;
import static java.util.Optional.of;
package com.nitorcreations.scanners;
public class FieldScanner extends AbstractScanner {
private static final String NAME_FOR_INNERCLASS = null;
private static final String innerClassFieldReferenceInBytecode = "this$0";
private final Logger logger = LoggerFactory.getLogger(FieldScanner.class);
public FieldScanner(final List<Class<?>> classes) {
super(classes);
}
public List<Edge> getEdges() {
List<Edge> edges = new ArrayList<>();
for (Class<?> clazz : classes) {
edges.addAll(extractFieldEdges(clazz));
} | return mergeBiDirectionals(edges); |
NitorCreations/DomainReverseMapper | drm-core/src/main/java/com/nitorcreations/scanners/FieldScanner.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static Edge createEdge(Class<?> sourceClass, Class<?> field, EdgeType type, String name) {
// DomainObject source = new DomainObject(sourceClass, name);
// DomainObject target = new DomainObject(field);
// return new Edge(source, target, type, UNI_DIRECTIONAL);
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static List<Edge> mergeBiDirectionals(List<Edge> edges) {
// Collection<List<Edge>> groupedEdges = groupEdges(edges);
// List<Edge> uniDirectionals = takeSingleItemsGroups(groupedEdges);
// List<Edge> biDirectionals = mergeNonSingleGroups(groupedEdges);
// List<Edge> mergedEdges = Lists.newArrayList();
// mergedEdges.addAll(uniDirectionals);
// mergedEdges.addAll(biDirectionals);
// return mergedEdges;
// }
| import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static com.nitorcreations.scanners.EdgeOperations.createEdge;
import static com.nitorcreations.scanners.EdgeOperations.mergeBiDirectionals;
import static java.util.Optional.empty;
import static java.util.Optional.of; | private List<Edge> extractFieldEdges(Class<?> clazz) {
List<Edge> fieldEdges = new ArrayList<>();
try {
InputStream is = clazz.getClassLoader().getResourceAsStream(clazz.getName().replace(".", "/") + ".class");
ClassReader reader = new ClassReader(is);
reader.accept(new ClassVisitor(Opcodes.ASM4) {
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
try {
Optional<Edge> fieldEdge = createFieldEdge(clazz, clazz.getDeclaredField(name));
if (fieldEdge.isPresent()) {
fieldEdges.add(fieldEdge.get());
}
} catch (NoSuchFieldException e) {
// should never happen
} catch (NoClassDefFoundError e) {
logger.warn("Skipped field " + name + " in class " + clazz.getName() + " because it's type class is not available. Field description: " + desc);
}
return super.visitField(access, name, desc, signature, value);
}
}, ClassReader.SKIP_CODE);
} catch (IOException e) {
logger.warn("Failed to read bytecode for class " + clazz.getName(), e);
}
return fieldEdges;
}
private Optional<Edge> createFieldEdge(Class<?> clazz, Field field) {
if (isDomainClass(field.getType())) {
if (innerClassFieldReferenceInBytecode.equals(field.getName())) { | // Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static Edge createEdge(Class<?> sourceClass, Class<?> field, EdgeType type, String name) {
// DomainObject source = new DomainObject(sourceClass, name);
// DomainObject target = new DomainObject(field);
// return new Edge(source, target, type, UNI_DIRECTIONAL);
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static List<Edge> mergeBiDirectionals(List<Edge> edges) {
// Collection<List<Edge>> groupedEdges = groupEdges(edges);
// List<Edge> uniDirectionals = takeSingleItemsGroups(groupedEdges);
// List<Edge> biDirectionals = mergeNonSingleGroups(groupedEdges);
// List<Edge> mergedEdges = Lists.newArrayList();
// mergedEdges.addAll(uniDirectionals);
// mergedEdges.addAll(biDirectionals);
// return mergedEdges;
// }
// Path: drm-core/src/main/java/com/nitorcreations/scanners/FieldScanner.java
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static com.nitorcreations.scanners.EdgeOperations.createEdge;
import static com.nitorcreations.scanners.EdgeOperations.mergeBiDirectionals;
import static java.util.Optional.empty;
import static java.util.Optional.of;
private List<Edge> extractFieldEdges(Class<?> clazz) {
List<Edge> fieldEdges = new ArrayList<>();
try {
InputStream is = clazz.getClassLoader().getResourceAsStream(clazz.getName().replace(".", "/") + ".class");
ClassReader reader = new ClassReader(is);
reader.accept(new ClassVisitor(Opcodes.ASM4) {
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
try {
Optional<Edge> fieldEdge = createFieldEdge(clazz, clazz.getDeclaredField(name));
if (fieldEdge.isPresent()) {
fieldEdges.add(fieldEdge.get());
}
} catch (NoSuchFieldException e) {
// should never happen
} catch (NoClassDefFoundError e) {
logger.warn("Skipped field " + name + " in class " + clazz.getName() + " because it's type class is not available. Field description: " + desc);
}
return super.visitField(access, name, desc, signature, value);
}
}, ClassReader.SKIP_CODE);
} catch (IOException e) {
logger.warn("Failed to read bytecode for class " + clazz.getName(), e);
}
return fieldEdges;
}
private Optional<Edge> createFieldEdge(Class<?> clazz, Field field) {
if (isDomainClass(field.getType())) {
if (innerClassFieldReferenceInBytecode.equals(field.getName())) { | return of(createEdge(clazz, (Class) field.getType(), EdgeType.INNER_CLASS, NAME_FOR_INNERCLASS)); |
NitorCreations/DomainReverseMapper | drm-core/src/main/java/com/nitorcreations/scanners/FieldScanner.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static Edge createEdge(Class<?> sourceClass, Class<?> field, EdgeType type, String name) {
// DomainObject source = new DomainObject(sourceClass, name);
// DomainObject target = new DomainObject(field);
// return new Edge(source, target, type, UNI_DIRECTIONAL);
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static List<Edge> mergeBiDirectionals(List<Edge> edges) {
// Collection<List<Edge>> groupedEdges = groupEdges(edges);
// List<Edge> uniDirectionals = takeSingleItemsGroups(groupedEdges);
// List<Edge> biDirectionals = mergeNonSingleGroups(groupedEdges);
// List<Edge> mergedEdges = Lists.newArrayList();
// mergedEdges.addAll(uniDirectionals);
// mergedEdges.addAll(biDirectionals);
// return mergedEdges;
// }
| import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static com.nitorcreations.scanners.EdgeOperations.createEdge;
import static com.nitorcreations.scanners.EdgeOperations.mergeBiDirectionals;
import static java.util.Optional.empty;
import static java.util.Optional.of; | private List<Edge> extractFieldEdges(Class<?> clazz) {
List<Edge> fieldEdges = new ArrayList<>();
try {
InputStream is = clazz.getClassLoader().getResourceAsStream(clazz.getName().replace(".", "/") + ".class");
ClassReader reader = new ClassReader(is);
reader.accept(new ClassVisitor(Opcodes.ASM4) {
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
try {
Optional<Edge> fieldEdge = createFieldEdge(clazz, clazz.getDeclaredField(name));
if (fieldEdge.isPresent()) {
fieldEdges.add(fieldEdge.get());
}
} catch (NoSuchFieldException e) {
// should never happen
} catch (NoClassDefFoundError e) {
logger.warn("Skipped field " + name + " in class " + clazz.getName() + " because it's type class is not available. Field description: " + desc);
}
return super.visitField(access, name, desc, signature, value);
}
}, ClassReader.SKIP_CODE);
} catch (IOException e) {
logger.warn("Failed to read bytecode for class " + clazz.getName(), e);
}
return fieldEdges;
}
private Optional<Edge> createFieldEdge(Class<?> clazz, Field field) {
if (isDomainClass(field.getType())) {
if (innerClassFieldReferenceInBytecode.equals(field.getName())) { | // Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static Edge createEdge(Class<?> sourceClass, Class<?> field, EdgeType type, String name) {
// DomainObject source = new DomainObject(sourceClass, name);
// DomainObject target = new DomainObject(field);
// return new Edge(source, target, type, UNI_DIRECTIONAL);
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
// public static List<Edge> mergeBiDirectionals(List<Edge> edges) {
// Collection<List<Edge>> groupedEdges = groupEdges(edges);
// List<Edge> uniDirectionals = takeSingleItemsGroups(groupedEdges);
// List<Edge> biDirectionals = mergeNonSingleGroups(groupedEdges);
// List<Edge> mergedEdges = Lists.newArrayList();
// mergedEdges.addAll(uniDirectionals);
// mergedEdges.addAll(biDirectionals);
// return mergedEdges;
// }
// Path: drm-core/src/main/java/com/nitorcreations/scanners/FieldScanner.java
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static com.nitorcreations.scanners.EdgeOperations.createEdge;
import static com.nitorcreations.scanners.EdgeOperations.mergeBiDirectionals;
import static java.util.Optional.empty;
import static java.util.Optional.of;
private List<Edge> extractFieldEdges(Class<?> clazz) {
List<Edge> fieldEdges = new ArrayList<>();
try {
InputStream is = clazz.getClassLoader().getResourceAsStream(clazz.getName().replace(".", "/") + ".class");
ClassReader reader = new ClassReader(is);
reader.accept(new ClassVisitor(Opcodes.ASM4) {
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
try {
Optional<Edge> fieldEdge = createFieldEdge(clazz, clazz.getDeclaredField(name));
if (fieldEdge.isPresent()) {
fieldEdges.add(fieldEdge.get());
}
} catch (NoSuchFieldException e) {
// should never happen
} catch (NoClassDefFoundError e) {
logger.warn("Skipped field " + name + " in class " + clazz.getName() + " because it's type class is not available. Field description: " + desc);
}
return super.visitField(access, name, desc, signature, value);
}
}, ClassReader.SKIP_CODE);
} catch (IOException e) {
logger.warn("Failed to read bytecode for class " + clazz.getName(), e);
}
return fieldEdges;
}
private Optional<Edge> createFieldEdge(Class<?> clazz, Field field) {
if (isDomainClass(field.getType())) {
if (innerClassFieldReferenceInBytecode.equals(field.getName())) { | return of(createEdge(clazz, (Class) field.getType(), EdgeType.INNER_CLASS, NAME_FOR_INNERCLASS)); |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/DomainMapperTest.java | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Selfie.java
// public class Selfie {
// private Selfie me;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
// public class Task {
// private final List<Employee> assignedEmployees = new ArrayList<>();
// private final Manager manager;
// private boolean completed;
// private final String description;
//
// public Task(final String description, final Manager manager, final Employee... employees) {
// this.description = description;
// this.manager = manager;
// assignedEmployees.addAll(Arrays.asList(employees));
// completed = false;
// }
//
// public Manager getManager() {
// return manager;
// }
//
// public List<Employee> getAssignedEmployees() {
// return assignedEmployees;
// }
//
// public void addEmployee(final Employee e) {
// assignedEmployees.add(e);
// }
//
// public void removeEmployee(final Employee e) {
// assignedEmployees.remove(e);
// }
//
// public void completeTask() {
// completed = true;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Timesheet.java
// public class Timesheet {
// private final Employee who;
// private final Task task;
// private Integer hours;
// private List<String> stuff;
//
// public Timesheet(final Employee who, final Task task, final Integer hours) {
// this.who = who;
// this.task = task;
// this.hours = hours;
// }
//
// public Employee getWho() {
// return who;
// }
//
// public Task getTask() {
// return task;
// }
//
// public Integer getHours() {
// return hours;
// }
//
// /**
// * Manager can alter hours before closing task
// *
// * @param hours New amount of hours
// */
// public void alterHours(final Integer hours) {
// this.hours = hours;
// }
//
// @Override
// public String toString() {
// return "Timesheet [who=" + who + ", task=" + task + ", hours=" + hours + "]";
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DOMAIN_DECLARATION = "digraph domain {\n";
| import com.nitorcreations.testdomain.Selfie;
import com.nitorcreations.testdomain.Task;
import com.nitorcreations.testdomain.Timesheet;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DEFAULTS;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DOMAIN_DECLARATION;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat; | package com.nitorcreations;
public class DomainMapperTest {
private DomainMapper domainMapper;
@Test
public void testDescribeDomain_singleClass() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>(); | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Selfie.java
// public class Selfie {
// private Selfie me;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
// public class Task {
// private final List<Employee> assignedEmployees = new ArrayList<>();
// private final Manager manager;
// private boolean completed;
// private final String description;
//
// public Task(final String description, final Manager manager, final Employee... employees) {
// this.description = description;
// this.manager = manager;
// assignedEmployees.addAll(Arrays.asList(employees));
// completed = false;
// }
//
// public Manager getManager() {
// return manager;
// }
//
// public List<Employee> getAssignedEmployees() {
// return assignedEmployees;
// }
//
// public void addEmployee(final Employee e) {
// assignedEmployees.add(e);
// }
//
// public void removeEmployee(final Employee e) {
// assignedEmployees.remove(e);
// }
//
// public void completeTask() {
// completed = true;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Timesheet.java
// public class Timesheet {
// private final Employee who;
// private final Task task;
// private Integer hours;
// private List<String> stuff;
//
// public Timesheet(final Employee who, final Task task, final Integer hours) {
// this.who = who;
// this.task = task;
// this.hours = hours;
// }
//
// public Employee getWho() {
// return who;
// }
//
// public Task getTask() {
// return task;
// }
//
// public Integer getHours() {
// return hours;
// }
//
// /**
// * Manager can alter hours before closing task
// *
// * @param hours New amount of hours
// */
// public void alterHours(final Integer hours) {
// this.hours = hours;
// }
//
// @Override
// public String toString() {
// return "Timesheet [who=" + who + ", task=" + task + ", hours=" + hours + "]";
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DOMAIN_DECLARATION = "digraph domain {\n";
// Path: drm-core/src/test/java/com/nitorcreations/DomainMapperTest.java
import com.nitorcreations.testdomain.Selfie;
import com.nitorcreations.testdomain.Task;
import com.nitorcreations.testdomain.Timesheet;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DEFAULTS;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DOMAIN_DECLARATION;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat;
package com.nitorcreations;
public class DomainMapperTest {
private DomainMapper domainMapper;
@Test
public void testDescribeDomain_singleClass() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>(); | list.add(Employee.class); |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/DomainMapperTest.java | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Selfie.java
// public class Selfie {
// private Selfie me;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
// public class Task {
// private final List<Employee> assignedEmployees = new ArrayList<>();
// private final Manager manager;
// private boolean completed;
// private final String description;
//
// public Task(final String description, final Manager manager, final Employee... employees) {
// this.description = description;
// this.manager = manager;
// assignedEmployees.addAll(Arrays.asList(employees));
// completed = false;
// }
//
// public Manager getManager() {
// return manager;
// }
//
// public List<Employee> getAssignedEmployees() {
// return assignedEmployees;
// }
//
// public void addEmployee(final Employee e) {
// assignedEmployees.add(e);
// }
//
// public void removeEmployee(final Employee e) {
// assignedEmployees.remove(e);
// }
//
// public void completeTask() {
// completed = true;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Timesheet.java
// public class Timesheet {
// private final Employee who;
// private final Task task;
// private Integer hours;
// private List<String> stuff;
//
// public Timesheet(final Employee who, final Task task, final Integer hours) {
// this.who = who;
// this.task = task;
// this.hours = hours;
// }
//
// public Employee getWho() {
// return who;
// }
//
// public Task getTask() {
// return task;
// }
//
// public Integer getHours() {
// return hours;
// }
//
// /**
// * Manager can alter hours before closing task
// *
// * @param hours New amount of hours
// */
// public void alterHours(final Integer hours) {
// this.hours = hours;
// }
//
// @Override
// public String toString() {
// return "Timesheet [who=" + who + ", task=" + task + ", hours=" + hours + "]";
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DOMAIN_DECLARATION = "digraph domain {\n";
| import com.nitorcreations.testdomain.Selfie;
import com.nitorcreations.testdomain.Task;
import com.nitorcreations.testdomain.Timesheet;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DEFAULTS;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DOMAIN_DECLARATION;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat; | package com.nitorcreations;
public class DomainMapperTest {
private DomainMapper domainMapper;
@Test
public void testDescribeDomain_singleClass() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Employee.class);
domainMapper = new DomainMapper(list); | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Selfie.java
// public class Selfie {
// private Selfie me;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
// public class Task {
// private final List<Employee> assignedEmployees = new ArrayList<>();
// private final Manager manager;
// private boolean completed;
// private final String description;
//
// public Task(final String description, final Manager manager, final Employee... employees) {
// this.description = description;
// this.manager = manager;
// assignedEmployees.addAll(Arrays.asList(employees));
// completed = false;
// }
//
// public Manager getManager() {
// return manager;
// }
//
// public List<Employee> getAssignedEmployees() {
// return assignedEmployees;
// }
//
// public void addEmployee(final Employee e) {
// assignedEmployees.add(e);
// }
//
// public void removeEmployee(final Employee e) {
// assignedEmployees.remove(e);
// }
//
// public void completeTask() {
// completed = true;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Timesheet.java
// public class Timesheet {
// private final Employee who;
// private final Task task;
// private Integer hours;
// private List<String> stuff;
//
// public Timesheet(final Employee who, final Task task, final Integer hours) {
// this.who = who;
// this.task = task;
// this.hours = hours;
// }
//
// public Employee getWho() {
// return who;
// }
//
// public Task getTask() {
// return task;
// }
//
// public Integer getHours() {
// return hours;
// }
//
// /**
// * Manager can alter hours before closing task
// *
// * @param hours New amount of hours
// */
// public void alterHours(final Integer hours) {
// this.hours = hours;
// }
//
// @Override
// public String toString() {
// return "Timesheet [who=" + who + ", task=" + task + ", hours=" + hours + "]";
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DOMAIN_DECLARATION = "digraph domain {\n";
// Path: drm-core/src/test/java/com/nitorcreations/DomainMapperTest.java
import com.nitorcreations.testdomain.Selfie;
import com.nitorcreations.testdomain.Task;
import com.nitorcreations.testdomain.Timesheet;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DEFAULTS;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DOMAIN_DECLARATION;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat;
package com.nitorcreations;
public class DomainMapperTest {
private DomainMapper domainMapper;
@Test
public void testDescribeDomain_singleClass() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Employee.class);
domainMapper = new DomainMapper(list); | String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain.person\";\n Employee\n }\n}"; |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/DomainMapperTest.java | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Selfie.java
// public class Selfie {
// private Selfie me;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
// public class Task {
// private final List<Employee> assignedEmployees = new ArrayList<>();
// private final Manager manager;
// private boolean completed;
// private final String description;
//
// public Task(final String description, final Manager manager, final Employee... employees) {
// this.description = description;
// this.manager = manager;
// assignedEmployees.addAll(Arrays.asList(employees));
// completed = false;
// }
//
// public Manager getManager() {
// return manager;
// }
//
// public List<Employee> getAssignedEmployees() {
// return assignedEmployees;
// }
//
// public void addEmployee(final Employee e) {
// assignedEmployees.add(e);
// }
//
// public void removeEmployee(final Employee e) {
// assignedEmployees.remove(e);
// }
//
// public void completeTask() {
// completed = true;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Timesheet.java
// public class Timesheet {
// private final Employee who;
// private final Task task;
// private Integer hours;
// private List<String> stuff;
//
// public Timesheet(final Employee who, final Task task, final Integer hours) {
// this.who = who;
// this.task = task;
// this.hours = hours;
// }
//
// public Employee getWho() {
// return who;
// }
//
// public Task getTask() {
// return task;
// }
//
// public Integer getHours() {
// return hours;
// }
//
// /**
// * Manager can alter hours before closing task
// *
// * @param hours New amount of hours
// */
// public void alterHours(final Integer hours) {
// this.hours = hours;
// }
//
// @Override
// public String toString() {
// return "Timesheet [who=" + who + ", task=" + task + ", hours=" + hours + "]";
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DOMAIN_DECLARATION = "digraph domain {\n";
| import com.nitorcreations.testdomain.Selfie;
import com.nitorcreations.testdomain.Task;
import com.nitorcreations.testdomain.Timesheet;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DEFAULTS;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DOMAIN_DECLARATION;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat; | package com.nitorcreations;
public class DomainMapperTest {
private DomainMapper domainMapper;
@Test
public void testDescribeDomain_singleClass() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Employee.class);
domainMapper = new DomainMapper(list); | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Selfie.java
// public class Selfie {
// private Selfie me;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
// public class Task {
// private final List<Employee> assignedEmployees = new ArrayList<>();
// private final Manager manager;
// private boolean completed;
// private final String description;
//
// public Task(final String description, final Manager manager, final Employee... employees) {
// this.description = description;
// this.manager = manager;
// assignedEmployees.addAll(Arrays.asList(employees));
// completed = false;
// }
//
// public Manager getManager() {
// return manager;
// }
//
// public List<Employee> getAssignedEmployees() {
// return assignedEmployees;
// }
//
// public void addEmployee(final Employee e) {
// assignedEmployees.add(e);
// }
//
// public void removeEmployee(final Employee e) {
// assignedEmployees.remove(e);
// }
//
// public void completeTask() {
// completed = true;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Timesheet.java
// public class Timesheet {
// private final Employee who;
// private final Task task;
// private Integer hours;
// private List<String> stuff;
//
// public Timesheet(final Employee who, final Task task, final Integer hours) {
// this.who = who;
// this.task = task;
// this.hours = hours;
// }
//
// public Employee getWho() {
// return who;
// }
//
// public Task getTask() {
// return task;
// }
//
// public Integer getHours() {
// return hours;
// }
//
// /**
// * Manager can alter hours before closing task
// *
// * @param hours New amount of hours
// */
// public void alterHours(final Integer hours) {
// this.hours = hours;
// }
//
// @Override
// public String toString() {
// return "Timesheet [who=" + who + ", task=" + task + ", hours=" + hours + "]";
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DOMAIN_DECLARATION = "digraph domain {\n";
// Path: drm-core/src/test/java/com/nitorcreations/DomainMapperTest.java
import com.nitorcreations.testdomain.Selfie;
import com.nitorcreations.testdomain.Task;
import com.nitorcreations.testdomain.Timesheet;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DEFAULTS;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DOMAIN_DECLARATION;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat;
package com.nitorcreations;
public class DomainMapperTest {
private DomainMapper domainMapper;
@Test
public void testDescribeDomain_singleClass() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Employee.class);
domainMapper = new DomainMapper(list); | String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain.person\";\n Employee\n }\n}"; |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/DomainMapperTest.java | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Selfie.java
// public class Selfie {
// private Selfie me;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
// public class Task {
// private final List<Employee> assignedEmployees = new ArrayList<>();
// private final Manager manager;
// private boolean completed;
// private final String description;
//
// public Task(final String description, final Manager manager, final Employee... employees) {
// this.description = description;
// this.manager = manager;
// assignedEmployees.addAll(Arrays.asList(employees));
// completed = false;
// }
//
// public Manager getManager() {
// return manager;
// }
//
// public List<Employee> getAssignedEmployees() {
// return assignedEmployees;
// }
//
// public void addEmployee(final Employee e) {
// assignedEmployees.add(e);
// }
//
// public void removeEmployee(final Employee e) {
// assignedEmployees.remove(e);
// }
//
// public void completeTask() {
// completed = true;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Timesheet.java
// public class Timesheet {
// private final Employee who;
// private final Task task;
// private Integer hours;
// private List<String> stuff;
//
// public Timesheet(final Employee who, final Task task, final Integer hours) {
// this.who = who;
// this.task = task;
// this.hours = hours;
// }
//
// public Employee getWho() {
// return who;
// }
//
// public Task getTask() {
// return task;
// }
//
// public Integer getHours() {
// return hours;
// }
//
// /**
// * Manager can alter hours before closing task
// *
// * @param hours New amount of hours
// */
// public void alterHours(final Integer hours) {
// this.hours = hours;
// }
//
// @Override
// public String toString() {
// return "Timesheet [who=" + who + ", task=" + task + ", hours=" + hours + "]";
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DOMAIN_DECLARATION = "digraph domain {\n";
| import com.nitorcreations.testdomain.Selfie;
import com.nitorcreations.testdomain.Task;
import com.nitorcreations.testdomain.Timesheet;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DEFAULTS;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DOMAIN_DECLARATION;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat; | package com.nitorcreations;
public class DomainMapperTest {
private DomainMapper domainMapper;
@Test
public void testDescribeDomain_singleClass() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Employee.class);
domainMapper = new DomainMapper(list);
String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain.person\";\n Employee\n }\n}";
assertThat(domainMapper.describeDomain(), is(description));
}
@Test
public void testDescribeDomain_selfie() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>(); | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Selfie.java
// public class Selfie {
// private Selfie me;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
// public class Task {
// private final List<Employee> assignedEmployees = new ArrayList<>();
// private final Manager manager;
// private boolean completed;
// private final String description;
//
// public Task(final String description, final Manager manager, final Employee... employees) {
// this.description = description;
// this.manager = manager;
// assignedEmployees.addAll(Arrays.asList(employees));
// completed = false;
// }
//
// public Manager getManager() {
// return manager;
// }
//
// public List<Employee> getAssignedEmployees() {
// return assignedEmployees;
// }
//
// public void addEmployee(final Employee e) {
// assignedEmployees.add(e);
// }
//
// public void removeEmployee(final Employee e) {
// assignedEmployees.remove(e);
// }
//
// public void completeTask() {
// completed = true;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Timesheet.java
// public class Timesheet {
// private final Employee who;
// private final Task task;
// private Integer hours;
// private List<String> stuff;
//
// public Timesheet(final Employee who, final Task task, final Integer hours) {
// this.who = who;
// this.task = task;
// this.hours = hours;
// }
//
// public Employee getWho() {
// return who;
// }
//
// public Task getTask() {
// return task;
// }
//
// public Integer getHours() {
// return hours;
// }
//
// /**
// * Manager can alter hours before closing task
// *
// * @param hours New amount of hours
// */
// public void alterHours(final Integer hours) {
// this.hours = hours;
// }
//
// @Override
// public String toString() {
// return "Timesheet [who=" + who + ", task=" + task + ", hours=" + hours + "]";
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DOMAIN_DECLARATION = "digraph domain {\n";
// Path: drm-core/src/test/java/com/nitorcreations/DomainMapperTest.java
import com.nitorcreations.testdomain.Selfie;
import com.nitorcreations.testdomain.Task;
import com.nitorcreations.testdomain.Timesheet;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DEFAULTS;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DOMAIN_DECLARATION;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat;
package com.nitorcreations;
public class DomainMapperTest {
private DomainMapper domainMapper;
@Test
public void testDescribeDomain_singleClass() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Employee.class);
domainMapper = new DomainMapper(list);
String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain.person\";\n Employee\n }\n}";
assertThat(domainMapper.describeDomain(), is(description));
}
@Test
public void testDescribeDomain_selfie() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>(); | list.add(Selfie.class); |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/DomainMapperTest.java | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Selfie.java
// public class Selfie {
// private Selfie me;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
// public class Task {
// private final List<Employee> assignedEmployees = new ArrayList<>();
// private final Manager manager;
// private boolean completed;
// private final String description;
//
// public Task(final String description, final Manager manager, final Employee... employees) {
// this.description = description;
// this.manager = manager;
// assignedEmployees.addAll(Arrays.asList(employees));
// completed = false;
// }
//
// public Manager getManager() {
// return manager;
// }
//
// public List<Employee> getAssignedEmployees() {
// return assignedEmployees;
// }
//
// public void addEmployee(final Employee e) {
// assignedEmployees.add(e);
// }
//
// public void removeEmployee(final Employee e) {
// assignedEmployees.remove(e);
// }
//
// public void completeTask() {
// completed = true;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Timesheet.java
// public class Timesheet {
// private final Employee who;
// private final Task task;
// private Integer hours;
// private List<String> stuff;
//
// public Timesheet(final Employee who, final Task task, final Integer hours) {
// this.who = who;
// this.task = task;
// this.hours = hours;
// }
//
// public Employee getWho() {
// return who;
// }
//
// public Task getTask() {
// return task;
// }
//
// public Integer getHours() {
// return hours;
// }
//
// /**
// * Manager can alter hours before closing task
// *
// * @param hours New amount of hours
// */
// public void alterHours(final Integer hours) {
// this.hours = hours;
// }
//
// @Override
// public String toString() {
// return "Timesheet [who=" + who + ", task=" + task + ", hours=" + hours + "]";
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DOMAIN_DECLARATION = "digraph domain {\n";
| import com.nitorcreations.testdomain.Selfie;
import com.nitorcreations.testdomain.Task;
import com.nitorcreations.testdomain.Timesheet;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DEFAULTS;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DOMAIN_DECLARATION;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat; | package com.nitorcreations;
public class DomainMapperTest {
private DomainMapper domainMapper;
@Test
public void testDescribeDomain_singleClass() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Employee.class);
domainMapper = new DomainMapper(list);
String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain.person\";\n Employee\n }\n}";
assertThat(domainMapper.describeDomain(), is(description));
}
@Test
public void testDescribeDomain_selfie() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Selfie.class);
domainMapper = new DomainMapper(list);
String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain\";\n Selfie\n }\n Selfie -> Selfie [ taillabel = \"me\" dir=forward arrowhead=open];\n}";
assertThat(domainMapper.describeDomain(), is(description));
}
@Test
public void testDescribeDomain_doubleReferer() throws ClassNotFoundException { | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Selfie.java
// public class Selfie {
// private Selfie me;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
// public class Task {
// private final List<Employee> assignedEmployees = new ArrayList<>();
// private final Manager manager;
// private boolean completed;
// private final String description;
//
// public Task(final String description, final Manager manager, final Employee... employees) {
// this.description = description;
// this.manager = manager;
// assignedEmployees.addAll(Arrays.asList(employees));
// completed = false;
// }
//
// public Manager getManager() {
// return manager;
// }
//
// public List<Employee> getAssignedEmployees() {
// return assignedEmployees;
// }
//
// public void addEmployee(final Employee e) {
// assignedEmployees.add(e);
// }
//
// public void removeEmployee(final Employee e) {
// assignedEmployees.remove(e);
// }
//
// public void completeTask() {
// completed = true;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Timesheet.java
// public class Timesheet {
// private final Employee who;
// private final Task task;
// private Integer hours;
// private List<String> stuff;
//
// public Timesheet(final Employee who, final Task task, final Integer hours) {
// this.who = who;
// this.task = task;
// this.hours = hours;
// }
//
// public Employee getWho() {
// return who;
// }
//
// public Task getTask() {
// return task;
// }
//
// public Integer getHours() {
// return hours;
// }
//
// /**
// * Manager can alter hours before closing task
// *
// * @param hours New amount of hours
// */
// public void alterHours(final Integer hours) {
// this.hours = hours;
// }
//
// @Override
// public String toString() {
// return "Timesheet [who=" + who + ", task=" + task + ", hours=" + hours + "]";
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DOMAIN_DECLARATION = "digraph domain {\n";
// Path: drm-core/src/test/java/com/nitorcreations/DomainMapperTest.java
import com.nitorcreations.testdomain.Selfie;
import com.nitorcreations.testdomain.Task;
import com.nitorcreations.testdomain.Timesheet;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DEFAULTS;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DOMAIN_DECLARATION;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat;
package com.nitorcreations;
public class DomainMapperTest {
private DomainMapper domainMapper;
@Test
public void testDescribeDomain_singleClass() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Employee.class);
domainMapper = new DomainMapper(list);
String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain.person\";\n Employee\n }\n}";
assertThat(domainMapper.describeDomain(), is(description));
}
@Test
public void testDescribeDomain_selfie() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Selfie.class);
domainMapper = new DomainMapper(list);
String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain\";\n Selfie\n }\n Selfie -> Selfie [ taillabel = \"me\" dir=forward arrowhead=open];\n}";
assertThat(domainMapper.describeDomain(), is(description));
}
@Test
public void testDescribeDomain_doubleReferer() throws ClassNotFoundException { | domainMapper = new DomainMapper(Arrays.asList(DoubleReferer.class, Manager.class)); |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/DomainMapperTest.java | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Selfie.java
// public class Selfie {
// private Selfie me;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
// public class Task {
// private final List<Employee> assignedEmployees = new ArrayList<>();
// private final Manager manager;
// private boolean completed;
// private final String description;
//
// public Task(final String description, final Manager manager, final Employee... employees) {
// this.description = description;
// this.manager = manager;
// assignedEmployees.addAll(Arrays.asList(employees));
// completed = false;
// }
//
// public Manager getManager() {
// return manager;
// }
//
// public List<Employee> getAssignedEmployees() {
// return assignedEmployees;
// }
//
// public void addEmployee(final Employee e) {
// assignedEmployees.add(e);
// }
//
// public void removeEmployee(final Employee e) {
// assignedEmployees.remove(e);
// }
//
// public void completeTask() {
// completed = true;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Timesheet.java
// public class Timesheet {
// private final Employee who;
// private final Task task;
// private Integer hours;
// private List<String> stuff;
//
// public Timesheet(final Employee who, final Task task, final Integer hours) {
// this.who = who;
// this.task = task;
// this.hours = hours;
// }
//
// public Employee getWho() {
// return who;
// }
//
// public Task getTask() {
// return task;
// }
//
// public Integer getHours() {
// return hours;
// }
//
// /**
// * Manager can alter hours before closing task
// *
// * @param hours New amount of hours
// */
// public void alterHours(final Integer hours) {
// this.hours = hours;
// }
//
// @Override
// public String toString() {
// return "Timesheet [who=" + who + ", task=" + task + ", hours=" + hours + "]";
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DOMAIN_DECLARATION = "digraph domain {\n";
| import com.nitorcreations.testdomain.Selfie;
import com.nitorcreations.testdomain.Task;
import com.nitorcreations.testdomain.Timesheet;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DEFAULTS;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DOMAIN_DECLARATION;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat; | package com.nitorcreations;
public class DomainMapperTest {
private DomainMapper domainMapper;
@Test
public void testDescribeDomain_singleClass() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Employee.class);
domainMapper = new DomainMapper(list);
String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain.person\";\n Employee\n }\n}";
assertThat(domainMapper.describeDomain(), is(description));
}
@Test
public void testDescribeDomain_selfie() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Selfie.class);
domainMapper = new DomainMapper(list);
String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain\";\n Selfie\n }\n Selfie -> Selfie [ taillabel = \"me\" dir=forward arrowhead=open];\n}";
assertThat(domainMapper.describeDomain(), is(description));
}
@Test
public void testDescribeDomain_doubleReferer() throws ClassNotFoundException { | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Selfie.java
// public class Selfie {
// private Selfie me;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
// public class Task {
// private final List<Employee> assignedEmployees = new ArrayList<>();
// private final Manager manager;
// private boolean completed;
// private final String description;
//
// public Task(final String description, final Manager manager, final Employee... employees) {
// this.description = description;
// this.manager = manager;
// assignedEmployees.addAll(Arrays.asList(employees));
// completed = false;
// }
//
// public Manager getManager() {
// return manager;
// }
//
// public List<Employee> getAssignedEmployees() {
// return assignedEmployees;
// }
//
// public void addEmployee(final Employee e) {
// assignedEmployees.add(e);
// }
//
// public void removeEmployee(final Employee e) {
// assignedEmployees.remove(e);
// }
//
// public void completeTask() {
// completed = true;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Timesheet.java
// public class Timesheet {
// private final Employee who;
// private final Task task;
// private Integer hours;
// private List<String> stuff;
//
// public Timesheet(final Employee who, final Task task, final Integer hours) {
// this.who = who;
// this.task = task;
// this.hours = hours;
// }
//
// public Employee getWho() {
// return who;
// }
//
// public Task getTask() {
// return task;
// }
//
// public Integer getHours() {
// return hours;
// }
//
// /**
// * Manager can alter hours before closing task
// *
// * @param hours New amount of hours
// */
// public void alterHours(final Integer hours) {
// this.hours = hours;
// }
//
// @Override
// public String toString() {
// return "Timesheet [who=" + who + ", task=" + task + ", hours=" + hours + "]";
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
//
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
// public static final String DOMAIN_DECLARATION = "digraph domain {\n";
// Path: drm-core/src/test/java/com/nitorcreations/DomainMapperTest.java
import com.nitorcreations.testdomain.Selfie;
import com.nitorcreations.testdomain.Task;
import com.nitorcreations.testdomain.Timesheet;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DEFAULTS;
import static com.nitorcreations.presenters.DefaultGraphvizPresenter.DOMAIN_DECLARATION;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat;
package com.nitorcreations;
public class DomainMapperTest {
private DomainMapper domainMapper;
@Test
public void testDescribeDomain_singleClass() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Employee.class);
domainMapper = new DomainMapper(list);
String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain.person\";\n Employee\n }\n}";
assertThat(domainMapper.describeDomain(), is(description));
}
@Test
public void testDescribeDomain_selfie() throws ClassNotFoundException {
List<Class<?>> list = new ArrayList<>();
list.add(Selfie.class);
domainMapper = new DomainMapper(list);
String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain\";\n Selfie\n }\n Selfie -> Selfie [ taillabel = \"me\" dir=forward arrowhead=open];\n}";
assertThat(domainMapper.describeDomain(), is(description));
}
@Test
public void testDescribeDomain_doubleReferer() throws ClassNotFoundException { | domainMapper = new DomainMapper(Arrays.asList(DoubleReferer.class, Manager.class)); |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/scanners/HierarchyScannerTest.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
| import com.google.common.collect.Lists;
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import org.junit.Test;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder; | package com.nitorcreations.scanners;
public class HierarchyScannerTest {
private Edge parentToChild = new Edge(new DomainObject(Child.class), | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
// Path: drm-core/src/test/java/com/nitorcreations/scanners/HierarchyScannerTest.java
import com.google.common.collect.Lists;
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import org.junit.Test;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
package com.nitorcreations.scanners;
public class HierarchyScannerTest {
private Edge parentToChild = new Edge(new DomainObject(Child.class), | new DomainObject(Parent.class), EdgeType.EXTENDS); |
NitorCreations/DomainReverseMapper | drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
| import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.joining; | package com.nitorcreations.presenters;
public class DefaultGraphvizPresenter implements Presenter {
public static final String DOMAIN_DECLARATION = "digraph domain {\n";
public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
private static final String INHERITANCE_STYLE = "arrowhead=empty color=slategray";
private final AtomicInteger count = new AtomicInteger();
| // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.joining;
package com.nitorcreations.presenters;
public class DefaultGraphvizPresenter implements Presenter {
public static final String DOMAIN_DECLARATION = "digraph domain {\n";
public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
private static final String INHERITANCE_STYLE = "arrowhead=empty color=slategray";
private final AtomicInteger count = new AtomicInteger();
| private Object getEdgeDescription(Edge edge) { |
NitorCreations/DomainReverseMapper | drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
| import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.joining; | package com.nitorcreations.presenters;
public class DefaultGraphvizPresenter implements Presenter {
public static final String DOMAIN_DECLARATION = "digraph domain {\n";
public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
private static final String INHERITANCE_STYLE = "arrowhead=empty color=slategray";
private final AtomicInteger count = new AtomicInteger();
private Object getEdgeDescription(Edge edge) {
StringBuilder sb = new StringBuilder();
if (edge.target.description != null) {
sb.append(" headlabel = \"").append(edge.target.description).append("\"");
}
if (edge.source.description != null) {
sb.append(" taillabel = \"").append(edge.source.description).append("\"");
}
sb.append(" ").append(linkDirection(edge));
return sb.toString();
}
private String linkDirection(Edge edge) {
if (edge.source.description == null) {
return "dir=back arrowtail=open";
}
if (edge.target.description == null) {
return "dir=forward arrowhead=open";
}
return "dir=both arrowhead=open arrowtail=open";
}
private String describeInheritance(List<Edge> edges) {
return edges.stream() | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.joining;
package com.nitorcreations.presenters;
public class DefaultGraphvizPresenter implements Presenter {
public static final String DOMAIN_DECLARATION = "digraph domain {\n";
public static final String DEFAULTS = " edge [ fontsize = 11 ];\n node [ shape=box style=rounded ];";
private static final String INHERITANCE_STYLE = "arrowhead=empty color=slategray";
private final AtomicInteger count = new AtomicInteger();
private Object getEdgeDescription(Edge edge) {
StringBuilder sb = new StringBuilder();
if (edge.target.description != null) {
sb.append(" headlabel = \"").append(edge.target.description).append("\"");
}
if (edge.source.description != null) {
sb.append(" taillabel = \"").append(edge.source.description).append("\"");
}
sb.append(" ").append(linkDirection(edge));
return sb.toString();
}
private String linkDirection(Edge edge) {
if (edge.source.description == null) {
return "dir=back arrowtail=open";
}
if (edge.target.description == null) {
return "dir=forward arrowhead=open";
}
return "dir=both arrowhead=open arrowtail=open";
}
private String describeInheritance(List<Edge> edges) {
return edges.stream() | .filter(e -> e.type == EdgeType.EXTENDS) |
NitorCreations/DomainReverseMapper | drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
| import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.joining; | sb.append(" taillabel = \"").append(edge.source.description).append("\"");
}
sb.append(" ").append(linkDirection(edge));
return sb.toString();
}
private String linkDirection(Edge edge) {
if (edge.source.description == null) {
return "dir=back arrowtail=open";
}
if (edge.target.description == null) {
return "dir=forward arrowhead=open";
}
return "dir=both arrowhead=open arrowtail=open";
}
private String describeInheritance(List<Edge> edges) {
return edges.stream()
.filter(e -> e.type == EdgeType.EXTENDS)
.map(this::describeInheritance)
.collect(joining());
}
private String describeInheritance(Edge hierarchyEdge) {
return String.format(" %s -> %s [%s];\n",
hierarchyEdge.source.className,
hierarchyEdge.target.className,
INHERITANCE_STYLE);
}
| // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
// Path: drm-core/src/main/java/com/nitorcreations/presenters/DefaultGraphvizPresenter.java
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.joining;
sb.append(" taillabel = \"").append(edge.source.description).append("\"");
}
sb.append(" ").append(linkDirection(edge));
return sb.toString();
}
private String linkDirection(Edge edge) {
if (edge.source.description == null) {
return "dir=back arrowtail=open";
}
if (edge.target.description == null) {
return "dir=forward arrowhead=open";
}
return "dir=both arrowhead=open arrowtail=open";
}
private String describeInheritance(List<Edge> edges) {
return edges.stream()
.filter(e -> e.type == EdgeType.EXTENDS)
.map(this::describeInheritance)
.collect(joining());
}
private String describeInheritance(Edge hierarchyEdge) {
return String.format(" %s -> %s [%s];\n",
hierarchyEdge.source.className,
hierarchyEdge.target.className,
INHERITANCE_STYLE);
}
| private String describePackages(List<DomainObject> domainObjects) { |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/scanners/FieldScannerTest.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/Direction.java
// public enum Direction {
// UNI_DIRECTIONAL, BI_DIRECTIONAL
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Child.java
// public class Child {
// Mother mommy;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Husband.java
// public class Husband {
// Wife wife;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Mother.java
// public class Mother {
// List<Child> childs;
// Child favorite;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Wife.java
// public class Wife {
// private Husband husband;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/weirdos/Outer.java
// public class Outer {
//
// public class Inner {
// }
// }
| import com.nitorcreations.domain.Direction;
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import com.nitorcreations.testdomain.*;
import com.nitorcreations.testdomain.family.Child;
import com.nitorcreations.testdomain.family.Husband;
import com.nitorcreations.testdomain.family.Mother;
import com.nitorcreations.testdomain.family.Wife;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import com.nitorcreations.testdomain.weirdos.Outer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder; | package com.nitorcreations.scanners;
public class FieldScannerTest {
private final Edge firstReference = createReference( | // Path: drm-core/src/main/java/com/nitorcreations/domain/Direction.java
// public enum Direction {
// UNI_DIRECTIONAL, BI_DIRECTIONAL
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Child.java
// public class Child {
// Mother mommy;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Husband.java
// public class Husband {
// Wife wife;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Mother.java
// public class Mother {
// List<Child> childs;
// Child favorite;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Wife.java
// public class Wife {
// private Husband husband;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/weirdos/Outer.java
// public class Outer {
//
// public class Inner {
// }
// }
// Path: drm-core/src/test/java/com/nitorcreations/scanners/FieldScannerTest.java
import com.nitorcreations.domain.Direction;
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import com.nitorcreations.testdomain.*;
import com.nitorcreations.testdomain.family.Child;
import com.nitorcreations.testdomain.family.Husband;
import com.nitorcreations.testdomain.family.Mother;
import com.nitorcreations.testdomain.family.Wife;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import com.nitorcreations.testdomain.weirdos.Outer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
package com.nitorcreations.scanners;
public class FieldScannerTest {
private final Edge firstReference = createReference( | DoubleReferer.class, "myBoss", Manager.class, null, EdgeType.ONE_TO_ONE, Direction.UNI_DIRECTIONAL); |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/scanners/FieldScannerTest.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/Direction.java
// public enum Direction {
// UNI_DIRECTIONAL, BI_DIRECTIONAL
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Child.java
// public class Child {
// Mother mommy;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Husband.java
// public class Husband {
// Wife wife;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Mother.java
// public class Mother {
// List<Child> childs;
// Child favorite;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Wife.java
// public class Wife {
// private Husband husband;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/weirdos/Outer.java
// public class Outer {
//
// public class Inner {
// }
// }
| import com.nitorcreations.domain.Direction;
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import com.nitorcreations.testdomain.*;
import com.nitorcreations.testdomain.family.Child;
import com.nitorcreations.testdomain.family.Husband;
import com.nitorcreations.testdomain.family.Mother;
import com.nitorcreations.testdomain.family.Wife;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import com.nitorcreations.testdomain.weirdos.Outer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder; | package com.nitorcreations.scanners;
public class FieldScannerTest {
private final Edge firstReference = createReference( | // Path: drm-core/src/main/java/com/nitorcreations/domain/Direction.java
// public enum Direction {
// UNI_DIRECTIONAL, BI_DIRECTIONAL
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Child.java
// public class Child {
// Mother mommy;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Husband.java
// public class Husband {
// Wife wife;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Mother.java
// public class Mother {
// List<Child> childs;
// Child favorite;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Wife.java
// public class Wife {
// private Husband husband;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/weirdos/Outer.java
// public class Outer {
//
// public class Inner {
// }
// }
// Path: drm-core/src/test/java/com/nitorcreations/scanners/FieldScannerTest.java
import com.nitorcreations.domain.Direction;
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import com.nitorcreations.testdomain.*;
import com.nitorcreations.testdomain.family.Child;
import com.nitorcreations.testdomain.family.Husband;
import com.nitorcreations.testdomain.family.Mother;
import com.nitorcreations.testdomain.family.Wife;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import com.nitorcreations.testdomain.weirdos.Outer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
package com.nitorcreations.scanners;
public class FieldScannerTest {
private final Edge firstReference = createReference( | DoubleReferer.class, "myBoss", Manager.class, null, EdgeType.ONE_TO_ONE, Direction.UNI_DIRECTIONAL); |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/scanners/FieldScannerTest.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/Direction.java
// public enum Direction {
// UNI_DIRECTIONAL, BI_DIRECTIONAL
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Child.java
// public class Child {
// Mother mommy;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Husband.java
// public class Husband {
// Wife wife;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Mother.java
// public class Mother {
// List<Child> childs;
// Child favorite;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Wife.java
// public class Wife {
// private Husband husband;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/weirdos/Outer.java
// public class Outer {
//
// public class Inner {
// }
// }
| import com.nitorcreations.domain.Direction;
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import com.nitorcreations.testdomain.*;
import com.nitorcreations.testdomain.family.Child;
import com.nitorcreations.testdomain.family.Husband;
import com.nitorcreations.testdomain.family.Mother;
import com.nitorcreations.testdomain.family.Wife;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import com.nitorcreations.testdomain.weirdos.Outer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder; | package com.nitorcreations.scanners;
public class FieldScannerTest {
private final Edge firstReference = createReference( | // Path: drm-core/src/main/java/com/nitorcreations/domain/Direction.java
// public enum Direction {
// UNI_DIRECTIONAL, BI_DIRECTIONAL
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Child.java
// public class Child {
// Mother mommy;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Husband.java
// public class Husband {
// Wife wife;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Mother.java
// public class Mother {
// List<Child> childs;
// Child favorite;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Wife.java
// public class Wife {
// private Husband husband;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/weirdos/Outer.java
// public class Outer {
//
// public class Inner {
// }
// }
// Path: drm-core/src/test/java/com/nitorcreations/scanners/FieldScannerTest.java
import com.nitorcreations.domain.Direction;
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import com.nitorcreations.testdomain.*;
import com.nitorcreations.testdomain.family.Child;
import com.nitorcreations.testdomain.family.Husband;
import com.nitorcreations.testdomain.family.Mother;
import com.nitorcreations.testdomain.family.Wife;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import com.nitorcreations.testdomain.weirdos.Outer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
package com.nitorcreations.scanners;
public class FieldScannerTest {
private final Edge firstReference = createReference( | DoubleReferer.class, "myBoss", Manager.class, null, EdgeType.ONE_TO_ONE, Direction.UNI_DIRECTIONAL); |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/scanners/FieldScannerTest.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/Direction.java
// public enum Direction {
// UNI_DIRECTIONAL, BI_DIRECTIONAL
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Child.java
// public class Child {
// Mother mommy;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Husband.java
// public class Husband {
// Wife wife;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Mother.java
// public class Mother {
// List<Child> childs;
// Child favorite;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Wife.java
// public class Wife {
// private Husband husband;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/weirdos/Outer.java
// public class Outer {
//
// public class Inner {
// }
// }
| import com.nitorcreations.domain.Direction;
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import com.nitorcreations.testdomain.*;
import com.nitorcreations.testdomain.family.Child;
import com.nitorcreations.testdomain.family.Husband;
import com.nitorcreations.testdomain.family.Mother;
import com.nitorcreations.testdomain.family.Wife;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import com.nitorcreations.testdomain.weirdos.Outer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder; | package com.nitorcreations.scanners;
public class FieldScannerTest {
private final Edge firstReference = createReference( | // Path: drm-core/src/main/java/com/nitorcreations/domain/Direction.java
// public enum Direction {
// UNI_DIRECTIONAL, BI_DIRECTIONAL
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Child.java
// public class Child {
// Mother mommy;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Husband.java
// public class Husband {
// Wife wife;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Mother.java
// public class Mother {
// List<Child> childs;
// Child favorite;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/family/Wife.java
// public class Wife {
// private Husband husband;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/DoubleReferer.java
// public class DoubleReferer {
// private Manager myBoss;
// private Manager myTeamManager;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/weirdos/Outer.java
// public class Outer {
//
// public class Inner {
// }
// }
// Path: drm-core/src/test/java/com/nitorcreations/scanners/FieldScannerTest.java
import com.nitorcreations.domain.Direction;
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import com.nitorcreations.testdomain.*;
import com.nitorcreations.testdomain.family.Child;
import com.nitorcreations.testdomain.family.Husband;
import com.nitorcreations.testdomain.family.Mother;
import com.nitorcreations.testdomain.family.Wife;
import com.nitorcreations.testdomain.person.DoubleReferer;
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import com.nitorcreations.testdomain.weirdos.Outer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
package com.nitorcreations.scanners;
public class FieldScannerTest {
private final Edge firstReference = createReference( | DoubleReferer.class, "myBoss", Manager.class, null, EdgeType.ONE_TO_ONE, Direction.UNI_DIRECTIONAL); |
NitorCreations/DomainReverseMapper | drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
| import com.google.common.collect.Lists;
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.Collection;
import java.util.List;
import static com.nitorcreations.domain.Direction.BI_DIRECTIONAL;
import static com.nitorcreations.domain.Direction.UNI_DIRECTIONAL;
import static com.nitorcreations.domain.EdgeType.resolveEdgeType;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList; | package com.nitorcreations.scanners;
public class EdgeOperations {
public static Edge createEdge(Class<?> sourceClass, Class<?> field, EdgeType type, String name) { | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
// Path: drm-core/src/main/java/com/nitorcreations/scanners/EdgeOperations.java
import com.google.common.collect.Lists;
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.Collection;
import java.util.List;
import static com.nitorcreations.domain.Direction.BI_DIRECTIONAL;
import static com.nitorcreations.domain.Direction.UNI_DIRECTIONAL;
import static com.nitorcreations.domain.EdgeType.resolveEdgeType;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList;
package com.nitorcreations.scanners;
public class EdgeOperations {
public static Edge createEdge(Class<?> sourceClass, Class<?> field, EdgeType type, String name) { | DomainObject source = new DomainObject(sourceClass, name); |
NitorCreations/DomainReverseMapper | drm-core/src/main/java/com/nitorcreations/scanners/HierarchyScanner.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
| import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.ArrayList;
import java.util.List; | package com.nitorcreations.scanners;
public class HierarchyScanner extends AbstractScanner {
public HierarchyScanner(List<Class<?>> classes) {
super(classes);
}
| // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
// Path: drm-core/src/main/java/com/nitorcreations/scanners/HierarchyScanner.java
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.ArrayList;
import java.util.List;
package com.nitorcreations.scanners;
public class HierarchyScanner extends AbstractScanner {
public HierarchyScanner(List<Class<?>> classes) {
super(classes);
}
| public List<Edge> getEdges() { |
NitorCreations/DomainReverseMapper | drm-core/src/main/java/com/nitorcreations/scanners/HierarchyScanner.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
| import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.ArrayList;
import java.util.List; | package com.nitorcreations.scanners;
public class HierarchyScanner extends AbstractScanner {
public HierarchyScanner(List<Class<?>> classes) {
super(classes);
}
public List<Edge> getEdges() {
List<Edge> edges = new ArrayList<>();
for (Class<?> clazz : classes) {
Class<?> superclass = clazz.getSuperclass();
if (isDomainClass(superclass)) { | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
// Path: drm-core/src/main/java/com/nitorcreations/scanners/HierarchyScanner.java
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.ArrayList;
import java.util.List;
package com.nitorcreations.scanners;
public class HierarchyScanner extends AbstractScanner {
public HierarchyScanner(List<Class<?>> classes) {
super(classes);
}
public List<Edge> getEdges() {
List<Edge> edges = new ArrayList<>();
for (Class<?> clazz : classes) {
Class<?> superclass = clazz.getSuperclass();
if (isDomainClass(superclass)) { | DomainObject child = new DomainObject(clazz); |
NitorCreations/DomainReverseMapper | drm-core/src/main/java/com/nitorcreations/scanners/HierarchyScanner.java | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
| import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.ArrayList;
import java.util.List; | package com.nitorcreations.scanners;
public class HierarchyScanner extends AbstractScanner {
public HierarchyScanner(List<Class<?>> classes) {
super(classes);
}
public List<Edge> getEdges() {
List<Edge> edges = new ArrayList<>();
for (Class<?> clazz : classes) {
Class<?> superclass = clazz.getSuperclass();
if (isDomainClass(superclass)) {
DomainObject child = new DomainObject(clazz);
DomainObject parent = new DomainObject(superclass); | // Path: drm-core/src/main/java/com/nitorcreations/domain/DomainObject.java
// public class DomainObject {
//
// public final String packageName;
// public final String className;
// public final String description;
//
// public DomainObject(String packageName, String className, String description) {
// this.packageName = packageName;
// this.className = className;
// this.description = description;
// }
//
// public DomainObject(Class<?> clazz, String description) {
// this(clazz.getPackage().getName(), clazz.getSimpleName(), description);
// }
//
// public DomainObject(Class<?> clazz) {
// this(clazz, null);
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/Edge.java
// public class Edge {
//
// public final DomainObject source;
// public final DomainObject target;
// public final EdgeType type;
// public final Direction direction;
//
// public Edge(DomainObject source, DomainObject target, EdgeType type, Direction direction) {
// this.source = source;
// this.target = target;
// this.type = type;
// this.direction = direction;
// }
//
// public Edge(DomainObject source, DomainObject target, EdgeType type) {
// this(source, target, type, null);
// }
//
// @Override
// public final int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public final boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public String toString() {
// return ReflectionToStringBuilder.toString(this);
// }
// }
//
// Path: drm-core/src/main/java/com/nitorcreations/domain/EdgeType.java
// public enum EdgeType {
//
// ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, EXTENDS, INNER_CLASS;
//
// public static EdgeType resolveEdgeType(EdgeType source, EdgeType target) {
// if (source.equals(target)) {
// switch (source) {
// case ONE_TO_ONE:
// case MANY_TO_MANY:
// return source;
// case MANY_TO_ONE:
// case ONE_TO_MANY:
// return MANY_TO_MANY;
// case EXTENDS:
// case INNER_CLASS:
// throw new RuntimeException("impossible");
// }
// }
// if (source.equals(ONE_TO_ONE)) {
// return target;
// } else if (target.equals(ONE_TO_ONE)) {
// return source;
// }
// throw new RuntimeException("impossible");
// }
//
// }
// Path: drm-core/src/main/java/com/nitorcreations/scanners/HierarchyScanner.java
import com.nitorcreations.domain.DomainObject;
import com.nitorcreations.domain.Edge;
import com.nitorcreations.domain.EdgeType;
import java.util.ArrayList;
import java.util.List;
package com.nitorcreations.scanners;
public class HierarchyScanner extends AbstractScanner {
public HierarchyScanner(List<Class<?>> classes) {
super(classes);
}
public List<Edge> getEdges() {
List<Edge> edges = new ArrayList<>();
for (Class<?> clazz : classes) {
Class<?> superclass = clazz.getSuperclass();
if (isDomainClass(superclass)) {
DomainObject child = new DomainObject(clazz);
DomainObject parent = new DomainObject(superclass); | edges.add(new Edge(child, parent, EdgeType.EXTENDS)); |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Company.java
// public class Company {
// private List<Person> employees;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/PhoneNumber.java
// public class PhoneNumber {
// private String number;
// }
| import com.nitorcreations.testdomain.Company;
import com.nitorcreations.testdomain.PhoneNumber;
import java.util.List; | package com.nitorcreations.testdomain.person;
public class Person {
private Company company; | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/Company.java
// public class Company {
// private List<Person> employees;
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/PhoneNumber.java
// public class PhoneNumber {
// private String number;
// }
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
import com.nitorcreations.testdomain.Company;
import com.nitorcreations.testdomain.PhoneNumber;
import java.util.List;
package com.nitorcreations.testdomain.person;
public class Person {
private Company company; | private List<PhoneNumber> contactNumbers; |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/testdomain/Task.java | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
| import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; | package com.nitorcreations.testdomain;
public class Task {
private final List<Employee> assignedEmployees = new ArrayList<>(); | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Employee.java
// public class Employee extends Person {
// private final String name;
// private final String department;
//
// public Employee(final String name, final String department) {
// this.name = name;
// this.department = department;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDepartment() {
// return department;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/Task.java
import com.nitorcreations.testdomain.person.Employee;
import com.nitorcreations.testdomain.person.Manager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
package com.nitorcreations.testdomain;
public class Task {
private final List<Employee> assignedEmployees = new ArrayList<>(); | private final Manager manager; |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/domain/EdgeTest.java | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
| import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat; | package com.nitorcreations.domain;
public class EdgeTest {
@Test
public void testEqualsContract() throws Exception {
EqualsVerifier.forClass(Edge.class).verify();
}
@Test
public void toStringWorks() { | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
// Path: drm-core/src/test/java/com/nitorcreations/domain/EdgeTest.java
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
package com.nitorcreations.domain;
public class EdgeTest {
@Test
public void testEqualsContract() throws Exception {
EqualsVerifier.forClass(Edge.class).verify();
}
@Test
public void toStringWorks() { | String toString = new Edge(new DomainObject(Person.class), new DomainObject(Manager.class), EdgeType.ONE_TO_ONE, Direction.BI_DIRECTIONAL).toString(); |
NitorCreations/DomainReverseMapper | drm-core/src/test/java/com/nitorcreations/domain/EdgeTest.java | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
| import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat; | package com.nitorcreations.domain;
public class EdgeTest {
@Test
public void testEqualsContract() throws Exception {
EqualsVerifier.forClass(Edge.class).verify();
}
@Test
public void toStringWorks() { | // Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Manager.java
// public class Manager extends Person {
// private final String name;
//
// public Manager(final String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: drm-core/src/test/java/com/nitorcreations/testdomain/person/Person.java
// public class Person {
// private Company company;
// private List<PhoneNumber> contactNumbers;
// }
// Path: drm-core/src/test/java/com/nitorcreations/domain/EdgeTest.java
import com.nitorcreations.testdomain.person.Manager;
import com.nitorcreations.testdomain.person.Person;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
package com.nitorcreations.domain;
public class EdgeTest {
@Test
public void testEqualsContract() throws Exception {
EqualsVerifier.forClass(Edge.class).verify();
}
@Test
public void toStringWorks() { | String toString = new Edge(new DomainObject(Person.class), new DomainObject(Manager.class), EdgeType.ONE_TO_ONE, Direction.BI_DIRECTIONAL).toString(); |
xfyre/tapestry5-xtensions | src/main/java/com/xfyre/tapestry5/xtensions/services/ModalIntegrationWorker.java | // Path: src/main/java/com/xfyre/tapestry5/xtensions/mixins/ModalIntegration.java
// @MixinAfter
// public class ModalIntegration {
// @InjectContainer
// private Form form;
//
// void afterRender ( MarkupWriter markupWriter ) {
// if ( form.getHasErrors () )
// markupWriter.attributeNS ( null, "data-submission-failed", "true" );
// }
// }
| import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.model.MutableComponentModel;
import org.apache.tapestry5.plastic.PlasticClass;
import org.apache.tapestry5.services.transform.ComponentClassTransformWorker2;
import org.apache.tapestry5.services.transform.TransformationSupport;
import com.xfyre.tapestry5.xtensions.mixins.ModalIntegration; | package com.xfyre.tapestry5.xtensions.services;
public class ModalIntegrationWorker implements ComponentClassTransformWorker2 {
@Override
public void transform ( PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model ) {
if ( Form.class.getName ().equals ( plasticClass.getClassName () ) ) | // Path: src/main/java/com/xfyre/tapestry5/xtensions/mixins/ModalIntegration.java
// @MixinAfter
// public class ModalIntegration {
// @InjectContainer
// private Form form;
//
// void afterRender ( MarkupWriter markupWriter ) {
// if ( form.getHasErrors () )
// markupWriter.attributeNS ( null, "data-submission-failed", "true" );
// }
// }
// Path: src/main/java/com/xfyre/tapestry5/xtensions/services/ModalIntegrationWorker.java
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.model.MutableComponentModel;
import org.apache.tapestry5.plastic.PlasticClass;
import org.apache.tapestry5.services.transform.ComponentClassTransformWorker2;
import org.apache.tapestry5.services.transform.TransformationSupport;
import com.xfyre.tapestry5.xtensions.mixins.ModalIntegration;
package com.xfyre.tapestry5.xtensions.services;
public class ModalIntegrationWorker implements ComponentClassTransformWorker2 {
@Override
public void transform ( PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model ) {
if ( Form.class.getName ().equals ( plasticClass.getClassName () ) ) | model.addMixinClassName ( ModalIntegration.class.getName () ); |
Falseclock/HtcOneTweaker | src/kz/virtex/htc/tweaker/TweakerService.java | // Path: src/kz/virtex/htc/tweaker/utils/MediaStorageMgr.java
// public class MediaStorageMgr
// {
// private static boolean isExternalStorageRemovable = false;
// private static boolean hasRemovableStorageSlot;
// private static boolean hasPhoneStorage;
// private static File sSDCardDirectory;
// private static File sPhoneStorageDirectory;
//
// static
// {
// hasPhoneStorage = false;
// hasRemovableStorageSlot = false;
// sSDCardDirectory = null;
// sPhoneStorageDirectory = null;
// isExternalStorageRemovable = Environment.isExternalStorageRemovable();
// hasPhoneStorage = HtcWrapEnvironment.hasPhoneStorage();
// hasRemovableStorageSlot = HtcWrapEnvironment.hasRemovableStorageSlot();
//
// if (isExternalStorageRemovable)
// {
// sSDCardDirectory = Environment.getExternalStorageDirectory();
// if (hasPhoneStorage)
// {
// sPhoneStorageDirectory = HtcWrapEnvironment.getPhoneStorageDirectory();
// }
// }
// else
// {
// sPhoneStorageDirectory = Environment.getExternalStorageDirectory();
// if (hasRemovableStorageSlot)
// {
// sSDCardDirectory = HtcWrapEnvironment.getRemovableStorageDirectory();
// }
// }
// }
//
// public MediaStorageMgr()
// {
// }
//
// public static String getSDCardFullPath()
// {
// File localFile = sSDCardDirectory;
// String str1 = null;
// if (localFile != null)
// {
// String str2 = smartAddslash(sSDCardDirectory.getPath());
// str1 = str2 + "My Documents/My Recordings";
// }
// return str1;
// }
//
// public static String getPhoneStorageFullPath()
// {
// File localFile = sPhoneStorageDirectory;
// String str1 = null;
// if (localFile != null)
// {
// String str2 = smartAddslash(sPhoneStorageDirectory.getPath());
// str1 = str2 + "My Documents/My Recordings";
// }
// return str1;
// }
//
// public static String smartAddslash(String paramString)
// {
// if ((paramString == null) || (paramString.length() == 0) || (paramString.endsWith("/")))
// {
// return paramString;
// }
// return paramString + '/';
// }
// }
//
// Path: src/kz/virtex/htc/tweaker/utils/ParseExceptionContents.java
// public class ParseExceptionContents
// {
// final static String newLine = System.getProperty("line.separator");
// final static String headerLine = "---------------------------------------------------------------------";
// final static String headerTitlePortion = "-- StackTraceElement Index #";
//
// public static void xposed(StackTraceElement[] stackTrace)
// {
// XposedBridge.log(build(stackTrace));
// }
//
// public static void logd(StackTraceElement[] stackTrace)
// {
// Log.d("ParseExceptionContents", build(stackTrace));
// }
//
// public static void loge(StackTraceElement[] stackTrace)
// {
// Log.e("ParseExceptionContents", build(stackTrace));
// }
//
// private static String build(StackTraceElement[] stackTrace)
// {
// int index = 0;
// StringBuilder builder = new StringBuilder();
//
// builder.append(headerLine + newLine);
// for (StackTraceElement element : stackTrace)
// {
// final String exceptionMsg
// = "ClassName: " + element.getClassName() + newLine
// + "MethodName: " + element.getMethodName() + newLine
// + "FileName: " + element.getFileName() + newLine
// + "LineNumber: " + element.getLineNumber() + newLine
// + "\t" + newLine
// ;
//
// builder.append(headerTitlePortion + index++ + newLine);
// builder.append(exceptionMsg);
// }
//
// return builder.toString();
// }
//
// }
| import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import kz.virtex.htc.tweaker.utils.MediaStorageMgr;
import kz.virtex.htc.tweaker.utils.ParseExceptionContents;
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log; | cleanUpRecordsByInterval(deleteInterval);
break;
}
}
}
private void cleanUpRecordsByInterval(int deleteInterval)
{
Log.d("TweakerService", "deleting by interval: " + deleteInterval);
Calendar now = Calendar.getInstance();
Date date = new Date();
now.setTime(date);
for (int i = 0; i < mFileList.size(); i++)
{
Calendar old = Calendar.getInstance();
old.setTime(mFileList.get(i).getDate());
if (getElapsedDaysText(old, now) > deleteInterval)
{
try
{
Log.d("TweakerService", "deleting " + mFileList.get(i).getName());
File file = new File(mFileList.get(i).getPath());
file.delete();
}
catch (Exception e)
{ | // Path: src/kz/virtex/htc/tweaker/utils/MediaStorageMgr.java
// public class MediaStorageMgr
// {
// private static boolean isExternalStorageRemovable = false;
// private static boolean hasRemovableStorageSlot;
// private static boolean hasPhoneStorage;
// private static File sSDCardDirectory;
// private static File sPhoneStorageDirectory;
//
// static
// {
// hasPhoneStorage = false;
// hasRemovableStorageSlot = false;
// sSDCardDirectory = null;
// sPhoneStorageDirectory = null;
// isExternalStorageRemovable = Environment.isExternalStorageRemovable();
// hasPhoneStorage = HtcWrapEnvironment.hasPhoneStorage();
// hasRemovableStorageSlot = HtcWrapEnvironment.hasRemovableStorageSlot();
//
// if (isExternalStorageRemovable)
// {
// sSDCardDirectory = Environment.getExternalStorageDirectory();
// if (hasPhoneStorage)
// {
// sPhoneStorageDirectory = HtcWrapEnvironment.getPhoneStorageDirectory();
// }
// }
// else
// {
// sPhoneStorageDirectory = Environment.getExternalStorageDirectory();
// if (hasRemovableStorageSlot)
// {
// sSDCardDirectory = HtcWrapEnvironment.getRemovableStorageDirectory();
// }
// }
// }
//
// public MediaStorageMgr()
// {
// }
//
// public static String getSDCardFullPath()
// {
// File localFile = sSDCardDirectory;
// String str1 = null;
// if (localFile != null)
// {
// String str2 = smartAddslash(sSDCardDirectory.getPath());
// str1 = str2 + "My Documents/My Recordings";
// }
// return str1;
// }
//
// public static String getPhoneStorageFullPath()
// {
// File localFile = sPhoneStorageDirectory;
// String str1 = null;
// if (localFile != null)
// {
// String str2 = smartAddslash(sPhoneStorageDirectory.getPath());
// str1 = str2 + "My Documents/My Recordings";
// }
// return str1;
// }
//
// public static String smartAddslash(String paramString)
// {
// if ((paramString == null) || (paramString.length() == 0) || (paramString.endsWith("/")))
// {
// return paramString;
// }
// return paramString + '/';
// }
// }
//
// Path: src/kz/virtex/htc/tweaker/utils/ParseExceptionContents.java
// public class ParseExceptionContents
// {
// final static String newLine = System.getProperty("line.separator");
// final static String headerLine = "---------------------------------------------------------------------";
// final static String headerTitlePortion = "-- StackTraceElement Index #";
//
// public static void xposed(StackTraceElement[] stackTrace)
// {
// XposedBridge.log(build(stackTrace));
// }
//
// public static void logd(StackTraceElement[] stackTrace)
// {
// Log.d("ParseExceptionContents", build(stackTrace));
// }
//
// public static void loge(StackTraceElement[] stackTrace)
// {
// Log.e("ParseExceptionContents", build(stackTrace));
// }
//
// private static String build(StackTraceElement[] stackTrace)
// {
// int index = 0;
// StringBuilder builder = new StringBuilder();
//
// builder.append(headerLine + newLine);
// for (StackTraceElement element : stackTrace)
// {
// final String exceptionMsg
// = "ClassName: " + element.getClassName() + newLine
// + "MethodName: " + element.getMethodName() + newLine
// + "FileName: " + element.getFileName() + newLine
// + "LineNumber: " + element.getLineNumber() + newLine
// + "\t" + newLine
// ;
//
// builder.append(headerTitlePortion + index++ + newLine);
// builder.append(exceptionMsg);
// }
//
// return builder.toString();
// }
//
// }
// Path: src/kz/virtex/htc/tweaker/TweakerService.java
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import kz.virtex.htc.tweaker.utils.MediaStorageMgr;
import kz.virtex.htc.tweaker.utils.ParseExceptionContents;
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
cleanUpRecordsByInterval(deleteInterval);
break;
}
}
}
private void cleanUpRecordsByInterval(int deleteInterval)
{
Log.d("TweakerService", "deleting by interval: " + deleteInterval);
Calendar now = Calendar.getInstance();
Date date = new Date();
now.setTime(date);
for (int i = 0; i < mFileList.size(); i++)
{
Calendar old = Calendar.getInstance();
old.setTime(mFileList.get(i).getDate());
if (getElapsedDaysText(old, now) > deleteInterval)
{
try
{
Log.d("TweakerService", "deleting " + mFileList.get(i).getName());
File file = new File(mFileList.get(i).getPath());
file.delete();
}
catch (Exception e)
{ | ParseExceptionContents.loge(e.getStackTrace()); |
Falseclock/HtcOneTweaker | src/kz/virtex/htc/tweaker/TweakerService.java | // Path: src/kz/virtex/htc/tweaker/utils/MediaStorageMgr.java
// public class MediaStorageMgr
// {
// private static boolean isExternalStorageRemovable = false;
// private static boolean hasRemovableStorageSlot;
// private static boolean hasPhoneStorage;
// private static File sSDCardDirectory;
// private static File sPhoneStorageDirectory;
//
// static
// {
// hasPhoneStorage = false;
// hasRemovableStorageSlot = false;
// sSDCardDirectory = null;
// sPhoneStorageDirectory = null;
// isExternalStorageRemovable = Environment.isExternalStorageRemovable();
// hasPhoneStorage = HtcWrapEnvironment.hasPhoneStorage();
// hasRemovableStorageSlot = HtcWrapEnvironment.hasRemovableStorageSlot();
//
// if (isExternalStorageRemovable)
// {
// sSDCardDirectory = Environment.getExternalStorageDirectory();
// if (hasPhoneStorage)
// {
// sPhoneStorageDirectory = HtcWrapEnvironment.getPhoneStorageDirectory();
// }
// }
// else
// {
// sPhoneStorageDirectory = Environment.getExternalStorageDirectory();
// if (hasRemovableStorageSlot)
// {
// sSDCardDirectory = HtcWrapEnvironment.getRemovableStorageDirectory();
// }
// }
// }
//
// public MediaStorageMgr()
// {
// }
//
// public static String getSDCardFullPath()
// {
// File localFile = sSDCardDirectory;
// String str1 = null;
// if (localFile != null)
// {
// String str2 = smartAddslash(sSDCardDirectory.getPath());
// str1 = str2 + "My Documents/My Recordings";
// }
// return str1;
// }
//
// public static String getPhoneStorageFullPath()
// {
// File localFile = sPhoneStorageDirectory;
// String str1 = null;
// if (localFile != null)
// {
// String str2 = smartAddslash(sPhoneStorageDirectory.getPath());
// str1 = str2 + "My Documents/My Recordings";
// }
// return str1;
// }
//
// public static String smartAddslash(String paramString)
// {
// if ((paramString == null) || (paramString.length() == 0) || (paramString.endsWith("/")))
// {
// return paramString;
// }
// return paramString + '/';
// }
// }
//
// Path: src/kz/virtex/htc/tweaker/utils/ParseExceptionContents.java
// public class ParseExceptionContents
// {
// final static String newLine = System.getProperty("line.separator");
// final static String headerLine = "---------------------------------------------------------------------";
// final static String headerTitlePortion = "-- StackTraceElement Index #";
//
// public static void xposed(StackTraceElement[] stackTrace)
// {
// XposedBridge.log(build(stackTrace));
// }
//
// public static void logd(StackTraceElement[] stackTrace)
// {
// Log.d("ParseExceptionContents", build(stackTrace));
// }
//
// public static void loge(StackTraceElement[] stackTrace)
// {
// Log.e("ParseExceptionContents", build(stackTrace));
// }
//
// private static String build(StackTraceElement[] stackTrace)
// {
// int index = 0;
// StringBuilder builder = new StringBuilder();
//
// builder.append(headerLine + newLine);
// for (StackTraceElement element : stackTrace)
// {
// final String exceptionMsg
// = "ClassName: " + element.getClassName() + newLine
// + "MethodName: " + element.getMethodName() + newLine
// + "FileName: " + element.getFileName() + newLine
// + "LineNumber: " + element.getLineNumber() + newLine
// + "\t" + newLine
// ;
//
// builder.append(headerTitlePortion + index++ + newLine);
// builder.append(exceptionMsg);
// }
//
// return builder.toString();
// }
//
// }
| import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import kz.virtex.htc.tweaker.utils.MediaStorageMgr;
import kz.virtex.htc.tweaker.utils.ParseExceptionContents;
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log; | }
private void cleanUpRecordsByCount(int deleteCount)
{
Log.d("TweakerService", "deleting by count: " + deleteCount);
for (int i = 0; i < mFileList.size(); i++)
{
if (deleteCount <= 0)
{
try
{
Log.d("TweakerService", "deleting " + mFileList.get(i).getName());
File file = new File(mFileList.get(i).getPath());
file.delete();
}
catch (Exception e)
{
ParseExceptionContents.loge(e.getStackTrace());
}
}
deleteCount--;
}
}
private void getRecords()
{
mFileList = new ArrayList<Ls>();
| // Path: src/kz/virtex/htc/tweaker/utils/MediaStorageMgr.java
// public class MediaStorageMgr
// {
// private static boolean isExternalStorageRemovable = false;
// private static boolean hasRemovableStorageSlot;
// private static boolean hasPhoneStorage;
// private static File sSDCardDirectory;
// private static File sPhoneStorageDirectory;
//
// static
// {
// hasPhoneStorage = false;
// hasRemovableStorageSlot = false;
// sSDCardDirectory = null;
// sPhoneStorageDirectory = null;
// isExternalStorageRemovable = Environment.isExternalStorageRemovable();
// hasPhoneStorage = HtcWrapEnvironment.hasPhoneStorage();
// hasRemovableStorageSlot = HtcWrapEnvironment.hasRemovableStorageSlot();
//
// if (isExternalStorageRemovable)
// {
// sSDCardDirectory = Environment.getExternalStorageDirectory();
// if (hasPhoneStorage)
// {
// sPhoneStorageDirectory = HtcWrapEnvironment.getPhoneStorageDirectory();
// }
// }
// else
// {
// sPhoneStorageDirectory = Environment.getExternalStorageDirectory();
// if (hasRemovableStorageSlot)
// {
// sSDCardDirectory = HtcWrapEnvironment.getRemovableStorageDirectory();
// }
// }
// }
//
// public MediaStorageMgr()
// {
// }
//
// public static String getSDCardFullPath()
// {
// File localFile = sSDCardDirectory;
// String str1 = null;
// if (localFile != null)
// {
// String str2 = smartAddslash(sSDCardDirectory.getPath());
// str1 = str2 + "My Documents/My Recordings";
// }
// return str1;
// }
//
// public static String getPhoneStorageFullPath()
// {
// File localFile = sPhoneStorageDirectory;
// String str1 = null;
// if (localFile != null)
// {
// String str2 = smartAddslash(sPhoneStorageDirectory.getPath());
// str1 = str2 + "My Documents/My Recordings";
// }
// return str1;
// }
//
// public static String smartAddslash(String paramString)
// {
// if ((paramString == null) || (paramString.length() == 0) || (paramString.endsWith("/")))
// {
// return paramString;
// }
// return paramString + '/';
// }
// }
//
// Path: src/kz/virtex/htc/tweaker/utils/ParseExceptionContents.java
// public class ParseExceptionContents
// {
// final static String newLine = System.getProperty("line.separator");
// final static String headerLine = "---------------------------------------------------------------------";
// final static String headerTitlePortion = "-- StackTraceElement Index #";
//
// public static void xposed(StackTraceElement[] stackTrace)
// {
// XposedBridge.log(build(stackTrace));
// }
//
// public static void logd(StackTraceElement[] stackTrace)
// {
// Log.d("ParseExceptionContents", build(stackTrace));
// }
//
// public static void loge(StackTraceElement[] stackTrace)
// {
// Log.e("ParseExceptionContents", build(stackTrace));
// }
//
// private static String build(StackTraceElement[] stackTrace)
// {
// int index = 0;
// StringBuilder builder = new StringBuilder();
//
// builder.append(headerLine + newLine);
// for (StackTraceElement element : stackTrace)
// {
// final String exceptionMsg
// = "ClassName: " + element.getClassName() + newLine
// + "MethodName: " + element.getMethodName() + newLine
// + "FileName: " + element.getFileName() + newLine
// + "LineNumber: " + element.getLineNumber() + newLine
// + "\t" + newLine
// ;
//
// builder.append(headerTitlePortion + index++ + newLine);
// builder.append(exceptionMsg);
// }
//
// return builder.toString();
// }
//
// }
// Path: src/kz/virtex/htc/tweaker/TweakerService.java
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import kz.virtex.htc.tweaker.utils.MediaStorageMgr;
import kz.virtex.htc.tweaker.utils.ParseExceptionContents;
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
}
private void cleanUpRecordsByCount(int deleteCount)
{
Log.d("TweakerService", "deleting by count: " + deleteCount);
for (int i = 0; i < mFileList.size(); i++)
{
if (deleteCount <= 0)
{
try
{
Log.d("TweakerService", "deleting " + mFileList.get(i).getName());
File file = new File(mFileList.get(i).getPath());
file.delete();
}
catch (Exception e)
{
ParseExceptionContents.loge(e.getStackTrace());
}
}
deleteCount--;
}
}
private void getRecords()
{
mFileList = new ArrayList<Ls>();
| getRecordsList(MediaStorageMgr.getSDCardFullPath() + "/" + Const.AUTO_REC_MAIN); |
edertone/TurboCommons | TurboCommons-Java/src/main/java/org/turbocommons/utils/ArrayUtils.java | // Path: TurboCommons-Java/src/main/java/org/turbocommons/managers/ValidationManager.java
// public class ValidationManager {
//
// /**
// * Constant that defines the correct validation status
// */
// public static final int VALIDATION_OK = 0;
//
//
// /**
// * Constant that defines the warning validation status
// */
// public static final int VALIDATION_WARNING = 1;
//
//
// /**
// * Constant that defines the error validation status
// */
// public static final int VALIDATION_ERROR = 2;
//
//
// /** Stores the current state for the applied validations (VALIDATION_OK / VALIDATION_WARNING / VALIDATION_ERROR) */
// public int validationStatus = 0;
//
//
// /** Stores the list of generated warning or error messages, in the same order as happened. */
// public List<String> failedMessagesList = new ArrayList<String>();
//
//
// /** Stores the list of failure status codes, in the same order as happened. */
// public List<Integer> failedStatusList = new ArrayList<Integer>();
//
//
// /** Stores the last error message generated by a validation error / warning or empty string if no validation errors happened */
// public String lastMessage = "";
//
//
// /**
// * Validation will fail if specified value is not a true boolean value
// *
// * @param value A boolean expression to validate
// * @param errorMessage The error message that will be generated if validation fails
// * @param isWarning Tells if the validation fail will be processed as a validation error or a validation warning
// *
// * @return False in case the validation fails or true if validation succeeds.
// */
// public Boolean isTrue(boolean value, Optional<String> errorMessage, Optional<Boolean> isWarning){
//
// // Set optional parameters default values
// String errorMes = (!errorMessage.isPresent()) ? "value is not true" : errorMessage.get();
// Boolean isWarn = (!isWarning.isPresent()) ? false : isWarning.get();
//
// String res = (value != true) ? errorMes : "";
//
// this._updateValidationStatus(res, isWarn);
//
// return (res == "");
// }
//
//
// /**
// * Update the class validation Status depending on the provided error message.
// *
// * @param errorMessage The error message that's been generated from a previously executed validation method
// * @param isWarning Tells if the validation fail will be processed as a validation error or a validation warning
// *
// * @return void
// */
// private void _updateValidationStatus(String errorMessage, Boolean isWarning){
//
// // TODO
// }
// }
| import java.util.Arrays;
import org.turbocommons.managers.ValidationManager;
| /**
* TurboCommons is a general purpose and cross-language library that implements frequently used and generic software development tasks.
*
* Website : -> http://www.turbocommons.org
* License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
* License Url : -> http://www.apache.org/licenses/LICENSE-2.0
* CopyRight : -> Copyright 2015 Edertone Advanded Solutions (08211 Castellar del Vallès, Barcelona). http://www.edertone.com
*/
package org.turbocommons.utils;
/**
* Utilities to perform common array operations
*/
public class ArrayUtils {
/**
* Check if two provided arrays are identical
*
* @param {array} array1 First array to compare
* @param {array} array2 Second array to compare
*
* @returns boolean true if arrays are exactly the same, false if not
*/
public static <T>Boolean isEqual(T[] array1, T[] array2){
| // Path: TurboCommons-Java/src/main/java/org/turbocommons/managers/ValidationManager.java
// public class ValidationManager {
//
// /**
// * Constant that defines the correct validation status
// */
// public static final int VALIDATION_OK = 0;
//
//
// /**
// * Constant that defines the warning validation status
// */
// public static final int VALIDATION_WARNING = 1;
//
//
// /**
// * Constant that defines the error validation status
// */
// public static final int VALIDATION_ERROR = 2;
//
//
// /** Stores the current state for the applied validations (VALIDATION_OK / VALIDATION_WARNING / VALIDATION_ERROR) */
// public int validationStatus = 0;
//
//
// /** Stores the list of generated warning or error messages, in the same order as happened. */
// public List<String> failedMessagesList = new ArrayList<String>();
//
//
// /** Stores the list of failure status codes, in the same order as happened. */
// public List<Integer> failedStatusList = new ArrayList<Integer>();
//
//
// /** Stores the last error message generated by a validation error / warning or empty string if no validation errors happened */
// public String lastMessage = "";
//
//
// /**
// * Validation will fail if specified value is not a true boolean value
// *
// * @param value A boolean expression to validate
// * @param errorMessage The error message that will be generated if validation fails
// * @param isWarning Tells if the validation fail will be processed as a validation error or a validation warning
// *
// * @return False in case the validation fails or true if validation succeeds.
// */
// public Boolean isTrue(boolean value, Optional<String> errorMessage, Optional<Boolean> isWarning){
//
// // Set optional parameters default values
// String errorMes = (!errorMessage.isPresent()) ? "value is not true" : errorMessage.get();
// Boolean isWarn = (!isWarning.isPresent()) ? false : isWarning.get();
//
// String res = (value != true) ? errorMes : "";
//
// this._updateValidationStatus(res, isWarn);
//
// return (res == "");
// }
//
//
// /**
// * Update the class validation Status depending on the provided error message.
// *
// * @param errorMessage The error message that's been generated from a previously executed validation method
// * @param isWarning Tells if the validation fail will be processed as a validation error or a validation warning
// *
// * @return void
// */
// private void _updateValidationStatus(String errorMessage, Boolean isWarning){
//
// // TODO
// }
// }
// Path: TurboCommons-Java/src/main/java/org/turbocommons/utils/ArrayUtils.java
import java.util.Arrays;
import org.turbocommons.managers.ValidationManager;
/**
* TurboCommons is a general purpose and cross-language library that implements frequently used and generic software development tasks.
*
* Website : -> http://www.turbocommons.org
* License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
* License Url : -> http://www.apache.org/licenses/LICENSE-2.0
* CopyRight : -> Copyright 2015 Edertone Advanded Solutions (08211 Castellar del Vallès, Barcelona). http://www.edertone.com
*/
package org.turbocommons.utils;
/**
* Utilities to perform common array operations
*/
public class ArrayUtils {
/**
* Check if two provided arrays are identical
*
* @param {array} array1 First array to compare
* @param {array} array2 Second array to compare
*
* @returns boolean true if arrays are exactly the same, false if not
*/
public static <T>Boolean isEqual(T[] array1, T[] array2){
| ValidationManager validationManager = new ValidationManager();
|
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/conduit/Differential.java | // Path: src/main/java/com/uber/jenkins/phabricator/PhabricatorPostbuildAction.java
// public class PhabricatorPostbuildAction implements BuildBadgeAction {
//
// private final String iconPath;
// private final String text;
// private final String color = "#1FBAD6";
// private final String background = "transparent";
// private final String border = "0";
// private final String borderColor = "transparent";
// private final String link;
//
// private PhabricatorPostbuildAction(String text, String link) {
// this.iconPath = null;
// this.text = text;
// this.link = link;
// }
//
// public static PhabricatorPostbuildAction createShortText(String text, String link) {
// return new PhabricatorPostbuildAction(text, link);
// }
//
// public String getIconFileName() {
// return null;
// }
//
// public String getDisplayName() {
// return "";
// }
//
// /* Action methods */
// public String getUrlName() {
// return "";
// }
//
// @Exported
// public boolean isTextOnly() {
// return (iconPath == null);
// }
//
// @Exported
// public String getIconPath() {
// return iconPath;
// }
//
// @Exported
// public String getText() {
// return text;
// }
//
// @Exported
// public String getColor() {
// return color;
// }
//
// @Exported
// public String getBackground() {
// return background;
// }
//
// @Exported
// public String getBorder() {
// return border;
// }
//
// @Exported
// public String getBorderColor() {
// return borderColor;
// }
//
// @Exported
// public String getLink() {
// return link;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/PhabricatorPostbuildSummaryAction.java
// @ExportedBean(defaultVisibility = 2)
// public class PhabricatorPostbuildSummaryAction implements Action {
//
// private final String iconPath;
// private final String url;
// private final String diffID;
// private final String revisionID;
// private final String authorName;
// private final String authorEmail;
// private final String commitMessage;
//
// public PhabricatorPostbuildSummaryAction(
// String iconPath, String phabricatorLink, String diffID, String revisionID,
// String authorName, String authorEmail, String commitMessage) {
// this.iconPath = iconPath;
// this.url = phabricatorLink;
// this.diffID = diffID;
// this.revisionID = revisionID;
// this.authorName = authorName;
// this.authorEmail = authorEmail;
// this.commitMessage = commitMessage;
// }
//
// public String getIconFileName() {
// return null;
// }
//
// public String getDisplayName() {
// return "";
// }
//
// /* Action methods */
// public String getUrlName() {
// return "";
// }
//
// @Exported
// public String getIconPath() {
// return PhabricatorPlugin.getIconPath(iconPath);
// }
//
// @Exported
// public String getUrl() {
// return url;
// }
//
// @Exported
// public String getRevisionID() {
// return revisionID;
// }
//
// @Exported
// public String getDiffID() {
// return diffID;
// }
//
// @Exported
// public String getAuthorName() {
// return authorName;
// }
//
// @Exported
// public String getAuthorEmail() {
// return authorEmail;
// }
//
// @Exported
// public String getCommitMessage() {
// return commitMessage;
// }
// }
| import java.util.Set;
import hudson.model.Run;
import com.uber.jenkins.phabricator.PhabricatorPostbuildAction;
import com.uber.jenkins.phabricator.PhabricatorPostbuildSummaryAction;
import net.sf.json.JSONArray;
import net.sf.json.JSONNull;
import net.sf.json.JSONObject;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet; | if (rawDiffId == null || rawDiffId.equals("")) {
return null;
}
return rawDiffId;
}
public String getRevisionID(boolean formatted) {
Object rawRevisionIdObj = rawJSON.get("revisionID");
String rawRevisionId = rawRevisionIdObj != null && !(rawRevisionIdObj instanceof net.sf.json.JSONNull) ? (String) rawRevisionIdObj : null;
if (rawRevisionId == null || rawRevisionId.equals("")) {
return null;
}
if (formatted) {
return String.format("D%s", rawRevisionId);
}
return rawRevisionId;
}
public String getPhabricatorLink(String phabricatorURL) {
String revisionID = getRevisionID(true);
try {
URL base = new URL(phabricatorURL);
return new URL(base, revisionID).toString();
} catch (MalformedURLException e) {
return String.format("%s%s", phabricatorURL, revisionID);
}
}
public void decorate(Run<?, ?> build, String phabricatorURL) {
// Add a badge next to the build | // Path: src/main/java/com/uber/jenkins/phabricator/PhabricatorPostbuildAction.java
// public class PhabricatorPostbuildAction implements BuildBadgeAction {
//
// private final String iconPath;
// private final String text;
// private final String color = "#1FBAD6";
// private final String background = "transparent";
// private final String border = "0";
// private final String borderColor = "transparent";
// private final String link;
//
// private PhabricatorPostbuildAction(String text, String link) {
// this.iconPath = null;
// this.text = text;
// this.link = link;
// }
//
// public static PhabricatorPostbuildAction createShortText(String text, String link) {
// return new PhabricatorPostbuildAction(text, link);
// }
//
// public String getIconFileName() {
// return null;
// }
//
// public String getDisplayName() {
// return "";
// }
//
// /* Action methods */
// public String getUrlName() {
// return "";
// }
//
// @Exported
// public boolean isTextOnly() {
// return (iconPath == null);
// }
//
// @Exported
// public String getIconPath() {
// return iconPath;
// }
//
// @Exported
// public String getText() {
// return text;
// }
//
// @Exported
// public String getColor() {
// return color;
// }
//
// @Exported
// public String getBackground() {
// return background;
// }
//
// @Exported
// public String getBorder() {
// return border;
// }
//
// @Exported
// public String getBorderColor() {
// return borderColor;
// }
//
// @Exported
// public String getLink() {
// return link;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/PhabricatorPostbuildSummaryAction.java
// @ExportedBean(defaultVisibility = 2)
// public class PhabricatorPostbuildSummaryAction implements Action {
//
// private final String iconPath;
// private final String url;
// private final String diffID;
// private final String revisionID;
// private final String authorName;
// private final String authorEmail;
// private final String commitMessage;
//
// public PhabricatorPostbuildSummaryAction(
// String iconPath, String phabricatorLink, String diffID, String revisionID,
// String authorName, String authorEmail, String commitMessage) {
// this.iconPath = iconPath;
// this.url = phabricatorLink;
// this.diffID = diffID;
// this.revisionID = revisionID;
// this.authorName = authorName;
// this.authorEmail = authorEmail;
// this.commitMessage = commitMessage;
// }
//
// public String getIconFileName() {
// return null;
// }
//
// public String getDisplayName() {
// return "";
// }
//
// /* Action methods */
// public String getUrlName() {
// return "";
// }
//
// @Exported
// public String getIconPath() {
// return PhabricatorPlugin.getIconPath(iconPath);
// }
//
// @Exported
// public String getUrl() {
// return url;
// }
//
// @Exported
// public String getRevisionID() {
// return revisionID;
// }
//
// @Exported
// public String getDiffID() {
// return diffID;
// }
//
// @Exported
// public String getAuthorName() {
// return authorName;
// }
//
// @Exported
// public String getAuthorEmail() {
// return authorEmail;
// }
//
// @Exported
// public String getCommitMessage() {
// return commitMessage;
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/Differential.java
import java.util.Set;
import hudson.model.Run;
import com.uber.jenkins.phabricator.PhabricatorPostbuildAction;
import com.uber.jenkins.phabricator.PhabricatorPostbuildSummaryAction;
import net.sf.json.JSONArray;
import net.sf.json.JSONNull;
import net.sf.json.JSONObject;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
if (rawDiffId == null || rawDiffId.equals("")) {
return null;
}
return rawDiffId;
}
public String getRevisionID(boolean formatted) {
Object rawRevisionIdObj = rawJSON.get("revisionID");
String rawRevisionId = rawRevisionIdObj != null && !(rawRevisionIdObj instanceof net.sf.json.JSONNull) ? (String) rawRevisionIdObj : null;
if (rawRevisionId == null || rawRevisionId.equals("")) {
return null;
}
if (formatted) {
return String.format("D%s", rawRevisionId);
}
return rawRevisionId;
}
public String getPhabricatorLink(String phabricatorURL) {
String revisionID = getRevisionID(true);
try {
URL base = new URL(phabricatorURL);
return new URL(base, revisionID).toString();
} catch (MalformedURLException e) {
return String.format("%s%s", phabricatorURL, revisionID);
}
}
public void decorate(Run<?, ?> build, String phabricatorURL) {
// Add a badge next to the build | build.addAction(PhabricatorPostbuildAction.createShortText( |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/conduit/Differential.java | // Path: src/main/java/com/uber/jenkins/phabricator/PhabricatorPostbuildAction.java
// public class PhabricatorPostbuildAction implements BuildBadgeAction {
//
// private final String iconPath;
// private final String text;
// private final String color = "#1FBAD6";
// private final String background = "transparent";
// private final String border = "0";
// private final String borderColor = "transparent";
// private final String link;
//
// private PhabricatorPostbuildAction(String text, String link) {
// this.iconPath = null;
// this.text = text;
// this.link = link;
// }
//
// public static PhabricatorPostbuildAction createShortText(String text, String link) {
// return new PhabricatorPostbuildAction(text, link);
// }
//
// public String getIconFileName() {
// return null;
// }
//
// public String getDisplayName() {
// return "";
// }
//
// /* Action methods */
// public String getUrlName() {
// return "";
// }
//
// @Exported
// public boolean isTextOnly() {
// return (iconPath == null);
// }
//
// @Exported
// public String getIconPath() {
// return iconPath;
// }
//
// @Exported
// public String getText() {
// return text;
// }
//
// @Exported
// public String getColor() {
// return color;
// }
//
// @Exported
// public String getBackground() {
// return background;
// }
//
// @Exported
// public String getBorder() {
// return border;
// }
//
// @Exported
// public String getBorderColor() {
// return borderColor;
// }
//
// @Exported
// public String getLink() {
// return link;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/PhabricatorPostbuildSummaryAction.java
// @ExportedBean(defaultVisibility = 2)
// public class PhabricatorPostbuildSummaryAction implements Action {
//
// private final String iconPath;
// private final String url;
// private final String diffID;
// private final String revisionID;
// private final String authorName;
// private final String authorEmail;
// private final String commitMessage;
//
// public PhabricatorPostbuildSummaryAction(
// String iconPath, String phabricatorLink, String diffID, String revisionID,
// String authorName, String authorEmail, String commitMessage) {
// this.iconPath = iconPath;
// this.url = phabricatorLink;
// this.diffID = diffID;
// this.revisionID = revisionID;
// this.authorName = authorName;
// this.authorEmail = authorEmail;
// this.commitMessage = commitMessage;
// }
//
// public String getIconFileName() {
// return null;
// }
//
// public String getDisplayName() {
// return "";
// }
//
// /* Action methods */
// public String getUrlName() {
// return "";
// }
//
// @Exported
// public String getIconPath() {
// return PhabricatorPlugin.getIconPath(iconPath);
// }
//
// @Exported
// public String getUrl() {
// return url;
// }
//
// @Exported
// public String getRevisionID() {
// return revisionID;
// }
//
// @Exported
// public String getDiffID() {
// return diffID;
// }
//
// @Exported
// public String getAuthorName() {
// return authorName;
// }
//
// @Exported
// public String getAuthorEmail() {
// return authorEmail;
// }
//
// @Exported
// public String getCommitMessage() {
// return commitMessage;
// }
// }
| import java.util.Set;
import hudson.model.Run;
import com.uber.jenkins.phabricator.PhabricatorPostbuildAction;
import com.uber.jenkins.phabricator.PhabricatorPostbuildSummaryAction;
import net.sf.json.JSONArray;
import net.sf.json.JSONNull;
import net.sf.json.JSONObject;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet; | }
public String getRevisionID(boolean formatted) {
Object rawRevisionIdObj = rawJSON.get("revisionID");
String rawRevisionId = rawRevisionIdObj != null && !(rawRevisionIdObj instanceof net.sf.json.JSONNull) ? (String) rawRevisionIdObj : null;
if (rawRevisionId == null || rawRevisionId.equals("")) {
return null;
}
if (formatted) {
return String.format("D%s", rawRevisionId);
}
return rawRevisionId;
}
public String getPhabricatorLink(String phabricatorURL) {
String revisionID = getRevisionID(true);
try {
URL base = new URL(phabricatorURL);
return new URL(base, revisionID).toString();
} catch (MalformedURLException e) {
return String.format("%s%s", phabricatorURL, revisionID);
}
}
public void decorate(Run<?, ?> build, String phabricatorURL) {
// Add a badge next to the build
build.addAction(PhabricatorPostbuildAction.createShortText(
getRevisionID(true),
getPhabricatorLink(phabricatorURL)));
// Add some long-form text | // Path: src/main/java/com/uber/jenkins/phabricator/PhabricatorPostbuildAction.java
// public class PhabricatorPostbuildAction implements BuildBadgeAction {
//
// private final String iconPath;
// private final String text;
// private final String color = "#1FBAD6";
// private final String background = "transparent";
// private final String border = "0";
// private final String borderColor = "transparent";
// private final String link;
//
// private PhabricatorPostbuildAction(String text, String link) {
// this.iconPath = null;
// this.text = text;
// this.link = link;
// }
//
// public static PhabricatorPostbuildAction createShortText(String text, String link) {
// return new PhabricatorPostbuildAction(text, link);
// }
//
// public String getIconFileName() {
// return null;
// }
//
// public String getDisplayName() {
// return "";
// }
//
// /* Action methods */
// public String getUrlName() {
// return "";
// }
//
// @Exported
// public boolean isTextOnly() {
// return (iconPath == null);
// }
//
// @Exported
// public String getIconPath() {
// return iconPath;
// }
//
// @Exported
// public String getText() {
// return text;
// }
//
// @Exported
// public String getColor() {
// return color;
// }
//
// @Exported
// public String getBackground() {
// return background;
// }
//
// @Exported
// public String getBorder() {
// return border;
// }
//
// @Exported
// public String getBorderColor() {
// return borderColor;
// }
//
// @Exported
// public String getLink() {
// return link;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/PhabricatorPostbuildSummaryAction.java
// @ExportedBean(defaultVisibility = 2)
// public class PhabricatorPostbuildSummaryAction implements Action {
//
// private final String iconPath;
// private final String url;
// private final String diffID;
// private final String revisionID;
// private final String authorName;
// private final String authorEmail;
// private final String commitMessage;
//
// public PhabricatorPostbuildSummaryAction(
// String iconPath, String phabricatorLink, String diffID, String revisionID,
// String authorName, String authorEmail, String commitMessage) {
// this.iconPath = iconPath;
// this.url = phabricatorLink;
// this.diffID = diffID;
// this.revisionID = revisionID;
// this.authorName = authorName;
// this.authorEmail = authorEmail;
// this.commitMessage = commitMessage;
// }
//
// public String getIconFileName() {
// return null;
// }
//
// public String getDisplayName() {
// return "";
// }
//
// /* Action methods */
// public String getUrlName() {
// return "";
// }
//
// @Exported
// public String getIconPath() {
// return PhabricatorPlugin.getIconPath(iconPath);
// }
//
// @Exported
// public String getUrl() {
// return url;
// }
//
// @Exported
// public String getRevisionID() {
// return revisionID;
// }
//
// @Exported
// public String getDiffID() {
// return diffID;
// }
//
// @Exported
// public String getAuthorName() {
// return authorName;
// }
//
// @Exported
// public String getAuthorEmail() {
// return authorEmail;
// }
//
// @Exported
// public String getCommitMessage() {
// return commitMessage;
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/Differential.java
import java.util.Set;
import hudson.model.Run;
import com.uber.jenkins.phabricator.PhabricatorPostbuildAction;
import com.uber.jenkins.phabricator.PhabricatorPostbuildSummaryAction;
import net.sf.json.JSONArray;
import net.sf.json.JSONNull;
import net.sf.json.JSONObject;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
}
public String getRevisionID(boolean formatted) {
Object rawRevisionIdObj = rawJSON.get("revisionID");
String rawRevisionId = rawRevisionIdObj != null && !(rawRevisionIdObj instanceof net.sf.json.JSONNull) ? (String) rawRevisionIdObj : null;
if (rawRevisionId == null || rawRevisionId.equals("")) {
return null;
}
if (formatted) {
return String.format("D%s", rawRevisionId);
}
return rawRevisionId;
}
public String getPhabricatorLink(String phabricatorURL) {
String revisionID = getRevisionID(true);
try {
URL base = new URL(phabricatorURL);
return new URL(base, revisionID).toString();
} catch (MalformedURLException e) {
return String.format("%s%s", phabricatorURL, revisionID);
}
}
public void decorate(Run<?, ?> build, String phabricatorURL) {
// Add a badge next to the build
build.addAction(PhabricatorPostbuildAction.createShortText(
getRevisionID(true),
getPhabricatorLink(phabricatorURL)));
// Add some long-form text | PhabricatorPostbuildSummaryAction summary = createSummary(phabricatorURL); |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/RemoteFileFetcher.java | // Path: src/main/java/com/uber/jenkins/phabricator/utils/CommonUtils.java
// public class CommonUtils {
//
// public static boolean isBlank(String str) {
// return str == null || str.trim().isEmpty();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
| import static java.lang.Integer.parseInt;
import com.uber.jenkins.phabricator.utils.CommonUtils;
import com.uber.jenkins.phabricator.utils.Logger;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import hudson.FilePath; | // Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator;
public class RemoteFileFetcher {
private static final int DEFAULT_MAX_SIZE = 1000;
private static final String LOGGER_TAG = "file-fetcher";
private final FilePath workspace; | // Path: src/main/java/com/uber/jenkins/phabricator/utils/CommonUtils.java
// public class CommonUtils {
//
// public static boolean isBlank(String str) {
// return str == null || str.trim().isEmpty();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/RemoteFileFetcher.java
import static java.lang.Integer.parseInt;
import com.uber.jenkins.phabricator.utils.CommonUtils;
import com.uber.jenkins.phabricator.utils.Logger;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import hudson.FilePath;
// Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator;
public class RemoteFileFetcher {
private static final int DEFAULT_MAX_SIZE = 1000;
private static final String LOGGER_TAG = "file-fetcher";
private final FilePath workspace; | private final Logger logger; |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/RemoteFileFetcher.java | // Path: src/main/java/com/uber/jenkins/phabricator/utils/CommonUtils.java
// public class CommonUtils {
//
// public static boolean isBlank(String str) {
// return str == null || str.trim().isEmpty();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
| import static java.lang.Integer.parseInt;
import com.uber.jenkins.phabricator.utils.CommonUtils;
import com.uber.jenkins.phabricator.utils.Logger;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import hudson.FilePath; | // Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator;
public class RemoteFileFetcher {
private static final int DEFAULT_MAX_SIZE = 1000;
private static final String LOGGER_TAG = "file-fetcher";
private final FilePath workspace;
private final Logger logger;
private final String fileName;
private final String maxSize;
public RemoteFileFetcher(FilePath workspace, Logger logger, String fileName, String maxSize) {
this.workspace = workspace;
this.logger = logger;
this.fileName = fileName;
this.maxSize = maxSize;
}
/**
* Attempt to read a remote file
*
* @return the content of the remote comment file, if present
* @throws InterruptedException if there is an error fetching the file
* @throws IOException if any network error occurs
*/
public String getRemoteFile() throws InterruptedException, IOException { | // Path: src/main/java/com/uber/jenkins/phabricator/utils/CommonUtils.java
// public class CommonUtils {
//
// public static boolean isBlank(String str) {
// return str == null || str.trim().isEmpty();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/RemoteFileFetcher.java
import static java.lang.Integer.parseInt;
import com.uber.jenkins.phabricator.utils.CommonUtils;
import com.uber.jenkins.phabricator.utils.Logger;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import hudson.FilePath;
// Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator;
public class RemoteFileFetcher {
private static final int DEFAULT_MAX_SIZE = 1000;
private static final String LOGGER_TAG = "file-fetcher";
private final FilePath workspace;
private final Logger logger;
private final String fileName;
private final String maxSize;
public RemoteFileFetcher(FilePath workspace, Logger logger, String fileName, String maxSize) {
this.workspace = workspace;
this.logger = logger;
this.fileName = fileName;
this.maxSize = maxSize;
}
/**
* Attempt to read a remote file
*
* @return the content of the remote comment file, if present
* @throws InterruptedException if there is an error fetching the file
* @throws IOException if any network error occurs
*/
public String getRemoteFile() throws InterruptedException, IOException { | if (CommonUtils.isBlank(fileName)) { |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/conduit/HarbormasterClient.java | // Path: src/main/java/com/uber/jenkins/phabricator/lint/LintResults.java
// public class LintResults {
//
// private final List<LintResult> results;
//
// public LintResults() {
// this.results = new ArrayList<LintResult>();
// }
//
// public void add(LintResult result) {
// results.add(result);
// }
//
// public List<LintResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (LintResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitResults.java
// public class UnitResults {
//
// private final List<UnitResult> results;
//
// public UnitResults() {
// this.results = new ArrayList<UnitResult>();
// }
//
// public void add(UnitResult result) {
// results.add(result);
// }
//
// public List<UnitResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (UnitResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
| import com.uber.jenkins.phabricator.lint.LintResults;
import com.uber.jenkins.phabricator.unit.UnitResults;
import net.sf.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; | package com.uber.jenkins.phabricator.conduit;
public class HarbormasterClient {
/**
* See https://secure.phabricator.com/conduit/method/harbormaster.sendmessage/
*/
public enum MessageType {
pass,
fail,
work,
}
private final ConduitAPIClient conduit;
public HarbormasterClient(ConduitAPIClient conduit) {
this.conduit = conduit;
}
/**
* Sets a sendHarbormasterMessage build status
*
* @param phid Phabricator object ID
* @param messageType type of message to send; either 'pass', 'fail' or 'work'
* @param unitResults the results from the unit tests
* @param coverage the results from the coverage provider
* @param lintResults
* @return the Conduit API response
* @throws IOException if there is a network error talking to Conduit
* @throws ConduitAPIException if any error is experienced talking to Conduit
*/
public JSONObject sendHarbormasterMessage(
String phid,
MessageType messageType, | // Path: src/main/java/com/uber/jenkins/phabricator/lint/LintResults.java
// public class LintResults {
//
// private final List<LintResult> results;
//
// public LintResults() {
// this.results = new ArrayList<LintResult>();
// }
//
// public void add(LintResult result) {
// results.add(result);
// }
//
// public List<LintResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (LintResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitResults.java
// public class UnitResults {
//
// private final List<UnitResult> results;
//
// public UnitResults() {
// this.results = new ArrayList<UnitResult>();
// }
//
// public void add(UnitResult result) {
// results.add(result);
// }
//
// public List<UnitResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (UnitResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/HarbormasterClient.java
import com.uber.jenkins.phabricator.lint.LintResults;
import com.uber.jenkins.phabricator.unit.UnitResults;
import net.sf.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
package com.uber.jenkins.phabricator.conduit;
public class HarbormasterClient {
/**
* See https://secure.phabricator.com/conduit/method/harbormaster.sendmessage/
*/
public enum MessageType {
pass,
fail,
work,
}
private final ConduitAPIClient conduit;
public HarbormasterClient(ConduitAPIClient conduit) {
this.conduit = conduit;
}
/**
* Sets a sendHarbormasterMessage build status
*
* @param phid Phabricator object ID
* @param messageType type of message to send; either 'pass', 'fail' or 'work'
* @param unitResults the results from the unit tests
* @param coverage the results from the coverage provider
* @param lintResults
* @return the Conduit API response
* @throws IOException if there is a network error talking to Conduit
* @throws ConduitAPIException if any error is experienced talking to Conduit
*/
public JSONObject sendHarbormasterMessage(
String phid,
MessageType messageType, | UnitResults unitResults, |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/conduit/HarbormasterClient.java | // Path: src/main/java/com/uber/jenkins/phabricator/lint/LintResults.java
// public class LintResults {
//
// private final List<LintResult> results;
//
// public LintResults() {
// this.results = new ArrayList<LintResult>();
// }
//
// public void add(LintResult result) {
// results.add(result);
// }
//
// public List<LintResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (LintResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitResults.java
// public class UnitResults {
//
// private final List<UnitResult> results;
//
// public UnitResults() {
// this.results = new ArrayList<UnitResult>();
// }
//
// public void add(UnitResult result) {
// results.add(result);
// }
//
// public List<UnitResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (UnitResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
| import com.uber.jenkins.phabricator.lint.LintResults;
import com.uber.jenkins.phabricator.unit.UnitResults;
import net.sf.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; | package com.uber.jenkins.phabricator.conduit;
public class HarbormasterClient {
/**
* See https://secure.phabricator.com/conduit/method/harbormaster.sendmessage/
*/
public enum MessageType {
pass,
fail,
work,
}
private final ConduitAPIClient conduit;
public HarbormasterClient(ConduitAPIClient conduit) {
this.conduit = conduit;
}
/**
* Sets a sendHarbormasterMessage build status
*
* @param phid Phabricator object ID
* @param messageType type of message to send; either 'pass', 'fail' or 'work'
* @param unitResults the results from the unit tests
* @param coverage the results from the coverage provider
* @param lintResults
* @return the Conduit API response
* @throws IOException if there is a network error talking to Conduit
* @throws ConduitAPIException if any error is experienced talking to Conduit
*/
public JSONObject sendHarbormasterMessage(
String phid,
MessageType messageType,
UnitResults unitResults,
Map<String, String> coverage, | // Path: src/main/java/com/uber/jenkins/phabricator/lint/LintResults.java
// public class LintResults {
//
// private final List<LintResult> results;
//
// public LintResults() {
// this.results = new ArrayList<LintResult>();
// }
//
// public void add(LintResult result) {
// results.add(result);
// }
//
// public List<LintResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (LintResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitResults.java
// public class UnitResults {
//
// private final List<UnitResult> results;
//
// public UnitResults() {
// this.results = new ArrayList<UnitResult>();
// }
//
// public void add(UnitResult result) {
// results.add(result);
// }
//
// public List<UnitResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (UnitResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/HarbormasterClient.java
import com.uber.jenkins.phabricator.lint.LintResults;
import com.uber.jenkins.phabricator.unit.UnitResults;
import net.sf.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
package com.uber.jenkins.phabricator.conduit;
public class HarbormasterClient {
/**
* See https://secure.phabricator.com/conduit/method/harbormaster.sendmessage/
*/
public enum MessageType {
pass,
fail,
work,
}
private final ConduitAPIClient conduit;
public HarbormasterClient(ConduitAPIClient conduit) {
this.conduit = conduit;
}
/**
* Sets a sendHarbormasterMessage build status
*
* @param phid Phabricator object ID
* @param messageType type of message to send; either 'pass', 'fail' or 'work'
* @param unitResults the results from the unit tests
* @param coverage the results from the coverage provider
* @param lintResults
* @return the Conduit API response
* @throws IOException if there is a network error talking to Conduit
* @throws ConduitAPIException if any error is experienced talking to Conduit
*/
public JSONObject sendHarbormasterMessage(
String phid,
MessageType messageType,
UnitResults unitResults,
Map<String, String> coverage, | LintResults lintResults) throws ConduitAPIException, IOException { |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/tasks/ApplyPatchTask.java | // Path: src/main/java/com/uber/jenkins/phabricator/LauncherFactory.java
// public class LauncherFactory {
//
// private final Launcher launcher;
// private final PrintStream stderr;
// private final EnvVars environment;
// private final FilePath pwd;
//
// public LauncherFactory(Launcher launcher, EnvVars environment, PrintStream stderr, FilePath pwd) {
// this.launcher = launcher;
// this.environment = environment;
// this.stderr = stderr;
// this.pwd = pwd;
// }
//
// public PrintStream getStderr() {
// return this.stderr;
// }
//
// /**
// * Create a launcher
// *
// * @return a launcher suitable for executing programs within Jenkins
// */
// public Launcher.ProcStarter launch() {
// return launcher.launch().envs(environment).stderr(stderr).pwd(pwd);
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/ArcanistClient.java
// public class ArcanistClient {
//
// private final String arcPath;
// private final String methodName;
// private final String conduitUrl;
// private final String conduitToken;
// private final String[] arguments;
//
// public ArcanistClient(
// String arcPath,
// String methodName,
// String conduitUrl,
// String conduitToken,
// String... arguments) {
// this.arcPath = arcPath;
// this.methodName = methodName;
// this.conduitUrl = conduitUrl;
// this.conduitToken = conduitToken;
// this.arguments = arguments;
// }
//
// private ArgumentListBuilder getConduitCommand() {
// ArgumentListBuilder builder = new ArgumentListBuilder(this.arcPath, this.methodName);
// builder.add(arguments);
//
// if (!CommonUtils.isBlank(this.conduitUrl)) {
// builder.add("--conduit-uri=" + this.conduitUrl);
// }
//
// if (!CommonUtils.isBlank(this.conduitToken)) {
// builder.addMasked("--conduit-token=" + this.conduitToken);
// }
// return builder;
// }
//
// private Launcher.ProcStarter getCommand(Launcher.ProcStarter starter) throws IOException {
// return starter.cmds(this.getConduitCommand());
// }
//
// public int callConduit(Launcher.ProcStarter starter, PrintStream stderr) throws IOException, InterruptedException {
// Launcher.ProcStarter command = this.getCommand(starter);
// return command.stdout(stderr).stderr(stderr).join();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
| import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import com.google.common.annotations.VisibleForTesting;
import com.uber.jenkins.phabricator.LauncherFactory;
import com.uber.jenkins.phabricator.conduit.ArcanistClient;
import com.uber.jenkins.phabricator.utils.Logger;
import hudson.model.Computer;
import org.apache.commons.lang.StringUtils;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList; | // Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator.tasks;
public class ApplyPatchTask extends Task {
private static final String DEFAULT_GIT_PATH = "git";
private static final String DEFAULT_HG_PATH = "hg";
| // Path: src/main/java/com/uber/jenkins/phabricator/LauncherFactory.java
// public class LauncherFactory {
//
// private final Launcher launcher;
// private final PrintStream stderr;
// private final EnvVars environment;
// private final FilePath pwd;
//
// public LauncherFactory(Launcher launcher, EnvVars environment, PrintStream stderr, FilePath pwd) {
// this.launcher = launcher;
// this.environment = environment;
// this.stderr = stderr;
// this.pwd = pwd;
// }
//
// public PrintStream getStderr() {
// return this.stderr;
// }
//
// /**
// * Create a launcher
// *
// * @return a launcher suitable for executing programs within Jenkins
// */
// public Launcher.ProcStarter launch() {
// return launcher.launch().envs(environment).stderr(stderr).pwd(pwd);
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/ArcanistClient.java
// public class ArcanistClient {
//
// private final String arcPath;
// private final String methodName;
// private final String conduitUrl;
// private final String conduitToken;
// private final String[] arguments;
//
// public ArcanistClient(
// String arcPath,
// String methodName,
// String conduitUrl,
// String conduitToken,
// String... arguments) {
// this.arcPath = arcPath;
// this.methodName = methodName;
// this.conduitUrl = conduitUrl;
// this.conduitToken = conduitToken;
// this.arguments = arguments;
// }
//
// private ArgumentListBuilder getConduitCommand() {
// ArgumentListBuilder builder = new ArgumentListBuilder(this.arcPath, this.methodName);
// builder.add(arguments);
//
// if (!CommonUtils.isBlank(this.conduitUrl)) {
// builder.add("--conduit-uri=" + this.conduitUrl);
// }
//
// if (!CommonUtils.isBlank(this.conduitToken)) {
// builder.addMasked("--conduit-token=" + this.conduitToken);
// }
// return builder;
// }
//
// private Launcher.ProcStarter getCommand(Launcher.ProcStarter starter) throws IOException {
// return starter.cmds(this.getConduitCommand());
// }
//
// public int callConduit(Launcher.ProcStarter starter, PrintStream stderr) throws IOException, InterruptedException {
// Launcher.ProcStarter command = this.getCommand(starter);
// return command.stdout(stderr).stderr(stderr).join();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/tasks/ApplyPatchTask.java
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import com.google.common.annotations.VisibleForTesting;
import com.uber.jenkins.phabricator.LauncherFactory;
import com.uber.jenkins.phabricator.conduit.ArcanistClient;
import com.uber.jenkins.phabricator.utils.Logger;
import hudson.model.Computer;
import org.apache.commons.lang.StringUtils;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
// Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator.tasks;
public class ApplyPatchTask extends Task {
private static final String DEFAULT_GIT_PATH = "git";
private static final String DEFAULT_HG_PATH = "hg";
| private final LauncherFactory starter; |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/tasks/ApplyPatchTask.java | // Path: src/main/java/com/uber/jenkins/phabricator/LauncherFactory.java
// public class LauncherFactory {
//
// private final Launcher launcher;
// private final PrintStream stderr;
// private final EnvVars environment;
// private final FilePath pwd;
//
// public LauncherFactory(Launcher launcher, EnvVars environment, PrintStream stderr, FilePath pwd) {
// this.launcher = launcher;
// this.environment = environment;
// this.stderr = stderr;
// this.pwd = pwd;
// }
//
// public PrintStream getStderr() {
// return this.stderr;
// }
//
// /**
// * Create a launcher
// *
// * @return a launcher suitable for executing programs within Jenkins
// */
// public Launcher.ProcStarter launch() {
// return launcher.launch().envs(environment).stderr(stderr).pwd(pwd);
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/ArcanistClient.java
// public class ArcanistClient {
//
// private final String arcPath;
// private final String methodName;
// private final String conduitUrl;
// private final String conduitToken;
// private final String[] arguments;
//
// public ArcanistClient(
// String arcPath,
// String methodName,
// String conduitUrl,
// String conduitToken,
// String... arguments) {
// this.arcPath = arcPath;
// this.methodName = methodName;
// this.conduitUrl = conduitUrl;
// this.conduitToken = conduitToken;
// this.arguments = arguments;
// }
//
// private ArgumentListBuilder getConduitCommand() {
// ArgumentListBuilder builder = new ArgumentListBuilder(this.arcPath, this.methodName);
// builder.add(arguments);
//
// if (!CommonUtils.isBlank(this.conduitUrl)) {
// builder.add("--conduit-uri=" + this.conduitUrl);
// }
//
// if (!CommonUtils.isBlank(this.conduitToken)) {
// builder.addMasked("--conduit-token=" + this.conduitToken);
// }
// return builder;
// }
//
// private Launcher.ProcStarter getCommand(Launcher.ProcStarter starter) throws IOException {
// return starter.cmds(this.getConduitCommand());
// }
//
// public int callConduit(Launcher.ProcStarter starter, PrintStream stderr) throws IOException, InterruptedException {
// Launcher.ProcStarter command = this.getCommand(starter);
// return command.stdout(stderr).stderr(stderr).join();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
| import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import com.google.common.annotations.VisibleForTesting;
import com.uber.jenkins.phabricator.LauncherFactory;
import com.uber.jenkins.phabricator.conduit.ArcanistClient;
import com.uber.jenkins.phabricator.utils.Logger;
import hudson.model.Computer;
import org.apache.commons.lang.StringUtils;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList; | // Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator.tasks;
public class ApplyPatchTask extends Task {
private static final String DEFAULT_GIT_PATH = "git";
private static final String DEFAULT_HG_PATH = "hg";
private final LauncherFactory starter;
private final PrintStream logStream;
private final String scmType;
private String gitPath;
private String hgPath;
private final String arcPath;
private final boolean skipForcedClean;
private final String baseCommit;
private final String conduitUrl;
private final String conduitToken;
private final String diffID;
private final boolean createCommit;
private final boolean createBranch;
private final boolean patchWithForceFlag;
public ApplyPatchTask( | // Path: src/main/java/com/uber/jenkins/phabricator/LauncherFactory.java
// public class LauncherFactory {
//
// private final Launcher launcher;
// private final PrintStream stderr;
// private final EnvVars environment;
// private final FilePath pwd;
//
// public LauncherFactory(Launcher launcher, EnvVars environment, PrintStream stderr, FilePath pwd) {
// this.launcher = launcher;
// this.environment = environment;
// this.stderr = stderr;
// this.pwd = pwd;
// }
//
// public PrintStream getStderr() {
// return this.stderr;
// }
//
// /**
// * Create a launcher
// *
// * @return a launcher suitable for executing programs within Jenkins
// */
// public Launcher.ProcStarter launch() {
// return launcher.launch().envs(environment).stderr(stderr).pwd(pwd);
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/ArcanistClient.java
// public class ArcanistClient {
//
// private final String arcPath;
// private final String methodName;
// private final String conduitUrl;
// private final String conduitToken;
// private final String[] arguments;
//
// public ArcanistClient(
// String arcPath,
// String methodName,
// String conduitUrl,
// String conduitToken,
// String... arguments) {
// this.arcPath = arcPath;
// this.methodName = methodName;
// this.conduitUrl = conduitUrl;
// this.conduitToken = conduitToken;
// this.arguments = arguments;
// }
//
// private ArgumentListBuilder getConduitCommand() {
// ArgumentListBuilder builder = new ArgumentListBuilder(this.arcPath, this.methodName);
// builder.add(arguments);
//
// if (!CommonUtils.isBlank(this.conduitUrl)) {
// builder.add("--conduit-uri=" + this.conduitUrl);
// }
//
// if (!CommonUtils.isBlank(this.conduitToken)) {
// builder.addMasked("--conduit-token=" + this.conduitToken);
// }
// return builder;
// }
//
// private Launcher.ProcStarter getCommand(Launcher.ProcStarter starter) throws IOException {
// return starter.cmds(this.getConduitCommand());
// }
//
// public int callConduit(Launcher.ProcStarter starter, PrintStream stderr) throws IOException, InterruptedException {
// Launcher.ProcStarter command = this.getCommand(starter);
// return command.stdout(stderr).stderr(stderr).join();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/tasks/ApplyPatchTask.java
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import com.google.common.annotations.VisibleForTesting;
import com.uber.jenkins.phabricator.LauncherFactory;
import com.uber.jenkins.phabricator.conduit.ArcanistClient;
import com.uber.jenkins.phabricator.utils.Logger;
import hudson.model.Computer;
import org.apache.commons.lang.StringUtils;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
// Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator.tasks;
public class ApplyPatchTask extends Task {
private static final String DEFAULT_GIT_PATH = "git";
private static final String DEFAULT_HG_PATH = "hg";
private final LauncherFactory starter;
private final PrintStream logStream;
private final String scmType;
private String gitPath;
private String hgPath;
private final String arcPath;
private final boolean skipForcedClean;
private final String baseCommit;
private final String conduitUrl;
private final String conduitToken;
private final String diffID;
private final boolean createCommit;
private final boolean createBranch;
private final boolean patchWithForceFlag;
public ApplyPatchTask( | Logger logger, LauncherFactory starter, String baseCommit, |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/tasks/ApplyPatchTask.java | // Path: src/main/java/com/uber/jenkins/phabricator/LauncherFactory.java
// public class LauncherFactory {
//
// private final Launcher launcher;
// private final PrintStream stderr;
// private final EnvVars environment;
// private final FilePath pwd;
//
// public LauncherFactory(Launcher launcher, EnvVars environment, PrintStream stderr, FilePath pwd) {
// this.launcher = launcher;
// this.environment = environment;
// this.stderr = stderr;
// this.pwd = pwd;
// }
//
// public PrintStream getStderr() {
// return this.stderr;
// }
//
// /**
// * Create a launcher
// *
// * @return a launcher suitable for executing programs within Jenkins
// */
// public Launcher.ProcStarter launch() {
// return launcher.launch().envs(environment).stderr(stderr).pwd(pwd);
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/ArcanistClient.java
// public class ArcanistClient {
//
// private final String arcPath;
// private final String methodName;
// private final String conduitUrl;
// private final String conduitToken;
// private final String[] arguments;
//
// public ArcanistClient(
// String arcPath,
// String methodName,
// String conduitUrl,
// String conduitToken,
// String... arguments) {
// this.arcPath = arcPath;
// this.methodName = methodName;
// this.conduitUrl = conduitUrl;
// this.conduitToken = conduitToken;
// this.arguments = arguments;
// }
//
// private ArgumentListBuilder getConduitCommand() {
// ArgumentListBuilder builder = new ArgumentListBuilder(this.arcPath, this.methodName);
// builder.add(arguments);
//
// if (!CommonUtils.isBlank(this.conduitUrl)) {
// builder.add("--conduit-uri=" + this.conduitUrl);
// }
//
// if (!CommonUtils.isBlank(this.conduitToken)) {
// builder.addMasked("--conduit-token=" + this.conduitToken);
// }
// return builder;
// }
//
// private Launcher.ProcStarter getCommand(Launcher.ProcStarter starter) throws IOException {
// return starter.cmds(this.getConduitCommand());
// }
//
// public int callConduit(Launcher.ProcStarter starter, PrintStream stderr) throws IOException, InterruptedException {
// Launcher.ProcStarter command = this.getCommand(starter);
// return command.stdout(stderr).stderr(stderr).join();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
| import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import com.google.common.annotations.VisibleForTesting;
import com.uber.jenkins.phabricator.LauncherFactory;
import com.uber.jenkins.phabricator.conduit.ArcanistClient;
import com.uber.jenkins.phabricator.utils.Logger;
import hudson.model.Computer;
import org.apache.commons.lang.StringUtils;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList; | e.printStackTrace(logStream);
this.result = Result.FAILURE;
}
}
private int applyArcPatch() throws IOException, InterruptedException {
int exitCode;
List<String> arcPatchParams = new ArrayList<String>(Arrays.asList("--diff", diffID));
switch (scmType) {
case "git":
case "hg":
if (!createCommit) {
arcPatchParams.add("--nocommit");
}
if (!createBranch) {
arcPatchParams.add("--nobranch");
}
break;
case "svn":
break;
default:
info("Unknown scm type " + scmType + " skipping");
}
if (patchWithForceFlag) {
arcPatchParams.add("--force");
}
| // Path: src/main/java/com/uber/jenkins/phabricator/LauncherFactory.java
// public class LauncherFactory {
//
// private final Launcher launcher;
// private final PrintStream stderr;
// private final EnvVars environment;
// private final FilePath pwd;
//
// public LauncherFactory(Launcher launcher, EnvVars environment, PrintStream stderr, FilePath pwd) {
// this.launcher = launcher;
// this.environment = environment;
// this.stderr = stderr;
// this.pwd = pwd;
// }
//
// public PrintStream getStderr() {
// return this.stderr;
// }
//
// /**
// * Create a launcher
// *
// * @return a launcher suitable for executing programs within Jenkins
// */
// public Launcher.ProcStarter launch() {
// return launcher.launch().envs(environment).stderr(stderr).pwd(pwd);
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/ArcanistClient.java
// public class ArcanistClient {
//
// private final String arcPath;
// private final String methodName;
// private final String conduitUrl;
// private final String conduitToken;
// private final String[] arguments;
//
// public ArcanistClient(
// String arcPath,
// String methodName,
// String conduitUrl,
// String conduitToken,
// String... arguments) {
// this.arcPath = arcPath;
// this.methodName = methodName;
// this.conduitUrl = conduitUrl;
// this.conduitToken = conduitToken;
// this.arguments = arguments;
// }
//
// private ArgumentListBuilder getConduitCommand() {
// ArgumentListBuilder builder = new ArgumentListBuilder(this.arcPath, this.methodName);
// builder.add(arguments);
//
// if (!CommonUtils.isBlank(this.conduitUrl)) {
// builder.add("--conduit-uri=" + this.conduitUrl);
// }
//
// if (!CommonUtils.isBlank(this.conduitToken)) {
// builder.addMasked("--conduit-token=" + this.conduitToken);
// }
// return builder;
// }
//
// private Launcher.ProcStarter getCommand(Launcher.ProcStarter starter) throws IOException {
// return starter.cmds(this.getConduitCommand());
// }
//
// public int callConduit(Launcher.ProcStarter starter, PrintStream stderr) throws IOException, InterruptedException {
// Launcher.ProcStarter command = this.getCommand(starter);
// return command.stdout(stderr).stderr(stderr).join();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/tasks/ApplyPatchTask.java
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import com.google.common.annotations.VisibleForTesting;
import com.uber.jenkins.phabricator.LauncherFactory;
import com.uber.jenkins.phabricator.conduit.ArcanistClient;
import com.uber.jenkins.phabricator.utils.Logger;
import hudson.model.Computer;
import org.apache.commons.lang.StringUtils;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
e.printStackTrace(logStream);
this.result = Result.FAILURE;
}
}
private int applyArcPatch() throws IOException, InterruptedException {
int exitCode;
List<String> arcPatchParams = new ArrayList<String>(Arrays.asList("--diff", diffID));
switch (scmType) {
case "git":
case "hg":
if (!createCommit) {
arcPatchParams.add("--nocommit");
}
if (!createBranch) {
arcPatchParams.add("--nobranch");
}
break;
case "svn":
break;
default:
info("Unknown scm type " + scmType + " skipping");
}
if (patchWithForceFlag) {
arcPatchParams.add("--force");
}
| ArcanistClient arc = new ArcanistClient( |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/PhabricatorNotifierDescriptor.java | // Path: src/main/java/com/uber/jenkins/phabricator/utils/CommonUtils.java
// public class CommonUtils {
//
// public static boolean isBlank(String str) {
// return str == null || str.trim().isEmpty();
// }
// }
| import hudson.model.AbstractProject;
import hudson.model.Job;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;
import hudson.util.ListBoxModel;
import jenkins.model.Jenkins;
import com.uber.jenkins.phabricator.credentials.ConduitCredentials;
import com.uber.jenkins.phabricator.utils.CommonUtils;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import hudson.Extension; | @Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
// To persist global configuration information,
// set that to properties and call save().
req.bindJSON(this, formData.getJSONObject("uberalls"));
save();
return super.configure(req, formData);
}
@SuppressWarnings("unused")
public ListBoxModel doFillCredentialsIDItems(
@AncestorInPath Jenkins context,
@QueryParameter String remoteBase) {
return ConduitCredentialsDescriptor.doFillCredentialsIDItems(
context);
}
public ConduitCredentials getCredentials(Job owner) {
return ConduitCredentialsDescriptor.getCredentials(owner, credentialsID);
}
public String getCredentialsID() {
return credentialsID;
}
public void setCredentialsID(String credentialsID) {
this.credentialsID = credentialsID;
}
public String getUberallsURL() { | // Path: src/main/java/com/uber/jenkins/phabricator/utils/CommonUtils.java
// public class CommonUtils {
//
// public static boolean isBlank(String str) {
// return str == null || str.trim().isEmpty();
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/PhabricatorNotifierDescriptor.java
import hudson.model.AbstractProject;
import hudson.model.Job;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;
import hudson.util.ListBoxModel;
import jenkins.model.Jenkins;
import com.uber.jenkins.phabricator.credentials.ConduitCredentials;
import com.uber.jenkins.phabricator.utils.CommonUtils;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import hudson.Extension;
@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
// To persist global configuration information,
// set that to properties and call save().
req.bindJSON(this, formData.getJSONObject("uberalls"));
save();
return super.configure(req, formData);
}
@SuppressWarnings("unused")
public ListBoxModel doFillCredentialsIDItems(
@AncestorInPath Jenkins context,
@QueryParameter String remoteBase) {
return ConduitCredentialsDescriptor.doFillCredentialsIDItems(
context);
}
public ConduitCredentials getCredentials(Job owner) {
return ConduitCredentialsDescriptor.getCredentials(owner, credentialsID);
}
public String getCredentialsID() {
return credentialsID;
}
public void setCredentialsID(String credentialsID) {
this.credentialsID = credentialsID;
}
public String getUberallsURL() { | if (!CommonUtils.isBlank(uberallsURL)) { |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/provider/InstanceProvider.java | // Path: src/main/java/com/uber/jenkins/phabricator/unit/JUnitTestProvider.java
// @SuppressWarnings("unused")
// public class JUnitTestProvider extends UnitTestProvider {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public boolean resultsAvailable() {
// return getJUnitResults() != null;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public UnitResults getResults() {
// return convertJUnit(getJUnitResults());
// }
//
// /**
// * Convert JUnit's TestResult representation into a generic UnitResults
// *
// * @param jUnitResults The result of the JUnit run
// * @return The converted results
// */
// public UnitResults convertJUnit(TestResult jUnitResults) {
// UnitResults results = new UnitResults();
// if (jUnitResults == null) {
// return results;
// }
// for (SuiteResult sr : jUnitResults.getSuites()) {
// for (CaseResult cr : sr.getCases()) {
// UnitResult result = new UnitResult(
// cr.getClassName(),
// cr.getDisplayName(),
// cr.getErrorStackTrace(),
// cr.getDuration(),
// cr.getFailCount(),
// cr.getSkipCount(),
// cr.getPassCount()
// );
// results.add(result);
// }
// }
// return results;
// }
//
// private TestResult getJUnitResults() {
// Run<?, ?> build = getBuild();
//
// TestResultAction jUnitAction = build.getAction(TestResultAction.class);
// if (jUnitAction == null) {
// return null;
// }
// return jUnitAction.getResult();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitTestProvider.java
// public abstract class UnitTestProvider {
//
// private Run<?, ?> build;
//
// protected Run<?, ?> getBuild() {
// return build;
// }
//
// /**
// * Set the owning build for this provider
// *
// * @param build The build that is associated with the current run
// */
// public void setBuild(Run<?, ?> build) {
// this.build = build;
// }
//
// /**
// * Determine if the current provider has results available for the build
// *
// * @return Whether results are available
// */
// public abstract boolean resultsAvailable();
//
// /**
// * Convert the provider's results to a standard format
// *
// * @return The results of the unit tests
// */
// public abstract UnitResults getResults();
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
| import com.uber.jenkins.phabricator.utils.Logger;
import jenkins.model.Jenkins;
import com.uber.jenkins.phabricator.unit.JUnitTestProvider;
import com.uber.jenkins.phabricator.unit.UnitTestProvider; | // Copyright (c) 2015 Uber
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package com.uber.jenkins.phabricator.provider;
public abstract class InstanceProvider<T> {
private static final String JUNIT_PLUGIN_NAME = "junit";
private static final String LOGGER_TAG = "plugin-provider";
private final Jenkins jenkins;
private final String pluginName; | // Path: src/main/java/com/uber/jenkins/phabricator/unit/JUnitTestProvider.java
// @SuppressWarnings("unused")
// public class JUnitTestProvider extends UnitTestProvider {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public boolean resultsAvailable() {
// return getJUnitResults() != null;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public UnitResults getResults() {
// return convertJUnit(getJUnitResults());
// }
//
// /**
// * Convert JUnit's TestResult representation into a generic UnitResults
// *
// * @param jUnitResults The result of the JUnit run
// * @return The converted results
// */
// public UnitResults convertJUnit(TestResult jUnitResults) {
// UnitResults results = new UnitResults();
// if (jUnitResults == null) {
// return results;
// }
// for (SuiteResult sr : jUnitResults.getSuites()) {
// for (CaseResult cr : sr.getCases()) {
// UnitResult result = new UnitResult(
// cr.getClassName(),
// cr.getDisplayName(),
// cr.getErrorStackTrace(),
// cr.getDuration(),
// cr.getFailCount(),
// cr.getSkipCount(),
// cr.getPassCount()
// );
// results.add(result);
// }
// }
// return results;
// }
//
// private TestResult getJUnitResults() {
// Run<?, ?> build = getBuild();
//
// TestResultAction jUnitAction = build.getAction(TestResultAction.class);
// if (jUnitAction == null) {
// return null;
// }
// return jUnitAction.getResult();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitTestProvider.java
// public abstract class UnitTestProvider {
//
// private Run<?, ?> build;
//
// protected Run<?, ?> getBuild() {
// return build;
// }
//
// /**
// * Set the owning build for this provider
// *
// * @param build The build that is associated with the current run
// */
// public void setBuild(Run<?, ?> build) {
// this.build = build;
// }
//
// /**
// * Determine if the current provider has results available for the build
// *
// * @return Whether results are available
// */
// public abstract boolean resultsAvailable();
//
// /**
// * Convert the provider's results to a standard format
// *
// * @return The results of the unit tests
// */
// public abstract UnitResults getResults();
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/provider/InstanceProvider.java
import com.uber.jenkins.phabricator.utils.Logger;
import jenkins.model.Jenkins;
import com.uber.jenkins.phabricator.unit.JUnitTestProvider;
import com.uber.jenkins.phabricator.unit.UnitTestProvider;
// Copyright (c) 2015 Uber
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package com.uber.jenkins.phabricator.provider;
public abstract class InstanceProvider<T> {
private static final String JUNIT_PLUGIN_NAME = "junit";
private static final String LOGGER_TAG = "plugin-provider";
private final Jenkins jenkins;
private final String pluginName; | private final Logger logger; |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/provider/InstanceProvider.java | // Path: src/main/java/com/uber/jenkins/phabricator/unit/JUnitTestProvider.java
// @SuppressWarnings("unused")
// public class JUnitTestProvider extends UnitTestProvider {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public boolean resultsAvailable() {
// return getJUnitResults() != null;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public UnitResults getResults() {
// return convertJUnit(getJUnitResults());
// }
//
// /**
// * Convert JUnit's TestResult representation into a generic UnitResults
// *
// * @param jUnitResults The result of the JUnit run
// * @return The converted results
// */
// public UnitResults convertJUnit(TestResult jUnitResults) {
// UnitResults results = new UnitResults();
// if (jUnitResults == null) {
// return results;
// }
// for (SuiteResult sr : jUnitResults.getSuites()) {
// for (CaseResult cr : sr.getCases()) {
// UnitResult result = new UnitResult(
// cr.getClassName(),
// cr.getDisplayName(),
// cr.getErrorStackTrace(),
// cr.getDuration(),
// cr.getFailCount(),
// cr.getSkipCount(),
// cr.getPassCount()
// );
// results.add(result);
// }
// }
// return results;
// }
//
// private TestResult getJUnitResults() {
// Run<?, ?> build = getBuild();
//
// TestResultAction jUnitAction = build.getAction(TestResultAction.class);
// if (jUnitAction == null) {
// return null;
// }
// return jUnitAction.getResult();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitTestProvider.java
// public abstract class UnitTestProvider {
//
// private Run<?, ?> build;
//
// protected Run<?, ?> getBuild() {
// return build;
// }
//
// /**
// * Set the owning build for this provider
// *
// * @param build The build that is associated with the current run
// */
// public void setBuild(Run<?, ?> build) {
// this.build = build;
// }
//
// /**
// * Determine if the current provider has results available for the build
// *
// * @return Whether results are available
// */
// public abstract boolean resultsAvailable();
//
// /**
// * Convert the provider's results to a standard format
// *
// * @return The results of the unit tests
// */
// public abstract UnitResults getResults();
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
| import com.uber.jenkins.phabricator.utils.Logger;
import jenkins.model.Jenkins;
import com.uber.jenkins.phabricator.unit.JUnitTestProvider;
import com.uber.jenkins.phabricator.unit.UnitTestProvider; | // Copyright (c) 2015 Uber
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package com.uber.jenkins.phabricator.provider;
public abstract class InstanceProvider<T> {
private static final String JUNIT_PLUGIN_NAME = "junit";
private static final String LOGGER_TAG = "plugin-provider";
private final Jenkins jenkins;
private final String pluginName;
private final Logger logger;
/**
* Encapsulate lazily loading a concrete implementation when a plugin is available
*
* @param jenkins the instance of Jenkins
* @param pluginName the name of the plugin, e.g. "cobertura" or "junit" (maven name)
*/
private InstanceProvider(Jenkins jenkins, String pluginName, Logger logger) {
this.jenkins = jenkins;
this.pluginName = pluginName;
this.logger = logger;
}
| // Path: src/main/java/com/uber/jenkins/phabricator/unit/JUnitTestProvider.java
// @SuppressWarnings("unused")
// public class JUnitTestProvider extends UnitTestProvider {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public boolean resultsAvailable() {
// return getJUnitResults() != null;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public UnitResults getResults() {
// return convertJUnit(getJUnitResults());
// }
//
// /**
// * Convert JUnit's TestResult representation into a generic UnitResults
// *
// * @param jUnitResults The result of the JUnit run
// * @return The converted results
// */
// public UnitResults convertJUnit(TestResult jUnitResults) {
// UnitResults results = new UnitResults();
// if (jUnitResults == null) {
// return results;
// }
// for (SuiteResult sr : jUnitResults.getSuites()) {
// for (CaseResult cr : sr.getCases()) {
// UnitResult result = new UnitResult(
// cr.getClassName(),
// cr.getDisplayName(),
// cr.getErrorStackTrace(),
// cr.getDuration(),
// cr.getFailCount(),
// cr.getSkipCount(),
// cr.getPassCount()
// );
// results.add(result);
// }
// }
// return results;
// }
//
// private TestResult getJUnitResults() {
// Run<?, ?> build = getBuild();
//
// TestResultAction jUnitAction = build.getAction(TestResultAction.class);
// if (jUnitAction == null) {
// return null;
// }
// return jUnitAction.getResult();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitTestProvider.java
// public abstract class UnitTestProvider {
//
// private Run<?, ?> build;
//
// protected Run<?, ?> getBuild() {
// return build;
// }
//
// /**
// * Set the owning build for this provider
// *
// * @param build The build that is associated with the current run
// */
// public void setBuild(Run<?, ?> build) {
// this.build = build;
// }
//
// /**
// * Determine if the current provider has results available for the build
// *
// * @return Whether results are available
// */
// public abstract boolean resultsAvailable();
//
// /**
// * Convert the provider's results to a standard format
// *
// * @return The results of the unit tests
// */
// public abstract UnitResults getResults();
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/provider/InstanceProvider.java
import com.uber.jenkins.phabricator.utils.Logger;
import jenkins.model.Jenkins;
import com.uber.jenkins.phabricator.unit.JUnitTestProvider;
import com.uber.jenkins.phabricator.unit.UnitTestProvider;
// Copyright (c) 2015 Uber
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package com.uber.jenkins.phabricator.provider;
public abstract class InstanceProvider<T> {
private static final String JUNIT_PLUGIN_NAME = "junit";
private static final String LOGGER_TAG = "plugin-provider";
private final Jenkins jenkins;
private final String pluginName;
private final Logger logger;
/**
* Encapsulate lazily loading a concrete implementation when a plugin is available
*
* @param jenkins the instance of Jenkins
* @param pluginName the name of the plugin, e.g. "cobertura" or "junit" (maven name)
*/
private InstanceProvider(Jenkins jenkins, String pluginName, Logger logger) {
this.jenkins = jenkins;
this.pluginName = pluginName;
this.logger = logger;
}
| public static UnitTestProvider getUnitTestProvider(Logger logger) { |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/provider/InstanceProvider.java | // Path: src/main/java/com/uber/jenkins/phabricator/unit/JUnitTestProvider.java
// @SuppressWarnings("unused")
// public class JUnitTestProvider extends UnitTestProvider {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public boolean resultsAvailable() {
// return getJUnitResults() != null;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public UnitResults getResults() {
// return convertJUnit(getJUnitResults());
// }
//
// /**
// * Convert JUnit's TestResult representation into a generic UnitResults
// *
// * @param jUnitResults The result of the JUnit run
// * @return The converted results
// */
// public UnitResults convertJUnit(TestResult jUnitResults) {
// UnitResults results = new UnitResults();
// if (jUnitResults == null) {
// return results;
// }
// for (SuiteResult sr : jUnitResults.getSuites()) {
// for (CaseResult cr : sr.getCases()) {
// UnitResult result = new UnitResult(
// cr.getClassName(),
// cr.getDisplayName(),
// cr.getErrorStackTrace(),
// cr.getDuration(),
// cr.getFailCount(),
// cr.getSkipCount(),
// cr.getPassCount()
// );
// results.add(result);
// }
// }
// return results;
// }
//
// private TestResult getJUnitResults() {
// Run<?, ?> build = getBuild();
//
// TestResultAction jUnitAction = build.getAction(TestResultAction.class);
// if (jUnitAction == null) {
// return null;
// }
// return jUnitAction.getResult();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitTestProvider.java
// public abstract class UnitTestProvider {
//
// private Run<?, ?> build;
//
// protected Run<?, ?> getBuild() {
// return build;
// }
//
// /**
// * Set the owning build for this provider
// *
// * @param build The build that is associated with the current run
// */
// public void setBuild(Run<?, ?> build) {
// this.build = build;
// }
//
// /**
// * Determine if the current provider has results available for the build
// *
// * @return Whether results are available
// */
// public abstract boolean resultsAvailable();
//
// /**
// * Convert the provider's results to a standard format
// *
// * @return The results of the unit tests
// */
// public abstract UnitResults getResults();
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
| import com.uber.jenkins.phabricator.utils.Logger;
import jenkins.model.Jenkins;
import com.uber.jenkins.phabricator.unit.JUnitTestProvider;
import com.uber.jenkins.phabricator.unit.UnitTestProvider; | // Copyright (c) 2015 Uber
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package com.uber.jenkins.phabricator.provider;
public abstract class InstanceProvider<T> {
private static final String JUNIT_PLUGIN_NAME = "junit";
private static final String LOGGER_TAG = "plugin-provider";
private final Jenkins jenkins;
private final String pluginName;
private final Logger logger;
/**
* Encapsulate lazily loading a concrete implementation when a plugin is available
*
* @param jenkins the instance of Jenkins
* @param pluginName the name of the plugin, e.g. "cobertura" or "junit" (maven name)
*/
private InstanceProvider(Jenkins jenkins, String pluginName, Logger logger) {
this.jenkins = jenkins;
this.pluginName = pluginName;
this.logger = logger;
}
public static UnitTestProvider getUnitTestProvider(Logger logger) {
return new InstanceProvider<UnitTestProvider>(Jenkins.getInstance(),
JUNIT_PLUGIN_NAME, logger) {
@Override
protected UnitTestProvider makeInstance() { | // Path: src/main/java/com/uber/jenkins/phabricator/unit/JUnitTestProvider.java
// @SuppressWarnings("unused")
// public class JUnitTestProvider extends UnitTestProvider {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public boolean resultsAvailable() {
// return getJUnitResults() != null;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public UnitResults getResults() {
// return convertJUnit(getJUnitResults());
// }
//
// /**
// * Convert JUnit's TestResult representation into a generic UnitResults
// *
// * @param jUnitResults The result of the JUnit run
// * @return The converted results
// */
// public UnitResults convertJUnit(TestResult jUnitResults) {
// UnitResults results = new UnitResults();
// if (jUnitResults == null) {
// return results;
// }
// for (SuiteResult sr : jUnitResults.getSuites()) {
// for (CaseResult cr : sr.getCases()) {
// UnitResult result = new UnitResult(
// cr.getClassName(),
// cr.getDisplayName(),
// cr.getErrorStackTrace(),
// cr.getDuration(),
// cr.getFailCount(),
// cr.getSkipCount(),
// cr.getPassCount()
// );
// results.add(result);
// }
// }
// return results;
// }
//
// private TestResult getJUnitResults() {
// Run<?, ?> build = getBuild();
//
// TestResultAction jUnitAction = build.getAction(TestResultAction.class);
// if (jUnitAction == null) {
// return null;
// }
// return jUnitAction.getResult();
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitTestProvider.java
// public abstract class UnitTestProvider {
//
// private Run<?, ?> build;
//
// protected Run<?, ?> getBuild() {
// return build;
// }
//
// /**
// * Set the owning build for this provider
// *
// * @param build The build that is associated with the current run
// */
// public void setBuild(Run<?, ?> build) {
// this.build = build;
// }
//
// /**
// * Determine if the current provider has results available for the build
// *
// * @return Whether results are available
// */
// public abstract boolean resultsAvailable();
//
// /**
// * Convert the provider's results to a standard format
// *
// * @return The results of the unit tests
// */
// public abstract UnitResults getResults();
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/provider/InstanceProvider.java
import com.uber.jenkins.phabricator.utils.Logger;
import jenkins.model.Jenkins;
import com.uber.jenkins.phabricator.unit.JUnitTestProvider;
import com.uber.jenkins.phabricator.unit.UnitTestProvider;
// Copyright (c) 2015 Uber
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package com.uber.jenkins.phabricator.provider;
public abstract class InstanceProvider<T> {
private static final String JUNIT_PLUGIN_NAME = "junit";
private static final String LOGGER_TAG = "plugin-provider";
private final Jenkins jenkins;
private final String pluginName;
private final Logger logger;
/**
* Encapsulate lazily loading a concrete implementation when a plugin is available
*
* @param jenkins the instance of Jenkins
* @param pluginName the name of the plugin, e.g. "cobertura" or "junit" (maven name)
*/
private InstanceProvider(Jenkins jenkins, String pluginName, Logger logger) {
this.jenkins = jenkins;
this.pluginName = pluginName;
this.logger = logger;
}
public static UnitTestProvider getUnitTestProvider(Logger logger) {
return new InstanceProvider<UnitTestProvider>(Jenkins.getInstance(),
JUNIT_PLUGIN_NAME, logger) {
@Override
protected UnitTestProvider makeInstance() { | return new JUnitTestProvider(); |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/conduit/ArcanistClient.java | // Path: src/main/java/com/uber/jenkins/phabricator/utils/CommonUtils.java
// public class CommonUtils {
//
// public static boolean isBlank(String str) {
// return str == null || str.trim().isEmpty();
// }
// }
| import com.uber.jenkins.phabricator.utils.CommonUtils;
import java.io.IOException;
import java.io.PrintStream;
import hudson.Launcher;
import hudson.util.ArgumentListBuilder; | // Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator.conduit;
public class ArcanistClient {
private final String arcPath;
private final String methodName;
private final String conduitUrl;
private final String conduitToken;
private final String[] arguments;
public ArcanistClient(
String arcPath,
String methodName,
String conduitUrl,
String conduitToken,
String... arguments) {
this.arcPath = arcPath;
this.methodName = methodName;
this.conduitUrl = conduitUrl;
this.conduitToken = conduitToken;
this.arguments = arguments;
}
private ArgumentListBuilder getConduitCommand() {
ArgumentListBuilder builder = new ArgumentListBuilder(this.arcPath, this.methodName);
builder.add(arguments);
| // Path: src/main/java/com/uber/jenkins/phabricator/utils/CommonUtils.java
// public class CommonUtils {
//
// public static boolean isBlank(String str) {
// return str == null || str.trim().isEmpty();
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/ArcanistClient.java
import com.uber.jenkins.phabricator.utils.CommonUtils;
import java.io.IOException;
import java.io.PrintStream;
import hudson.Launcher;
import hudson.util.ArgumentListBuilder;
// Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator.conduit;
public class ArcanistClient {
private final String arcPath;
private final String methodName;
private final String conduitUrl;
private final String conduitToken;
private final String[] arguments;
public ArcanistClient(
String arcPath,
String methodName,
String conduitUrl,
String conduitToken,
String... arguments) {
this.arcPath = arcPath;
this.methodName = methodName;
this.conduitUrl = conduitUrl;
this.conduitToken = conduitToken;
this.arguments = arguments;
}
private ArgumentListBuilder getConduitCommand() {
ArgumentListBuilder builder = new ArgumentListBuilder(this.arcPath, this.methodName);
builder.add(arguments);
| if (!CommonUtils.isBlank(this.conduitUrl)) { |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/tasks/Task.java | // Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
| import com.uber.jenkins.phabricator.utils.Logger; | // Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator.tasks;
/**
* Base task for all operations in the phabricator-jenkins plugin.
*/
public abstract class Task {
protected Result result = Result.UNKNOWN; | // Path: src/main/java/com/uber/jenkins/phabricator/utils/Logger.java
// public class Logger {
//
// private static final String LOG_FORMAT = "[phabricator:%s] %s";
//
// private final PrintStream stream;
//
// /**
// * Logger constructor.
// *
// * @param stream The stream.
// */
// public Logger(PrintStream stream) {
// this.stream = stream;
// }
//
// /**
// * Gets the stream.
// *
// * @return The stream where logs go to.
// */
// public PrintStream getStream() {
// return stream;
// }
//
// /**
// * Logs the message to the stream.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void info(String tag, String message) {
// stream.println(String.format(LOG_FORMAT, tag, message));
// }
//
// /**
// * Logs the message to the stream as a warning.
// *
// * @param tag The tag for the message.
// * @param message The message to log.
// */
// public void warn(String tag, String message) {
// info(tag, message);
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/tasks/Task.java
import com.uber.jenkins.phabricator.utils.Logger;
// Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator.tasks;
/**
* Base task for all operations in the phabricator-jenkins plugin.
*/
public abstract class Task {
protected Result result = Result.UNKNOWN; | private final Logger logger; |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/conduit/DifferentialClient.java | // Path: src/main/java/com/uber/jenkins/phabricator/conduit/HarbormasterClient.java
// public enum MessageType {
// pass,
// fail,
// work,
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/lint/LintResults.java
// public class LintResults {
//
// private final List<LintResult> results;
//
// public LintResults() {
// this.results = new ArrayList<LintResult>();
// }
//
// public void add(LintResult result) {
// results.add(result);
// }
//
// public List<LintResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (LintResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitResults.java
// public class UnitResults {
//
// private final List<UnitResult> results;
//
// public UnitResults() {
// this.results = new ArrayList<UnitResult>();
// }
//
// public void add(UnitResult result) {
// results.add(result);
// }
//
// public List<UnitResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (UnitResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
| import com.uber.jenkins.phabricator.conduit.HarbormasterClient.MessageType;
import com.uber.jenkins.phabricator.lint.LintResults;
import com.uber.jenkins.phabricator.unit.UnitResults;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import java.io.IOException;
import java.util.Map; | } catch (JSONException e) {
throw new ConduitAPIException(
String.format("No 'result' object found in conduit call: (%s) %s",
e.getMessage(),
query.toString(2)));
}
try {
return response.getJSONObject(diffID);
} catch (JSONException e) {
throw new ConduitAPIException(
String.format("Unable to find '%s' key in 'result': (%s) %s",
diffID,
e.getMessage(),
response.toString(2)));
}
}
/**
* Sets a sendHarbormasterMessage build status
*
* @param phid Phabricator object ID
* @param messageType type of message to send; either 'pass', 'fail' or 'work'
* @param unitResults the results from the unit tests
* @param coverage the results from the coverage provider
* @return the Conduit API response
* @throws IOException if there is a network error talking to Conduit
* @throws ConduitAPIException if any error is experienced talking to Conduit
*/
public JSONObject sendHarbormasterMessage( | // Path: src/main/java/com/uber/jenkins/phabricator/conduit/HarbormasterClient.java
// public enum MessageType {
// pass,
// fail,
// work,
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/lint/LintResults.java
// public class LintResults {
//
// private final List<LintResult> results;
//
// public LintResults() {
// this.results = new ArrayList<LintResult>();
// }
//
// public void add(LintResult result) {
// results.add(result);
// }
//
// public List<LintResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (LintResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitResults.java
// public class UnitResults {
//
// private final List<UnitResult> results;
//
// public UnitResults() {
// this.results = new ArrayList<UnitResult>();
// }
//
// public void add(UnitResult result) {
// results.add(result);
// }
//
// public List<UnitResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (UnitResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/DifferentialClient.java
import com.uber.jenkins.phabricator.conduit.HarbormasterClient.MessageType;
import com.uber.jenkins.phabricator.lint.LintResults;
import com.uber.jenkins.phabricator.unit.UnitResults;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import java.io.IOException;
import java.util.Map;
} catch (JSONException e) {
throw new ConduitAPIException(
String.format("No 'result' object found in conduit call: (%s) %s",
e.getMessage(),
query.toString(2)));
}
try {
return response.getJSONObject(diffID);
} catch (JSONException e) {
throw new ConduitAPIException(
String.format("Unable to find '%s' key in 'result': (%s) %s",
diffID,
e.getMessage(),
response.toString(2)));
}
}
/**
* Sets a sendHarbormasterMessage build status
*
* @param phid Phabricator object ID
* @param messageType type of message to send; either 'pass', 'fail' or 'work'
* @param unitResults the results from the unit tests
* @param coverage the results from the coverage provider
* @return the Conduit API response
* @throws IOException if there is a network error talking to Conduit
* @throws ConduitAPIException if any error is experienced talking to Conduit
*/
public JSONObject sendHarbormasterMessage( | String phid, MessageType messageType, UnitResults unitResults, |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/conduit/DifferentialClient.java | // Path: src/main/java/com/uber/jenkins/phabricator/conduit/HarbormasterClient.java
// public enum MessageType {
// pass,
// fail,
// work,
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/lint/LintResults.java
// public class LintResults {
//
// private final List<LintResult> results;
//
// public LintResults() {
// this.results = new ArrayList<LintResult>();
// }
//
// public void add(LintResult result) {
// results.add(result);
// }
//
// public List<LintResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (LintResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitResults.java
// public class UnitResults {
//
// private final List<UnitResult> results;
//
// public UnitResults() {
// this.results = new ArrayList<UnitResult>();
// }
//
// public void add(UnitResult result) {
// results.add(result);
// }
//
// public List<UnitResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (UnitResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
| import com.uber.jenkins.phabricator.conduit.HarbormasterClient.MessageType;
import com.uber.jenkins.phabricator.lint.LintResults;
import com.uber.jenkins.phabricator.unit.UnitResults;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import java.io.IOException;
import java.util.Map; | } catch (JSONException e) {
throw new ConduitAPIException(
String.format("No 'result' object found in conduit call: (%s) %s",
e.getMessage(),
query.toString(2)));
}
try {
return response.getJSONObject(diffID);
} catch (JSONException e) {
throw new ConduitAPIException(
String.format("Unable to find '%s' key in 'result': (%s) %s",
diffID,
e.getMessage(),
response.toString(2)));
}
}
/**
* Sets a sendHarbormasterMessage build status
*
* @param phid Phabricator object ID
* @param messageType type of message to send; either 'pass', 'fail' or 'work'
* @param unitResults the results from the unit tests
* @param coverage the results from the coverage provider
* @return the Conduit API response
* @throws IOException if there is a network error talking to Conduit
* @throws ConduitAPIException if any error is experienced talking to Conduit
*/
public JSONObject sendHarbormasterMessage( | // Path: src/main/java/com/uber/jenkins/phabricator/conduit/HarbormasterClient.java
// public enum MessageType {
// pass,
// fail,
// work,
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/lint/LintResults.java
// public class LintResults {
//
// private final List<LintResult> results;
//
// public LintResults() {
// this.results = new ArrayList<LintResult>();
// }
//
// public void add(LintResult result) {
// results.add(result);
// }
//
// public List<LintResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (LintResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitResults.java
// public class UnitResults {
//
// private final List<UnitResult> results;
//
// public UnitResults() {
// this.results = new ArrayList<UnitResult>();
// }
//
// public void add(UnitResult result) {
// results.add(result);
// }
//
// public List<UnitResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (UnitResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/DifferentialClient.java
import com.uber.jenkins.phabricator.conduit.HarbormasterClient.MessageType;
import com.uber.jenkins.phabricator.lint.LintResults;
import com.uber.jenkins.phabricator.unit.UnitResults;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import java.io.IOException;
import java.util.Map;
} catch (JSONException e) {
throw new ConduitAPIException(
String.format("No 'result' object found in conduit call: (%s) %s",
e.getMessage(),
query.toString(2)));
}
try {
return response.getJSONObject(diffID);
} catch (JSONException e) {
throw new ConduitAPIException(
String.format("Unable to find '%s' key in 'result': (%s) %s",
diffID,
e.getMessage(),
response.toString(2)));
}
}
/**
* Sets a sendHarbormasterMessage build status
*
* @param phid Phabricator object ID
* @param messageType type of message to send; either 'pass', 'fail' or 'work'
* @param unitResults the results from the unit tests
* @param coverage the results from the coverage provider
* @return the Conduit API response
* @throws IOException if there is a network error talking to Conduit
* @throws ConduitAPIException if any error is experienced talking to Conduit
*/
public JSONObject sendHarbormasterMessage( | String phid, MessageType messageType, UnitResults unitResults, |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/conduit/DifferentialClient.java | // Path: src/main/java/com/uber/jenkins/phabricator/conduit/HarbormasterClient.java
// public enum MessageType {
// pass,
// fail,
// work,
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/lint/LintResults.java
// public class LintResults {
//
// private final List<LintResult> results;
//
// public LintResults() {
// this.results = new ArrayList<LintResult>();
// }
//
// public void add(LintResult result) {
// results.add(result);
// }
//
// public List<LintResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (LintResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitResults.java
// public class UnitResults {
//
// private final List<UnitResult> results;
//
// public UnitResults() {
// this.results = new ArrayList<UnitResult>();
// }
//
// public void add(UnitResult result) {
// results.add(result);
// }
//
// public List<UnitResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (UnitResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
| import com.uber.jenkins.phabricator.conduit.HarbormasterClient.MessageType;
import com.uber.jenkins.phabricator.lint.LintResults;
import com.uber.jenkins.phabricator.unit.UnitResults;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import java.io.IOException;
import java.util.Map; | String.format("No 'result' object found in conduit call: (%s) %s",
e.getMessage(),
query.toString(2)));
}
try {
return response.getJSONObject(diffID);
} catch (JSONException e) {
throw new ConduitAPIException(
String.format("Unable to find '%s' key in 'result': (%s) %s",
diffID,
e.getMessage(),
response.toString(2)));
}
}
/**
* Sets a sendHarbormasterMessage build status
*
* @param phid Phabricator object ID
* @param messageType type of message to send; either 'pass', 'fail' or 'work'
* @param unitResults the results from the unit tests
* @param coverage the results from the coverage provider
* @return the Conduit API response
* @throws IOException if there is a network error talking to Conduit
* @throws ConduitAPIException if any error is experienced talking to Conduit
*/
public JSONObject sendHarbormasterMessage(
String phid, MessageType messageType, UnitResults unitResults,
Map<String, String> coverage, | // Path: src/main/java/com/uber/jenkins/phabricator/conduit/HarbormasterClient.java
// public enum MessageType {
// pass,
// fail,
// work,
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/lint/LintResults.java
// public class LintResults {
//
// private final List<LintResult> results;
//
// public LintResults() {
// this.results = new ArrayList<LintResult>();
// }
//
// public void add(LintResult result) {
// results.add(result);
// }
//
// public List<LintResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (LintResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
//
// Path: src/main/java/com/uber/jenkins/phabricator/unit/UnitResults.java
// public class UnitResults {
//
// private final List<UnitResult> results;
//
// public UnitResults() {
// this.results = new ArrayList<UnitResult>();
// }
//
// public void add(UnitResult result) {
// results.add(result);
// }
//
// public List<UnitResult> getResults() {
// return results;
// }
//
// /**
// * Convert a suite of unit results to Harbormaster JSON format
// *
// * @return Harbormaster-formatted unit results
// */
// public List<JSONObject> toHarbormaster() {
// List<JSONObject> harbormasterData = new ArrayList<JSONObject>();
//
// for (UnitResult result : results) {
// harbormasterData.add(result.toHarbormaster());
// }
//
// return harbormasterData;
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/conduit/DifferentialClient.java
import com.uber.jenkins.phabricator.conduit.HarbormasterClient.MessageType;
import com.uber.jenkins.phabricator.lint.LintResults;
import com.uber.jenkins.phabricator.unit.UnitResults;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import java.io.IOException;
import java.util.Map;
String.format("No 'result' object found in conduit call: (%s) %s",
e.getMessage(),
query.toString(2)));
}
try {
return response.getJSONObject(diffID);
} catch (JSONException e) {
throw new ConduitAPIException(
String.format("Unable to find '%s' key in 'result': (%s) %s",
diffID,
e.getMessage(),
response.toString(2)));
}
}
/**
* Sets a sendHarbormasterMessage build status
*
* @param phid Phabricator object ID
* @param messageType type of message to send; either 'pass', 'fail' or 'work'
* @param unitResults the results from the unit tests
* @param coverage the results from the coverage provider
* @return the Conduit API response
* @throws IOException if there is a network error talking to Conduit
* @throws ConduitAPIException if any error is experienced talking to Conduit
*/
public JSONObject sendHarbormasterMessage(
String phid, MessageType messageType, UnitResults unitResults,
Map<String, String> coverage, | LintResults lintResults) throws ConduitAPIException, IOException { |
uber/phabricator-jenkins-plugin | src/main/java/com/uber/jenkins/phabricator/credentials/ConduitCredentialsImpl.java | // Path: src/main/java/com/uber/jenkins/phabricator/utils/CommonUtils.java
// public class CommonUtils {
//
// public static boolean isBlank(String str) {
// return str == null || str.trim().isEmpty();
// }
// }
| import hudson.Extension;
import hudson.util.Secret;
import com.cloudbees.plugins.credentials.CredentialsDescriptor;
import com.cloudbees.plugins.credentials.NameWith;
import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials;
import com.uber.jenkins.phabricator.utils.CommonUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable; | // Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator.credentials;
@NameWith(value = ConduitCredentialsNameProvider.class, priority = 50)
@SuppressWarnings("unused")
public class ConduitCredentialsImpl extends BaseStandardCredentials implements ConduitCredentials {
@NonNull
private final Secret token;
@Nullable
private final String gateway;
@NonNull
private final String url;
@DataBoundConstructor
public ConduitCredentialsImpl(
@CheckForNull String id,
@NonNull @CheckForNull String url,
@Nullable String gateway,
@CheckForNull String description,
@CheckForNull String token) {
super(id, description);
this.url = url;
this.gateway = gateway;
this.token = Secret.fromString(token);
}
@NonNull
public Secret getToken() {
return token;
}
@Nullable
public String getGateway() { | // Path: src/main/java/com/uber/jenkins/phabricator/utils/CommonUtils.java
// public class CommonUtils {
//
// public static boolean isBlank(String str) {
// return str == null || str.trim().isEmpty();
// }
// }
// Path: src/main/java/com/uber/jenkins/phabricator/credentials/ConduitCredentialsImpl.java
import hudson.Extension;
import hudson.util.Secret;
import com.cloudbees.plugins.credentials.CredentialsDescriptor;
import com.cloudbees.plugins.credentials.NameWith;
import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials;
import com.uber.jenkins.phabricator.utils.CommonUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
// Copyright (c) 2015 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.uber.jenkins.phabricator.credentials;
@NameWith(value = ConduitCredentialsNameProvider.class, priority = 50)
@SuppressWarnings("unused")
public class ConduitCredentialsImpl extends BaseStandardCredentials implements ConduitCredentials {
@NonNull
private final Secret token;
@Nullable
private final String gateway;
@NonNull
private final String url;
@DataBoundConstructor
public ConduitCredentialsImpl(
@CheckForNull String id,
@NonNull @CheckForNull String url,
@Nullable String gateway,
@CheckForNull String description,
@CheckForNull String token) {
super(id, description);
this.url = url;
this.gateway = gateway;
this.token = Secret.fromString(token);
}
@NonNull
public Secret getToken() {
return token;
}
@Nullable
public String getGateway() { | return !CommonUtils.isBlank(gateway) ? gateway : getUrl(); |
zhouphenix/Multi-SwipeToRefreshLayout | app/src/main/java/lib/phenix/com/views/fragments/ViewPagerFragment.java | // Path: app/src/main/java/lib/phenix/com/views/SimplePagerAdapter.java
// public class SimplePagerAdapter extends FragmentPagerAdapter {
//
// List<Class<? extends Fragment>> classes;
//
// public SimplePagerAdapter(FragmentManager fm, List<Class<? extends Fragment>> classes) {
// super(fm);
// this.classes = classes;
// }
//
// public SimplePagerAdapter(FragmentManager fm, Class<? extends Fragment>... classes) {
// super(fm);
// this.classes = new ArrayList<>();
// this.classes.addAll(Arrays.asList(classes));
// }
//
// @Override
// public void setPrimaryItem(ViewGroup container, int position, Object object) {
// super.setPrimaryItem(container, position, object);
// }
//
// @Override
// public Fragment getItem(int position) {
// try {
// return classes.get(position).newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public int getCount() {
// return classes.size();
// }
//
// @Override
// public CharSequence getPageTitle(int position) {
// return classes.get(position).getSimpleName();
// }
//
//
// }
| import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import lib.phenix.com.views.R;
import lib.phenix.com.views.SimplePagerAdapter; | package lib.phenix.com.views.fragments;
/**
* A simple {@link Fragment} subclass.
*/
public class ViewPagerFragment extends Fragment {
public ViewPagerFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.layout_pager, container, false);
ViewPager viewPager = (ViewPager) v.findViewById(R.id.pager); | // Path: app/src/main/java/lib/phenix/com/views/SimplePagerAdapter.java
// public class SimplePagerAdapter extends FragmentPagerAdapter {
//
// List<Class<? extends Fragment>> classes;
//
// public SimplePagerAdapter(FragmentManager fm, List<Class<? extends Fragment>> classes) {
// super(fm);
// this.classes = classes;
// }
//
// public SimplePagerAdapter(FragmentManager fm, Class<? extends Fragment>... classes) {
// super(fm);
// this.classes = new ArrayList<>();
// this.classes.addAll(Arrays.asList(classes));
// }
//
// @Override
// public void setPrimaryItem(ViewGroup container, int position, Object object) {
// super.setPrimaryItem(container, position, object);
// }
//
// @Override
// public Fragment getItem(int position) {
// try {
// return classes.get(position).newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public int getCount() {
// return classes.size();
// }
//
// @Override
// public CharSequence getPageTitle(int position) {
// return classes.get(position).getSimpleName();
// }
//
//
// }
// Path: app/src/main/java/lib/phenix/com/views/fragments/ViewPagerFragment.java
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import lib.phenix.com.views.R;
import lib.phenix.com.views.SimplePagerAdapter;
package lib.phenix.com.views.fragments;
/**
* A simple {@link Fragment} subclass.
*/
public class ViewPagerFragment extends Fragment {
public ViewPagerFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.layout_pager, container, false);
ViewPager viewPager = (ViewPager) v.findViewById(R.id.pager); | SimplePagerAdapter pagerAdapter = new SimplePagerAdapter(getChildFragmentManager(), ScrollFragment.class,RecyclerFragment.class,WebViewFragment.class); |
dessalines/simple-vote | service/src/main/java/com/simplevote/tools/Tools.java | // Path: service/src/main/java/com/simplevote/DataSources.java
// public class DataSources {
//
// public static final String CODE_DIR = System.getProperty("user.dir");
//
// public static Boolean SSL = false;
//
// public static final String PROPERTIES_FILE = CODE_DIR + "/simplevote.properties";
//
// public static Properties PROPERTIES = Tools.loadProperties(PROPERTIES_FILE);
//
// public static final String CHANGELOG_MASTER = "liquibase/db.changelog-master.xml";
// }
//
// Path: service/src/main/java/com/simplevote/types/User.java
// public class User implements JSONWriter {
//
// private Long id;
// private String name, jwt;
//
// private User(Long id, String name, String jwt) {
// this.id = id;
// this.name = name;
// this.jwt = jwt;
// }
//
// public User() {}
//
// public static User create(com.simplevote.db.Tables.User user) {
// return new User(user.getLongId(),
// user.getString("name"),
// null);
// }
//
// public static User create(String jwt) {
// DecodedJWT dJWT = Tools.decodeJWTToken(jwt);
// return new User(
// Long.valueOf(dJWT.getClaim("user_id").asString()),
// dJWT.getClaim("user_name").asString(),
// jwt);
// }
//
// public static User create(Long id, String name, String jwt) {
// return new User(id, name, jwt);
// }
//
//
// @Override
// public String toString() {
// return this.json();
// }
//
// public Long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getJwt() {
// return jwt;
// }
//
// public void setJwt(String jwt) {
// this.jwt = jwt;
// }
//
// public static User fromJson(String dataStr) {
//
// try {
// return Tools.JACKSON.readValue(dataStr, User.class);
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// return null;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// User user = (User) o;
//
// if (!id.equals(user.id)) return false;
// return name.equals(user.name);
// }
//
// @Override
// public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + name.hashCode();
// return result;
// }
// }
| import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpCookie;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Scanner;
import java.util.stream.Collectors;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTCreationException;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.MapType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.simplevote.DataSources;
import com.simplevote.types.User;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.jasypt.util.password.BasicPasswordEncryptor;
import org.javalite.activejdbc.Base;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Logger;
import liquibase.Liquibase;
import liquibase.database.Database;
import liquibase.database.DatabaseFactory;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.LiquibaseException;
import liquibase.resource.ClassLoaderResourceAccessor;
import spark.Request; | package com.simplevote.tools;
/**
* Created by tyler on 4/20/17.
*/
public class Tools {
public static Logger log = (Logger) LoggerFactory.getLogger(Tools.class);
public static SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd");
public static ObjectMapper JACKSON = new ObjectMapper();
public static TypeFactory typeFactory = JACKSON.getTypeFactory();
public static MapType mapType = typeFactory.constructMapType(HashMap.class, String.class, String.class);
public static final BasicPasswordEncryptor PASS_ENCRYPT = new BasicPasswordEncryptor();
public static final HikariConfig hikariConfig() {
HikariConfig hc = new HikariConfig(); | // Path: service/src/main/java/com/simplevote/DataSources.java
// public class DataSources {
//
// public static final String CODE_DIR = System.getProperty("user.dir");
//
// public static Boolean SSL = false;
//
// public static final String PROPERTIES_FILE = CODE_DIR + "/simplevote.properties";
//
// public static Properties PROPERTIES = Tools.loadProperties(PROPERTIES_FILE);
//
// public static final String CHANGELOG_MASTER = "liquibase/db.changelog-master.xml";
// }
//
// Path: service/src/main/java/com/simplevote/types/User.java
// public class User implements JSONWriter {
//
// private Long id;
// private String name, jwt;
//
// private User(Long id, String name, String jwt) {
// this.id = id;
// this.name = name;
// this.jwt = jwt;
// }
//
// public User() {}
//
// public static User create(com.simplevote.db.Tables.User user) {
// return new User(user.getLongId(),
// user.getString("name"),
// null);
// }
//
// public static User create(String jwt) {
// DecodedJWT dJWT = Tools.decodeJWTToken(jwt);
// return new User(
// Long.valueOf(dJWT.getClaim("user_id").asString()),
// dJWT.getClaim("user_name").asString(),
// jwt);
// }
//
// public static User create(Long id, String name, String jwt) {
// return new User(id, name, jwt);
// }
//
//
// @Override
// public String toString() {
// return this.json();
// }
//
// public Long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getJwt() {
// return jwt;
// }
//
// public void setJwt(String jwt) {
// this.jwt = jwt;
// }
//
// public static User fromJson(String dataStr) {
//
// try {
// return Tools.JACKSON.readValue(dataStr, User.class);
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// return null;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// User user = (User) o;
//
// if (!id.equals(user.id)) return false;
// return name.equals(user.name);
// }
//
// @Override
// public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + name.hashCode();
// return result;
// }
// }
// Path: service/src/main/java/com/simplevote/tools/Tools.java
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpCookie;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Scanner;
import java.util.stream.Collectors;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTCreationException;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.MapType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.simplevote.DataSources;
import com.simplevote.types.User;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.jasypt.util.password.BasicPasswordEncryptor;
import org.javalite.activejdbc.Base;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Logger;
import liquibase.Liquibase;
import liquibase.database.Database;
import liquibase.database.DatabaseFactory;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.LiquibaseException;
import liquibase.resource.ClassLoaderResourceAccessor;
import spark.Request;
package com.simplevote.tools;
/**
* Created by tyler on 4/20/17.
*/
public class Tools {
public static Logger log = (Logger) LoggerFactory.getLogger(Tools.class);
public static SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd");
public static ObjectMapper JACKSON = new ObjectMapper();
public static TypeFactory typeFactory = JACKSON.getTypeFactory();
public static MapType mapType = typeFactory.constructMapType(HashMap.class, String.class, String.class);
public static final BasicPasswordEncryptor PASS_ENCRYPT = new BasicPasswordEncryptor();
public static final HikariConfig hikariConfig() {
HikariConfig hc = new HikariConfig(); | DataSources.PROPERTIES = Tools.loadProperties(DataSources.PROPERTIES_FILE); |
dessalines/simple-vote | service/src/main/java/com/simplevote/tools/Tools.java | // Path: service/src/main/java/com/simplevote/DataSources.java
// public class DataSources {
//
// public static final String CODE_DIR = System.getProperty("user.dir");
//
// public static Boolean SSL = false;
//
// public static final String PROPERTIES_FILE = CODE_DIR + "/simplevote.properties";
//
// public static Properties PROPERTIES = Tools.loadProperties(PROPERTIES_FILE);
//
// public static final String CHANGELOG_MASTER = "liquibase/db.changelog-master.xml";
// }
//
// Path: service/src/main/java/com/simplevote/types/User.java
// public class User implements JSONWriter {
//
// private Long id;
// private String name, jwt;
//
// private User(Long id, String name, String jwt) {
// this.id = id;
// this.name = name;
// this.jwt = jwt;
// }
//
// public User() {}
//
// public static User create(com.simplevote.db.Tables.User user) {
// return new User(user.getLongId(),
// user.getString("name"),
// null);
// }
//
// public static User create(String jwt) {
// DecodedJWT dJWT = Tools.decodeJWTToken(jwt);
// return new User(
// Long.valueOf(dJWT.getClaim("user_id").asString()),
// dJWT.getClaim("user_name").asString(),
// jwt);
// }
//
// public static User create(Long id, String name, String jwt) {
// return new User(id, name, jwt);
// }
//
//
// @Override
// public String toString() {
// return this.json();
// }
//
// public Long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getJwt() {
// return jwt;
// }
//
// public void setJwt(String jwt) {
// this.jwt = jwt;
// }
//
// public static User fromJson(String dataStr) {
//
// try {
// return Tools.JACKSON.readValue(dataStr, User.class);
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// return null;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// User user = (User) o;
//
// if (!id.equals(user.id)) return false;
// return name.equals(user.name);
// }
//
// @Override
// public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + name.hashCode();
// return result;
// }
// }
| import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpCookie;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Scanner;
import java.util.stream.Collectors;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTCreationException;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.MapType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.simplevote.DataSources;
import com.simplevote.types.User;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.jasypt.util.password.BasicPasswordEncryptor;
import org.javalite.activejdbc.Base;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Logger;
import liquibase.Liquibase;
import liquibase.database.Database;
import liquibase.database.DatabaseFactory;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.LiquibaseException;
import liquibase.resource.ClassLoaderResourceAccessor;
import spark.Request; | }
public static final void dbClose() {
Base.close();
}
public static final Algorithm getJWTAlgorithm() {
Algorithm JWTAlgorithm = null;
try {
JWTAlgorithm = Algorithm.HMAC256(DataSources.PROPERTIES.getProperty("jdbc.password"));
} catch (UnsupportedEncodingException | JWTCreationException exception) {
}
return JWTAlgorithm;
}
public static final DecodedJWT decodeJWTToken(String token) {
DecodedJWT jwt = null;
try {
JWTVerifier verifier = JWT.require(getJWTAlgorithm()).withIssuer("simplevote").build(); // Reusable verifier
// instance
jwt = verifier.verify(token);
} catch (JWTVerificationException e) {
}
return jwt;
}
| // Path: service/src/main/java/com/simplevote/DataSources.java
// public class DataSources {
//
// public static final String CODE_DIR = System.getProperty("user.dir");
//
// public static Boolean SSL = false;
//
// public static final String PROPERTIES_FILE = CODE_DIR + "/simplevote.properties";
//
// public static Properties PROPERTIES = Tools.loadProperties(PROPERTIES_FILE);
//
// public static final String CHANGELOG_MASTER = "liquibase/db.changelog-master.xml";
// }
//
// Path: service/src/main/java/com/simplevote/types/User.java
// public class User implements JSONWriter {
//
// private Long id;
// private String name, jwt;
//
// private User(Long id, String name, String jwt) {
// this.id = id;
// this.name = name;
// this.jwt = jwt;
// }
//
// public User() {}
//
// public static User create(com.simplevote.db.Tables.User user) {
// return new User(user.getLongId(),
// user.getString("name"),
// null);
// }
//
// public static User create(String jwt) {
// DecodedJWT dJWT = Tools.decodeJWTToken(jwt);
// return new User(
// Long.valueOf(dJWT.getClaim("user_id").asString()),
// dJWT.getClaim("user_name").asString(),
// jwt);
// }
//
// public static User create(Long id, String name, String jwt) {
// return new User(id, name, jwt);
// }
//
//
// @Override
// public String toString() {
// return this.json();
// }
//
// public Long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getJwt() {
// return jwt;
// }
//
// public void setJwt(String jwt) {
// this.jwt = jwt;
// }
//
// public static User fromJson(String dataStr) {
//
// try {
// return Tools.JACKSON.readValue(dataStr, User.class);
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// return null;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// User user = (User) o;
//
// if (!id.equals(user.id)) return false;
// return name.equals(user.name);
// }
//
// @Override
// public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + name.hashCode();
// return result;
// }
// }
// Path: service/src/main/java/com/simplevote/tools/Tools.java
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpCookie;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Scanner;
import java.util.stream.Collectors;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTCreationException;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.MapType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.simplevote.DataSources;
import com.simplevote.types.User;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.jasypt.util.password.BasicPasswordEncryptor;
import org.javalite.activejdbc.Base;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Logger;
import liquibase.Liquibase;
import liquibase.database.Database;
import liquibase.database.DatabaseFactory;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.LiquibaseException;
import liquibase.resource.ClassLoaderResourceAccessor;
import spark.Request;
}
public static final void dbClose() {
Base.close();
}
public static final Algorithm getJWTAlgorithm() {
Algorithm JWTAlgorithm = null;
try {
JWTAlgorithm = Algorithm.HMAC256(DataSources.PROPERTIES.getProperty("jdbc.password"));
} catch (UnsupportedEncodingException | JWTCreationException exception) {
}
return JWTAlgorithm;
}
public static final DecodedJWT decodeJWTToken(String token) {
DecodedJWT jwt = null;
try {
JWTVerifier verifier = JWT.require(getJWTAlgorithm()).withIssuer("simplevote").build(); // Reusable verifier
// instance
jwt = verifier.verify(token);
} catch (JWTVerificationException e) {
}
return jwt;
}
| public static final User getUserFromJWTHeader(Request req) { |
idega/se.idega.idegaweb.commune.accounting | src/java/se/idega/idegaweb/commune/accounting/business/InvoiceComparator.java | // Path: src/java/se/idega/idegaweb/commune/accounting/invoice/data/InvoiceRecord.java
// public interface InvoiceRecord extends com.idega.data.IDOEntity
// {
// public float getAmount();
// public float getAmountVAT();
// public java.lang.String getChangedBy();
// public se.idega.idegaweb.commune.care.data.ChildCareContract getChildCareContract();
// public java.lang.String getCreatedBy();
// public java.sql.Date getDateChanged();
// public java.sql.Date getDateCreated();
// public int getDays();
// public java.lang.String getDoublePosting();
// public se.idega.idegaweb.commune.accounting.invoice.data.InvoiceHeader getInvoiceHeader();
// public int getInvoiceHeaderId();
// public java.lang.String getInvoiceText();
// public java.lang.String getInvoiceText2();
// public java.lang.String getNotes();
// public int getOrderId();
// public java.lang.String getOwnPosting();
// public se.idega.idegaweb.commune.accounting.invoice.data.PaymentRecord getPaymentRecord();
// public int getPaymentRecordId();
// public java.sql.Date getPeriodEndCheck();
// public java.sql.Date getPeriodEndPlacement();
// public java.sql.Date getPeriodStartCheck();
// public java.sql.Date getPeriodStartPlacement();
// public com.idega.block.school.data.School getProvider();
// public int getProviderId();
// public se.idega.idegaweb.commune.accounting.regulations.data.RegulationSpecType getRegSpecType();
// public int getRegSpecTypeId();
// public java.lang.String getRuleText();
// public com.idega.block.school.data.SchoolClassMember getSchoolClassMember();
// public int getSchoolClassMemberId();
// public com.idega.block.school.data.SchoolType getSchoolType();
// public int getSchoolTypeId();
// public se.idega.idegaweb.commune.accounting.regulations.data.Regulation getVATRuleRegulation();
// public int getVATRuleRegulationId();
// public void setAmount(float p0);
// public void setAmountVAT(float p0);
// public void setChangedBy(java.lang.String p0);
// public void setChildCareContract(se.idega.idegaweb.commune.care.data.ChildCareContract p0);
// public void setCreatedBy(java.lang.String p0);
// public void setDateChanged(java.sql.Date p0);
// public void setDateCreated(java.sql.Date p0);
// public void setDays(int p0);
// public void setDoublePosting(java.lang.String p0);
// public void setInvoiceHeader(se.idega.idegaweb.commune.accounting.invoice.data.InvoiceHeader p0);
// public void setInvoiceHeaderId(int p0);
// public void setInvoiceText(java.lang.String p0);
// public void setInvoiceText2(java.lang.String p0);
// public void setNotes(java.lang.String p0);
// public void setOrderId(int p0);
// public void setOwnPosting(java.lang.String p0);
// public void setPaymentRecord(se.idega.idegaweb.commune.accounting.invoice.data.PaymentRecord p0);
// public void setPaymentRecordId(int p0);
// public void setPeriodEndCheck(java.sql.Date p0);
// public void setPeriodEndPlacement(java.sql.Date p0);
// public void setPeriodStartCheck(java.sql.Date p0);
// public void setPeriodStartPlacement(java.sql.Date p0);
// public void setProvider(com.idega.block.school.data.School p0);
// public void setProviderId(int p0);
// public void setRegSpecType(se.idega.idegaweb.commune.accounting.regulations.data.RegulationSpecType p0);
// public void setRegSpecTypeId(int p0);
// public void setRuleText(java.lang.String p0);
// public void setSchoolClassMember(com.idega.block.school.data.SchoolClassMember p0);
// public void setSchoolClassMemberId(int p0);
// public void setSchoolType(com.idega.block.school.data.SchoolType p0);
// public void setSchoolTypeId(int p0);
// public void setVATRuleRegulation(se.idega.idegaweb.commune.accounting.regulations.data.Regulation p0);
// public void setVATRuleRegulation(int p0);
// }
| import java.text.Collator;
import java.util.Comparator;
import se.idega.idegaweb.commune.accounting.invoice.data.InvoiceRecord;
import com.idega.util.LocaleUtil; | package se.idega.idegaweb.commune.accounting.business;
/**
* A class to compare a collection of InvoiceRecords or InvoiceHeaders objects.
* @author Sigtryggur
*/
public class InvoiceComparator implements Comparator {
private Collator collator;
private String compareString1;
private String compareString2;
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare(Object o1, Object o2) {
this.collator = Collator.getInstance(LocaleUtil.getSwedishLocale());
| // Path: src/java/se/idega/idegaweb/commune/accounting/invoice/data/InvoiceRecord.java
// public interface InvoiceRecord extends com.idega.data.IDOEntity
// {
// public float getAmount();
// public float getAmountVAT();
// public java.lang.String getChangedBy();
// public se.idega.idegaweb.commune.care.data.ChildCareContract getChildCareContract();
// public java.lang.String getCreatedBy();
// public java.sql.Date getDateChanged();
// public java.sql.Date getDateCreated();
// public int getDays();
// public java.lang.String getDoublePosting();
// public se.idega.idegaweb.commune.accounting.invoice.data.InvoiceHeader getInvoiceHeader();
// public int getInvoiceHeaderId();
// public java.lang.String getInvoiceText();
// public java.lang.String getInvoiceText2();
// public java.lang.String getNotes();
// public int getOrderId();
// public java.lang.String getOwnPosting();
// public se.idega.idegaweb.commune.accounting.invoice.data.PaymentRecord getPaymentRecord();
// public int getPaymentRecordId();
// public java.sql.Date getPeriodEndCheck();
// public java.sql.Date getPeriodEndPlacement();
// public java.sql.Date getPeriodStartCheck();
// public java.sql.Date getPeriodStartPlacement();
// public com.idega.block.school.data.School getProvider();
// public int getProviderId();
// public se.idega.idegaweb.commune.accounting.regulations.data.RegulationSpecType getRegSpecType();
// public int getRegSpecTypeId();
// public java.lang.String getRuleText();
// public com.idega.block.school.data.SchoolClassMember getSchoolClassMember();
// public int getSchoolClassMemberId();
// public com.idega.block.school.data.SchoolType getSchoolType();
// public int getSchoolTypeId();
// public se.idega.idegaweb.commune.accounting.regulations.data.Regulation getVATRuleRegulation();
// public int getVATRuleRegulationId();
// public void setAmount(float p0);
// public void setAmountVAT(float p0);
// public void setChangedBy(java.lang.String p0);
// public void setChildCareContract(se.idega.idegaweb.commune.care.data.ChildCareContract p0);
// public void setCreatedBy(java.lang.String p0);
// public void setDateChanged(java.sql.Date p0);
// public void setDateCreated(java.sql.Date p0);
// public void setDays(int p0);
// public void setDoublePosting(java.lang.String p0);
// public void setInvoiceHeader(se.idega.idegaweb.commune.accounting.invoice.data.InvoiceHeader p0);
// public void setInvoiceHeaderId(int p0);
// public void setInvoiceText(java.lang.String p0);
// public void setInvoiceText2(java.lang.String p0);
// public void setNotes(java.lang.String p0);
// public void setOrderId(int p0);
// public void setOwnPosting(java.lang.String p0);
// public void setPaymentRecord(se.idega.idegaweb.commune.accounting.invoice.data.PaymentRecord p0);
// public void setPaymentRecordId(int p0);
// public void setPeriodEndCheck(java.sql.Date p0);
// public void setPeriodEndPlacement(java.sql.Date p0);
// public void setPeriodStartCheck(java.sql.Date p0);
// public void setPeriodStartPlacement(java.sql.Date p0);
// public void setProvider(com.idega.block.school.data.School p0);
// public void setProviderId(int p0);
// public void setRegSpecType(se.idega.idegaweb.commune.accounting.regulations.data.RegulationSpecType p0);
// public void setRegSpecTypeId(int p0);
// public void setRuleText(java.lang.String p0);
// public void setSchoolClassMember(com.idega.block.school.data.SchoolClassMember p0);
// public void setSchoolClassMemberId(int p0);
// public void setSchoolType(com.idega.block.school.data.SchoolType p0);
// public void setSchoolTypeId(int p0);
// public void setVATRuleRegulation(se.idega.idegaweb.commune.accounting.regulations.data.Regulation p0);
// public void setVATRuleRegulation(int p0);
// }
// Path: src/java/se/idega/idegaweb/commune/accounting/business/InvoiceComparator.java
import java.text.Collator;
import java.util.Comparator;
import se.idega.idegaweb.commune.accounting.invoice.data.InvoiceRecord;
import com.idega.util.LocaleUtil;
package se.idega.idegaweb.commune.accounting.business;
/**
* A class to compare a collection of InvoiceRecords or InvoiceHeaders objects.
* @author Sigtryggur
*/
public class InvoiceComparator implements Comparator {
private Collator collator;
private String compareString1;
private String compareString2;
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare(Object o1, Object o2) {
this.collator = Collator.getInstance(LocaleUtil.getSwedishLocale());
| if (o1 instanceof InvoiceRecord){ |
idega/se.idega.idegaweb.commune.accounting | src/java/se/idega/idegaweb/commune/accounting/presentation/AccountingBlock.java | // Path: src/java/se/idega/idegaweb/commune/accounting/business/AccountingException.java
// public class AccountingException extends Exception {
//
// private String textKey = null;
// private String defaultText = null;
//
// /**
// * Constructs an accounting exception with the specified text key and default text.
// * @param textKey the text key for the error message
// * @param defaultText the default text for the error message
// */
// public AccountingException(String textKey, String defaultText) {
// super(textKey);
// this.textKey = textKey;
// this.defaultText = defaultText;
// }
//
// /**
// * Constructs an accounting exception with the specified text key and default text.
// * @param textKey the text key for the error message
// * @param defaultText the default text for the error message
// */
// public AccountingException(String textKey, String defaultText,Exception cause) {
// super(textKey,cause);
// this.textKey = textKey;
// this.defaultText = defaultText;
// }
//
// /**
// * Returns the error message text key.
// */
// public String getTextKey() {
// return this.textKey;
// }
//
// /**
// * Returns the default error message text.
// */
// public String getDefaultText() {
// return this.defaultText;
// }
//
// }
| import java.rmi.RemoteException;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Locale;
import se.idega.idegaweb.commune.accounting.business.AccountingBusiness;
import se.idega.idegaweb.commune.accounting.business.AccountingException;
import se.idega.idegaweb.commune.business.CommuneUserBusiness;
import se.idega.idegaweb.commune.care.business.AccountingSession;
import se.idega.idegaweb.commune.presentation.CommuneBlock;
import com.idega.business.IBOLookup;
import com.idega.business.IBOLookupException;
import com.idega.business.IBORuntimeException;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWUserContext;
import com.idega.idegaweb.UnavailableIWContext;
import com.idega.presentation.IWContext;
import com.idega.presentation.text.Link;
import com.idega.presentation.text.Text;
import com.idega.presentation.ui.CheckBox;
import com.idega.presentation.ui.DropdownMenu;
import com.idega.presentation.ui.IntegerInput;
import com.idega.presentation.ui.SubmitButton;
import com.idega.presentation.ui.TextInput;
import com.idega.presentation.ui.util.SelectorUtility; | */
public DateFormat getDateTimeFormat(Locale locale){
return DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,locale);
}
/**
* Returns a formatted and localized form label.
* @param textKey the text key to localize
* @param defaultText the default localized text
* @author anders
*/
protected Text getLocalizedLabel(String textKey, String defaultText) {
return getSmallHeader(localize(textKey, defaultText) + ":");
}
/**
* Returns a formatted and localized form text.
* @param textKey the text key to localize
* @param defaultText the default localized text
* @author anders
*/
public Text getLocalizedText(String textKey, String defaultText) {
return getSmallText(localize(textKey, defaultText));
}
/**
* Returns a formatted and localized exception text.
* @param ex AccountingException to localize
* @author roar
*/ | // Path: src/java/se/idega/idegaweb/commune/accounting/business/AccountingException.java
// public class AccountingException extends Exception {
//
// private String textKey = null;
// private String defaultText = null;
//
// /**
// * Constructs an accounting exception with the specified text key and default text.
// * @param textKey the text key for the error message
// * @param defaultText the default text for the error message
// */
// public AccountingException(String textKey, String defaultText) {
// super(textKey);
// this.textKey = textKey;
// this.defaultText = defaultText;
// }
//
// /**
// * Constructs an accounting exception with the specified text key and default text.
// * @param textKey the text key for the error message
// * @param defaultText the default text for the error message
// */
// public AccountingException(String textKey, String defaultText,Exception cause) {
// super(textKey,cause);
// this.textKey = textKey;
// this.defaultText = defaultText;
// }
//
// /**
// * Returns the error message text key.
// */
// public String getTextKey() {
// return this.textKey;
// }
//
// /**
// * Returns the default error message text.
// */
// public String getDefaultText() {
// return this.defaultText;
// }
//
// }
// Path: src/java/se/idega/idegaweb/commune/accounting/presentation/AccountingBlock.java
import java.rmi.RemoteException;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Locale;
import se.idega.idegaweb.commune.accounting.business.AccountingBusiness;
import se.idega.idegaweb.commune.accounting.business.AccountingException;
import se.idega.idegaweb.commune.business.CommuneUserBusiness;
import se.idega.idegaweb.commune.care.business.AccountingSession;
import se.idega.idegaweb.commune.presentation.CommuneBlock;
import com.idega.business.IBOLookup;
import com.idega.business.IBOLookupException;
import com.idega.business.IBORuntimeException;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWUserContext;
import com.idega.idegaweb.UnavailableIWContext;
import com.idega.presentation.IWContext;
import com.idega.presentation.text.Link;
import com.idega.presentation.text.Text;
import com.idega.presentation.ui.CheckBox;
import com.idega.presentation.ui.DropdownMenu;
import com.idega.presentation.ui.IntegerInput;
import com.idega.presentation.ui.SubmitButton;
import com.idega.presentation.ui.TextInput;
import com.idega.presentation.ui.util.SelectorUtility;
*/
public DateFormat getDateTimeFormat(Locale locale){
return DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,locale);
}
/**
* Returns a formatted and localized form label.
* @param textKey the text key to localize
* @param defaultText the default localized text
* @author anders
*/
protected Text getLocalizedLabel(String textKey, String defaultText) {
return getSmallHeader(localize(textKey, defaultText) + ":");
}
/**
* Returns a formatted and localized form text.
* @param textKey the text key to localize
* @param defaultText the default localized text
* @author anders
*/
public Text getLocalizedText(String textKey, String defaultText) {
return getSmallText(localize(textKey, defaultText));
}
/**
* Returns a formatted and localized exception text.
* @param ex AccountingException to localize
* @author roar
*/ | public Text getLocalizedException(AccountingException ex) { |
idega/se.idega.idegaweb.commune.accounting | src/java/se/idega/idegaweb/commune/accounting/business/PaymentComparator.java | // Path: src/java/se/idega/idegaweb/commune/accounting/invoice/data/PaymentHeader.java
// public interface PaymentHeader extends com.idega.data.IDOEntity
// {
// public java.sql.Date getDateAttested();
// public java.sql.Date getPeriod();
// public com.idega.block.school.data.School getSchool();
// public com.idega.block.school.data.SchoolCategory getSchoolCategory();
// public java.lang.String getSchoolCategoryID();
// public int getSchoolID();
// public int getSignatureID();
// public char getStatus();
// public void setDateAttested(java.sql.Date p0);
// public void setPeriod(java.sql.Date p0);
// public void setSchool(com.idega.block.school.data.School p0);
// public void setSchoolCategory(com.idega.block.school.data.SchoolCategory p0);
// public void setSchoolCategoryID(int p0);
// public void setSchoolID(int p0);
// public void setSignaturelID(com.idega.user.data.User p0);
// public void setSignaturelID(int p0);
// public void setStatus(char p0);
// }
//
// Path: src/java/se/idega/idegaweb/commune/accounting/invoice/data/PaymentRecord.java
// public interface PaymentRecord extends com.idega.data.IDOEntity
// {
// public java.lang.String getChangedBy();
// public java.lang.String getCreatedBy();
// public java.sql.Date getDateChanged();
// public java.sql.Date getDateCreated();
// public java.sql.Date getDateTransaction();
// public java.lang.String getDoublePosting();
// public java.lang.String getNotes();
// public int getOrderId();
// public java.lang.String getOwnPosting();
// public se.idega.idegaweb.commune.accounting.invoice.data.PaymentHeader getPaymentHeader();
// public int getPaymentHeaderId();
// public java.lang.String getPaymentText();
// public java.sql.Date getPeriod();
// public float getPieceAmount();
// public int getPlacements();
// public java.lang.String getRuleSpecType();
// public char getStatus();
// public float getTotalAmount();
// public float getTotalAmountVAT();
// public se.idega.idegaweb.commune.accounting.regulations.data.Regulation getVATRuleRegulation();
// public int getVATRuleRegulationId();
// public void setChangedBy(java.lang.String p0);
// public void setCreatedBy(java.lang.String p0);
// public void setDateChanged(java.sql.Date p0);
// public void setDateCreated(java.sql.Date p0);
// public void setDateTransaction(java.sql.Date p0);
// public void setDoublePosting(java.lang.String p0);
// public void setNotes(java.lang.String p0);
// public void setOrderId(int p0);
// public void setOwnPosting(java.lang.String p0);
// public void setPaymentHeader(se.idega.idegaweb.commune.accounting.invoice.data.PaymentHeader p0);
// public void setPaymentHeaderId(int p0);
// public void setPaymentText(java.lang.String p0);
// public void setPeriod(java.sql.Date p0);
// public void setPieceAmount(float p0);
// public void setPlacements(int p0);
// public void setRuleSpecType(java.lang.String p0);
// public void setStatus(char p0);
// public void setTotalAmount(float p0);
// public void setTotalAmountVAT(float p0);
// public void setVATRuleRegulation(se.idega.idegaweb.commune.accounting.regulations.data.Regulation p0);
// public void setVATRuleRegulationId(int p0);
// }
| import java.text.Collator;
import java.util.Comparator;
import se.idega.idegaweb.commune.accounting.invoice.data.PaymentHeader;
import se.idega.idegaweb.commune.accounting.invoice.data.PaymentRecord;
import com.idega.util.LocaleUtil; | package se.idega.idegaweb.commune.accounting.business;
/**
* A class to compare a collection of PaymentRecords or PaymentHeaders objects.
* @author Sigtryggur
*/
public class PaymentComparator implements Comparator {
private Collator collator;
private String compareString1;
private String compareString2;
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare(Object o1, Object o2) {
this.collator = Collator.getInstance(LocaleUtil.getSwedishLocale());
| // Path: src/java/se/idega/idegaweb/commune/accounting/invoice/data/PaymentHeader.java
// public interface PaymentHeader extends com.idega.data.IDOEntity
// {
// public java.sql.Date getDateAttested();
// public java.sql.Date getPeriod();
// public com.idega.block.school.data.School getSchool();
// public com.idega.block.school.data.SchoolCategory getSchoolCategory();
// public java.lang.String getSchoolCategoryID();
// public int getSchoolID();
// public int getSignatureID();
// public char getStatus();
// public void setDateAttested(java.sql.Date p0);
// public void setPeriod(java.sql.Date p0);
// public void setSchool(com.idega.block.school.data.School p0);
// public void setSchoolCategory(com.idega.block.school.data.SchoolCategory p0);
// public void setSchoolCategoryID(int p0);
// public void setSchoolID(int p0);
// public void setSignaturelID(com.idega.user.data.User p0);
// public void setSignaturelID(int p0);
// public void setStatus(char p0);
// }
//
// Path: src/java/se/idega/idegaweb/commune/accounting/invoice/data/PaymentRecord.java
// public interface PaymentRecord extends com.idega.data.IDOEntity
// {
// public java.lang.String getChangedBy();
// public java.lang.String getCreatedBy();
// public java.sql.Date getDateChanged();
// public java.sql.Date getDateCreated();
// public java.sql.Date getDateTransaction();
// public java.lang.String getDoublePosting();
// public java.lang.String getNotes();
// public int getOrderId();
// public java.lang.String getOwnPosting();
// public se.idega.idegaweb.commune.accounting.invoice.data.PaymentHeader getPaymentHeader();
// public int getPaymentHeaderId();
// public java.lang.String getPaymentText();
// public java.sql.Date getPeriod();
// public float getPieceAmount();
// public int getPlacements();
// public java.lang.String getRuleSpecType();
// public char getStatus();
// public float getTotalAmount();
// public float getTotalAmountVAT();
// public se.idega.idegaweb.commune.accounting.regulations.data.Regulation getVATRuleRegulation();
// public int getVATRuleRegulationId();
// public void setChangedBy(java.lang.String p0);
// public void setCreatedBy(java.lang.String p0);
// public void setDateChanged(java.sql.Date p0);
// public void setDateCreated(java.sql.Date p0);
// public void setDateTransaction(java.sql.Date p0);
// public void setDoublePosting(java.lang.String p0);
// public void setNotes(java.lang.String p0);
// public void setOrderId(int p0);
// public void setOwnPosting(java.lang.String p0);
// public void setPaymentHeader(se.idega.idegaweb.commune.accounting.invoice.data.PaymentHeader p0);
// public void setPaymentHeaderId(int p0);
// public void setPaymentText(java.lang.String p0);
// public void setPeriod(java.sql.Date p0);
// public void setPieceAmount(float p0);
// public void setPlacements(int p0);
// public void setRuleSpecType(java.lang.String p0);
// public void setStatus(char p0);
// public void setTotalAmount(float p0);
// public void setTotalAmountVAT(float p0);
// public void setVATRuleRegulation(se.idega.idegaweb.commune.accounting.regulations.data.Regulation p0);
// public void setVATRuleRegulationId(int p0);
// }
// Path: src/java/se/idega/idegaweb/commune/accounting/business/PaymentComparator.java
import java.text.Collator;
import java.util.Comparator;
import se.idega.idegaweb.commune.accounting.invoice.data.PaymentHeader;
import se.idega.idegaweb.commune.accounting.invoice.data.PaymentRecord;
import com.idega.util.LocaleUtil;
package se.idega.idegaweb.commune.accounting.business;
/**
* A class to compare a collection of PaymentRecords or PaymentHeaders objects.
* @author Sigtryggur
*/
public class PaymentComparator implements Comparator {
private Collator collator;
private String compareString1;
private String compareString2;
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare(Object o1, Object o2) {
this.collator = Collator.getInstance(LocaleUtil.getSwedishLocale());
| if (o1 instanceof PaymentHeader) { |
idega/se.idega.idegaweb.commune.accounting | src/java/se/idega/idegaweb/commune/accounting/business/PaymentComparator.java | // Path: src/java/se/idega/idegaweb/commune/accounting/invoice/data/PaymentHeader.java
// public interface PaymentHeader extends com.idega.data.IDOEntity
// {
// public java.sql.Date getDateAttested();
// public java.sql.Date getPeriod();
// public com.idega.block.school.data.School getSchool();
// public com.idega.block.school.data.SchoolCategory getSchoolCategory();
// public java.lang.String getSchoolCategoryID();
// public int getSchoolID();
// public int getSignatureID();
// public char getStatus();
// public void setDateAttested(java.sql.Date p0);
// public void setPeriod(java.sql.Date p0);
// public void setSchool(com.idega.block.school.data.School p0);
// public void setSchoolCategory(com.idega.block.school.data.SchoolCategory p0);
// public void setSchoolCategoryID(int p0);
// public void setSchoolID(int p0);
// public void setSignaturelID(com.idega.user.data.User p0);
// public void setSignaturelID(int p0);
// public void setStatus(char p0);
// }
//
// Path: src/java/se/idega/idegaweb/commune/accounting/invoice/data/PaymentRecord.java
// public interface PaymentRecord extends com.idega.data.IDOEntity
// {
// public java.lang.String getChangedBy();
// public java.lang.String getCreatedBy();
// public java.sql.Date getDateChanged();
// public java.sql.Date getDateCreated();
// public java.sql.Date getDateTransaction();
// public java.lang.String getDoublePosting();
// public java.lang.String getNotes();
// public int getOrderId();
// public java.lang.String getOwnPosting();
// public se.idega.idegaweb.commune.accounting.invoice.data.PaymentHeader getPaymentHeader();
// public int getPaymentHeaderId();
// public java.lang.String getPaymentText();
// public java.sql.Date getPeriod();
// public float getPieceAmount();
// public int getPlacements();
// public java.lang.String getRuleSpecType();
// public char getStatus();
// public float getTotalAmount();
// public float getTotalAmountVAT();
// public se.idega.idegaweb.commune.accounting.regulations.data.Regulation getVATRuleRegulation();
// public int getVATRuleRegulationId();
// public void setChangedBy(java.lang.String p0);
// public void setCreatedBy(java.lang.String p0);
// public void setDateChanged(java.sql.Date p0);
// public void setDateCreated(java.sql.Date p0);
// public void setDateTransaction(java.sql.Date p0);
// public void setDoublePosting(java.lang.String p0);
// public void setNotes(java.lang.String p0);
// public void setOrderId(int p0);
// public void setOwnPosting(java.lang.String p0);
// public void setPaymentHeader(se.idega.idegaweb.commune.accounting.invoice.data.PaymentHeader p0);
// public void setPaymentHeaderId(int p0);
// public void setPaymentText(java.lang.String p0);
// public void setPeriod(java.sql.Date p0);
// public void setPieceAmount(float p0);
// public void setPlacements(int p0);
// public void setRuleSpecType(java.lang.String p0);
// public void setStatus(char p0);
// public void setTotalAmount(float p0);
// public void setTotalAmountVAT(float p0);
// public void setVATRuleRegulation(se.idega.idegaweb.commune.accounting.regulations.data.Regulation p0);
// public void setVATRuleRegulationId(int p0);
// }
| import java.text.Collator;
import java.util.Comparator;
import se.idega.idegaweb.commune.accounting.invoice.data.PaymentHeader;
import se.idega.idegaweb.commune.accounting.invoice.data.PaymentRecord;
import com.idega.util.LocaleUtil; | package se.idega.idegaweb.commune.accounting.business;
/**
* A class to compare a collection of PaymentRecords or PaymentHeaders objects.
* @author Sigtryggur
*/
public class PaymentComparator implements Comparator {
private Collator collator;
private String compareString1;
private String compareString2;
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare(Object o1, Object o2) {
this.collator = Collator.getInstance(LocaleUtil.getSwedishLocale());
if (o1 instanceof PaymentHeader) {
this.compareString1 = ((PaymentHeader) o1).getSchool().getName();
this.compareString2 = ((PaymentHeader) o2).getSchool().getName();
} | // Path: src/java/se/idega/idegaweb/commune/accounting/invoice/data/PaymentHeader.java
// public interface PaymentHeader extends com.idega.data.IDOEntity
// {
// public java.sql.Date getDateAttested();
// public java.sql.Date getPeriod();
// public com.idega.block.school.data.School getSchool();
// public com.idega.block.school.data.SchoolCategory getSchoolCategory();
// public java.lang.String getSchoolCategoryID();
// public int getSchoolID();
// public int getSignatureID();
// public char getStatus();
// public void setDateAttested(java.sql.Date p0);
// public void setPeriod(java.sql.Date p0);
// public void setSchool(com.idega.block.school.data.School p0);
// public void setSchoolCategory(com.idega.block.school.data.SchoolCategory p0);
// public void setSchoolCategoryID(int p0);
// public void setSchoolID(int p0);
// public void setSignaturelID(com.idega.user.data.User p0);
// public void setSignaturelID(int p0);
// public void setStatus(char p0);
// }
//
// Path: src/java/se/idega/idegaweb/commune/accounting/invoice/data/PaymentRecord.java
// public interface PaymentRecord extends com.idega.data.IDOEntity
// {
// public java.lang.String getChangedBy();
// public java.lang.String getCreatedBy();
// public java.sql.Date getDateChanged();
// public java.sql.Date getDateCreated();
// public java.sql.Date getDateTransaction();
// public java.lang.String getDoublePosting();
// public java.lang.String getNotes();
// public int getOrderId();
// public java.lang.String getOwnPosting();
// public se.idega.idegaweb.commune.accounting.invoice.data.PaymentHeader getPaymentHeader();
// public int getPaymentHeaderId();
// public java.lang.String getPaymentText();
// public java.sql.Date getPeriod();
// public float getPieceAmount();
// public int getPlacements();
// public java.lang.String getRuleSpecType();
// public char getStatus();
// public float getTotalAmount();
// public float getTotalAmountVAT();
// public se.idega.idegaweb.commune.accounting.regulations.data.Regulation getVATRuleRegulation();
// public int getVATRuleRegulationId();
// public void setChangedBy(java.lang.String p0);
// public void setCreatedBy(java.lang.String p0);
// public void setDateChanged(java.sql.Date p0);
// public void setDateCreated(java.sql.Date p0);
// public void setDateTransaction(java.sql.Date p0);
// public void setDoublePosting(java.lang.String p0);
// public void setNotes(java.lang.String p0);
// public void setOrderId(int p0);
// public void setOwnPosting(java.lang.String p0);
// public void setPaymentHeader(se.idega.idegaweb.commune.accounting.invoice.data.PaymentHeader p0);
// public void setPaymentHeaderId(int p0);
// public void setPaymentText(java.lang.String p0);
// public void setPeriod(java.sql.Date p0);
// public void setPieceAmount(float p0);
// public void setPlacements(int p0);
// public void setRuleSpecType(java.lang.String p0);
// public void setStatus(char p0);
// public void setTotalAmount(float p0);
// public void setTotalAmountVAT(float p0);
// public void setVATRuleRegulation(se.idega.idegaweb.commune.accounting.regulations.data.Regulation p0);
// public void setVATRuleRegulationId(int p0);
// }
// Path: src/java/se/idega/idegaweb/commune/accounting/business/PaymentComparator.java
import java.text.Collator;
import java.util.Comparator;
import se.idega.idegaweb.commune.accounting.invoice.data.PaymentHeader;
import se.idega.idegaweb.commune.accounting.invoice.data.PaymentRecord;
import com.idega.util.LocaleUtil;
package se.idega.idegaweb.commune.accounting.business;
/**
* A class to compare a collection of PaymentRecords or PaymentHeaders objects.
* @author Sigtryggur
*/
public class PaymentComparator implements Comparator {
private Collator collator;
private String compareString1;
private String compareString2;
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare(Object o1, Object o2) {
this.collator = Collator.getInstance(LocaleUtil.getSwedishLocale());
if (o1 instanceof PaymentHeader) {
this.compareString1 = ((PaymentHeader) o1).getSchool().getName();
this.compareString2 = ((PaymentHeader) o2).getSchool().getName();
} | else if (o1 instanceof PaymentRecord) { |
jeffprestes/brasilino | android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/database/CandieSQLiteHelper.java | // Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/domain/Token.java
// public class Token
// {
// @SerializedName("token")
// private String token;
// @SerializedName("url")
// private String url;
//
// public Token() {}
//
// public Token(Cursor cursor) {
// this.url = null;
// this.token = cursor.getString(cursor.getColumnIndex(DomainNamespace.TOKEN));
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public Uri getUrl() {
// if(url == null) return null;
// return Uri.parse(url);
// }
//
// public void setUrl(Uri url) {
// this.url = (url == null?null:url.toString());
// }
//
// public ContentValues toContentValues() {
// ContentValues values = new ContentValues();
// values.put(DomainNamespace.TOKEN, token);
// return values;
// }
//
// public static String[] getColumns() {
// return new String[]{DomainNamespace.ID, DomainNamespace.TOKEN};
// }
//
// public class DomainNamespace {
// public static final String TABLE_NAME = "token";
// public static final String ID = "_id";
// public static final String TOKEN = "token";
// }
// }
| import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.paypal.developer.brasilino.domain.Token; | package com.paypal.developer.brasilino.database;
public class CandieSQLiteHelper extends SQLiteOpenHelper {
private static final String DB_NAME = "candies.db";
private static final int DB_VERSION = 1;
private static final String DATABASE_CREATION = "create table " + | // Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/domain/Token.java
// public class Token
// {
// @SerializedName("token")
// private String token;
// @SerializedName("url")
// private String url;
//
// public Token() {}
//
// public Token(Cursor cursor) {
// this.url = null;
// this.token = cursor.getString(cursor.getColumnIndex(DomainNamespace.TOKEN));
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public Uri getUrl() {
// if(url == null) return null;
// return Uri.parse(url);
// }
//
// public void setUrl(Uri url) {
// this.url = (url == null?null:url.toString());
// }
//
// public ContentValues toContentValues() {
// ContentValues values = new ContentValues();
// values.put(DomainNamespace.TOKEN, token);
// return values;
// }
//
// public static String[] getColumns() {
// return new String[]{DomainNamespace.ID, DomainNamespace.TOKEN};
// }
//
// public class DomainNamespace {
// public static final String TABLE_NAME = "token";
// public static final String ID = "_id";
// public static final String TOKEN = "token";
// }
// }
// Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/database/CandieSQLiteHelper.java
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.paypal.developer.brasilino.domain.Token;
package com.paypal.developer.brasilino.database;
public class CandieSQLiteHelper extends SQLiteOpenHelper {
private static final String DB_NAME = "candies.db";
private static final int DB_VERSION = 1;
private static final String DATABASE_CREATION = "create table " + | Token.DomainNamespace.TABLE_NAME + "(" + |
jeffprestes/brasilino | android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/application/CarrinhoApplication.java | // Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/database/CandieSQLiteDataSource.java
// public class CandieSQLiteDataSource
// {
// private SQLiteDatabase database;
// private SQLiteOpenHelper dbHelper;
//
// public CandieSQLiteDataSource(Context context) {
// dbHelper = new CandieSQLiteHelper(context);
// }
//
// private void open() throws SQLiteException {
// database = dbHelper.getWritableDatabase();
// }
//
// private SQLiteDatabase getWritableDatabase() throws SQLiteException {
// if(database == null)
// open();
// return database;
// }
//
// public void close() {
// database.close();
// dbHelper.close();
// database = null;
// }
//
// public Token getToken() {
//
// Cursor cursor = getWritableDatabase().query(
// Token.DomainNamespace.TABLE_NAME,
// Token.getColumns(),
// null,
// null,
// null,
// null,
// null
// );
//
// if(cursor == null)
// return null;
//
// if(cursor.moveToFirst()) {
// Token token = new Token(cursor);
// if(!cursor.isClosed())cursor.close();
// return token;
// }
//
// return null;
// }
//
// public boolean saveToken(Token token) {
// boolean successful = false;
// SQLiteDatabase db = getWritableDatabase();
// db.beginTransaction();
// try {
// long insertId = db.insert(
// Token.DomainNamespace.TABLE_NAME,
// null,
// token.toContentValues()
// );
// if(insertId >= 0) {
// successful = true;
// db.setTransactionSuccessful();
// }
// } catch (Exception ex) {
// successful = false;
// } finally {
// db.endTransaction();
// }
//
// return successful;
// }
//
// public boolean updateToken(Token token) {
// SQLiteDatabase db = getWritableDatabase();
// Cursor cursor = getWritableDatabase().query(
// Token.DomainNamespace.TABLE_NAME,
// Token.getColumns(),
// null,
// null,
// null,
// null,
// null
// );
// if(cursor != null && cursor.moveToFirst()) {
// int id = cursor.getInt(cursor.getColumnIndex(Token.DomainNamespace.ID));
// if(!cursor.isClosed())cursor.close();
// if(id >= 0) {
// int updated = db.update(
// Token.DomainNamespace.TABLE_NAME,
// token.toContentValues(),
// Token.DomainNamespace.ID + "=?",
// new String[]{String.valueOf(id)}
// );
// if(updated > 0)
// return true;
// }
// }
// return false;
// }
//
// }
//
// Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/util/OkHttpStack.java
// public class OkHttpStack extends HurlStack {
// private final OkUrlFactory mFactory;
//
// public OkHttpStack() {
// this(new OkHttpClient());
// }
//
// public OkHttpStack(OkHttpClient client) {
// if (client == null) {
// throw new NullPointerException("Client must not be null.");
// }
// mFactory = new OkUrlFactory(client);
// }
//
// @Override protected HttpURLConnection createConnection(URL url) throws IOException {
// return mFactory.open(url);
// }
// }
| import android.app.Application;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.paypal.developer.brasilino.database.CandieSQLiteDataSource;
import com.paypal.developer.brasilino.util.OkHttpStack; | package com.paypal.developer.brasilino.application;
/**
* Created by ricardo on 30/01/2015.
*/
public class CarrinhoApplication extends Application {
private static final String UNBIND_FLAG = "UNBIND_FLAG";
| // Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/database/CandieSQLiteDataSource.java
// public class CandieSQLiteDataSource
// {
// private SQLiteDatabase database;
// private SQLiteOpenHelper dbHelper;
//
// public CandieSQLiteDataSource(Context context) {
// dbHelper = new CandieSQLiteHelper(context);
// }
//
// private void open() throws SQLiteException {
// database = dbHelper.getWritableDatabase();
// }
//
// private SQLiteDatabase getWritableDatabase() throws SQLiteException {
// if(database == null)
// open();
// return database;
// }
//
// public void close() {
// database.close();
// dbHelper.close();
// database = null;
// }
//
// public Token getToken() {
//
// Cursor cursor = getWritableDatabase().query(
// Token.DomainNamespace.TABLE_NAME,
// Token.getColumns(),
// null,
// null,
// null,
// null,
// null
// );
//
// if(cursor == null)
// return null;
//
// if(cursor.moveToFirst()) {
// Token token = new Token(cursor);
// if(!cursor.isClosed())cursor.close();
// return token;
// }
//
// return null;
// }
//
// public boolean saveToken(Token token) {
// boolean successful = false;
// SQLiteDatabase db = getWritableDatabase();
// db.beginTransaction();
// try {
// long insertId = db.insert(
// Token.DomainNamespace.TABLE_NAME,
// null,
// token.toContentValues()
// );
// if(insertId >= 0) {
// successful = true;
// db.setTransactionSuccessful();
// }
// } catch (Exception ex) {
// successful = false;
// } finally {
// db.endTransaction();
// }
//
// return successful;
// }
//
// public boolean updateToken(Token token) {
// SQLiteDatabase db = getWritableDatabase();
// Cursor cursor = getWritableDatabase().query(
// Token.DomainNamespace.TABLE_NAME,
// Token.getColumns(),
// null,
// null,
// null,
// null,
// null
// );
// if(cursor != null && cursor.moveToFirst()) {
// int id = cursor.getInt(cursor.getColumnIndex(Token.DomainNamespace.ID));
// if(!cursor.isClosed())cursor.close();
// if(id >= 0) {
// int updated = db.update(
// Token.DomainNamespace.TABLE_NAME,
// token.toContentValues(),
// Token.DomainNamespace.ID + "=?",
// new String[]{String.valueOf(id)}
// );
// if(updated > 0)
// return true;
// }
// }
// return false;
// }
//
// }
//
// Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/util/OkHttpStack.java
// public class OkHttpStack extends HurlStack {
// private final OkUrlFactory mFactory;
//
// public OkHttpStack() {
// this(new OkHttpClient());
// }
//
// public OkHttpStack(OkHttpClient client) {
// if (client == null) {
// throw new NullPointerException("Client must not be null.");
// }
// mFactory = new OkUrlFactory(client);
// }
//
// @Override protected HttpURLConnection createConnection(URL url) throws IOException {
// return mFactory.open(url);
// }
// }
// Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/application/CarrinhoApplication.java
import android.app.Application;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.paypal.developer.brasilino.database.CandieSQLiteDataSource;
import com.paypal.developer.brasilino.util.OkHttpStack;
package com.paypal.developer.brasilino.application;
/**
* Created by ricardo on 30/01/2015.
*/
public class CarrinhoApplication extends Application {
private static final String UNBIND_FLAG = "UNBIND_FLAG";
| private CandieSQLiteDataSource dataSource; |
jeffprestes/brasilino | android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/application/CarrinhoApplication.java | // Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/database/CandieSQLiteDataSource.java
// public class CandieSQLiteDataSource
// {
// private SQLiteDatabase database;
// private SQLiteOpenHelper dbHelper;
//
// public CandieSQLiteDataSource(Context context) {
// dbHelper = new CandieSQLiteHelper(context);
// }
//
// private void open() throws SQLiteException {
// database = dbHelper.getWritableDatabase();
// }
//
// private SQLiteDatabase getWritableDatabase() throws SQLiteException {
// if(database == null)
// open();
// return database;
// }
//
// public void close() {
// database.close();
// dbHelper.close();
// database = null;
// }
//
// public Token getToken() {
//
// Cursor cursor = getWritableDatabase().query(
// Token.DomainNamespace.TABLE_NAME,
// Token.getColumns(),
// null,
// null,
// null,
// null,
// null
// );
//
// if(cursor == null)
// return null;
//
// if(cursor.moveToFirst()) {
// Token token = new Token(cursor);
// if(!cursor.isClosed())cursor.close();
// return token;
// }
//
// return null;
// }
//
// public boolean saveToken(Token token) {
// boolean successful = false;
// SQLiteDatabase db = getWritableDatabase();
// db.beginTransaction();
// try {
// long insertId = db.insert(
// Token.DomainNamespace.TABLE_NAME,
// null,
// token.toContentValues()
// );
// if(insertId >= 0) {
// successful = true;
// db.setTransactionSuccessful();
// }
// } catch (Exception ex) {
// successful = false;
// } finally {
// db.endTransaction();
// }
//
// return successful;
// }
//
// public boolean updateToken(Token token) {
// SQLiteDatabase db = getWritableDatabase();
// Cursor cursor = getWritableDatabase().query(
// Token.DomainNamespace.TABLE_NAME,
// Token.getColumns(),
// null,
// null,
// null,
// null,
// null
// );
// if(cursor != null && cursor.moveToFirst()) {
// int id = cursor.getInt(cursor.getColumnIndex(Token.DomainNamespace.ID));
// if(!cursor.isClosed())cursor.close();
// if(id >= 0) {
// int updated = db.update(
// Token.DomainNamespace.TABLE_NAME,
// token.toContentValues(),
// Token.DomainNamespace.ID + "=?",
// new String[]{String.valueOf(id)}
// );
// if(updated > 0)
// return true;
// }
// }
// return false;
// }
//
// }
//
// Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/util/OkHttpStack.java
// public class OkHttpStack extends HurlStack {
// private final OkUrlFactory mFactory;
//
// public OkHttpStack() {
// this(new OkHttpClient());
// }
//
// public OkHttpStack(OkHttpClient client) {
// if (client == null) {
// throw new NullPointerException("Client must not be null.");
// }
// mFactory = new OkUrlFactory(client);
// }
//
// @Override protected HttpURLConnection createConnection(URL url) throws IOException {
// return mFactory.open(url);
// }
// }
| import android.app.Application;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.paypal.developer.brasilino.database.CandieSQLiteDataSource;
import com.paypal.developer.brasilino.util.OkHttpStack; | * @param request A valid Volley {@link com.android.volley.Request}
*/
public void addRequestToQueue(Request<?> request) {
addRequestToQueue(request, CarrinhoApplication.class.getSimpleName());
}
/**
* <p>Add a Volley {@link com.android.volley.Request} to the application request queue.</p>
* <p>But, first, associate a {@link java.lang.String} tag to the request. So, it can be
* stopped latter</p>
* @param request A valid Volley {@link com.android.volley.Request}
* @param tag {@link java.lang.String} that will be associated to the specific request
*/
public void addRequestToQueue(Request<?> request, String tag) {
request.setTag(tag);
request.setRetryPolicy(new DefaultRetryPolicy(
10000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT
));
getQueue().add(request);
}
/**
* Get the application {@link com.android.volley.RequestQueue}. It holds all the application
* internet request
* @return The application {@link com.android.volley.RequestQueue}
*/
public RequestQueue getQueue() {
if(queue == null) { | // Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/database/CandieSQLiteDataSource.java
// public class CandieSQLiteDataSource
// {
// private SQLiteDatabase database;
// private SQLiteOpenHelper dbHelper;
//
// public CandieSQLiteDataSource(Context context) {
// dbHelper = new CandieSQLiteHelper(context);
// }
//
// private void open() throws SQLiteException {
// database = dbHelper.getWritableDatabase();
// }
//
// private SQLiteDatabase getWritableDatabase() throws SQLiteException {
// if(database == null)
// open();
// return database;
// }
//
// public void close() {
// database.close();
// dbHelper.close();
// database = null;
// }
//
// public Token getToken() {
//
// Cursor cursor = getWritableDatabase().query(
// Token.DomainNamespace.TABLE_NAME,
// Token.getColumns(),
// null,
// null,
// null,
// null,
// null
// );
//
// if(cursor == null)
// return null;
//
// if(cursor.moveToFirst()) {
// Token token = new Token(cursor);
// if(!cursor.isClosed())cursor.close();
// return token;
// }
//
// return null;
// }
//
// public boolean saveToken(Token token) {
// boolean successful = false;
// SQLiteDatabase db = getWritableDatabase();
// db.beginTransaction();
// try {
// long insertId = db.insert(
// Token.DomainNamespace.TABLE_NAME,
// null,
// token.toContentValues()
// );
// if(insertId >= 0) {
// successful = true;
// db.setTransactionSuccessful();
// }
// } catch (Exception ex) {
// successful = false;
// } finally {
// db.endTransaction();
// }
//
// return successful;
// }
//
// public boolean updateToken(Token token) {
// SQLiteDatabase db = getWritableDatabase();
// Cursor cursor = getWritableDatabase().query(
// Token.DomainNamespace.TABLE_NAME,
// Token.getColumns(),
// null,
// null,
// null,
// null,
// null
// );
// if(cursor != null && cursor.moveToFirst()) {
// int id = cursor.getInt(cursor.getColumnIndex(Token.DomainNamespace.ID));
// if(!cursor.isClosed())cursor.close();
// if(id >= 0) {
// int updated = db.update(
// Token.DomainNamespace.TABLE_NAME,
// token.toContentValues(),
// Token.DomainNamespace.ID + "=?",
// new String[]{String.valueOf(id)}
// );
// if(updated > 0)
// return true;
// }
// }
// return false;
// }
//
// }
//
// Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/util/OkHttpStack.java
// public class OkHttpStack extends HurlStack {
// private final OkUrlFactory mFactory;
//
// public OkHttpStack() {
// this(new OkHttpClient());
// }
//
// public OkHttpStack(OkHttpClient client) {
// if (client == null) {
// throw new NullPointerException("Client must not be null.");
// }
// mFactory = new OkUrlFactory(client);
// }
//
// @Override protected HttpURLConnection createConnection(URL url) throws IOException {
// return mFactory.open(url);
// }
// }
// Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/application/CarrinhoApplication.java
import android.app.Application;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.paypal.developer.brasilino.database.CandieSQLiteDataSource;
import com.paypal.developer.brasilino.util.OkHttpStack;
* @param request A valid Volley {@link com.android.volley.Request}
*/
public void addRequestToQueue(Request<?> request) {
addRequestToQueue(request, CarrinhoApplication.class.getSimpleName());
}
/**
* <p>Add a Volley {@link com.android.volley.Request} to the application request queue.</p>
* <p>But, first, associate a {@link java.lang.String} tag to the request. So, it can be
* stopped latter</p>
* @param request A valid Volley {@link com.android.volley.Request}
* @param tag {@link java.lang.String} that will be associated to the specific request
*/
public void addRequestToQueue(Request<?> request, String tag) {
request.setTag(tag);
request.setRetryPolicy(new DefaultRetryPolicy(
10000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT
));
getQueue().add(request);
}
/**
* Get the application {@link com.android.volley.RequestQueue}. It holds all the application
* internet request
* @return The application {@link com.android.volley.RequestQueue}
*/
public RequestQueue getQueue() {
if(queue == null) { | queue = Volley.newRequestQueue(app, new OkHttpStack()); |
jeffprestes/brasilino | android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/util/Util.java | // Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/broadcast/PaymentOrderReceiver.java
// public class PaymentOrderReceiver extends BroadcastReceiver {
//
// public PaymentOrderReceiver() {}
//
// @Override
// public void onReceive(Context context, Intent intent) {
//
// NotificationManagerCompat.from(context).cancel(Util.NOTIFICATION_ID);
//
// if(intent != null && intent.hasExtra(IntentParameters.UUID)) {
// CandieSQLiteDataSource dataSource = CarrinhoApplication.getDatasource();
//
// if(dataSource != null) {
// Token token = dataSource.getToken();
// if(token != null) {
//
// Util.sendMessage(
// "/candies/payment",
// "start"
// );
//
// Intent serviceIntent = new Intent(context, PaymentService.class);
// serviceIntent.putExtras(intent.getExtras());
// serviceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// context.startService(serviceIntent);
// return;
// }
// }
//
// Util.sendMessage(
// "/candies/payment",
// "token"
// );
//
// Intent webIntent = new Intent(context, PermissionActivity.class);
// webIntent.putExtras(intent.getExtras());
// webIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// context.startActivity(webIntent);
// }
// }
// }
| import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.util.Log;
import com.paypal.developer.brasilino.R;
import com.paypal.developer.brasilino.broadcast.PaymentOrderReceiver;
import java.util.Calendar; | package com.paypal.developer.brasilino.util;
/**
* Created by ricardo on 31/01/2015.
*/
public class Util
{
public static final int NOTIFICATION_ID = 123456;
public static final double PRODUCT_DEFAULT_VALUE_FIVE = 1.0f;
public static final double PRODUCT_DEFAULT_VALUE_TEN = 2.0f;
public static void dispatchNotification(Context context, String uuid, String major, String minor, int productImage)
{
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), productImage);
dispatchNotification(context, uuid, major, minor, bitmap);
bitmap.recycle();
}
public static void dispatchNotification(Context context, String uuid, String major, String minor, Bitmap productImage)
{
Bundle infoBundle = new Bundle();
infoBundle.putString(IntentParameters.UUID,uuid);
infoBundle.putString(IntentParameters.MAJOR,major);
infoBundle.putString(IntentParameters.MINOR,minor);
| // Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/broadcast/PaymentOrderReceiver.java
// public class PaymentOrderReceiver extends BroadcastReceiver {
//
// public PaymentOrderReceiver() {}
//
// @Override
// public void onReceive(Context context, Intent intent) {
//
// NotificationManagerCompat.from(context).cancel(Util.NOTIFICATION_ID);
//
// if(intent != null && intent.hasExtra(IntentParameters.UUID)) {
// CandieSQLiteDataSource dataSource = CarrinhoApplication.getDatasource();
//
// if(dataSource != null) {
// Token token = dataSource.getToken();
// if(token != null) {
//
// Util.sendMessage(
// "/candies/payment",
// "start"
// );
//
// Intent serviceIntent = new Intent(context, PaymentService.class);
// serviceIntent.putExtras(intent.getExtras());
// serviceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// context.startService(serviceIntent);
// return;
// }
// }
//
// Util.sendMessage(
// "/candies/payment",
// "token"
// );
//
// Intent webIntent = new Intent(context, PermissionActivity.class);
// webIntent.putExtras(intent.getExtras());
// webIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// context.startActivity(webIntent);
// }
// }
// }
// Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/util/Util.java
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.util.Log;
import com.paypal.developer.brasilino.R;
import com.paypal.developer.brasilino.broadcast.PaymentOrderReceiver;
import java.util.Calendar;
package com.paypal.developer.brasilino.util;
/**
* Created by ricardo on 31/01/2015.
*/
public class Util
{
public static final int NOTIFICATION_ID = 123456;
public static final double PRODUCT_DEFAULT_VALUE_FIVE = 1.0f;
public static final double PRODUCT_DEFAULT_VALUE_TEN = 2.0f;
public static void dispatchNotification(Context context, String uuid, String major, String minor, int productImage)
{
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), productImage);
dispatchNotification(context, uuid, major, minor, bitmap);
bitmap.recycle();
}
public static void dispatchNotification(Context context, String uuid, String major, String minor, Bitmap productImage)
{
Bundle infoBundle = new Bundle();
infoBundle.putString(IntentParameters.UUID,uuid);
infoBundle.putString(IntentParameters.MAJOR,major);
infoBundle.putString(IntentParameters.MINOR,minor);
| Intent purchaseIntent = new Intent(context, PaymentOrderReceiver.class); |
jeffprestes/brasilino | android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/database/CandieSQLiteDataSource.java | // Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/domain/Token.java
// public class Token
// {
// @SerializedName("token")
// private String token;
// @SerializedName("url")
// private String url;
//
// public Token() {}
//
// public Token(Cursor cursor) {
// this.url = null;
// this.token = cursor.getString(cursor.getColumnIndex(DomainNamespace.TOKEN));
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public Uri getUrl() {
// if(url == null) return null;
// return Uri.parse(url);
// }
//
// public void setUrl(Uri url) {
// this.url = (url == null?null:url.toString());
// }
//
// public ContentValues toContentValues() {
// ContentValues values = new ContentValues();
// values.put(DomainNamespace.TOKEN, token);
// return values;
// }
//
// public static String[] getColumns() {
// return new String[]{DomainNamespace.ID, DomainNamespace.TOKEN};
// }
//
// public class DomainNamespace {
// public static final String TABLE_NAME = "token";
// public static final String ID = "_id";
// public static final String TOKEN = "token";
// }
// }
| import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import com.paypal.developer.brasilino.domain.Token; | package com.paypal.developer.brasilino.database;
public class CandieSQLiteDataSource
{
private SQLiteDatabase database;
private SQLiteOpenHelper dbHelper;
public CandieSQLiteDataSource(Context context) {
dbHelper = new CandieSQLiteHelper(context);
}
private void open() throws SQLiteException {
database = dbHelper.getWritableDatabase();
}
private SQLiteDatabase getWritableDatabase() throws SQLiteException {
if(database == null)
open();
return database;
}
public void close() {
database.close();
dbHelper.close();
database = null;
}
| // Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/domain/Token.java
// public class Token
// {
// @SerializedName("token")
// private String token;
// @SerializedName("url")
// private String url;
//
// public Token() {}
//
// public Token(Cursor cursor) {
// this.url = null;
// this.token = cursor.getString(cursor.getColumnIndex(DomainNamespace.TOKEN));
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public Uri getUrl() {
// if(url == null) return null;
// return Uri.parse(url);
// }
//
// public void setUrl(Uri url) {
// this.url = (url == null?null:url.toString());
// }
//
// public ContentValues toContentValues() {
// ContentValues values = new ContentValues();
// values.put(DomainNamespace.TOKEN, token);
// return values;
// }
//
// public static String[] getColumns() {
// return new String[]{DomainNamespace.ID, DomainNamespace.TOKEN};
// }
//
// public class DomainNamespace {
// public static final String TABLE_NAME = "token";
// public static final String ID = "_id";
// public static final String TOKEN = "token";
// }
// }
// Path: android/Brasilino/app/src/main/java/com/paypal/developer/brasilino/database/CandieSQLiteDataSource.java
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import com.paypal.developer.brasilino.domain.Token;
package com.paypal.developer.brasilino.database;
public class CandieSQLiteDataSource
{
private SQLiteDatabase database;
private SQLiteOpenHelper dbHelper;
public CandieSQLiteDataSource(Context context) {
dbHelper = new CandieSQLiteHelper(context);
}
private void open() throws SQLiteException {
database = dbHelper.getWritableDatabase();
}
private SQLiteDatabase getWritableDatabase() throws SQLiteException {
if(database == null)
open();
return database;
}
public void close() {
database.close();
dbHelper.close();
database = null;
}
| public Token getToken() { |
ldbc-dev/ldbc_snb_datagen_deprecated2015 | src/main/java/ldbc/socialnet/dbgen/util/MapReduceKeyComparator.java | // Path: src/main/java/ldbc/socialnet/dbgen/util/MapReduceKey.java
// public class MapReduceKey implements WritableComparable<MapReduceKey> {
// public int block;
// public int key;
// public long id;
//
// public MapReduceKey( ) {
// }
//
// public MapReduceKey( int block, int key, long id) {
// this.block = block;
// this.key = key;
// this.id = id;
// }
//
// @Override
// public void write(DataOutput out) throws IOException {
// out.writeInt(block);
// out.writeInt(key);
// out.writeLong(id);
// }
//
// @Override
// public void readFields(DataInput in) throws IOException {
// block = in.readInt();
// key = in.readInt();
// id = in.readLong();
// }
//
// @Override
// public int compareTo( MapReduceKey mpk) {
// return block - mpk.block;
// }
// }
| import org.apache.hadoop.io.WritableComparator;
import ldbc.socialnet.dbgen.util.MapReduceKey;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.ArrayList;
import java.util.Iterator; | /*
* Copyright (c) 2013 LDBC
* Linked Data Benchmark Council (http://ldbc.eu)
*
* This file is part of ldbc_socialnet_dbgen.
*
* ldbc_socialnet_dbgen is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ldbc_socialnet_dbgen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ldbc_socialnet_dbgen. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011 OpenLink Software <[email protected]>
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; only Version 2 of the License dated
* June 1991.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package ldbc.socialnet.dbgen.util;
public class MapReduceKeyComparator extends WritableComparator {
protected MapReduceKeyComparator() { | // Path: src/main/java/ldbc/socialnet/dbgen/util/MapReduceKey.java
// public class MapReduceKey implements WritableComparable<MapReduceKey> {
// public int block;
// public int key;
// public long id;
//
// public MapReduceKey( ) {
// }
//
// public MapReduceKey( int block, int key, long id) {
// this.block = block;
// this.key = key;
// this.id = id;
// }
//
// @Override
// public void write(DataOutput out) throws IOException {
// out.writeInt(block);
// out.writeInt(key);
// out.writeLong(id);
// }
//
// @Override
// public void readFields(DataInput in) throws IOException {
// block = in.readInt();
// key = in.readInt();
// id = in.readLong();
// }
//
// @Override
// public int compareTo( MapReduceKey mpk) {
// return block - mpk.block;
// }
// }
// Path: src/main/java/ldbc/socialnet/dbgen/util/MapReduceKeyComparator.java
import org.apache.hadoop.io.WritableComparator;
import ldbc.socialnet.dbgen.util.MapReduceKey;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.ArrayList;
import java.util.Iterator;
/*
* Copyright (c) 2013 LDBC
* Linked Data Benchmark Council (http://ldbc.eu)
*
* This file is part of ldbc_socialnet_dbgen.
*
* ldbc_socialnet_dbgen is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ldbc_socialnet_dbgen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ldbc_socialnet_dbgen. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011 OpenLink Software <[email protected]>
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; only Version 2 of the License dated
* June 1991.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package ldbc.socialnet.dbgen.util;
public class MapReduceKeyComparator extends WritableComparator {
protected MapReduceKeyComparator() { | super(MapReduceKey.class); |
ldbc-dev/ldbc_snb_datagen_deprecated2015 | src/main/java/ldbc/socialnet/dbgen/util/MapReduceKeyGroupKeyComparator.java | // Path: src/main/java/ldbc/socialnet/dbgen/util/MapReduceKey.java
// public class MapReduceKey implements WritableComparable<MapReduceKey> {
// public int block;
// public int key;
// public long id;
//
// public MapReduceKey( ) {
// }
//
// public MapReduceKey( int block, int key, long id) {
// this.block = block;
// this.key = key;
// this.id = id;
// }
//
// @Override
// public void write(DataOutput out) throws IOException {
// out.writeInt(block);
// out.writeInt(key);
// out.writeLong(id);
// }
//
// @Override
// public void readFields(DataInput in) throws IOException {
// block = in.readInt();
// key = in.readInt();
// id = in.readLong();
// }
//
// @Override
// public int compareTo( MapReduceKey mpk) {
// return block - mpk.block;
// }
// }
| import org.apache.hadoop.io.WritableComparator;
import ldbc.socialnet.dbgen.util.MapReduceKey;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.ArrayList;
import java.util.Iterator; | /*
* Copyright (c) 2013 LDBC
* Linked Data Benchmark Council (http://ldbc.eu)
*
* This file is part of ldbc_socialnet_dbgen.
*
* ldbc_socialnet_dbgen is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ldbc_socialnet_dbgen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ldbc_socialnet_dbgen. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011 OpenLink Software <[email protected]>
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; only Version 2 of the License dated
* June 1991.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package ldbc.socialnet.dbgen.util;
public class MapReduceKeyGroupKeyComparator extends WritableComparator {
protected MapReduceKeyGroupKeyComparator() { | // Path: src/main/java/ldbc/socialnet/dbgen/util/MapReduceKey.java
// public class MapReduceKey implements WritableComparable<MapReduceKey> {
// public int block;
// public int key;
// public long id;
//
// public MapReduceKey( ) {
// }
//
// public MapReduceKey( int block, int key, long id) {
// this.block = block;
// this.key = key;
// this.id = id;
// }
//
// @Override
// public void write(DataOutput out) throws IOException {
// out.writeInt(block);
// out.writeInt(key);
// out.writeLong(id);
// }
//
// @Override
// public void readFields(DataInput in) throws IOException {
// block = in.readInt();
// key = in.readInt();
// id = in.readLong();
// }
//
// @Override
// public int compareTo( MapReduceKey mpk) {
// return block - mpk.block;
// }
// }
// Path: src/main/java/ldbc/socialnet/dbgen/util/MapReduceKeyGroupKeyComparator.java
import org.apache.hadoop.io.WritableComparator;
import ldbc.socialnet.dbgen.util.MapReduceKey;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.ArrayList;
import java.util.Iterator;
/*
* Copyright (c) 2013 LDBC
* Linked Data Benchmark Council (http://ldbc.eu)
*
* This file is part of ldbc_socialnet_dbgen.
*
* ldbc_socialnet_dbgen is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ldbc_socialnet_dbgen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ldbc_socialnet_dbgen. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011 OpenLink Software <[email protected]>
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; only Version 2 of the License dated
* June 1991.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package ldbc.socialnet.dbgen.util;
public class MapReduceKeyGroupKeyComparator extends WritableComparator {
protected MapReduceKeyGroupKeyComparator() { | super(MapReduceKey.class); |
ldbc-dev/ldbc_snb_datagen_deprecated2015 | src/main/java/ldbc/socialnet/dbgen/dictionary/UniversityDictionary.java | // Path: src/main/java/ldbc/socialnet/dbgen/util/RandomGeneratorFarm.java
// public class RandomGeneratorFarm {
//
// int numRandomGenerators;
// Random[] randomGenerators;
//
// public enum Aspect {
// DATE,
// BIRTH_DAY,
// FRIEND_REQUEST,
// FRIEND_REJECT,
// FRIEND_APROVAL,
// INITIATOR,
// UNIFORM,
// NUM_INTEREST,
// NUM_TAG,
// NUM_FRIEND,
// NUM_COMMENT,
// NUM_PHOTO_ALBUM,
// NUM_PHOTO,
// NUM_GROUP,
// NUM_USERS_PER_GROUP,
// NUM_POPULAR,
// NUM_LIKE,
// NUM_POST,
// FRIEND,
// FRIEND_LEVEL,
// GENDER,
// RANDOM,
// MEMBERSHIP,
// MEMBERSHIP_INDEX,
// GROUP,
// GROUP_MODERATOR,
// GROUP_INTEREST,
// EXTRA_INFO,
// EXACT_LONG_LAT,
// STATUS,
// HAVE_STATUS,
// STATUS_SINGLE,
// USER_AGENT,
// USER_AGENT_SENT,
// FILE_SELECT,
// IP,
// DIFF_IP_FOR_TRAVELER,
// DIFF_IP,
// BROWSER,
// DIFF_BROWSER,
// CITY,
// COUNTRY,
// TAG,
// UNIVERSITY,
// UNCORRELATED_UNIVERSITY,
// UNCORRELATED_UNIVERSITY_LOCATION,
// TOP_UNIVERSITY,
// POPULAR,
// EMAIL,
// TOP_EMAIL,
// COMPANY,
// UNCORRELATED_COMPANY,
// UNCORRELATED_COMPANY_LOCATION,
// LANGUAGE,
// ALBUM,
// ALBUM_MEMBERSHIP,
// NAME,
// SURNAME,
// TAG_OTHER_COUNTRY,
// SET_OF_TAG,
// TEXT_SIZE,
// REDUCED_TEXT,
// LARGE_TEXT,
// MEMBERSHIP_POST_CREATOR,
// REPLY_TO,
// TOPIC,
// NUM_ASPECT // This must be always the last one.
// }
//
// public RandomGeneratorFarm () {
// numRandomGenerators = Aspect.values().length;
// randomGenerators = new Random[numRandomGenerators];
// for( int i = 0; i < numRandomGenerators; ++i) {
// randomGenerators[i] = new Random();
// }
// }
//
// public Random get(Aspect aspect) {
// return randomGenerators[aspect.ordinal()];
// }
//
// public void resetRandomGenerators( long seed ) {
// Random seedRandom = new Random(53223436L + 1234567*seed);
// for (int i = 0; i < numRandomGenerators; i++) {
// randomGenerators[i].setSeed(seedRandom.nextLong());
// }
// }
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import ldbc.socialnet.dbgen.util.RandomGeneratorFarm; | new InputStreamReader(getClass( ).getResourceAsStream(dicFileName), "UTF-8"));
String line;
int curLocationId = -1;
String lastLocationName = "";
long totalNumUniversities = startIndex;
while ((line = dicAllInstitutes.readLine()) != null){
String data[] = line.split(SEPARATOR);
String locationName = data[0];
String cityName = data[2];
if (locationDic.getCountryId(locationName) != LocationDictionary.INVALID_LOCATION &&
locationDic.getCityId(cityName) != LocationDictionary.INVALID_LOCATION ) {
curLocationId = locationDic.getCountryId(locationName);
String universityName = data[1].trim();
universitiesByLocation.get(curLocationId).add(totalNumUniversities);
Integer cityId = locationDic.getCityId(cityName);
universityToLocation.put(totalNumUniversities, cityId);
this.universityName.put(totalNumUniversities,universityName);
totalNumUniversities++;
}
}
dicAllInstitutes.close();
System.out.println("Done ... " + totalNumUniversities + " universities were extracted");
} catch (IOException e) {
e.printStackTrace();
}
}
// 90% of people go to top-10 universities
// 10% go to remaining universities | // Path: src/main/java/ldbc/socialnet/dbgen/util/RandomGeneratorFarm.java
// public class RandomGeneratorFarm {
//
// int numRandomGenerators;
// Random[] randomGenerators;
//
// public enum Aspect {
// DATE,
// BIRTH_DAY,
// FRIEND_REQUEST,
// FRIEND_REJECT,
// FRIEND_APROVAL,
// INITIATOR,
// UNIFORM,
// NUM_INTEREST,
// NUM_TAG,
// NUM_FRIEND,
// NUM_COMMENT,
// NUM_PHOTO_ALBUM,
// NUM_PHOTO,
// NUM_GROUP,
// NUM_USERS_PER_GROUP,
// NUM_POPULAR,
// NUM_LIKE,
// NUM_POST,
// FRIEND,
// FRIEND_LEVEL,
// GENDER,
// RANDOM,
// MEMBERSHIP,
// MEMBERSHIP_INDEX,
// GROUP,
// GROUP_MODERATOR,
// GROUP_INTEREST,
// EXTRA_INFO,
// EXACT_LONG_LAT,
// STATUS,
// HAVE_STATUS,
// STATUS_SINGLE,
// USER_AGENT,
// USER_AGENT_SENT,
// FILE_SELECT,
// IP,
// DIFF_IP_FOR_TRAVELER,
// DIFF_IP,
// BROWSER,
// DIFF_BROWSER,
// CITY,
// COUNTRY,
// TAG,
// UNIVERSITY,
// UNCORRELATED_UNIVERSITY,
// UNCORRELATED_UNIVERSITY_LOCATION,
// TOP_UNIVERSITY,
// POPULAR,
// EMAIL,
// TOP_EMAIL,
// COMPANY,
// UNCORRELATED_COMPANY,
// UNCORRELATED_COMPANY_LOCATION,
// LANGUAGE,
// ALBUM,
// ALBUM_MEMBERSHIP,
// NAME,
// SURNAME,
// TAG_OTHER_COUNTRY,
// SET_OF_TAG,
// TEXT_SIZE,
// REDUCED_TEXT,
// LARGE_TEXT,
// MEMBERSHIP_POST_CREATOR,
// REPLY_TO,
// TOPIC,
// NUM_ASPECT // This must be always the last one.
// }
//
// public RandomGeneratorFarm () {
// numRandomGenerators = Aspect.values().length;
// randomGenerators = new Random[numRandomGenerators];
// for( int i = 0; i < numRandomGenerators; ++i) {
// randomGenerators[i] = new Random();
// }
// }
//
// public Random get(Aspect aspect) {
// return randomGenerators[aspect.ordinal()];
// }
//
// public void resetRandomGenerators( long seed ) {
// Random seedRandom = new Random(53223436L + 1234567*seed);
// for (int i = 0; i < numRandomGenerators; i++) {
// randomGenerators[i].setSeed(seedRandom.nextLong());
// }
// }
// }
// Path: src/main/java/ldbc/socialnet/dbgen/dictionary/UniversityDictionary.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import ldbc.socialnet.dbgen.util.RandomGeneratorFarm;
new InputStreamReader(getClass( ).getResourceAsStream(dicFileName), "UTF-8"));
String line;
int curLocationId = -1;
String lastLocationName = "";
long totalNumUniversities = startIndex;
while ((line = dicAllInstitutes.readLine()) != null){
String data[] = line.split(SEPARATOR);
String locationName = data[0];
String cityName = data[2];
if (locationDic.getCountryId(locationName) != LocationDictionary.INVALID_LOCATION &&
locationDic.getCityId(cityName) != LocationDictionary.INVALID_LOCATION ) {
curLocationId = locationDic.getCountryId(locationName);
String universityName = data[1].trim();
universitiesByLocation.get(curLocationId).add(totalNumUniversities);
Integer cityId = locationDic.getCityId(cityName);
universityToLocation.put(totalNumUniversities, cityId);
this.universityName.put(totalNumUniversities,universityName);
totalNumUniversities++;
}
}
dicAllInstitutes.close();
System.out.println("Done ... " + totalNumUniversities + " universities were extracted");
} catch (IOException e) {
e.printStackTrace();
}
}
// 90% of people go to top-10 universities
// 10% go to remaining universities | public int getRandomUniversity(RandomGeneratorFarm randomFarm, int locationId) { |
ldbc-dev/ldbc_snb_datagen_deprecated2015 | src/main/java/ldbc/socialnet/dbgen/dictionary/PopularPlacesDictionary.java | // Path: src/main/java/ldbc/socialnet/dbgen/objects/PopularPlace.java
// public class PopularPlace {
//
// String name;
// double latt;
// double longt;
//
// public PopularPlace(String _name, double _latt, double _longt){
// this.name = _name;
// this.latt = _latt;
// this.longt = _longt;
// }
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public double getLatt() {
// return latt;
// }
//
// public void setLatt(double latt) {
// this.latt = latt;
// }
//
// public double getLongt() {
// return longt;
// }
//
// public void setLongt(double longt) {
// this.longt = longt;
// }
//
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Random;
import java.util.Vector;
import ldbc.socialnet.dbgen.objects.PopularPlace; | /*
* Copyright (c) 2013 LDBC
* Linked Data Benchmark Council (http://ldbc.eu)
*
* This file is part of ldbc_socialnet_dbgen.
*
* ldbc_socialnet_dbgen is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ldbc_socialnet_dbgen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ldbc_socialnet_dbgen. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011 OpenLink Software <[email protected]>
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; only Version 2 of the License dated
* June 1991.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package ldbc.socialnet.dbgen.dictionary;
public class PopularPlacesDictionary {
String dicFileName;
LocationDictionary locationDic; | // Path: src/main/java/ldbc/socialnet/dbgen/objects/PopularPlace.java
// public class PopularPlace {
//
// String name;
// double latt;
// double longt;
//
// public PopularPlace(String _name, double _latt, double _longt){
// this.name = _name;
// this.latt = _latt;
// this.longt = _longt;
// }
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public double getLatt() {
// return latt;
// }
//
// public void setLatt(double latt) {
// this.latt = latt;
// }
//
// public double getLongt() {
// return longt;
// }
//
// public void setLongt(double longt) {
// this.longt = longt;
// }
//
// }
// Path: src/main/java/ldbc/socialnet/dbgen/dictionary/PopularPlacesDictionary.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Random;
import java.util.Vector;
import ldbc.socialnet.dbgen.objects.PopularPlace;
/*
* Copyright (c) 2013 LDBC
* Linked Data Benchmark Council (http://ldbc.eu)
*
* This file is part of ldbc_socialnet_dbgen.
*
* ldbc_socialnet_dbgen is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ldbc_socialnet_dbgen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ldbc_socialnet_dbgen. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011 OpenLink Software <[email protected]>
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; only Version 2 of the License dated
* June 1991.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package ldbc.socialnet.dbgen.dictionary;
public class PopularPlacesDictionary {
String dicFileName;
LocationDictionary locationDic; | HashMap<Integer, Vector<PopularPlace>> popularPlacesByLocations; |
ldbc-dev/ldbc_snb_datagen_deprecated2015 | src/main/java/ldbc/socialnet/dbgen/serializer/CSVSerializer/OrganizationResolver.java | // Path: src/main/java/ldbc/socialnet/dbgen/objects/Organization.java
// public class Organization {
//
//
// public long id;
// public String name;
// public ScalableGenerator.OrganisationType type;
// public int location;
// }
//
// Path: src/main/java/ldbc/socialnet/dbgen/vocabulary/DBP.java
// public class DBP {
//
// public static final String NAMESPACE = "http://dbpedia.org/resource/";
// public static final String PREFIX = "dbpedia:";
//
//
// /**
// * Gets the dbpedia resource prefix version of the input.
// */
// public static String prefixed(String string) {
// return PREFIX + string;
// }
//
// /**
// * Gets the dbpedia resource URL version of the input.
// */
// public static String getUrl(String string) {
// return NAMESPACE + string;
// }
//
// /**
// * Gets the dbpedia resource RDF-URL version of the input.
// */
// public static String fullPrefixed(String string) {
// return "<" + NAMESPACE + string + ">";
// }
// }
| import ldbc.socialnet.dbgen.objects.Organization;
import ldbc.socialnet.dbgen.vocabulary.DBP;
import java.util.ArrayList; | package ldbc.socialnet.dbgen.serializer.CSVSerializer;
/**
* Created by aprat on 4/14/14.
*/
public class OrganizationResolver implements EntityFieldResolver<Organization> {
@Override
public ArrayList<String> queryField(String string, Organization organization) {
ArrayList<String> ret = new ArrayList<String>();
if( string.equals("id") ) {
ret.add(Long.toString(organization.id));
return ret;
}
if( string.equals("type") ) {
ret.add(organization.type.toString());
return ret;
}
if( string.equals("name") ) {
ret.add(organization.name);
return ret;
}
if( string.equals("url") ) { | // Path: src/main/java/ldbc/socialnet/dbgen/objects/Organization.java
// public class Organization {
//
//
// public long id;
// public String name;
// public ScalableGenerator.OrganisationType type;
// public int location;
// }
//
// Path: src/main/java/ldbc/socialnet/dbgen/vocabulary/DBP.java
// public class DBP {
//
// public static final String NAMESPACE = "http://dbpedia.org/resource/";
// public static final String PREFIX = "dbpedia:";
//
//
// /**
// * Gets the dbpedia resource prefix version of the input.
// */
// public static String prefixed(String string) {
// return PREFIX + string;
// }
//
// /**
// * Gets the dbpedia resource URL version of the input.
// */
// public static String getUrl(String string) {
// return NAMESPACE + string;
// }
//
// /**
// * Gets the dbpedia resource RDF-URL version of the input.
// */
// public static String fullPrefixed(String string) {
// return "<" + NAMESPACE + string + ">";
// }
// }
// Path: src/main/java/ldbc/socialnet/dbgen/serializer/CSVSerializer/OrganizationResolver.java
import ldbc.socialnet.dbgen.objects.Organization;
import ldbc.socialnet.dbgen.vocabulary.DBP;
import java.util.ArrayList;
package ldbc.socialnet.dbgen.serializer.CSVSerializer;
/**
* Created by aprat on 4/14/14.
*/
public class OrganizationResolver implements EntityFieldResolver<Organization> {
@Override
public ArrayList<String> queryField(String string, Organization organization) {
ArrayList<String> ret = new ArrayList<String>();
if( string.equals("id") ) {
ret.add(Long.toString(organization.id));
return ret;
}
if( string.equals("type") ) {
ret.add(organization.type.toString());
return ret;
}
if( string.equals("name") ) {
ret.add(organization.name);
return ret;
}
if( string.equals("url") ) { | ret.add(DBP.getUrl(organization.name)); |
ldbc-dev/ldbc_snb_datagen_deprecated2015 | src/main/java/ldbc/socialnet/dbgen/serializer/CSVSerializer/TagResolver.java | // Path: src/main/java/ldbc/socialnet/dbgen/objects/Tag.java
// public class Tag {
// public int id;
// public int tagClass;
// public String name;
//
// }
//
// Path: src/main/java/ldbc/socialnet/dbgen/vocabulary/DBP.java
// public class DBP {
//
// public static final String NAMESPACE = "http://dbpedia.org/resource/";
// public static final String PREFIX = "dbpedia:";
//
//
// /**
// * Gets the dbpedia resource prefix version of the input.
// */
// public static String prefixed(String string) {
// return PREFIX + string;
// }
//
// /**
// * Gets the dbpedia resource URL version of the input.
// */
// public static String getUrl(String string) {
// return NAMESPACE + string;
// }
//
// /**
// * Gets the dbpedia resource RDF-URL version of the input.
// */
// public static String fullPrefixed(String string) {
// return "<" + NAMESPACE + string + ">";
// }
// }
| import ldbc.socialnet.dbgen.objects.Tag;
import ldbc.socialnet.dbgen.vocabulary.DBP;
import java.util.ArrayList; | package ldbc.socialnet.dbgen.serializer.CSVSerializer;
/**
* Created by aprat on 4/14/14.
*/
public class TagResolver implements EntityFieldResolver<Tag> {
@Override
public ArrayList<String> queryField(String string, Tag tag) {
ArrayList<String> ret = new ArrayList<String>();
if( string.equals("id") ) {
ret.add(Integer.toString(tag.id));
return ret;
}
if( string.equals("name") ) {
ret.add(tag.name);
return ret;
}
if( string.equals("url") ) { | // Path: src/main/java/ldbc/socialnet/dbgen/objects/Tag.java
// public class Tag {
// public int id;
// public int tagClass;
// public String name;
//
// }
//
// Path: src/main/java/ldbc/socialnet/dbgen/vocabulary/DBP.java
// public class DBP {
//
// public static final String NAMESPACE = "http://dbpedia.org/resource/";
// public static final String PREFIX = "dbpedia:";
//
//
// /**
// * Gets the dbpedia resource prefix version of the input.
// */
// public static String prefixed(String string) {
// return PREFIX + string;
// }
//
// /**
// * Gets the dbpedia resource URL version of the input.
// */
// public static String getUrl(String string) {
// return NAMESPACE + string;
// }
//
// /**
// * Gets the dbpedia resource RDF-URL version of the input.
// */
// public static String fullPrefixed(String string) {
// return "<" + NAMESPACE + string + ">";
// }
// }
// Path: src/main/java/ldbc/socialnet/dbgen/serializer/CSVSerializer/TagResolver.java
import ldbc.socialnet.dbgen.objects.Tag;
import ldbc.socialnet.dbgen.vocabulary.DBP;
import java.util.ArrayList;
package ldbc.socialnet.dbgen.serializer.CSVSerializer;
/**
* Created by aprat on 4/14/14.
*/
public class TagResolver implements EntityFieldResolver<Tag> {
@Override
public ArrayList<String> queryField(String string, Tag tag) {
ArrayList<String> ret = new ArrayList<String>();
if( string.equals("id") ) {
ret.add(Integer.toString(tag.id));
return ret;
}
if( string.equals("name") ) {
ret.add(tag.name);
return ret;
}
if( string.equals("url") ) { | ret.add(DBP.getUrl(tag.name)); |
ldbc-dev/ldbc_snb_datagen_deprecated2015 | src/main/java/ldbc/socialnet/dbgen/storage/StreamStoreManager.java | // Path: src/main/java/ldbc/socialnet/dbgen/objects/GPS.java
// public class GPS implements Serializable{
// private static final long serialVersionUID = 3657773293974543890L;
// long trackedTime;
// String trackedLocation;
// double longt;
// double latt;
// long userId; // Id of the user has been tracked
//
// public long getTrackedTime() {
// return trackedTime;
// }
// public void setTrackedTime(long trackedTime) {
// this.trackedTime = trackedTime;
// }
// public String getTrackedLocation() {
// return trackedLocation;
// }
// public void setTrackedLocation(String trackedLocation) {
// this.trackedLocation = trackedLocation;
// }
// public double getLongt() {
// return longt;
// }
// public void setLongt(double longt) {
// this.longt = longt;
// }
// public double getLatt() {
// return latt;
// }
// public void setLatt(double latt) {
// this.latt = latt;
// }
// public long getUserId() {
// return userId;
// }
// public void setUserId(long userId) {
// this.userId = userId;
// }
//
// }
| import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import ldbc.socialnet.dbgen.objects.GPS; |
public String getOutFileName() {
return outFileName;
}
public void setOutFileName(String outFileName) {
this.outFileName = outFileName;
}
public String getSortedFileName() {
return sortedFileName;
}
public void setSortedFileName(String sortedFileName) {
this.sortedFileName = sortedFileName;
}
public void initSerialization() {
try {
numberSerializedObject = 0;
fos = new FileOutputStream(baseDir + outFileName);
oos = new ObjectOutputStream(fos);
} catch (IOException i) {
i.printStackTrace();
}
}
| // Path: src/main/java/ldbc/socialnet/dbgen/objects/GPS.java
// public class GPS implements Serializable{
// private static final long serialVersionUID = 3657773293974543890L;
// long trackedTime;
// String trackedLocation;
// double longt;
// double latt;
// long userId; // Id of the user has been tracked
//
// public long getTrackedTime() {
// return trackedTime;
// }
// public void setTrackedTime(long trackedTime) {
// this.trackedTime = trackedTime;
// }
// public String getTrackedLocation() {
// return trackedLocation;
// }
// public void setTrackedLocation(String trackedLocation) {
// this.trackedLocation = trackedLocation;
// }
// public double getLongt() {
// return longt;
// }
// public void setLongt(double longt) {
// this.longt = longt;
// }
// public double getLatt() {
// return latt;
// }
// public void setLatt(double latt) {
// this.latt = latt;
// }
// public long getUserId() {
// return userId;
// }
// public void setUserId(long userId) {
// this.userId = userId;
// }
//
// }
// Path: src/main/java/ldbc/socialnet/dbgen/storage/StreamStoreManager.java
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import ldbc.socialnet.dbgen.objects.GPS;
public String getOutFileName() {
return outFileName;
}
public void setOutFileName(String outFileName) {
this.outFileName = outFileName;
}
public String getSortedFileName() {
return sortedFileName;
}
public void setSortedFileName(String sortedFileName) {
this.sortedFileName = sortedFileName;
}
public void initSerialization() {
try {
numberSerializedObject = 0;
fos = new FileOutputStream(baseDir + outFileName);
oos = new ObjectOutputStream(fos);
} catch (IOException i) {
i.printStackTrace();
}
}
| public void serialize(GPS gps){ |
ldbc-dev/ldbc_snb_datagen_deprecated2015 | src/main/java/ldbc/socialnet/dbgen/serializer/CSVSerializer/TagClassResolver.java | // Path: src/main/java/ldbc/socialnet/dbgen/objects/TagClass.java
// public class TagClass {
// public int id;
// public String name;
// public int parent;
// }
//
// Path: src/main/java/ldbc/socialnet/dbgen/vocabulary/DBPOWL.java
// public class DBPOWL {
//
// public static final String NAMESPACE = "http://dbpedia.org/ontology/";
// public static final String PREFIX = "dbpedia-owl:";
//
// public static final String Place = PREFIX+"Place";
// public static final String City = PREFIX+"City";
// public static final String Country = PREFIX+"Country";
// public static final String Continent = PREFIX+"Continent";
// public static final String Organisation = PREFIX+"Organisation";
// public static final String University = PREFIX+"University";
// public static final String Company = PREFIX+"Company";
// public static final String partOf = PREFIX+"isPartOf";
//
// /**
// * Gets the dbpedia ontology prefix version of the input.
// */
// public static String prefixed(String string) {
// return PREFIX + string;
// }
//
// /**
// * Gets the dbpedia ontology URL version of the input.
// */
// public static String getUrl(String string) {
// return NAMESPACE + string;
// }
//
// /**
// * Gets the dbpedia ontology RDF-URL version of the input.
// */
// public static String fullprefixed(String string) {
// return "<" + NAMESPACE + string + ">";
// }
// }
| import ldbc.socialnet.dbgen.objects.TagClass;
import ldbc.socialnet.dbgen.vocabulary.DBPOWL;
import java.util.ArrayList; | package ldbc.socialnet.dbgen.serializer.CSVSerializer;
/**
* Created by aprat on 4/14/14.
*/
public class TagClassResolver implements EntityFieldResolver<TagClass> {
@Override
public ArrayList<String> queryField(String string, TagClass tagClass) {
ArrayList<String> ret = new ArrayList<String>();
if( string.equals("id") ) {
ret.add(Integer.toString(tagClass.id));
return ret;
}
if( string.equals("name") ) {
ret.add(tagClass.name);
return ret;
}
if( string.equals("url") ) {
if( tagClass.name.equals("Thing") ) {
ret.add("http://www.w3.org/2002/07/owl#Thing");
} else { | // Path: src/main/java/ldbc/socialnet/dbgen/objects/TagClass.java
// public class TagClass {
// public int id;
// public String name;
// public int parent;
// }
//
// Path: src/main/java/ldbc/socialnet/dbgen/vocabulary/DBPOWL.java
// public class DBPOWL {
//
// public static final String NAMESPACE = "http://dbpedia.org/ontology/";
// public static final String PREFIX = "dbpedia-owl:";
//
// public static final String Place = PREFIX+"Place";
// public static final String City = PREFIX+"City";
// public static final String Country = PREFIX+"Country";
// public static final String Continent = PREFIX+"Continent";
// public static final String Organisation = PREFIX+"Organisation";
// public static final String University = PREFIX+"University";
// public static final String Company = PREFIX+"Company";
// public static final String partOf = PREFIX+"isPartOf";
//
// /**
// * Gets the dbpedia ontology prefix version of the input.
// */
// public static String prefixed(String string) {
// return PREFIX + string;
// }
//
// /**
// * Gets the dbpedia ontology URL version of the input.
// */
// public static String getUrl(String string) {
// return NAMESPACE + string;
// }
//
// /**
// * Gets the dbpedia ontology RDF-URL version of the input.
// */
// public static String fullprefixed(String string) {
// return "<" + NAMESPACE + string + ">";
// }
// }
// Path: src/main/java/ldbc/socialnet/dbgen/serializer/CSVSerializer/TagClassResolver.java
import ldbc.socialnet.dbgen.objects.TagClass;
import ldbc.socialnet.dbgen.vocabulary.DBPOWL;
import java.util.ArrayList;
package ldbc.socialnet.dbgen.serializer.CSVSerializer;
/**
* Created by aprat on 4/14/14.
*/
public class TagClassResolver implements EntityFieldResolver<TagClass> {
@Override
public ArrayList<String> queryField(String string, TagClass tagClass) {
ArrayList<String> ret = new ArrayList<String>();
if( string.equals("id") ) {
ret.add(Integer.toString(tagClass.id));
return ret;
}
if( string.equals("name") ) {
ret.add(tagClass.name);
return ret;
}
if( string.equals("url") ) {
if( tagClass.name.equals("Thing") ) {
ret.add("http://www.w3.org/2002/07/owl#Thing");
} else { | ret.add(DBPOWL.getUrl(tagClass.name)); |
ldbc-dev/ldbc_snb_datagen_deprecated2015 | src/main/java/ldbc/socialnet/dbgen/dictionary/LocationDictionary.java | // Path: src/main/java/ldbc/socialnet/dbgen/objects/Location.java
// @SuppressWarnings("serial")
// public class Location implements Serializable{
//
// public static final String CITY = "city";
// public static final String COUNTRY = "country";
// public static final String CONTINENT = "continent";
// public static final String AREA = "world";
//
// int id;
// int zId;
//
// String name;
// double latt;
// double longt;
// long population;
// String type;
//
// public int getzId() {
// return zId;
// }
// public void setzId(int zId) {
// this.zId = zId;
// }
// public Location(){
// }
// public Location(int _id, String _name, double _longt, double _latt, int _population, String _type){
// this.id = _id;
// this.name = _name;
// this.longt = _longt;
// this.latt = _latt;
// this.population = _population;
// this.type = _type;
// }
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public double getLongt() {
// return longt;
// }
// public void setLongt(double longt) {
// this.longt = longt;
// }
// public double getLatt() {
// return latt;
// }
// public void setLatt(double latt) {
// this.latt = latt;
// }
// public long getPopulation() {
// return population;
// }
// public void setPopulation(long population) {
// this.population = population;
// }
//
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
//
// }
//
// Path: src/main/java/ldbc/socialnet/dbgen/util/ZOrder.java
// public class ZOrder {
//
// private int MAX_BIT_NUMBER;
//
// public ZOrder(int maxNumBit){
// this.MAX_BIT_NUMBER = maxNumBit;
// }
//
// public int getZValue(int x, int y) {
//
// String sX = Integer.toBinaryString(x);
// int numberToAddX = MAX_BIT_NUMBER - sX.length();
// for (int i = 0; i < numberToAddX; i++){
// sX = "0" + sX;
// }
//
// String sY = Integer.toBinaryString(y);
// int numberToAddY = MAX_BIT_NUMBER - sY.length();
// for (int i = 0; i < numberToAddY; i++){
// sY = "0" + sY;
// }
//
// String sZ = "";
// for (int i = 0; i < sX.length(); i++){
// sZ = sZ + sX.substring(i, i+1) + "" + sY.substring(i, i+1);
// }
//
// return Integer.parseInt(sZ, 2);
// }
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import ldbc.socialnet.dbgen.objects.Location;
import ldbc.socialnet.dbgen.util.ZOrder; | /*
* Copyright (c) 2013 LDBC
* Linked Data Benchmark Council (http://ldbc.eu)
*
* This file is part of ldbc_socialnet_dbgen.
*
* ldbc_socialnet_dbgen is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ldbc_socialnet_dbgen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ldbc_socialnet_dbgen. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011 OpenLink Software <[email protected]>
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; only Version 2 of the License dated
* June 1991.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package ldbc.socialnet.dbgen.dictionary;
/**
* This class reads the files containing the country data and city data used in the ldbc socialnet generation and
* provides access methods to get such data.
* Most of the users has the prerequisite of requiring a valid location id.
*/
public class LocationDictionary {
public static final int INVALID_LOCATION = -1;
private static final String SEPARATOR = " ";
private static final String SEPARATOR_CITY = " ";
int numUsers;
int curLocationIdx;
LocationZorder[] sortLocation;
Vector<Integer> locationDistribution;
String cityFile;
String countryFile;
Vector<Integer> countries; | // Path: src/main/java/ldbc/socialnet/dbgen/objects/Location.java
// @SuppressWarnings("serial")
// public class Location implements Serializable{
//
// public static final String CITY = "city";
// public static final String COUNTRY = "country";
// public static final String CONTINENT = "continent";
// public static final String AREA = "world";
//
// int id;
// int zId;
//
// String name;
// double latt;
// double longt;
// long population;
// String type;
//
// public int getzId() {
// return zId;
// }
// public void setzId(int zId) {
// this.zId = zId;
// }
// public Location(){
// }
// public Location(int _id, String _name, double _longt, double _latt, int _population, String _type){
// this.id = _id;
// this.name = _name;
// this.longt = _longt;
// this.latt = _latt;
// this.population = _population;
// this.type = _type;
// }
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public double getLongt() {
// return longt;
// }
// public void setLongt(double longt) {
// this.longt = longt;
// }
// public double getLatt() {
// return latt;
// }
// public void setLatt(double latt) {
// this.latt = latt;
// }
// public long getPopulation() {
// return population;
// }
// public void setPopulation(long population) {
// this.population = population;
// }
//
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
//
// }
//
// Path: src/main/java/ldbc/socialnet/dbgen/util/ZOrder.java
// public class ZOrder {
//
// private int MAX_BIT_NUMBER;
//
// public ZOrder(int maxNumBit){
// this.MAX_BIT_NUMBER = maxNumBit;
// }
//
// public int getZValue(int x, int y) {
//
// String sX = Integer.toBinaryString(x);
// int numberToAddX = MAX_BIT_NUMBER - sX.length();
// for (int i = 0; i < numberToAddX; i++){
// sX = "0" + sX;
// }
//
// String sY = Integer.toBinaryString(y);
// int numberToAddY = MAX_BIT_NUMBER - sY.length();
// for (int i = 0; i < numberToAddY; i++){
// sY = "0" + sY;
// }
//
// String sZ = "";
// for (int i = 0; i < sX.length(); i++){
// sZ = sZ + sX.substring(i, i+1) + "" + sY.substring(i, i+1);
// }
//
// return Integer.parseInt(sZ, 2);
// }
// }
// Path: src/main/java/ldbc/socialnet/dbgen/dictionary/LocationDictionary.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import ldbc.socialnet.dbgen.objects.Location;
import ldbc.socialnet.dbgen.util.ZOrder;
/*
* Copyright (c) 2013 LDBC
* Linked Data Benchmark Council (http://ldbc.eu)
*
* This file is part of ldbc_socialnet_dbgen.
*
* ldbc_socialnet_dbgen is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ldbc_socialnet_dbgen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ldbc_socialnet_dbgen. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011 OpenLink Software <[email protected]>
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; only Version 2 of the License dated
* June 1991.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package ldbc.socialnet.dbgen.dictionary;
/**
* This class reads the files containing the country data and city data used in the ldbc socialnet generation and
* provides access methods to get such data.
* Most of the users has the prerequisite of requiring a valid location id.
*/
public class LocationDictionary {
public static final int INVALID_LOCATION = -1;
private static final String SEPARATOR = " ";
private static final String SEPARATOR_CITY = " ";
int numUsers;
int curLocationIdx;
LocationZorder[] sortLocation;
Vector<Integer> locationDistribution;
String cityFile;
String countryFile;
Vector<Integer> countries; | HashMap<Integer, Location> locations; |
ldbc-dev/ldbc_snb_datagen_deprecated2015 | src/main/java/ldbc/socialnet/dbgen/dictionary/LocationDictionary.java | // Path: src/main/java/ldbc/socialnet/dbgen/objects/Location.java
// @SuppressWarnings("serial")
// public class Location implements Serializable{
//
// public static final String CITY = "city";
// public static final String COUNTRY = "country";
// public static final String CONTINENT = "continent";
// public static final String AREA = "world";
//
// int id;
// int zId;
//
// String name;
// double latt;
// double longt;
// long population;
// String type;
//
// public int getzId() {
// return zId;
// }
// public void setzId(int zId) {
// this.zId = zId;
// }
// public Location(){
// }
// public Location(int _id, String _name, double _longt, double _latt, int _population, String _type){
// this.id = _id;
// this.name = _name;
// this.longt = _longt;
// this.latt = _latt;
// this.population = _population;
// this.type = _type;
// }
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public double getLongt() {
// return longt;
// }
// public void setLongt(double longt) {
// this.longt = longt;
// }
// public double getLatt() {
// return latt;
// }
// public void setLatt(double latt) {
// this.latt = latt;
// }
// public long getPopulation() {
// return population;
// }
// public void setPopulation(long population) {
// this.population = population;
// }
//
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
//
// }
//
// Path: src/main/java/ldbc/socialnet/dbgen/util/ZOrder.java
// public class ZOrder {
//
// private int MAX_BIT_NUMBER;
//
// public ZOrder(int maxNumBit){
// this.MAX_BIT_NUMBER = maxNumBit;
// }
//
// public int getZValue(int x, int y) {
//
// String sX = Integer.toBinaryString(x);
// int numberToAddX = MAX_BIT_NUMBER - sX.length();
// for (int i = 0; i < numberToAddX; i++){
// sX = "0" + sX;
// }
//
// String sY = Integer.toBinaryString(y);
// int numberToAddY = MAX_BIT_NUMBER - sY.length();
// for (int i = 0; i < numberToAddY; i++){
// sY = "0" + sY;
// }
//
// String sZ = "";
// for (int i = 0; i < sX.length(); i++){
// sZ = sZ + sX.substring(i, i+1) + "" + sY.substring(i, i+1);
// }
//
// return Integer.parseInt(sZ, 2);
// }
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import ldbc.socialnet.dbgen.objects.Location;
import ldbc.socialnet.dbgen.util.ZOrder; | dictionary.close();
System.out.println("Done ... " + treatedContinents.size() + " continents were extracted");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Gets a country id based on population.
* This method is assumed to be called in an ascending order of user ID.
*/
public int getLocationForUser(int userId) {
if (userId >= locationDistribution.get(curLocationIdx)) {
curLocationIdx++;
}
return countries.get(curLocationIdx);
}
public void advanceToUser(int user) {
curLocationIdx=0;
for(int i = 0; i < user-1; ++i){
getLocationForUser(i);
}
}
/**
* Sorts countries by its z-order value.
*/
private void orderByZ() { | // Path: src/main/java/ldbc/socialnet/dbgen/objects/Location.java
// @SuppressWarnings("serial")
// public class Location implements Serializable{
//
// public static final String CITY = "city";
// public static final String COUNTRY = "country";
// public static final String CONTINENT = "continent";
// public static final String AREA = "world";
//
// int id;
// int zId;
//
// String name;
// double latt;
// double longt;
// long population;
// String type;
//
// public int getzId() {
// return zId;
// }
// public void setzId(int zId) {
// this.zId = zId;
// }
// public Location(){
// }
// public Location(int _id, String _name, double _longt, double _latt, int _population, String _type){
// this.id = _id;
// this.name = _name;
// this.longt = _longt;
// this.latt = _latt;
// this.population = _population;
// this.type = _type;
// }
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public double getLongt() {
// return longt;
// }
// public void setLongt(double longt) {
// this.longt = longt;
// }
// public double getLatt() {
// return latt;
// }
// public void setLatt(double latt) {
// this.latt = latt;
// }
// public long getPopulation() {
// return population;
// }
// public void setPopulation(long population) {
// this.population = population;
// }
//
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
//
// }
//
// Path: src/main/java/ldbc/socialnet/dbgen/util/ZOrder.java
// public class ZOrder {
//
// private int MAX_BIT_NUMBER;
//
// public ZOrder(int maxNumBit){
// this.MAX_BIT_NUMBER = maxNumBit;
// }
//
// public int getZValue(int x, int y) {
//
// String sX = Integer.toBinaryString(x);
// int numberToAddX = MAX_BIT_NUMBER - sX.length();
// for (int i = 0; i < numberToAddX; i++){
// sX = "0" + sX;
// }
//
// String sY = Integer.toBinaryString(y);
// int numberToAddY = MAX_BIT_NUMBER - sY.length();
// for (int i = 0; i < numberToAddY; i++){
// sY = "0" + sY;
// }
//
// String sZ = "";
// for (int i = 0; i < sX.length(); i++){
// sZ = sZ + sX.substring(i, i+1) + "" + sY.substring(i, i+1);
// }
//
// return Integer.parseInt(sZ, 2);
// }
// }
// Path: src/main/java/ldbc/socialnet/dbgen/dictionary/LocationDictionary.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import ldbc.socialnet.dbgen.objects.Location;
import ldbc.socialnet.dbgen.util.ZOrder;
dictionary.close();
System.out.println("Done ... " + treatedContinents.size() + " continents were extracted");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Gets a country id based on population.
* This method is assumed to be called in an ascending order of user ID.
*/
public int getLocationForUser(int userId) {
if (userId >= locationDistribution.get(curLocationIdx)) {
curLocationIdx++;
}
return countries.get(curLocationIdx);
}
public void advanceToUser(int user) {
curLocationIdx=0;
for(int i = 0; i < user-1; ++i){
getLocationForUser(i);
}
}
/**
* Sorts countries by its z-order value.
*/
private void orderByZ() { | ZOrder zorder = new ZOrder(8); |
ldbc-dev/ldbc_snb_datagen_deprecated2015 | src/main/java/ldbc/socialnet/dbgen/dictionary/CompanyDictionary.java | // Path: src/main/java/ldbc/socialnet/dbgen/util/RandomGeneratorFarm.java
// public class RandomGeneratorFarm {
//
// int numRandomGenerators;
// Random[] randomGenerators;
//
// public enum Aspect {
// DATE,
// BIRTH_DAY,
// FRIEND_REQUEST,
// FRIEND_REJECT,
// FRIEND_APROVAL,
// INITIATOR,
// UNIFORM,
// NUM_INTEREST,
// NUM_TAG,
// NUM_FRIEND,
// NUM_COMMENT,
// NUM_PHOTO_ALBUM,
// NUM_PHOTO,
// NUM_GROUP,
// NUM_USERS_PER_GROUP,
// NUM_POPULAR,
// NUM_LIKE,
// NUM_POST,
// FRIEND,
// FRIEND_LEVEL,
// GENDER,
// RANDOM,
// MEMBERSHIP,
// MEMBERSHIP_INDEX,
// GROUP,
// GROUP_MODERATOR,
// GROUP_INTEREST,
// EXTRA_INFO,
// EXACT_LONG_LAT,
// STATUS,
// HAVE_STATUS,
// STATUS_SINGLE,
// USER_AGENT,
// USER_AGENT_SENT,
// FILE_SELECT,
// IP,
// DIFF_IP_FOR_TRAVELER,
// DIFF_IP,
// BROWSER,
// DIFF_BROWSER,
// CITY,
// COUNTRY,
// TAG,
// UNIVERSITY,
// UNCORRELATED_UNIVERSITY,
// UNCORRELATED_UNIVERSITY_LOCATION,
// TOP_UNIVERSITY,
// POPULAR,
// EMAIL,
// TOP_EMAIL,
// COMPANY,
// UNCORRELATED_COMPANY,
// UNCORRELATED_COMPANY_LOCATION,
// LANGUAGE,
// ALBUM,
// ALBUM_MEMBERSHIP,
// NAME,
// SURNAME,
// TAG_OTHER_COUNTRY,
// SET_OF_TAG,
// TEXT_SIZE,
// REDUCED_TEXT,
// LARGE_TEXT,
// MEMBERSHIP_POST_CREATOR,
// REPLY_TO,
// TOPIC,
// NUM_ASPECT // This must be always the last one.
// }
//
// public RandomGeneratorFarm () {
// numRandomGenerators = Aspect.values().length;
// randomGenerators = new Random[numRandomGenerators];
// for( int i = 0; i < numRandomGenerators; ++i) {
// randomGenerators[i] = new Random();
// }
// }
//
// public Random get(Aspect aspect) {
// return randomGenerators[aspect.ordinal()];
// }
//
// public void resetRandomGenerators( long seed ) {
// Random seedRandom = new Random(53223436L + 1234567*seed);
// for (int i = 0; i < numRandomGenerators; i++) {
// randomGenerators[i].setSeed(seedRandom.nextLong());
// }
// }
// }
| import ldbc.socialnet.dbgen.util.RandomGeneratorFarm;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*; | String locationName = data[0];
String companyName = data[1].trim();
if (locationDic.getCountryId(locationName) != LocationDictionary.INVALID_LOCATION) {
currentId = locationDic.getCountryId(locationName);
companiesByLocations.get(currentId).add(totalNumCompanies);
companyLocation.put(totalNumCompanies, currentId);
this.companyName.put(totalNumCompanies, companyName);
totalNumCompanies++;
}
}
dictionary.close();
System.out.println("Done ... " + totalNumCompanies + " companies were extracted");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Gets the company country id.
*/
public int getCountry(Long company) {
return companyLocation.get(company);
}
/**
* Gets a random company of the input country. In case the given country doesn't any company
* a random one will be selected.
* @param countryId: A country id.
*/ | // Path: src/main/java/ldbc/socialnet/dbgen/util/RandomGeneratorFarm.java
// public class RandomGeneratorFarm {
//
// int numRandomGenerators;
// Random[] randomGenerators;
//
// public enum Aspect {
// DATE,
// BIRTH_DAY,
// FRIEND_REQUEST,
// FRIEND_REJECT,
// FRIEND_APROVAL,
// INITIATOR,
// UNIFORM,
// NUM_INTEREST,
// NUM_TAG,
// NUM_FRIEND,
// NUM_COMMENT,
// NUM_PHOTO_ALBUM,
// NUM_PHOTO,
// NUM_GROUP,
// NUM_USERS_PER_GROUP,
// NUM_POPULAR,
// NUM_LIKE,
// NUM_POST,
// FRIEND,
// FRIEND_LEVEL,
// GENDER,
// RANDOM,
// MEMBERSHIP,
// MEMBERSHIP_INDEX,
// GROUP,
// GROUP_MODERATOR,
// GROUP_INTEREST,
// EXTRA_INFO,
// EXACT_LONG_LAT,
// STATUS,
// HAVE_STATUS,
// STATUS_SINGLE,
// USER_AGENT,
// USER_AGENT_SENT,
// FILE_SELECT,
// IP,
// DIFF_IP_FOR_TRAVELER,
// DIFF_IP,
// BROWSER,
// DIFF_BROWSER,
// CITY,
// COUNTRY,
// TAG,
// UNIVERSITY,
// UNCORRELATED_UNIVERSITY,
// UNCORRELATED_UNIVERSITY_LOCATION,
// TOP_UNIVERSITY,
// POPULAR,
// EMAIL,
// TOP_EMAIL,
// COMPANY,
// UNCORRELATED_COMPANY,
// UNCORRELATED_COMPANY_LOCATION,
// LANGUAGE,
// ALBUM,
// ALBUM_MEMBERSHIP,
// NAME,
// SURNAME,
// TAG_OTHER_COUNTRY,
// SET_OF_TAG,
// TEXT_SIZE,
// REDUCED_TEXT,
// LARGE_TEXT,
// MEMBERSHIP_POST_CREATOR,
// REPLY_TO,
// TOPIC,
// NUM_ASPECT // This must be always the last one.
// }
//
// public RandomGeneratorFarm () {
// numRandomGenerators = Aspect.values().length;
// randomGenerators = new Random[numRandomGenerators];
// for( int i = 0; i < numRandomGenerators; ++i) {
// randomGenerators[i] = new Random();
// }
// }
//
// public Random get(Aspect aspect) {
// return randomGenerators[aspect.ordinal()];
// }
//
// public void resetRandomGenerators( long seed ) {
// Random seedRandom = new Random(53223436L + 1234567*seed);
// for (int i = 0; i < numRandomGenerators; i++) {
// randomGenerators[i].setSeed(seedRandom.nextLong());
// }
// }
// }
// Path: src/main/java/ldbc/socialnet/dbgen/dictionary/CompanyDictionary.java
import ldbc.socialnet.dbgen.util.RandomGeneratorFarm;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
String locationName = data[0];
String companyName = data[1].trim();
if (locationDic.getCountryId(locationName) != LocationDictionary.INVALID_LOCATION) {
currentId = locationDic.getCountryId(locationName);
companiesByLocations.get(currentId).add(totalNumCompanies);
companyLocation.put(totalNumCompanies, currentId);
this.companyName.put(totalNumCompanies, companyName);
totalNumCompanies++;
}
}
dictionary.close();
System.out.println("Done ... " + totalNumCompanies + " companies were extracted");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Gets the company country id.
*/
public int getCountry(Long company) {
return companyLocation.get(company);
}
/**
* Gets a random company of the input country. In case the given country doesn't any company
* a random one will be selected.
* @param countryId: A country id.
*/ | public long getRandomCompany(RandomGeneratorFarm randomFarm, int countryId) { |
alphamu/PrayTime-Android | app/src/main/java/com/alimuzaffar/ramadanalarm/fragments/LocationHelper.java | // Path: app/src/main/java/com/alimuzaffar/ramadanalarm/Constants.java
// public interface Constants {
// // REQUEST CODES
// int REQUEST_CHECK_SETTINGS = 101;
// int REQUEST_ONBOARDING = 102;
// int REQUEST_LOCATION = 103;
// int REQUEST_WRITE_EXTERNAL = 104;
// int REQUEST_SET_ALARM = 105;
// int REQUEST_TNC = 106;
//
// int ALARM_ID = 1010;
// int PASSIVE_LOCATION_ID = 1011;
// int PRE_SUHOOR_ALARM_ID = 1012;
// int PRE_IFTAR_ALARM_ID = 1013;
//
// long ONE_MINUTE = 60000;
// long FIVE_MINUTES = ONE_MINUTE * 5;
//
// //EXTRAS
// String EXTRA_ALARM_INDEX = "alarm_index";
// String EXTRA_LAST_LOCATION = "last_location";
// String EXTRA_PRAYER_NAME = "prayer_name";
// String EXTRA_PRAYER_TIME = "prayer_time";
// String EXTRA_PRE_ALARM_FLAG = "pre_alarm_flag";
//
// String CONTENT_FRAGMENT = "content_fragment";
// String TIMES_FRAGMENT = "times_fragment";
// String CONFIG_FRAGMENT = "config_fragment";
// String LOCATION_FRAGMENT = "location_fragment";
//
// int NOTIFICATION_ID = 2010;
//
// }
//
// Path: app/src/main/java/com/alimuzaffar/ramadanalarm/util/PermissionUtil.java
// public abstract class PermissionUtil {
//
// /**
// * Check that all given permissions have been granted by verifying that each entry in the
// * given array is of the value {@link PackageManager#PERMISSION_GRANTED}.
// *
// * @see Activity#onRequestPermissionsResult(int, String[], int[])
// */
// public static boolean verifyPermissions(int[] grantResults) {
// // Verify that each required permission has been granted, otherwise return false.
// for (int result : grantResults) {
// if (result != PackageManager.PERMISSION_GRANTED) {
// return false;
// }
// }
// return true;
// }
//
// /**
// * Returns true if the Activity has access to all given permissions.
// * Always returns true on platforms below M.
// *
// * @see Activity#checkSelfPermission(String)
// */
// public static boolean hasSelfPermission(Activity activity, String[] permissions) {
// // Below Android M all permissions are granted at install time and are already available.
// if (!isMNC()) {
// return true;
// }
//
// // Verify that all required permissions have been granted
// for (String permission : permissions) {
// if (activity.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
// return false;
// }
// }
//
// return true;
// }
//
// /**
// * Returns true if the Activity has access to a given permission.
// * Always returns true on platforms below M.
// *
// * @see Activity#checkSelfPermission(String)
// */
// public static boolean hasSelfPermission(Activity activity, String permission) {
// // Below Android M all permissions are granted at install time and are already available.
// if (!isMNC()) {
// return true;
// }
// return activity.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED;
// }
//
// public static boolean isMNC() {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
// }
//
// }
| import android.Manifest;
import android.app.Activity;
import android.app.Fragment;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import com.alimuzaffar.ramadanalarm.Constants;
import com.alimuzaffar.ramadanalarm.util.PermissionUtil;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResult;
import com.google.android.gms.location.LocationSettingsStatusCodes; | }
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
if (activity instanceof LocationCallback) {
mCallback = (LocationCallback) activity;
} else {
throw new IllegalArgumentException("activity must extend BaseActivity and implement LocationHelper.LocationCallback");
}
}
@Override
public void onDetach() {
super.onDetach();
mCallback = null;
mActivity = null;
}
public Location getLocation() {
return sLastLocation;
}
public void checkLocationPermissions() { | // Path: app/src/main/java/com/alimuzaffar/ramadanalarm/Constants.java
// public interface Constants {
// // REQUEST CODES
// int REQUEST_CHECK_SETTINGS = 101;
// int REQUEST_ONBOARDING = 102;
// int REQUEST_LOCATION = 103;
// int REQUEST_WRITE_EXTERNAL = 104;
// int REQUEST_SET_ALARM = 105;
// int REQUEST_TNC = 106;
//
// int ALARM_ID = 1010;
// int PASSIVE_LOCATION_ID = 1011;
// int PRE_SUHOOR_ALARM_ID = 1012;
// int PRE_IFTAR_ALARM_ID = 1013;
//
// long ONE_MINUTE = 60000;
// long FIVE_MINUTES = ONE_MINUTE * 5;
//
// //EXTRAS
// String EXTRA_ALARM_INDEX = "alarm_index";
// String EXTRA_LAST_LOCATION = "last_location";
// String EXTRA_PRAYER_NAME = "prayer_name";
// String EXTRA_PRAYER_TIME = "prayer_time";
// String EXTRA_PRE_ALARM_FLAG = "pre_alarm_flag";
//
// String CONTENT_FRAGMENT = "content_fragment";
// String TIMES_FRAGMENT = "times_fragment";
// String CONFIG_FRAGMENT = "config_fragment";
// String LOCATION_FRAGMENT = "location_fragment";
//
// int NOTIFICATION_ID = 2010;
//
// }
//
// Path: app/src/main/java/com/alimuzaffar/ramadanalarm/util/PermissionUtil.java
// public abstract class PermissionUtil {
//
// /**
// * Check that all given permissions have been granted by verifying that each entry in the
// * given array is of the value {@link PackageManager#PERMISSION_GRANTED}.
// *
// * @see Activity#onRequestPermissionsResult(int, String[], int[])
// */
// public static boolean verifyPermissions(int[] grantResults) {
// // Verify that each required permission has been granted, otherwise return false.
// for (int result : grantResults) {
// if (result != PackageManager.PERMISSION_GRANTED) {
// return false;
// }
// }
// return true;
// }
//
// /**
// * Returns true if the Activity has access to all given permissions.
// * Always returns true on platforms below M.
// *
// * @see Activity#checkSelfPermission(String)
// */
// public static boolean hasSelfPermission(Activity activity, String[] permissions) {
// // Below Android M all permissions are granted at install time and are already available.
// if (!isMNC()) {
// return true;
// }
//
// // Verify that all required permissions have been granted
// for (String permission : permissions) {
// if (activity.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
// return false;
// }
// }
//
// return true;
// }
//
// /**
// * Returns true if the Activity has access to a given permission.
// * Always returns true on platforms below M.
// *
// * @see Activity#checkSelfPermission(String)
// */
// public static boolean hasSelfPermission(Activity activity, String permission) {
// // Below Android M all permissions are granted at install time and are already available.
// if (!isMNC()) {
// return true;
// }
// return activity.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED;
// }
//
// public static boolean isMNC() {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
// }
//
// }
// Path: app/src/main/java/com/alimuzaffar/ramadanalarm/fragments/LocationHelper.java
import android.Manifest;
import android.app.Activity;
import android.app.Fragment;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import com.alimuzaffar.ramadanalarm.Constants;
import com.alimuzaffar.ramadanalarm.util.PermissionUtil;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResult;
import com.google.android.gms.location.LocationSettingsStatusCodes;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
if (activity instanceof LocationCallback) {
mCallback = (LocationCallback) activity;
} else {
throw new IllegalArgumentException("activity must extend BaseActivity and implement LocationHelper.LocationCallback");
}
}
@Override
public void onDetach() {
super.onDetach();
mCallback = null;
mActivity = null;
}
public Location getLocation() {
return sLastLocation;
}
public void checkLocationPermissions() { | if (PermissionUtil.hasSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)) { |
googleapis/java-pubsublite-spark | src/test/java/com/google/cloud/pubsublite/spark/PslMicroBatchReaderTest.java | // Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static PslSourceOffset createPslSourceOffset(long... offsets) {
// Map<Partition, Offset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx++), Offset.of(offset));
// }
// return PslSourceOffset.builder().partitionOffsetMap(map).build();
// }
//
// Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static SparkSourceOffset createSparkSourceOffset(long... offsets) {
// Map<Partition, SparkPartitionOffset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx), SparkPartitionOffset.create(Partition.of(idx), offset));
// idx++;
// }
// return new SparkSourceOffset(map);
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
| import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
import static com.google.cloud.pubsublite.spark.TestingUtils.createPslSourceOffset;
import static com.google.cloud.pubsublite.spark.TestingUtils.createSparkSourceOffset;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.times;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class); | // Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static PslSourceOffset createPslSourceOffset(long... offsets) {
// Map<Partition, Offset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx++), Offset.of(offset));
// }
// return PslSourceOffset.builder().partitionOffsetMap(map).build();
// }
//
// Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static SparkSourceOffset createSparkSourceOffset(long... offsets) {
// Map<Partition, SparkPartitionOffset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx), SparkPartitionOffset.create(Partition.of(idx), offset));
// idx++;
// }
// return new SparkSourceOffset(map);
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
// Path: src/test/java/com/google/cloud/pubsublite/spark/PslMicroBatchReaderTest.java
import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
import static com.google.cloud.pubsublite.spark.TestingUtils.createPslSourceOffset;
import static com.google.cloud.pubsublite.spark.TestingUtils.createSparkSourceOffset;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.times;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class); | private final MultiPartitionCommitter committer = mock(MultiPartitionCommitter.class); |
googleapis/java-pubsublite-spark | src/test/java/com/google/cloud/pubsublite/spark/PslMicroBatchReaderTest.java | // Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static PslSourceOffset createPslSourceOffset(long... offsets) {
// Map<Partition, Offset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx++), Offset.of(offset));
// }
// return PslSourceOffset.builder().partitionOffsetMap(map).build();
// }
//
// Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static SparkSourceOffset createSparkSourceOffset(long... offsets) {
// Map<Partition, SparkPartitionOffset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx), SparkPartitionOffset.create(Partition.of(idx), offset));
// idx++;
// }
// return new SparkSourceOffset(map);
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
| import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
import static com.google.cloud.pubsublite.spark.TestingUtils.createPslSourceOffset;
import static com.google.cloud.pubsublite.spark.TestingUtils.createSparkSourceOffset;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.times;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class);
private final MultiPartitionCommitter committer = mock(MultiPartitionCommitter.class); | // Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static PslSourceOffset createPslSourceOffset(long... offsets) {
// Map<Partition, Offset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx++), Offset.of(offset));
// }
// return PslSourceOffset.builder().partitionOffsetMap(map).build();
// }
//
// Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static SparkSourceOffset createSparkSourceOffset(long... offsets) {
// Map<Partition, SparkPartitionOffset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx), SparkPartitionOffset.create(Partition.of(idx), offset));
// idx++;
// }
// return new SparkSourceOffset(map);
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
// Path: src/test/java/com/google/cloud/pubsublite/spark/PslMicroBatchReaderTest.java
import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
import static com.google.cloud.pubsublite.spark.TestingUtils.createPslSourceOffset;
import static com.google.cloud.pubsublite.spark.TestingUtils.createSparkSourceOffset;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.times;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class);
private final MultiPartitionCommitter committer = mock(MultiPartitionCommitter.class); | private final PartitionSubscriberFactory partitionSubscriberFactory = |
googleapis/java-pubsublite-spark | src/test/java/com/google/cloud/pubsublite/spark/PslMicroBatchReaderTest.java | // Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static PslSourceOffset createPslSourceOffset(long... offsets) {
// Map<Partition, Offset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx++), Offset.of(offset));
// }
// return PslSourceOffset.builder().partitionOffsetMap(map).build();
// }
//
// Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static SparkSourceOffset createSparkSourceOffset(long... offsets) {
// Map<Partition, SparkPartitionOffset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx), SparkPartitionOffset.create(Partition.of(idx), offset));
// idx++;
// }
// return new SparkSourceOffset(map);
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
| import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
import static com.google.cloud.pubsublite.spark.TestingUtils.createPslSourceOffset;
import static com.google.cloud.pubsublite.spark.TestingUtils.createSparkSourceOffset;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.times;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class);
private final MultiPartitionCommitter committer = mock(MultiPartitionCommitter.class);
private final PartitionSubscriberFactory partitionSubscriberFactory =
mock(PartitionSubscriberFactory.class); | // Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static PslSourceOffset createPslSourceOffset(long... offsets) {
// Map<Partition, Offset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx++), Offset.of(offset));
// }
// return PslSourceOffset.builder().partitionOffsetMap(map).build();
// }
//
// Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static SparkSourceOffset createSparkSourceOffset(long... offsets) {
// Map<Partition, SparkPartitionOffset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx), SparkPartitionOffset.create(Partition.of(idx), offset));
// idx++;
// }
// return new SparkSourceOffset(map);
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
// Path: src/test/java/com/google/cloud/pubsublite/spark/PslMicroBatchReaderTest.java
import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
import static com.google.cloud.pubsublite.spark.TestingUtils.createPslSourceOffset;
import static com.google.cloud.pubsublite.spark.TestingUtils.createSparkSourceOffset;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.times;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class);
private final MultiPartitionCommitter committer = mock(MultiPartitionCommitter.class);
private final PartitionSubscriberFactory partitionSubscriberFactory =
mock(PartitionSubscriberFactory.class); | private final PerTopicHeadOffsetReader headOffsetReader = mock(PerTopicHeadOffsetReader.class); |
googleapis/java-pubsublite-spark | src/test/java/com/google/cloud/pubsublite/spark/PslMicroBatchReaderTest.java | // Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static PslSourceOffset createPslSourceOffset(long... offsets) {
// Map<Partition, Offset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx++), Offset.of(offset));
// }
// return PslSourceOffset.builder().partitionOffsetMap(map).build();
// }
//
// Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static SparkSourceOffset createSparkSourceOffset(long... offsets) {
// Map<Partition, SparkPartitionOffset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx), SparkPartitionOffset.create(Partition.of(idx), offset));
// idx++;
// }
// return new SparkSourceOffset(map);
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
| import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
import static com.google.cloud.pubsublite.spark.TestingUtils.createPslSourceOffset;
import static com.google.cloud.pubsublite.spark.TestingUtils.createSparkSourceOffset;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.times;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class);
private final MultiPartitionCommitter committer = mock(MultiPartitionCommitter.class);
private final PartitionSubscriberFactory partitionSubscriberFactory =
mock(PartitionSubscriberFactory.class);
private final PerTopicHeadOffsetReader headOffsetReader = mock(PerTopicHeadOffsetReader.class);
private static final long MAX_MESSAGES_PER_BATCH = 20000;
private final PslMicroBatchReader reader =
new PslMicroBatchReader(
cursorClient,
committer,
partitionSubscriberFactory,
headOffsetReader,
UnitTestExamples.exampleSubscriptionPath(),
OPTIONS.flowControlSettings(),
MAX_MESSAGES_PER_BATCH);
@Test
public void testNoCommitCursors() {
when(cursorClient.listPartitionCursors(UnitTestExamples.exampleSubscriptionPath()))
.thenReturn(ApiFutures.immediateFuture(ImmutableMap.of())); | // Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static PslSourceOffset createPslSourceOffset(long... offsets) {
// Map<Partition, Offset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx++), Offset.of(offset));
// }
// return PslSourceOffset.builder().partitionOffsetMap(map).build();
// }
//
// Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static SparkSourceOffset createSparkSourceOffset(long... offsets) {
// Map<Partition, SparkPartitionOffset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx), SparkPartitionOffset.create(Partition.of(idx), offset));
// idx++;
// }
// return new SparkSourceOffset(map);
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
// Path: src/test/java/com/google/cloud/pubsublite/spark/PslMicroBatchReaderTest.java
import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
import static com.google.cloud.pubsublite.spark.TestingUtils.createPslSourceOffset;
import static com.google.cloud.pubsublite.spark.TestingUtils.createSparkSourceOffset;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.times;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class);
private final MultiPartitionCommitter committer = mock(MultiPartitionCommitter.class);
private final PartitionSubscriberFactory partitionSubscriberFactory =
mock(PartitionSubscriberFactory.class);
private final PerTopicHeadOffsetReader headOffsetReader = mock(PerTopicHeadOffsetReader.class);
private static final long MAX_MESSAGES_PER_BATCH = 20000;
private final PslMicroBatchReader reader =
new PslMicroBatchReader(
cursorClient,
committer,
partitionSubscriberFactory,
headOffsetReader,
UnitTestExamples.exampleSubscriptionPath(),
OPTIONS.flowControlSettings(),
MAX_MESSAGES_PER_BATCH);
@Test
public void testNoCommitCursors() {
when(cursorClient.listPartitionCursors(UnitTestExamples.exampleSubscriptionPath()))
.thenReturn(ApiFutures.immediateFuture(ImmutableMap.of())); | when(headOffsetReader.getHeadOffset()).thenReturn(createPslSourceOffset(301L, 200L)); |
googleapis/java-pubsublite-spark | src/test/java/com/google/cloud/pubsublite/spark/PslMicroBatchReaderTest.java | // Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static PslSourceOffset createPslSourceOffset(long... offsets) {
// Map<Partition, Offset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx++), Offset.of(offset));
// }
// return PslSourceOffset.builder().partitionOffsetMap(map).build();
// }
//
// Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static SparkSourceOffset createSparkSourceOffset(long... offsets) {
// Map<Partition, SparkPartitionOffset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx), SparkPartitionOffset.create(Partition.of(idx), offset));
// idx++;
// }
// return new SparkSourceOffset(map);
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
| import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
import static com.google.cloud.pubsublite.spark.TestingUtils.createPslSourceOffset;
import static com.google.cloud.pubsublite.spark.TestingUtils.createSparkSourceOffset;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.times;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory; | assertThat(((SparkSourceOffset) reader.getEndOffset()).getPartitionOffsetMap())
.containsExactly(
Partition.of(0L),
SparkPartitionOffset.create(Partition.of(0L), 300L),
Partition.of(1L),
SparkPartitionOffset.create(Partition.of(1L), 199L));
}
@Test
public void testEmptyOffsets() {
when(cursorClient.listPartitionCursors(UnitTestExamples.exampleSubscriptionPath()))
.thenReturn(ApiFutures.immediateFuture(ImmutableMap.of(Partition.of(0L), Offset.of(100L))));
when(headOffsetReader.getHeadOffset()).thenReturn(createPslSourceOffset(301L, 0L));
reader.setOffsetRange(Optional.empty(), Optional.empty());
assertThat(((SparkSourceOffset) reader.getStartOffset()).getPartitionOffsetMap())
.containsExactly(
Partition.of(0L),
SparkPartitionOffset.create(Partition.of(0L), 99L),
Partition.of(1L),
SparkPartitionOffset.create(Partition.of(1L), -1L));
assertThat(((SparkSourceOffset) reader.getEndOffset()).getPartitionOffsetMap())
.containsExactly(
Partition.of(0L),
SparkPartitionOffset.create(Partition.of(0L), 300L),
Partition.of(1L),
SparkPartitionOffset.create(Partition.of(1L), -1L));
}
@Test
public void testValidOffsets() { | // Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static PslSourceOffset createPslSourceOffset(long... offsets) {
// Map<Partition, Offset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx++), Offset.of(offset));
// }
// return PslSourceOffset.builder().partitionOffsetMap(map).build();
// }
//
// Path: src/test/java/com/google/cloud/pubsublite/spark/TestingUtils.java
// public static SparkSourceOffset createSparkSourceOffset(long... offsets) {
// Map<Partition, SparkPartitionOffset> map = new HashMap<>();
// int idx = 0;
// for (long offset : offsets) {
// map.put(Partition.of(idx), SparkPartitionOffset.create(Partition.of(idx), offset));
// idx++;
// }
// return new SparkSourceOffset(map);
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
// Path: src/test/java/com/google/cloud/pubsublite/spark/PslMicroBatchReaderTest.java
import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
import static com.google.cloud.pubsublite.spark.TestingUtils.createPslSourceOffset;
import static com.google.cloud.pubsublite.spark.TestingUtils.createSparkSourceOffset;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.times;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
assertThat(((SparkSourceOffset) reader.getEndOffset()).getPartitionOffsetMap())
.containsExactly(
Partition.of(0L),
SparkPartitionOffset.create(Partition.of(0L), 300L),
Partition.of(1L),
SparkPartitionOffset.create(Partition.of(1L), 199L));
}
@Test
public void testEmptyOffsets() {
when(cursorClient.listPartitionCursors(UnitTestExamples.exampleSubscriptionPath()))
.thenReturn(ApiFutures.immediateFuture(ImmutableMap.of(Partition.of(0L), Offset.of(100L))));
when(headOffsetReader.getHeadOffset()).thenReturn(createPslSourceOffset(301L, 0L));
reader.setOffsetRange(Optional.empty(), Optional.empty());
assertThat(((SparkSourceOffset) reader.getStartOffset()).getPartitionOffsetMap())
.containsExactly(
Partition.of(0L),
SparkPartitionOffset.create(Partition.of(0L), 99L),
Partition.of(1L),
SparkPartitionOffset.create(Partition.of(1L), -1L));
assertThat(((SparkSourceOffset) reader.getEndOffset()).getPartitionOffsetMap())
.containsExactly(
Partition.of(0L),
SparkPartitionOffset.create(Partition.of(0L), 300L),
Partition.of(1L),
SparkPartitionOffset.create(Partition.of(1L), -1L));
}
@Test
public void testValidOffsets() { | SparkSourceOffset startOffset = createSparkSourceOffset(10L, 100L); |
googleapis/java-pubsublite-spark | src/test/java/com/google/cloud/pubsublite/spark/PslContinuousReaderTest.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionCountReader.java
// public interface PartitionCountReader extends Closeable {
// int getPartitionCount();
//
// @Override
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
| import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.*;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionCountReader;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslContinuousReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class); | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionCountReader.java
// public interface PartitionCountReader extends Closeable {
// int getPartitionCount();
//
// @Override
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
// Path: src/test/java/com/google/cloud/pubsublite/spark/PslContinuousReaderTest.java
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.*;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionCountReader;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslContinuousReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class); | private final MultiPartitionCommitter committer = mock(MultiPartitionCommitter.class); |
googleapis/java-pubsublite-spark | src/test/java/com/google/cloud/pubsublite/spark/PslContinuousReaderTest.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionCountReader.java
// public interface PartitionCountReader extends Closeable {
// int getPartitionCount();
//
// @Override
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
| import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.*;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionCountReader;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslContinuousReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class);
private final MultiPartitionCommitter committer = mock(MultiPartitionCommitter.class); | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionCountReader.java
// public interface PartitionCountReader extends Closeable {
// int getPartitionCount();
//
// @Override
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
// Path: src/test/java/com/google/cloud/pubsublite/spark/PslContinuousReaderTest.java
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.*;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionCountReader;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslContinuousReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class);
private final MultiPartitionCommitter committer = mock(MultiPartitionCommitter.class); | private final PartitionSubscriberFactory partitionSubscriberFactory = |
googleapis/java-pubsublite-spark | src/test/java/com/google/cloud/pubsublite/spark/PslContinuousReaderTest.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionCountReader.java
// public interface PartitionCountReader extends Closeable {
// int getPartitionCount();
//
// @Override
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
| import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.*;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionCountReader;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslContinuousReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class);
private final MultiPartitionCommitter committer = mock(MultiPartitionCommitter.class);
private final PartitionSubscriberFactory partitionSubscriberFactory =
mock(PartitionSubscriberFactory.class); | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionCountReader.java
// public interface PartitionCountReader extends Closeable {
// int getPartitionCount();
//
// @Override
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
// Path: src/test/java/com/google/cloud/pubsublite/spark/PslContinuousReaderTest.java
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.*;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.internal.testing.UnitTestExamples;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionCountReader;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.common.collect.ImmutableMap;
import java.util.Optional;
import org.junit.Test;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslContinuousReaderTest {
private static final PslReadDataSourceOptions OPTIONS =
PslReadDataSourceOptions.builder()
.setSubscriptionPath(UnitTestExamples.exampleSubscriptionPath())
.build();
private final CursorClient cursorClient = mock(CursorClient.class);
private final MultiPartitionCommitter committer = mock(MultiPartitionCommitter.class);
private final PartitionSubscriberFactory partitionSubscriberFactory =
mock(PartitionSubscriberFactory.class); | private final PartitionCountReader partitionCountReader; |
googleapis/java-pubsublite-spark | src/main/java/com/google/cloud/pubsublite/spark/PslMicroBatchReader.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
| import org.apache.spark.sql.catalyst.InternalRow;
import org.apache.spark.sql.sources.v2.reader.InputPartition;
import org.apache.spark.sql.sources.v2.reader.streaming.MicroBatchReader;
import org.apache.spark.sql.sources.v2.reader.streaming.Offset;
import org.apache.spark.sql.types.StructType;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.cloudpubsub.FlowControlSettings;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReader implements MicroBatchReader {
private final CursorClient cursorClient; | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
// Path: src/main/java/com/google/cloud/pubsublite/spark/PslMicroBatchReader.java
import org.apache.spark.sql.catalyst.InternalRow;
import org.apache.spark.sql.sources.v2.reader.InputPartition;
import org.apache.spark.sql.sources.v2.reader.streaming.MicroBatchReader;
import org.apache.spark.sql.sources.v2.reader.streaming.Offset;
import org.apache.spark.sql.types.StructType;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.cloudpubsub.FlowControlSettings;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReader implements MicroBatchReader {
private final CursorClient cursorClient; | private final MultiPartitionCommitter committer; |
googleapis/java-pubsublite-spark | src/main/java/com/google/cloud/pubsublite/spark/PslMicroBatchReader.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
| import org.apache.spark.sql.catalyst.InternalRow;
import org.apache.spark.sql.sources.v2.reader.InputPartition;
import org.apache.spark.sql.sources.v2.reader.streaming.MicroBatchReader;
import org.apache.spark.sql.sources.v2.reader.streaming.Offset;
import org.apache.spark.sql.types.StructType;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.cloudpubsub.FlowControlSettings;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReader implements MicroBatchReader {
private final CursorClient cursorClient;
private final MultiPartitionCommitter committer; | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
// Path: src/main/java/com/google/cloud/pubsublite/spark/PslMicroBatchReader.java
import org.apache.spark.sql.catalyst.InternalRow;
import org.apache.spark.sql.sources.v2.reader.InputPartition;
import org.apache.spark.sql.sources.v2.reader.streaming.MicroBatchReader;
import org.apache.spark.sql.sources.v2.reader.streaming.Offset;
import org.apache.spark.sql.types.StructType;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.cloudpubsub.FlowControlSettings;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReader implements MicroBatchReader {
private final CursorClient cursorClient;
private final MultiPartitionCommitter committer; | private final PartitionSubscriberFactory partitionSubscriberFactory; |
googleapis/java-pubsublite-spark | src/main/java/com/google/cloud/pubsublite/spark/PslMicroBatchReader.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
| import org.apache.spark.sql.catalyst.InternalRow;
import org.apache.spark.sql.sources.v2.reader.InputPartition;
import org.apache.spark.sql.sources.v2.reader.streaming.MicroBatchReader;
import org.apache.spark.sql.sources.v2.reader.streaming.Offset;
import org.apache.spark.sql.types.StructType;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.cloudpubsub.FlowControlSettings;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReader implements MicroBatchReader {
private final CursorClient cursorClient;
private final MultiPartitionCommitter committer;
private final PartitionSubscriberFactory partitionSubscriberFactory; | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PerTopicHeadOffsetReader.java
// public interface PerTopicHeadOffsetReader extends Closeable {
//
// // Gets the head offsets for all partitions in the topic. Blocks.
// PslSourceOffset getHeadOffset();
//
// @Override
// void close();
// }
// Path: src/main/java/com/google/cloud/pubsublite/spark/PslMicroBatchReader.java
import org.apache.spark.sql.catalyst.InternalRow;
import org.apache.spark.sql.sources.v2.reader.InputPartition;
import org.apache.spark.sql.sources.v2.reader.streaming.MicroBatchReader;
import org.apache.spark.sql.sources.v2.reader.streaming.Offset;
import org.apache.spark.sql.types.StructType;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.cloudpubsub.FlowControlSettings;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.cloud.pubsublite.spark.internal.PerTopicHeadOffsetReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslMicroBatchReader implements MicroBatchReader {
private final CursorClient cursorClient;
private final MultiPartitionCommitter committer;
private final PartitionSubscriberFactory partitionSubscriberFactory; | private final PerTopicHeadOffsetReader headOffsetReader; |
googleapis/java-pubsublite-spark | src/main/java/com/google/cloud/pubsublite/spark/PslContinuousReader.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionCountReader.java
// public interface PartitionCountReader extends Closeable {
// int getPartitionCount();
//
// @Override
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
| import org.apache.spark.sql.sources.v2.reader.InputPartition;
import org.apache.spark.sql.sources.v2.reader.streaming.ContinuousReader;
import org.apache.spark.sql.sources.v2.reader.streaming.Offset;
import org.apache.spark.sql.sources.v2.reader.streaming.PartitionOffset;
import org.apache.spark.sql.types.StructType;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.cloudpubsub.FlowControlSettings;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionCountReader;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.common.annotations.VisibleForTesting;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.apache.spark.sql.catalyst.InternalRow; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslContinuousReader implements ContinuousReader {
private final CursorClient cursorClient; | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionCountReader.java
// public interface PartitionCountReader extends Closeable {
// int getPartitionCount();
//
// @Override
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
// Path: src/main/java/com/google/cloud/pubsublite/spark/PslContinuousReader.java
import org.apache.spark.sql.sources.v2.reader.InputPartition;
import org.apache.spark.sql.sources.v2.reader.streaming.ContinuousReader;
import org.apache.spark.sql.sources.v2.reader.streaming.Offset;
import org.apache.spark.sql.sources.v2.reader.streaming.PartitionOffset;
import org.apache.spark.sql.types.StructType;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.cloudpubsub.FlowControlSettings;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionCountReader;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.common.annotations.VisibleForTesting;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.apache.spark.sql.catalyst.InternalRow;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslContinuousReader implements ContinuousReader {
private final CursorClient cursorClient; | private final MultiPartitionCommitter committer; |
googleapis/java-pubsublite-spark | src/main/java/com/google/cloud/pubsublite/spark/PslContinuousReader.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionCountReader.java
// public interface PartitionCountReader extends Closeable {
// int getPartitionCount();
//
// @Override
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
| import org.apache.spark.sql.sources.v2.reader.InputPartition;
import org.apache.spark.sql.sources.v2.reader.streaming.ContinuousReader;
import org.apache.spark.sql.sources.v2.reader.streaming.Offset;
import org.apache.spark.sql.sources.v2.reader.streaming.PartitionOffset;
import org.apache.spark.sql.types.StructType;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.cloudpubsub.FlowControlSettings;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionCountReader;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.common.annotations.VisibleForTesting;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.apache.spark.sql.catalyst.InternalRow; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslContinuousReader implements ContinuousReader {
private final CursorClient cursorClient;
private final MultiPartitionCommitter committer; | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionCountReader.java
// public interface PartitionCountReader extends Closeable {
// int getPartitionCount();
//
// @Override
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
// Path: src/main/java/com/google/cloud/pubsublite/spark/PslContinuousReader.java
import org.apache.spark.sql.sources.v2.reader.InputPartition;
import org.apache.spark.sql.sources.v2.reader.streaming.ContinuousReader;
import org.apache.spark.sql.sources.v2.reader.streaming.Offset;
import org.apache.spark.sql.sources.v2.reader.streaming.PartitionOffset;
import org.apache.spark.sql.types.StructType;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.cloudpubsub.FlowControlSettings;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionCountReader;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.common.annotations.VisibleForTesting;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.apache.spark.sql.catalyst.InternalRow;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslContinuousReader implements ContinuousReader {
private final CursorClient cursorClient;
private final MultiPartitionCommitter committer; | private final PartitionSubscriberFactory partitionSubscriberFactory; |
googleapis/java-pubsublite-spark | src/main/java/com/google/cloud/pubsublite/spark/PslContinuousReader.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionCountReader.java
// public interface PartitionCountReader extends Closeable {
// int getPartitionCount();
//
// @Override
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
| import org.apache.spark.sql.sources.v2.reader.InputPartition;
import org.apache.spark.sql.sources.v2.reader.streaming.ContinuousReader;
import org.apache.spark.sql.sources.v2.reader.streaming.Offset;
import org.apache.spark.sql.sources.v2.reader.streaming.PartitionOffset;
import org.apache.spark.sql.types.StructType;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.cloudpubsub.FlowControlSettings;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionCountReader;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.common.annotations.VisibleForTesting;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.apache.spark.sql.catalyst.InternalRow; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslContinuousReader implements ContinuousReader {
private final CursorClient cursorClient;
private final MultiPartitionCommitter committer;
private final PartitionSubscriberFactory partitionSubscriberFactory;
private final SubscriptionPath subscriptionPath;
private final FlowControlSettings flowControlSettings;
private SparkSourceOffset startOffset; | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
// public interface MultiPartitionCommitter extends Closeable {
//
// interface CommitterFactory {
// Committer newCommitter(Partition partition);
// }
//
// void commit(PslSourceOffset offset);
//
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionCountReader.java
// public interface PartitionCountReader extends Closeable {
// int getPartitionCount();
//
// @Override
// void close();
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PartitionSubscriberFactory.java
// public interface PartitionSubscriberFactory extends Serializable {
// Subscriber newSubscriber(
// Partition partition, Offset offset, Consumer<List<SequencedMessage>> message_consumer)
// throws ApiException;
// }
// Path: src/main/java/com/google/cloud/pubsublite/spark/PslContinuousReader.java
import org.apache.spark.sql.sources.v2.reader.InputPartition;
import org.apache.spark.sql.sources.v2.reader.streaming.ContinuousReader;
import org.apache.spark.sql.sources.v2.reader.streaming.Offset;
import org.apache.spark.sql.sources.v2.reader.streaming.PartitionOffset;
import org.apache.spark.sql.types.StructType;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.cloudpubsub.FlowControlSettings;
import com.google.cloud.pubsublite.internal.CursorClient;
import com.google.cloud.pubsublite.spark.internal.MultiPartitionCommitter;
import com.google.cloud.pubsublite.spark.internal.PartitionCountReader;
import com.google.cloud.pubsublite.spark.internal.PartitionSubscriberFactory;
import com.google.common.annotations.VisibleForTesting;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.apache.spark.sql.catalyst.InternalRow;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslContinuousReader implements ContinuousReader {
private final CursorClient cursorClient;
private final MultiPartitionCommitter committer;
private final PartitionSubscriberFactory partitionSubscriberFactory;
private final SubscriptionPath subscriptionPath;
private final FlowControlSettings flowControlSettings;
private SparkSourceOffset startOffset; | private final PartitionCountReader partitionCountReader; |
googleapis/java-pubsublite-spark | src/main/java/com/google/cloud/pubsublite/spark/PslDataWriterFactory.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/CachedPublishers.java
// public class CachedPublishers {
//
// // TODO(jiangmichaellll): Use com.google.cloud.pubsublite.internal.wire.SystemExecutors
// // once new PSL client library is released.
// private final Executor listenerExecutor = Executors.newSingleThreadExecutor();
//
// @GuardedBy("this")
// private final Map<PslWriteDataSourceOptions, Publisher<MessageMetadata>> publishers =
// new HashMap<>();
//
// public synchronized Publisher<MessageMetadata> getOrCreate(
// PslWriteDataSourceOptions writeOptions) {
// Publisher<MessageMetadata> publisher = publishers.get(writeOptions);
// if (publisher != null && publisher.state() == ApiService.State.RUNNING) {
// return publisher;
// }
//
// publisher = writeOptions.createNewPublisher();
// publishers.put(writeOptions, publisher);
// publisher.addListener(
// new ApiService.Listener() {
// @Override
// public void failed(ApiService.State s, Throwable t) {
// removePublisher(writeOptions);
// }
// },
// listenerExecutor);
// publisher.startAsync().awaitRunning();
// return publisher;
// }
//
// private synchronized void removePublisher(PslWriteDataSourceOptions writeOptions) {
// publishers.remove(writeOptions);
// }
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PublisherFactory.java
// public interface PublisherFactory extends Serializable {
//
// Publisher<MessageMetadata> newPublisher();
// }
| import com.google.cloud.pubsublite.spark.internal.CachedPublishers;
import com.google.cloud.pubsublite.spark.internal.PublisherFactory;
import java.io.Serializable;
import org.apache.spark.sql.catalyst.InternalRow;
import org.apache.spark.sql.sources.v2.writer.DataWriter;
import org.apache.spark.sql.sources.v2.writer.DataWriterFactory;
import org.apache.spark.sql.types.StructType; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslDataWriterFactory implements Serializable, DataWriterFactory<InternalRow> {
private static final long serialVersionUID = -6904546364310978844L;
| // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/CachedPublishers.java
// public class CachedPublishers {
//
// // TODO(jiangmichaellll): Use com.google.cloud.pubsublite.internal.wire.SystemExecutors
// // once new PSL client library is released.
// private final Executor listenerExecutor = Executors.newSingleThreadExecutor();
//
// @GuardedBy("this")
// private final Map<PslWriteDataSourceOptions, Publisher<MessageMetadata>> publishers =
// new HashMap<>();
//
// public synchronized Publisher<MessageMetadata> getOrCreate(
// PslWriteDataSourceOptions writeOptions) {
// Publisher<MessageMetadata> publisher = publishers.get(writeOptions);
// if (publisher != null && publisher.state() == ApiService.State.RUNNING) {
// return publisher;
// }
//
// publisher = writeOptions.createNewPublisher();
// publishers.put(writeOptions, publisher);
// publisher.addListener(
// new ApiService.Listener() {
// @Override
// public void failed(ApiService.State s, Throwable t) {
// removePublisher(writeOptions);
// }
// },
// listenerExecutor);
// publisher.startAsync().awaitRunning();
// return publisher;
// }
//
// private synchronized void removePublisher(PslWriteDataSourceOptions writeOptions) {
// publishers.remove(writeOptions);
// }
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PublisherFactory.java
// public interface PublisherFactory extends Serializable {
//
// Publisher<MessageMetadata> newPublisher();
// }
// Path: src/main/java/com/google/cloud/pubsublite/spark/PslDataWriterFactory.java
import com.google.cloud.pubsublite.spark.internal.CachedPublishers;
import com.google.cloud.pubsublite.spark.internal.PublisherFactory;
import java.io.Serializable;
import org.apache.spark.sql.catalyst.InternalRow;
import org.apache.spark.sql.sources.v2.writer.DataWriter;
import org.apache.spark.sql.sources.v2.writer.DataWriterFactory;
import org.apache.spark.sql.types.StructType;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslDataWriterFactory implements Serializable, DataWriterFactory<InternalRow> {
private static final long serialVersionUID = -6904546364310978844L;
| private static final CachedPublishers CACHED_PUBLISHERS = new CachedPublishers(); |
googleapis/java-pubsublite-spark | src/main/java/com/google/cloud/pubsublite/spark/PslDataWriterFactory.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/CachedPublishers.java
// public class CachedPublishers {
//
// // TODO(jiangmichaellll): Use com.google.cloud.pubsublite.internal.wire.SystemExecutors
// // once new PSL client library is released.
// private final Executor listenerExecutor = Executors.newSingleThreadExecutor();
//
// @GuardedBy("this")
// private final Map<PslWriteDataSourceOptions, Publisher<MessageMetadata>> publishers =
// new HashMap<>();
//
// public synchronized Publisher<MessageMetadata> getOrCreate(
// PslWriteDataSourceOptions writeOptions) {
// Publisher<MessageMetadata> publisher = publishers.get(writeOptions);
// if (publisher != null && publisher.state() == ApiService.State.RUNNING) {
// return publisher;
// }
//
// publisher = writeOptions.createNewPublisher();
// publishers.put(writeOptions, publisher);
// publisher.addListener(
// new ApiService.Listener() {
// @Override
// public void failed(ApiService.State s, Throwable t) {
// removePublisher(writeOptions);
// }
// },
// listenerExecutor);
// publisher.startAsync().awaitRunning();
// return publisher;
// }
//
// private synchronized void removePublisher(PslWriteDataSourceOptions writeOptions) {
// publishers.remove(writeOptions);
// }
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PublisherFactory.java
// public interface PublisherFactory extends Serializable {
//
// Publisher<MessageMetadata> newPublisher();
// }
| import com.google.cloud.pubsublite.spark.internal.CachedPublishers;
import com.google.cloud.pubsublite.spark.internal.PublisherFactory;
import java.io.Serializable;
import org.apache.spark.sql.catalyst.InternalRow;
import org.apache.spark.sql.sources.v2.writer.DataWriter;
import org.apache.spark.sql.sources.v2.writer.DataWriterFactory;
import org.apache.spark.sql.types.StructType; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslDataWriterFactory implements Serializable, DataWriterFactory<InternalRow> {
private static final long serialVersionUID = -6904546364310978844L;
private static final CachedPublishers CACHED_PUBLISHERS = new CachedPublishers();
private final StructType inputSchema;
private final PslWriteDataSourceOptions writeOptions;
public PslDataWriterFactory(StructType inputSchema, PslWriteDataSourceOptions writeOptions) {
this.inputSchema = inputSchema;
this.writeOptions = writeOptions;
}
@Override
public DataWriter<InternalRow> createDataWriter(int partitionId, long taskId, long epochId) { | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/CachedPublishers.java
// public class CachedPublishers {
//
// // TODO(jiangmichaellll): Use com.google.cloud.pubsublite.internal.wire.SystemExecutors
// // once new PSL client library is released.
// private final Executor listenerExecutor = Executors.newSingleThreadExecutor();
//
// @GuardedBy("this")
// private final Map<PslWriteDataSourceOptions, Publisher<MessageMetadata>> publishers =
// new HashMap<>();
//
// public synchronized Publisher<MessageMetadata> getOrCreate(
// PslWriteDataSourceOptions writeOptions) {
// Publisher<MessageMetadata> publisher = publishers.get(writeOptions);
// if (publisher != null && publisher.state() == ApiService.State.RUNNING) {
// return publisher;
// }
//
// publisher = writeOptions.createNewPublisher();
// publishers.put(writeOptions, publisher);
// publisher.addListener(
// new ApiService.Listener() {
// @Override
// public void failed(ApiService.State s, Throwable t) {
// removePublisher(writeOptions);
// }
// },
// listenerExecutor);
// publisher.startAsync().awaitRunning();
// return publisher;
// }
//
// private synchronized void removePublisher(PslWriteDataSourceOptions writeOptions) {
// publishers.remove(writeOptions);
// }
// }
//
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PublisherFactory.java
// public interface PublisherFactory extends Serializable {
//
// Publisher<MessageMetadata> newPublisher();
// }
// Path: src/main/java/com/google/cloud/pubsublite/spark/PslDataWriterFactory.java
import com.google.cloud.pubsublite.spark.internal.CachedPublishers;
import com.google.cloud.pubsublite.spark.internal.PublisherFactory;
import java.io.Serializable;
import org.apache.spark.sql.catalyst.InternalRow;
import org.apache.spark.sql.sources.v2.writer.DataWriter;
import org.apache.spark.sql.sources.v2.writer.DataWriterFactory;
import org.apache.spark.sql.types.StructType;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslDataWriterFactory implements Serializable, DataWriterFactory<InternalRow> {
private static final long serialVersionUID = -6904546364310978844L;
private static final CachedPublishers CACHED_PUBLISHERS = new CachedPublishers();
private final StructType inputSchema;
private final PslWriteDataSourceOptions writeOptions;
public PslDataWriterFactory(StructType inputSchema, PslWriteDataSourceOptions writeOptions) {
this.inputSchema = inputSchema;
this.writeOptions = writeOptions;
}
@Override
public DataWriter<InternalRow> createDataWriter(int partitionId, long taskId, long epochId) { | PublisherFactory pf = () -> CACHED_PUBLISHERS.getOrCreate(writeOptions); |
googleapis/java-pubsublite-spark | src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/PslSourceOffset.java
// @AutoValue
// public abstract class PslSourceOffset {
//
// public abstract Map<Partition, Offset> partitionOffsetMap();
//
// public static Builder builder() {
// return new AutoValue_PslSourceOffset.Builder();
// }
//
// @AutoValue.Builder
// public abstract static class Builder {
//
// public abstract Builder partitionOffsetMap(Map<Partition, Offset> partitionOffsetMap);
//
// public abstract PslSourceOffset build();
// }
// }
| import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.wire.Committer;
import com.google.cloud.pubsublite.spark.PslSourceOffset;
import java.io.Closeable; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark.internal;
public interface MultiPartitionCommitter extends Closeable {
interface CommitterFactory {
Committer newCommitter(Partition partition);
}
| // Path: src/main/java/com/google/cloud/pubsublite/spark/PslSourceOffset.java
// @AutoValue
// public abstract class PslSourceOffset {
//
// public abstract Map<Partition, Offset> partitionOffsetMap();
//
// public static Builder builder() {
// return new AutoValue_PslSourceOffset.Builder();
// }
//
// @AutoValue.Builder
// public abstract static class Builder {
//
// public abstract Builder partitionOffsetMap(Map<Partition, Offset> partitionOffsetMap);
//
// public abstract PslSourceOffset build();
// }
// }
// Path: src/main/java/com/google/cloud/pubsublite/spark/internal/MultiPartitionCommitter.java
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.wire.Committer;
import com.google.cloud.pubsublite.spark.PslSourceOffset;
import java.io.Closeable;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark.internal;
public interface MultiPartitionCommitter extends Closeable {
interface CommitterFactory {
Committer newCommitter(Partition partition);
}
| void commit(PslSourceOffset offset); |
googleapis/java-pubsublite-spark | src/test/java/com/google/cloud/pubsublite/spark/PslDataWriterTest.java | // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PublisherFactory.java
// public interface PublisherFactory extends Serializable {
//
// Publisher<MessageMetadata> newPublisher();
// }
| import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.MessageMetadata;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.Publisher;
import com.google.cloud.pubsublite.spark.internal.PublisherFactory;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.apache.spark.sql.catalyst.InternalRow;
import org.apache.spark.sql.types.DataTypes;
import org.apache.spark.sql.types.Metadata;
import org.apache.spark.sql.types.StructField;
import org.apache.spark.sql.types.StructType;
import org.junit.Test; | /*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslDataWriterTest {
private final InternalRow row = mock(InternalRow.class);
@SuppressWarnings("unchecked")
private final Publisher<MessageMetadata> publisher = mock(Publisher.class);
| // Path: src/main/java/com/google/cloud/pubsublite/spark/internal/PublisherFactory.java
// public interface PublisherFactory extends Serializable {
//
// Publisher<MessageMetadata> newPublisher();
// }
// Path: src/test/java/com/google/cloud/pubsublite/spark/PslDataWriterTest.java
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.api.core.ApiFutures;
import com.google.cloud.pubsublite.MessageMetadata;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.internal.Publisher;
import com.google.cloud.pubsublite.spark.internal.PublisherFactory;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.apache.spark.sql.catalyst.InternalRow;
import org.apache.spark.sql.types.DataTypes;
import org.apache.spark.sql.types.Metadata;
import org.apache.spark.sql.types.StructField;
import org.apache.spark.sql.types.StructType;
import org.junit.Test;
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.google.cloud.pubsublite.spark;
public class PslDataWriterTest {
private final InternalRow row = mock(InternalRow.class);
@SuppressWarnings("unchecked")
private final Publisher<MessageMetadata> publisher = mock(Publisher.class);
| private final PublisherFactory publisherFactory = mock(PublisherFactory.class); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.