mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-30 21:04:16 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
|
@ -0,0 +1,170 @@
|
|||
package com.adins.mss.foundation.datatable;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.models.GetDataTableRequest;
|
||||
import com.adins.mss.base.models.GetDataTableResponse;
|
||||
import com.adins.mss.base.util.GsonHelper;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.db.dataaccess.TableDataAccess;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.adins.mss.foundation.http.net.HttpClient;
|
||||
import com.adins.mss.foundation.http.net.HttpsClient;
|
||||
import com.squareup.okhttp.MediaType;
|
||||
import com.squareup.okhttp.Request;
|
||||
import com.squareup.okhttp.RequestBody;
|
||||
import com.squareup.okhttp.Response;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class GetDataTableTask extends AsyncTask<Void, Void, GetDataTableResponse> {
|
||||
|
||||
private Context context;
|
||||
private Map<String, String> params;
|
||||
private HttpClient httpClient;
|
||||
private HttpsClient httpsClient;
|
||||
private String errMessage = null;
|
||||
|
||||
public GetDataTableTask(Context context, Map<String, String> params) {
|
||||
this.context = context;
|
||||
this.params = params;
|
||||
|
||||
try {
|
||||
httpsClient = new HttpsClient(context);
|
||||
httpsClient.setAcceptAllCertificate(true);
|
||||
httpsClient.setBypassHostnameVerification(true);
|
||||
httpsClient.setConnectionTimeout((long) 120000);
|
||||
httpsClient.initialize();
|
||||
|
||||
httpClient = new HttpClient(context);
|
||||
httpClient.setConnectionTimeout(120000);
|
||||
} catch (Exception e) {
|
||||
Log.e(GetDataTableTask.class.getSimpleName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GetDataTableResponse doInBackground(Void... voids) {
|
||||
String query = params.get("message");
|
||||
|
||||
if (Global.IS_DEV) {
|
||||
Log.d(this.getClass().getSimpleName(), query);
|
||||
}
|
||||
|
||||
JSONArray listData = null;
|
||||
try {
|
||||
listData = TableDataAccess.getDataByQuery(context, query);
|
||||
} catch (Exception e) {
|
||||
errMessage = "ERROR when execute query: " + query + " Caused By: " + e.getMessage();
|
||||
}
|
||||
|
||||
if (null == listData || listData.length() < 1) {
|
||||
if (errMessage == null || "".equalsIgnoreCase(errMessage)) {
|
||||
errMessage = context.getResources().getString(R.string.no_data_available);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Tool.isInternetconnected(context)) {
|
||||
errMessage = context.getString(com.adins.mss.base.R.string.no_internet_connection);
|
||||
}
|
||||
|
||||
if (errMessage != null && !"".equalsIgnoreCase(errMessage)) {
|
||||
return submitDataToServer(errMessage);
|
||||
} else {
|
||||
return submitDataToServer(listData.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(GetDataTableResponse jsonGetDataTableResponse) {
|
||||
super.onPostExecute(jsonGetDataTableResponse);
|
||||
if (null == errMessage && jsonGetDataTableResponse != null) {
|
||||
String filename = params.get("filename");
|
||||
if (1 != jsonGetDataTableResponse.getStatus().getCode()) {
|
||||
String message = "Error GET DATA TABLE TASK filename '" + filename + "': ";
|
||||
FireCrash.log(new RemoteException(), message + jsonGetDataTableResponse.getStatus().getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getAppInfo(Context context) {
|
||||
String packageName = null;
|
||||
String version = null;
|
||||
try {
|
||||
PackageInfo pInfo = context.getPackageManager().
|
||||
getPackageInfo(context.getPackageName(), 0);
|
||||
packageName = pInfo.packageName;
|
||||
String[] appVersion = pInfo.versionName.split("-");
|
||||
version = appVersion[0];
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
if (Global.IS_DEV) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
String loginId = GlobalData.getSharedGlobalData().getUser().getLogin_id();
|
||||
|
||||
return packageName + "-" + version + "-" + loginId;
|
||||
}
|
||||
|
||||
private GetDataTableResponse submitDataToServer(String data) {
|
||||
String url = params.get("url");
|
||||
String query = params.get("message");
|
||||
String filename = params.get("filename");
|
||||
|
||||
GetDataTableRequest jsonRequest = new GetDataTableRequest();
|
||||
jsonRequest.setAudit(GlobalData.getSharedGlobalData().getAuditData());
|
||||
jsonRequest.setFileName(filename);
|
||||
jsonRequest.setAppInfo(getAppInfo(context));
|
||||
jsonRequest.setQuery(query);
|
||||
jsonRequest.setData(data);
|
||||
if (GlobalData.getSharedGlobalData().getUser() != null) {
|
||||
jsonRequest.setUser(GlobalData.getSharedGlobalData().getUser().getLogin_id());
|
||||
}
|
||||
|
||||
String json = GsonHelper.toJson(jsonRequest);
|
||||
|
||||
Request.Builder builder = new Request.Builder()
|
||||
.url(url)
|
||||
.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
if (params.containsKey("X-Api-Key")) {
|
||||
builder.addHeader("X-Api-Key", params.get("X-Api-Key"));
|
||||
}
|
||||
|
||||
builder.post(RequestBody.create(MediaType.parse("Content-Type"), json));
|
||||
Request request = builder.build();
|
||||
|
||||
try {
|
||||
Response response = null;
|
||||
if (url.startsWith("https://")) {
|
||||
response = httpsClient.execute(request);
|
||||
} else if (url.startsWith("http://")) {
|
||||
response = httpClient.execute(request);
|
||||
}
|
||||
|
||||
if (response.code() != 200) {
|
||||
errMessage = "Error SEND DATA TABLE TO SERVER filename '" + filename + "': " + response.message();
|
||||
FireCrash.log(new RemoteException(), errMessage);
|
||||
return null;
|
||||
}
|
||||
|
||||
return GsonHelper.fromJson(response.body().string(), GetDataTableResponse.class);
|
||||
} catch (Exception e) {
|
||||
errMessage = "Error SEND DATA TABLE TO SERVER filename '" + filename + "': " + e.getMessage();
|
||||
FireCrash.log(e, errMessage);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
package com.services.plantask;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.todolist.todayplanrepository.IPlanTaskDataSource;
|
||||
import com.adins.mss.base.todolist.todayplanrepository.ResponseStartVisit;
|
||||
import com.adins.mss.base.todolist.todayplanrepository.TodayPlanRepository;
|
||||
import com.adins.mss.dao.PlanTask;
|
||||
import com.adins.mss.foundation.db.dataaccess.PlanTaskDataAccess;
|
||||
import com.services.AutoSendImageThread;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class StartVisitJob extends Service implements IPlanTaskDataSource.Result<ResponseStartVisit> {
|
||||
|
||||
private TodayPlanRepository todayPlanRepo;
|
||||
private final String CHANNEL_ID = "START_VISIT_PLAN_CHANNEL";
|
||||
private final String CHANNEL_NAME = "Start Plans Notification";
|
||||
private final String CHANNEL_DESC = "Start Plans Notification";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
todayPlanRepo = GlobalData.getSharedGlobalData().getTodayPlanRepo();
|
||||
if(todayPlanRepo == null){
|
||||
todayPlanRepo = new TodayPlanRepository(getApplicationContext());
|
||||
}
|
||||
}
|
||||
|
||||
private Notification createNotif(){
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
int importance = NotificationManager.IMPORTANCE_DEFAULT;
|
||||
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, importance);
|
||||
channel.setDescription(CHANNEL_DESC);
|
||||
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this,CHANNEL_ID);
|
||||
notifBuilder.setSmallIcon(AutoSendImageThread.getNotificationUploadingIcon());
|
||||
String title = getString(R.string.auto_start_visit_title);
|
||||
String content = getString(R.string.auto_start_visit_content);
|
||||
notifBuilder.setContentTitle(title);
|
||||
notifBuilder.setContentText(content);
|
||||
notifBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(content));
|
||||
notifBuilder.setProgress(0,0,true);
|
||||
return notifBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
startForeground(13,createNotif());
|
||||
startVisit();
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void startVisit(){
|
||||
String uuidUser = GlobalData.getSharedGlobalData().getUser().getUuid_user();
|
||||
List<PlanTask> currentPlans = PlanTaskDataAccess.getAllPlan(getApplicationContext(),uuidUser);
|
||||
todayPlanRepo.startVisit(currentPlans,this);
|
||||
}
|
||||
|
||||
//start visit callback
|
||||
@Override
|
||||
public void onResult(ResponseStartVisit result) {
|
||||
if(result != null){
|
||||
todayPlanRepo.setStartVisit(true);
|
||||
todayPlanRepo.setNeedSync(false);
|
||||
}
|
||||
|
||||
stopForeground(true);
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
if(!todayPlanRepo.isStartVisit())
|
||||
todayPlanRepo.setStartVisit(false);
|
||||
|
||||
stopForeground(true);
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 145 KiB |
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout android:id="@+id/itemDetailLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<TextView
|
||||
android:id="@+id/itemLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.7"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:text="Item"
|
||||
android:textSize="13dp"/>
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@color/timelineLine" />
|
||||
<TextView
|
||||
android:id="@+id/itemValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:layout_gravity="center|end"
|
||||
android:text="Value"
|
||||
android:textSize="13dp"
|
||||
android:textAlignment="textEnd" />
|
||||
</LinearLayout>
|
|
@ -0,0 +1,12 @@
|
|||
package com.adins.mss.base.todolist.form;
|
||||
|
||||
import com.adins.mss.dao.TaskH;
|
||||
|
||||
/**
|
||||
* Created by gigin.ginanjar on 09/09/2016.
|
||||
*/
|
||||
public interface OnTaskListClickListener {
|
||||
void onItemClickListener(TaskH item, int position);
|
||||
|
||||
void onItemLongClickListener(TaskH item, int position);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.adins.mss.odr.followup.api;
|
||||
|
||||
import com.adins.mss.foundation.http.MssRequestType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by olivia.dg on 11/24/2017.
|
||||
*/
|
||||
|
||||
public class DoFollowUpRequest extends MssRequestType {
|
||||
@SerializedName("group_task_id")
|
||||
private List<String> groupTaskId;
|
||||
|
||||
public List<String> getGroupTaskId() {
|
||||
return groupTaskId;
|
||||
}
|
||||
|
||||
public void setGroupTaskId(List<String> groupTaskId) {
|
||||
this.groupTaskId = groupTaskId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.adins.mss.coll.loyalti.pointacquisitiondaily;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.coll.R;
|
||||
import com.adins.mss.coll.loyalti.pointacquisitionmonthly.DummyMonthlyPointView;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.UserHelp.UserHelp;
|
||||
import com.github.mikephil.charting.formatter.IndexAxisValueFormatter;
|
||||
import com.github.mikephil.charting.formatter.ValueFormatter;
|
||||
|
||||
import static com.adins.mss.constant.Global.SHOW_USERHELP_DELAY_DEFAULT;
|
||||
|
||||
public class DummyDailyPointsView extends DummyMonthlyPointView {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_dummy_point_acquisition_view, container, false);
|
||||
barChart = view.findViewById(R.id.dummyMonthlyChart);
|
||||
rankLegends = view.findViewById(R.id.dummyLegendRanks);
|
||||
pointLegends = view.findViewById(R.id.dummyLegendPoints);
|
||||
TextView dummyChartTitle = view.findViewById(R.id.dummyChartTitle);
|
||||
dummyChartTitle.setText(getString(R.string.daily_point_chart_title,"X"));
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showUserHelp() {
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UserHelp.showAllUserHelp(getActivity(),DummyDailyPointsView.class.getSimpleName(),finishCallback);
|
||||
}
|
||||
}, SHOW_USERHELP_DELAY_DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ValueFormatter getXValueFormatter() {
|
||||
return new IndexAxisValueFormatter(new String[]{"01","02","03","04"});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bgColor">
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:background="@drawable/header"
|
||||
app:titleTextAppearance="?android:attr/textAppearanceSmall"
|
||||
android:titleTextColor="@color/fontColorWhite"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
android:fitsSystemWindows="true"/>
|
||||
|
||||
<com.github.jjobes.slidedatetimepicker.SlidingTabLayout
|
||||
android:id="@+id/slidingTabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@drawable/header"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/pager">
|
||||
</androidx.viewpager.widget.ViewPager>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,206 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/bg_grayscale"
|
||||
android:padding="8dp" >
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/btnPrintDepReport"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true" >
|
||||
|
||||
<TableLayout
|
||||
android:id="@+id/tableLayout1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true" >
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/rowBatchId"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/tv_gray"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="4dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.25"
|
||||
android:text="@string/label_batch_id"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/divider2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.1"
|
||||
android:text="@string/divider_colon"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtBatchId"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.25"
|
||||
android:text="@string/label_batch_id"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/rowDepTipe"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/tv_gray_light"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="8dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.25"
|
||||
android:text="@string/label_type_dep_name"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/divider5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.1"
|
||||
android:text="@string/divider_colon"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtDepTipe"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.25"
|
||||
android:text="@string/label_type_dep_name"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/rowBankName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/tv_gray"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="8dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.25"
|
||||
android:text="Branch Payment"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/divider6"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.1"
|
||||
android:text="@string/divider_colon"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtBankName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.25"
|
||||
android:text="@string/label_bank_name"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/rowBank"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/tv_gray_light"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="4dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.25"
|
||||
android:text="@string/label_bank_name"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/divider4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.1"
|
||||
android:text="@string/divider_colon"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtBank"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.25"
|
||||
android:text="@string/label_bank_name"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/rowEvidenceTransfer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/tv_gray"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="8dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textEvidence"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.25"
|
||||
android:text="@string/label_transfer_evidence"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.1"
|
||||
android:text="@string/divider_colon"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgEvidenceTransfer"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_weight="0.25"
|
||||
android:scaleType="fitStart"
|
||||
android:src="@drawable/profile_image" />
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
</ScrollView>
|
||||
|
||||
<!-- <ListView -->
|
||||
<!-- android:id="@+id/recapitulationList" -->
|
||||
<!-- android:layout_width="match_parent" -->
|
||||
<!-- android:layout_height="fill_parent" -->
|
||||
<!-- android:layout_below="@+id/textView2" -->
|
||||
<!-- android:layout_weight="1" > -->
|
||||
<!-- </ListView> -->
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnPrintDepReport"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@android:color/transparent"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/btn_print"/>
|
||||
|
||||
</RelativeLayout>
|
Binary file not shown.
After Width: | Height: | Size: 6 KiB |
|
@ -0,0 +1,403 @@
|
|||
package com.adins.mss.base.dynamicform.form.questions.viewholder;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.dynamicform.Constant;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.Lookup;
|
||||
import com.adins.mss.foundation.db.dataaccess.LookupDataAccess;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.adins.mss.foundation.questiongenerator.OptionAnswerBean;
|
||||
import com.adins.mss.foundation.questiongenerator.QuestionBean;
|
||||
import com.adins.mss.foundation.questiongenerator.form.QuestionView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by gigin.ginanjar on 31/08/2016.
|
||||
*/
|
||||
public class TextWithSuggestionQuestionViewHolder extends RecyclerView.ViewHolder {
|
||||
public QuestionView mView;
|
||||
public TextView mQuestionLabel;
|
||||
public AutoCompleteTextView mQuestionAnswer;
|
||||
public QuestionBean bean;
|
||||
private Context mContext;
|
||||
private LookupArrayAdapter arrayAdapter;
|
||||
private List<OptionAnswerBean> options;
|
||||
|
||||
public TextWithSuggestionQuestionViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mView = (QuestionView) itemView.findViewById(R.id.questionTwsLayout);
|
||||
mQuestionLabel = (TextView) itemView.findViewById(R.id.questionTwsLabel);
|
||||
mQuestionAnswer = (AutoCompleteTextView) itemView.findViewById(R.id.questionTwsAnswer);
|
||||
mQuestionAnswer.requestFocus();
|
||||
}
|
||||
|
||||
public TextWithSuggestionQuestionViewHolder(View itemView, Context context) {
|
||||
super(itemView);
|
||||
mView = (QuestionView) itemView.findViewById(R.id.questionTwsLayout);
|
||||
mQuestionLabel = (TextView) itemView.findViewById(R.id.questionTwsLabel);
|
||||
mQuestionAnswer = (AutoCompleteTextView) itemView.findViewById(R.id.questionTwsAnswer);
|
||||
mQuestionAnswer.requestFocus();
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public void bind(QuestionBean item, int number) {
|
||||
bean = item;
|
||||
if (bean.getIs_mandatory().equals(Global.TRUE_STRING))
|
||||
mQuestionAnswer.setHint(mContext.getString(R.string.requiredField));
|
||||
else
|
||||
mQuestionAnswer.setHint("");
|
||||
String questionLabel = number + ". " + bean.getQuestion_label();
|
||||
mQuestionLabel.setText(questionLabel);
|
||||
if (null != bean.getAnswer() && !"".equalsIgnoreCase(bean.getAnswer())) {
|
||||
mQuestionAnswer.setText(bean.getAnswer());
|
||||
} else {
|
||||
mQuestionAnswer.setText("");
|
||||
}
|
||||
InputFilter[] inputFilters = {new InputFilter.LengthFilter(bean.getMax_length())};
|
||||
mQuestionAnswer.setFilters(inputFilters);
|
||||
|
||||
arrayAdapter = new LookupArrayAdapter(mContext, bean);
|
||||
mQuestionAnswer.setAdapter(arrayAdapter);
|
||||
mQuestionAnswer.setThreshold(1);
|
||||
mQuestionAnswer.setSingleLine();
|
||||
mQuestionAnswer.setDropDownBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.dropdown_background));
|
||||
|
||||
mQuestionAnswer.addTextChangedListener(new TextWatcher() {
|
||||
String TempText = "";
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||
int after) {
|
||||
// save answer to bean
|
||||
TempText = mQuestionAnswer.getText().toString().trim();
|
||||
if(!TempText.isEmpty() && null==bean.getSelectedOptionAnswers()){
|
||||
TempText = "";
|
||||
}
|
||||
if (bean.isReadOnly()) {
|
||||
mQuestionAnswer.setKeyListener(null);
|
||||
mQuestionAnswer.setCursorVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
bean.setAnswer(s.toString().trim());
|
||||
if (bean.isRelevanted()) {
|
||||
String newText = mQuestionAnswer.getText().toString().trim();
|
||||
mView.setChanged(false);
|
||||
if (!TempText.equals(newText)) {
|
||||
mView.setChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mQuestionAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (!bean.isReadOnly()) {
|
||||
List<OptionAnswerBean> tempSelectedItems = bean.getSelectedOptionAnswers();
|
||||
OptionAnswerBean newSelectedItem = arrayAdapter.getLookupItem(position);
|
||||
if (tempSelectedItems != null && !tempSelectedItems.isEmpty()) {
|
||||
if (tempSelectedItems.get(0).getUuid_lookup() != null
|
||||
&& !tempSelectedItems.get(0).getUuid_lookup().equals(newSelectedItem.getUuid_lookup())) {
|
||||
mView.setChanged(true);
|
||||
bean.setChange(true);
|
||||
} else {
|
||||
bean.setChange(false);
|
||||
}
|
||||
} else {
|
||||
bean.setChange(false);
|
||||
}
|
||||
saveSelectedOptionToBean(newSelectedItem);
|
||||
} else {
|
||||
bean.setChange(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (bean.isReadOnly()) {
|
||||
mQuestionAnswer.setKeyListener(null);
|
||||
mQuestionAnswer.setCursorVisible(false);
|
||||
mQuestionAnswer.setEnabled(false);
|
||||
} else {
|
||||
mQuestionAnswer.setCursorVisible(true);
|
||||
mQuestionAnswer.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveSelectedOptionToBean(OptionAnswerBean option) {
|
||||
List<OptionAnswerBean> selectedOptionAnswers = new ArrayList<>();
|
||||
if(option == null){
|
||||
bean.setLovCode(null);
|
||||
bean.setLookupId(null);
|
||||
bean.setSelectedOptionAnswers(selectedOptionAnswers);
|
||||
return;
|
||||
}
|
||||
|
||||
option.setSelected(true);
|
||||
selectedOptionAnswers.add(option);
|
||||
bean.setLovCode(option.getCode());
|
||||
bean.setLookupId(option.getUuid_lookup());
|
||||
bean.setSelectedOptionAnswers(selectedOptionAnswers);
|
||||
bean.setAnswer(option.toString());
|
||||
}
|
||||
|
||||
private List<OptionAnswerBean> GetLookupFromDBTextWithSuggestion(Context context, QuestionBean bean, List<String> filters, String dynamicFilter) {
|
||||
List<OptionAnswerBean> optionAnswers = new ArrayList<>();
|
||||
if (!filters.isEmpty()) {
|
||||
if (filters.size() == 1) {
|
||||
List<Lookup> nLookups = LookupDataAccess.getAllByFilterTextWithSuggestion(context, bean.getLov_group(), filters.get(0), dynamicFilter);
|
||||
optionAnswers = OptionAnswerBean.getOptionList(nLookups);
|
||||
} else if (filters.size() == 2) {
|
||||
List<Lookup> nLookups = LookupDataAccess.getAllByFilterTextWithSuggestion(context, bean.getLov_group(), filters.get(0), filters.get(1), dynamicFilter);
|
||||
optionAnswers = OptionAnswerBean.getOptionList(nLookups);
|
||||
} else if (filters.size() == 3) {
|
||||
List<Lookup> nLookups = LookupDataAccess.getAllByFilterTextWithSuggestion(context, bean.getLov_group(), filters.get(0), filters.get(1), filters.get(2), dynamicFilter);
|
||||
optionAnswers = OptionAnswerBean.getOptionList(nLookups);
|
||||
} else if (filters.size() == 4) {
|
||||
List<Lookup> nLookups = LookupDataAccess.getAllByFilterTextWithSuggestion(context, bean.getLov_group(), filters.get(0), filters.get(1), filters.get(2), filters.get(3), dynamicFilter);
|
||||
optionAnswers = OptionAnswerBean.getOptionList(nLookups);
|
||||
} else if (filters.size() == 5) {
|
||||
List<Lookup> nLookups = LookupDataAccess.getAllByFilterTextWithSuggestion(context, bean.getLov_group(), filters.get(0), filters.get(1), filters.get(2), filters.get(3), filters.get(4), dynamicFilter);
|
||||
optionAnswers = OptionAnswerBean.getOptionList(nLookups);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (bean.getChoice_filter() != null && bean.getChoice_filter().length() > 0) {
|
||||
List<Lookup> lookups = new ArrayList<>();
|
||||
optionAnswers = OptionAnswerBean.getOptionList(lookups);
|
||||
} else {
|
||||
String lovGroup = bean.getLov_group();
|
||||
if (lovGroup != null) {
|
||||
List<Lookup> lookups = LookupDataAccess.getAllByLovGroupTextWithSuggestion(context, lovGroup, dynamicFilter);
|
||||
if (lookups != null)
|
||||
optionAnswers = OptionAnswerBean.getOptionList(lookups);
|
||||
}
|
||||
}
|
||||
}
|
||||
return optionAnswers;
|
||||
}
|
||||
|
||||
private List<OptionAnswerBean> GetLookupFromDB(Context context, QuestionBean bean, List<String> filters) {
|
||||
List<OptionAnswerBean> optionAnswers = new ArrayList<>();
|
||||
if (!filters.isEmpty()) {
|
||||
if (filters.size() == 1) {
|
||||
List<Lookup> nLookups = LookupDataAccess.getAllByFilter(context, bean.getLov_group(), filters.get(0));
|
||||
optionAnswers = OptionAnswerBean.getOptionList(nLookups);
|
||||
} else if (filters.size() == 2) {
|
||||
List<Lookup> nLookups = LookupDataAccess.getAllByFilter(context, bean.getLov_group(), filters.get(0), filters.get(1));
|
||||
optionAnswers = OptionAnswerBean.getOptionList(nLookups);
|
||||
} else if (filters.size() == 3) {
|
||||
List<Lookup> nLookups = LookupDataAccess.getAllByFilter(context, bean.getLov_group(), filters.get(0), filters.get(1), filters.get(2));
|
||||
optionAnswers = OptionAnswerBean.getOptionList(nLookups);
|
||||
} else if (filters.size() == 4) {
|
||||
List<Lookup> nLookups = LookupDataAccess.getAllByFilter(context, bean.getLov_group(), filters.get(0), filters.get(1), filters.get(2), filters.get(3));
|
||||
optionAnswers = OptionAnswerBean.getOptionList(nLookups);
|
||||
} else if (filters.size() == 5) {
|
||||
List<Lookup> nLookups = LookupDataAccess.getAllByFilter(context, bean.getLov_group(), filters.get(0), filters.get(1), filters.get(2), filters.get(3), filters.get(4));
|
||||
optionAnswers = OptionAnswerBean.getOptionList(nLookups);
|
||||
}
|
||||
} else {
|
||||
if (bean.getChoice_filter() != null && bean.getChoice_filter().length() > 0) {
|
||||
List<Lookup> lookups = new ArrayList<>();
|
||||
optionAnswers = OptionAnswerBean.getOptionList(lookups);
|
||||
} else {
|
||||
String lovGroup = bean.getLov_group();
|
||||
if (lovGroup != null) {
|
||||
List<Lookup> lookups = LookupDataAccess.getAllByLovGroup(context, lovGroup);
|
||||
if (lookups != null)
|
||||
optionAnswers = OptionAnswerBean.getOptionList(lookups);
|
||||
}
|
||||
}
|
||||
}
|
||||
return optionAnswers;
|
||||
}
|
||||
|
||||
protected List<OptionAnswerBean> getOptionsForQuestion(QuestionBean bean, String dynamicFilter) {
|
||||
List<String> filters = new ArrayList<>();
|
||||
int constraintAmount = 0;
|
||||
if (bean.getChoice_filter() != null) {
|
||||
String[] tempfilters = Tool.split(bean.getChoice_filter(), Global.DELIMETER_DATA3);
|
||||
|
||||
for (String newFilter : tempfilters) {
|
||||
int idxOfOpenBrace = newFilter.indexOf('{');
|
||||
if (idxOfOpenBrace != -1) {
|
||||
int idxOfCloseBrace = newFilter.indexOf('}');
|
||||
String tempIdentifier = newFilter.substring(idxOfOpenBrace + 1, idxOfCloseBrace).toUpperCase();
|
||||
if (tempIdentifier.contains("%")) {
|
||||
filters.add(tempIdentifier);
|
||||
} else {
|
||||
int idxOfOpenAbs = tempIdentifier.indexOf("$");
|
||||
if (idxOfOpenAbs != -1) {
|
||||
String finalIdentifier = tempIdentifier.substring(idxOfOpenAbs + 1);
|
||||
if (finalIdentifier.equals(Global.IDF_LOGIN_ID)) {
|
||||
String loginId = GlobalData.getSharedGlobalData().getUser().getLogin_id();
|
||||
int idxOfOpenAt = loginId.indexOf('@');
|
||||
if (idxOfOpenAt != -1) {
|
||||
loginId = loginId.substring(0, idxOfOpenAt);
|
||||
}
|
||||
filters.add(loginId);
|
||||
} else if (finalIdentifier.equals(Global.IDF_BRANCH_ID)) {
|
||||
String branchId = GlobalData.getSharedGlobalData().getUser().getBranch_id();
|
||||
filters.add(branchId);
|
||||
} else if (finalIdentifier.equals(Global.IDF_BRANCH_NAME)) {
|
||||
String branchName = GlobalData.getSharedGlobalData().getUser().getBranch_name();
|
||||
filters.add(branchName);
|
||||
} else if (finalIdentifier.equals(Global.IDF_UUID_USER)) {
|
||||
String uuidUser = GlobalData.getSharedGlobalData().getUser().getUuid_user();
|
||||
filters.add(uuidUser);
|
||||
} else if (finalIdentifier.equals(Global.IDF_JOB)) {
|
||||
String job = GlobalData.getSharedGlobalData().getUser().getFlag_job();
|
||||
filters.add(job);
|
||||
} else if (finalIdentifier.equals(Global.IDF_DEALER_NAME)) {
|
||||
String dealerName = GlobalData.getSharedGlobalData().getUser().getDealer_name();
|
||||
filters.add(dealerName);
|
||||
} else if (finalIdentifier.equals(Global.IDF_UUID_BRANCH)) {
|
||||
String uuidBranch = GlobalData.getSharedGlobalData().getUser().getUuid_branch();
|
||||
filters.add(uuidBranch);
|
||||
} else if (finalIdentifier.equals(Global.IDF_DEALER_ID)) {
|
||||
String dealerId = GlobalData.getSharedGlobalData().getUser().getUuid_dealer();
|
||||
filters.add(dealerId);
|
||||
}
|
||||
constraintAmount++;
|
||||
} else {
|
||||
QuestionBean bean2 = Constant.getListOfQuestion().get(tempIdentifier);
|
||||
if (bean2 != null) {
|
||||
if (Global.AT_TEXT_WITH_SUGGESTION.equals(bean2.getAnswer_type())) {
|
||||
filters.add(bean2.getLovCode());
|
||||
} else {
|
||||
for (OptionAnswerBean answerBean : bean2.getSelectedOptionAnswers()) {
|
||||
filters.add(answerBean.getCode());
|
||||
}
|
||||
}
|
||||
bean2.setRelevanted(true);
|
||||
constraintAmount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<OptionAnswerBean> optionAnswers;
|
||||
if (dynamicFilter != null) {
|
||||
optionAnswers = GetLookupFromDBTextWithSuggestion(mContext, bean, filters, dynamicFilter);
|
||||
} else {
|
||||
optionAnswers = GetLookupFromDB(mContext, bean, filters);
|
||||
}
|
||||
|
||||
return optionAnswers;
|
||||
}
|
||||
|
||||
class LookupArrayAdapter extends BaseAdapter implements Filterable {
|
||||
private Context mContext;
|
||||
private QuestionBean bean;
|
||||
private List<OptionAnswerBean> resultList = new ArrayList<>();
|
||||
|
||||
public LookupArrayAdapter(Context context, QuestionBean bean) {
|
||||
this.mContext = context;
|
||||
this.bean = bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return resultList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItem(int position) {
|
||||
return resultList.get(position).toString();
|
||||
}
|
||||
|
||||
public OptionAnswerBean getLookupItem(int position) {
|
||||
return resultList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
AutoTextViewHolder holder;
|
||||
if (convertView == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) mContext
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = inflater.inflate(R.layout.autotext_list, parent, false);
|
||||
}
|
||||
holder = new AutoTextViewHolder(convertView);
|
||||
holder.bind(getLookupItem(position));
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
Filter filter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
FilterResults filterResults = new FilterResults();
|
||||
if (constraint != null) {
|
||||
List<OptionAnswerBean> beanList = getOptionsForQuestion(bean, constraint.toString());
|
||||
// Assign the data to the FilterResults
|
||||
filterResults.values = beanList;
|
||||
filterResults.count = beanList.size();
|
||||
}
|
||||
return filterResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
if (results != null && results.count > 0) {
|
||||
resultList = (List<OptionAnswerBean>) results.values;
|
||||
options = resultList;
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
notifyDataSetInvalidated();
|
||||
}
|
||||
}
|
||||
};
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
|
||||
public class AutoTextViewHolder extends RecyclerView.ViewHolder {
|
||||
public View mView;
|
||||
public TextView textView;
|
||||
public OptionAnswerBean bean;
|
||||
|
||||
public AutoTextViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mView = itemView;
|
||||
textView = (TextView) itemView.findViewById(R.id.textauto);
|
||||
}
|
||||
|
||||
public void bind(OptionAnswerBean optBean) {
|
||||
bean = optBean;
|
||||
textView.setText(bean.getValue());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,279 @@
|
|||
package com.adins.mss.dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import android.database.Cursor;
|
||||
|
||||
import de.greenrobot.dao.AbstractDao;
|
||||
import de.greenrobot.dao.Property;
|
||||
import de.greenrobot.dao.internal.SqlUtils;
|
||||
import de.greenrobot.dao.internal.DaoConfig;
|
||||
import de.greenrobot.dao.database.Database;
|
||||
import de.greenrobot.dao.database.DatabaseStatement;
|
||||
import de.greenrobot.dao.query.Query;
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
|
||||
import com.adins.mss.dao.PlanTask;
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
/**
|
||||
* DAO for table "TR_PLAN_TASK".
|
||||
*/
|
||||
public class PlanTaskDao extends AbstractDao<PlanTask, String> {
|
||||
|
||||
public static final String TABLENAME = "TR_PLAN_TASK";
|
||||
|
||||
/**
|
||||
* Properties of entity PlanTask.<br/>
|
||||
* Can be used for QueryBuilder and for referencing column names.
|
||||
*/
|
||||
public static class Properties {
|
||||
public final static Property Uuid_plan_task = new Property(0, String.class, "uuid_plan_task", true, "UUID_PLAN_TASK");
|
||||
public final static Property Sequence = new Property(1, int.class, "sequence", false, "SEQUENCE");
|
||||
public final static Property Plan_status = new Property(2, String.class, "plan_status", false, "PLAN_STATUS");
|
||||
public final static Property Plan_start_date = new Property(3, java.util.Date.class, "plan_start_date", false, "PLAN_START_DATE");
|
||||
public final static Property Plan_crt_date = new Property(4, java.util.Date.class, "plan_crt_date", false, "PLAN_CRT_DATE");
|
||||
public final static Property View_sequence = new Property(5, Integer.class, "view_sequence", false, "VIEW_SEQUENCE");
|
||||
public final static Property Uuid_user = new Property(6, String.class, "uuid_user", false, "UUID_USER");
|
||||
public final static Property Uuid_task_h = new Property(7, String.class, "uuid_task_h", false, "UUID_TASK_H");
|
||||
};
|
||||
|
||||
private DaoSession daoSession;
|
||||
|
||||
private Query<PlanTask> user_PlanTaskListQuery;
|
||||
|
||||
public PlanTaskDao(DaoConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public PlanTaskDao(DaoConfig config, DaoSession daoSession) {
|
||||
super(config, daoSession);
|
||||
this.daoSession = daoSession;
|
||||
}
|
||||
|
||||
/** Creates the underlying database table. */
|
||||
public static void createTable(Database db, boolean ifNotExists) {
|
||||
String constraint = ifNotExists? "IF NOT EXISTS ": "";
|
||||
db.execSQL("CREATE TABLE " + constraint + "\"TR_PLAN_TASK\" (" + //
|
||||
"\"UUID_PLAN_TASK\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_plan_task
|
||||
"\"SEQUENCE\" INTEGER NOT NULL ," + // 1: sequence
|
||||
"\"PLAN_STATUS\" TEXT NOT NULL ," + // 2: plan_status
|
||||
"\"PLAN_START_DATE\" INTEGER," + // 3: plan_start_date
|
||||
"\"PLAN_CRT_DATE\" INTEGER," + // 4: plan_crt_date
|
||||
"\"VIEW_SEQUENCE\" INTEGER," + // 5: view_sequence
|
||||
"\"UUID_USER\" TEXT NOT NULL ," + // 6: uuid_user
|
||||
"\"UUID_TASK_H\" TEXT NOT NULL );"); // 7: uuid_task_h
|
||||
}
|
||||
|
||||
/** Drops the underlying database table. */
|
||||
public static void dropTable(Database db, boolean ifExists) {
|
||||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TR_PLAN_TASK\"";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected void bindValues(DatabaseStatement stmt, PlanTask entity) {
|
||||
stmt.clearBindings();
|
||||
stmt.bindString(1, entity.getUuid_plan_task());
|
||||
stmt.bindLong(2, entity.getSequence());
|
||||
stmt.bindString(3, entity.getPlan_status());
|
||||
|
||||
java.util.Date plan_start_date = entity.getPlan_start_date();
|
||||
if (plan_start_date != null) {
|
||||
stmt.bindLong(4, plan_start_date.getTime());
|
||||
}
|
||||
|
||||
java.util.Date plan_crt_date = entity.getPlan_crt_date();
|
||||
if (plan_crt_date != null) {
|
||||
stmt.bindLong(5, plan_crt_date.getTime());
|
||||
}
|
||||
|
||||
Integer view_sequence = entity.getView_sequence();
|
||||
if (view_sequence != null) {
|
||||
stmt.bindLong(6, view_sequence);
|
||||
}
|
||||
stmt.bindString(7, entity.getUuid_user());
|
||||
stmt.bindString(8, entity.getUuid_task_h());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachEntity(PlanTask entity) {
|
||||
super.attachEntity(entity);
|
||||
entity.__setDaoSession(daoSession);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public String readKey(Cursor cursor, int offset) {
|
||||
return cursor.getString(offset + 0);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public PlanTask readEntity(Cursor cursor, int offset) {
|
||||
PlanTask entity = new PlanTask( //
|
||||
cursor.getString(offset + 0), // uuid_plan_task
|
||||
cursor.getInt(offset + 1), // sequence
|
||||
cursor.getString(offset + 2), // plan_status
|
||||
cursor.isNull(offset + 3) ? null : new java.util.Date(cursor.getLong(offset + 3)), // plan_start_date
|
||||
cursor.isNull(offset + 4) ? null : new java.util.Date(cursor.getLong(offset + 4)), // plan_crt_date
|
||||
cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // view_sequence
|
||||
cursor.getString(offset + 6), // uuid_user
|
||||
cursor.getString(offset + 7) // uuid_task_h
|
||||
);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public void readEntity(Cursor cursor, PlanTask entity, int offset) {
|
||||
entity.setUuid_plan_task(cursor.getString(offset + 0));
|
||||
entity.setSequence(cursor.getInt(offset + 1));
|
||||
entity.setPlan_status(cursor.getString(offset + 2));
|
||||
entity.setPlan_start_date(cursor.isNull(offset + 3) ? null : new java.util.Date(cursor.getLong(offset + 3)));
|
||||
entity.setPlan_crt_date(cursor.isNull(offset + 4) ? null : new java.util.Date(cursor.getLong(offset + 4)));
|
||||
entity.setView_sequence(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
|
||||
entity.setUuid_user(cursor.getString(offset + 6));
|
||||
entity.setUuid_task_h(cursor.getString(offset + 7));
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected String updateKeyAfterInsert(PlanTask entity, long rowId) {
|
||||
return entity.getUuid_plan_task();
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public String getKey(PlanTask entity) {
|
||||
if(entity != null) {
|
||||
return entity.getUuid_plan_task();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected boolean isEntityUpdateable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Internal query to resolve the "planTaskList" to-many relationship of User. */
|
||||
public List<PlanTask> _queryUser_PlanTaskList(String uuid_user) {
|
||||
synchronized (this) {
|
||||
if (user_PlanTaskListQuery == null) {
|
||||
QueryBuilder<PlanTask> queryBuilder = queryBuilder();
|
||||
queryBuilder.where(Properties.Uuid_user.eq(null));
|
||||
user_PlanTaskListQuery = queryBuilder.build();
|
||||
}
|
||||
}
|
||||
Query<PlanTask> query = user_PlanTaskListQuery.forCurrentThread();
|
||||
query.setParameter(0, uuid_user);
|
||||
return query.list();
|
||||
}
|
||||
|
||||
private String selectDeep;
|
||||
|
||||
protected String getSelectDeep() {
|
||||
if (selectDeep == null) {
|
||||
StringBuilder builder = new StringBuilder("SELECT ");
|
||||
SqlUtils.appendColumns(builder, "T", getAllColumns());
|
||||
builder.append(',');
|
||||
SqlUtils.appendColumns(builder, "T0", daoSession.getTaskHDao().getAllColumns());
|
||||
builder.append(',');
|
||||
SqlUtils.appendColumns(builder, "T1", daoSession.getUserDao().getAllColumns());
|
||||
builder.append(" FROM TR_PLAN_TASK T");
|
||||
builder.append(" LEFT JOIN TR_TASK_H T0 ON T.\"UUID_TASK_H\"=T0.\"UUID_TASK_H\"");
|
||||
builder.append(" LEFT JOIN MS_USER T1 ON T.\"UUID_USER\"=T1.\"UUID_USER\"");
|
||||
builder.append(' ');
|
||||
selectDeep = builder.toString();
|
||||
}
|
||||
return selectDeep;
|
||||
}
|
||||
|
||||
protected PlanTask loadCurrentDeep(Cursor cursor, boolean lock) {
|
||||
PlanTask entity = loadCurrent(cursor, 0, lock);
|
||||
int offset = getAllColumns().length;
|
||||
|
||||
TaskH taskH = loadCurrentOther(daoSession.getTaskHDao(), cursor, offset);
|
||||
if(taskH != null) {
|
||||
entity.setTaskH(taskH);
|
||||
}
|
||||
offset += daoSession.getTaskHDao().getAllColumns().length;
|
||||
|
||||
User user = loadCurrentOther(daoSession.getUserDao(), cursor, offset);
|
||||
if(user != null) {
|
||||
entity.setUser(user);
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public PlanTask loadDeep(Long key) {
|
||||
assertSinglePk();
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder(getSelectDeep());
|
||||
builder.append("WHERE ");
|
||||
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
|
||||
String sql = builder.toString();
|
||||
|
||||
String[] keyArray = new String[] { key.toString() };
|
||||
Cursor cursor = db.rawQuery(sql, keyArray);
|
||||
|
||||
try {
|
||||
boolean available = cursor.moveToFirst();
|
||||
if (!available) {
|
||||
return null;
|
||||
} else if (!cursor.isLast()) {
|
||||
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
|
||||
}
|
||||
return loadCurrentDeep(cursor, true);
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */
|
||||
public List<PlanTask> loadAllDeepFromCursor(Cursor cursor) {
|
||||
int count = cursor.getCount();
|
||||
List<PlanTask> list = new ArrayList<PlanTask>(count);
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
if (identityScope != null) {
|
||||
identityScope.lock();
|
||||
identityScope.reserveRoom(count);
|
||||
}
|
||||
try {
|
||||
do {
|
||||
list.add(loadCurrentDeep(cursor, false));
|
||||
} while (cursor.moveToNext());
|
||||
} finally {
|
||||
if (identityScope != null) {
|
||||
identityScope.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<PlanTask> loadDeepAllAndCloseCursor(Cursor cursor) {
|
||||
try {
|
||||
return loadAllDeepFromCursor(cursor);
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** A raw-style query where you can pass any WHERE clause and arguments. */
|
||||
public List<PlanTask> queryDeep(String where, String... selectionArg) {
|
||||
Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg);
|
||||
return loadDeepAllAndCloseCursor(cursor);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue