Commit 94555bd3 authored by rahadi's avatar rahadi

Added Pemutakhiran Module

parent 67b4f6f8
......@@ -367,14 +367,14 @@ the specific language governing permissions and limitations under the License.
android:parentActivityName=".capi.activity.CapiMainActivity" />
<activity
android:name=".pemutakhiran.BSActivity"
android:name=".pemutakhiran.activities.BSActivity"
android:theme="@style/VsenAppTheme" />
<activity
android:name=".pemutakhiran.RutaActivity"
android:name=".pemutakhiran.activities.RutaActivity"
android:theme="@style/VsenAppTheme" />
<activity
android:name=".pemutakhiran.DsrtActivity"
android:name=".pemutakhiran.activities.DsrtActivity"
android:theme="@style/VsenAppTheme" />
</application>
......
......@@ -33,8 +33,8 @@ import org.odk.collect.android.BuildConfig;
import org.odk.collect.android.R;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.capi.activity.CapiLoginActivity;
import org.odk.collect.android.capi.activity.CapiMainActivity;
import org.odk.collect.android.capi.preferences.CapiInstancePreferences;
import org.odk.collect.android.pemutakhiran.BSActivity;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys;
......@@ -80,8 +80,8 @@ public class SplashScreenActivity extends AppCompatActivity {
}
if (preferences.getBoolean(PreferenceKeys.KEY_LOGIN_STATUS, false)) {
// startActivity(new Intent(this, CapiMainActivity.class));
startActivity(new Intent(this, BSActivity.class));
startActivity(new Intent(this, CapiMainActivity.class));
// startActivity(new Intent(this, BSActivity.class));
} else {
startActivity(new Intent(this, CapiLoginActivity.class));
}
......
......@@ -80,6 +80,9 @@ public class Collect extends Application {
public static final String DEFAULT_FONTSIZE = "16";
public static final String OFFLINE_LAYERS = ODK_ROOT + File.separator + "layers";
public static final String SETTINGS = ODK_ROOT + File.separator + "settings";
public static final String EMPTY_INSTANCES_PATH = ODK_ROOT + File.separator + "instances" + File.separator + "empty";
private static Collect singleton = null;
static {
......@@ -122,7 +125,8 @@ public class Collect extends Application {
}
String[] dirs = {
ODK_ROOT, FORMS_PATH, INSTANCES_PATH, CACHE_PATH, METADATA_PATH, OFFLINE_LAYERS
ODK_ROOT, FORMS_PATH, INSTANCES_PATH, CACHE_PATH, METADATA_PATH, OFFLINE_LAYERS,
EMPTY_INSTANCES_PATH
};
for (String dirName : dirs) {
......
......@@ -14,17 +14,17 @@ import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.GsonBuilder;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.listeners.OnSynchronizationCompletedListener;
import com.rahadi.vsen.listeners.OnSynchronizationErrorListener;
import com.rahadi.vsen.models.UserModel;
import com.rahadi.vsen.tasks.BSSynchronizationTask;
import com.rahadi.vsen.tasks.GetGenerateTask;
import com.rahadi.vsen.tasks.UserRegisterTask;
import org.json.JSONArray;
import org.json.JSONObject;
import org.odk.collect.android.R;
import org.odk.collect.android.pemutakhiran.BSActivity;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys;
import org.odk.collect.android.preferences.PreferencesActivity;
......@@ -112,16 +112,10 @@ public class CapiLoginActivity extends AppCompatActivity
new UserRegisterTask(username, uuid).execute(new OnSynchronizationCompletedListener<JSONObject>() {
@Override
public void onSynchronizationCompleted(JSONObject result) {
// TODO: 22/01/2018 RAHADI: FILL IN THE BLANK
Timber.d("UserRegister: " + result.toString());
Vsen.getInstance().setUserSession(new UserModel.Builder()
.setIdUser(username)
.setNamaUser("")
.setIdSupervisor("")
.setNamaSupervisor("")
.setPrivilege(0)
.setAuthToken(uuid)
.build());
UserModel r = new GsonBuilder().create().fromJson(result.toString(), UserModel.class);
Timber.d(r.toString());
Vsen.getInstance().setUserSession(r);
dialog.setMessage("Sinkronisasi Data..");
......@@ -129,12 +123,17 @@ public class CapiLoginActivity extends AppCompatActivity
new OnSynchronizationCompletedListener<JSONArray>() {
@Override
public void onSynchronizationCompleted(JSONArray result) {
Timber.d("BSSync: " + result.toString());
// TODO: 20/02/2018 RAHADI: dynamize
String formId = "VSEN18K.v2";
new GetGenerateTask(formId).execute(new OnSynchronizationCompletedListener<String>() {
@Override
public void onSynchronizationCompleted(String result) {
onLoginSucceed();
}
@Override
public void onSynchronizationFailed(Exception e) {
Timber.e(e);
onLoginFailed(e.toString());
}
});
......@@ -142,13 +141,16 @@ public class CapiLoginActivity extends AppCompatActivity
@Override
public void onSynchronizationFailed(Exception e) {
Timber.e(e);
onLoginFailed(e.toString());
}
}, new OnSynchronizationErrorListener() {
});
}
@Override
public void onSynchronizationError(Exception exception) {
Timber.e(exception);
onLoginFailed("Fail to get id on server : " + exception.getMessage());
public void onSynchronizationFailed(Exception e) {
Timber.e(e);
onLoginFailed(e.toString());
}
});
}
......@@ -159,7 +161,8 @@ public class CapiLoginActivity extends AppCompatActivity
loginBtn.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
GeneralSharedPreferences.getInstance().save(PreferenceKeys.KEY_LOGIN_STATUS, true);
Intent toMain = new Intent(this, BSActivity.class);
// Intent toMain = new Intent(this, BSActivity.class);
Intent toMain = new Intent(this, CapiMainActivity.class);
startActivity(toMain);
finish();
}
......
......@@ -3,21 +3,19 @@ package org.odk.collect.android.capi.activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import com.google.firebase.messaging.FirebaseMessaging;
......@@ -28,34 +26,23 @@ import com.mikepenz.materialdrawer.DrawerBuilder;
import com.mikepenz.materialdrawer.model.DividerDrawerItem;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IProfile;
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader;
import com.mikepenz.materialdrawer.util.DrawerImageLoader;
import com.squareup.picasso.Picasso;
import org.apache.commons.lang3.StringUtils;
import org.odk.collect.android.R;
import org.odk.collect.android.activities.FileManagerTabs;
import org.odk.collect.android.capi.preferences.Constants;
import org.odk.collect.android.capi.fragment.CapiFormFragment;
import org.odk.collect.android.activities.InstanceChooserList;
import org.odk.collect.android.activities.InstanceUploaderList;
import org.odk.collect.android.activities.SplashScreenActivity;
import org.odk.collect.android.capi.fragment.CapiFormFragment;
import org.odk.collect.android.capi.preferences.CapiInstancePreferences;
import org.odk.collect.android.capi.Helper;
import org.odk.collect.android.capi.ModelResponse;
import org.odk.collect.android.capi.ModelSurvey;
import org.odk.collect.android.listeners.DiskSyncListener;
import org.odk.collect.android.pemutakhiran.activities.BSActivity;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys;
import org.odk.collect.android.revalidasi.activities.DataDownloadActivity;
import org.odk.collect.android.revalidasi.notifikasi.GetUuidTask;
import org.odk.collect.android.tasks.DiskSyncTask;
import org.odk.collect.android.utilities.ApplicationConstants;
import java.util.ArrayList;
import timber.log.Timber;
......@@ -67,6 +54,7 @@ import timber.log.Timber;
public class CapiMainActivity extends AppCompatActivity implements DiskSyncListener {
//Identifier
private static final int MENU_PEMUTAKHIRAN = 3;
private static final int MENUSURVEY = 4;
private static final int MENU_UPDATE = 5;
private static final int MENUSETTING = 8;
......@@ -91,7 +79,7 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
getSupportActionBar().setTitle("Daftar Kuesioner");
diskSyncTask = (DiskSyncTask) getLastCustomNonConfigurationInstance();
if (diskSyncTask == null){
if (diskSyncTask == null) {
Timber.i("Starting new disk sync task");
diskSyncTask = new DiskSyncTask();
diskSyncTask.setDiskSyncListener(this);
......@@ -103,18 +91,18 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
initializeDrawer(this, savedInstanceState);
}
private void openFragment(Fragment fragment){
private void openFragment(Fragment fragment) {
try {
if(fragment != null){
if (fragment != null) {
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_main_menu, fragment).commit();
}
}catch (Exception e){
} catch (Exception e) {
Log.d("DEBUG", e.getMessage());
}
}
private void initLoader(){
private void initLoader() {
//init when url has been found
DrawerImageLoader.init(new AbstractDrawerImageLoader() {
@Override
......@@ -140,7 +128,7 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
diskSyncTask.setDiskSyncListener(this);
super.onResume();
if (diskSyncTask.getStatus() == AsyncTask.Status.FINISHED){
if (diskSyncTask.getStatus() == AsyncTask.Status.FINISHED) {
syncComplete(diskSyncTask.getStatusMessage());
}
}
......@@ -169,13 +157,13 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
prefs.reset(PreferenceKeys.KEY_USERGROUP);
prefs.reset(PreferenceKeys.KEY_METADATA_USERGROUP);
String uuid = (String) prefs.get(PreferenceKeys.KEY_UNIQUES);
if(StringUtils.isNotEmpty(uuid))
if (StringUtils.isNotEmpty(uuid))
FirebaseMessaging.getInstance().unsubscribeFromTopic(GetUuidTask.getPureUri(uuid));
startActivity(new Intent(CapiMainActivity.this, SplashScreenActivity.class));
finish();
}
private void initializeDrawer(final Context context, Bundle savedInstanceState){
private void initializeDrawer(final Context context, Bundle savedInstanceState) {
//get user data
String username = (String) prefs.get(PreferenceKeys.KEY_USERNAME);
......@@ -201,6 +189,8 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
.withItemAnimator(new DefaultItemAnimator())
.withAccountHeader(accountHeader)
.addDrawerItems(
new PrimaryDrawerItem().withName("Pemutakhiran").withIcon(R.drawable.wb_ic_edit_bs).withIdentifier(MENU_PEMUTAKHIRAN),
new DividerDrawerItem(),
new PrimaryDrawerItem().withName("Daftar Kuesioner").withIcon(R.drawable.ic_survey).withIdentifier(MENUSURVEY),
new PrimaryDrawerItem().withName("Update Isian").withIcon(R.drawable.ic_assignment_done).withIdentifier(MENU_UPDATE),
new DividerDrawerItem(),
......@@ -210,7 +200,11 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
switch ((int) drawerItem.getIdentifier()){
switch ((int) drawerItem.getIdentifier()) {
case MENU_PEMUTAKHIRAN:
startActivity(new Intent(context, BSActivity.class));
break;
case MENUSURVEY:
getSupportActionBar().setTitle("Daftar Kuesioner");
openFragment(capiListForms);
......
package org.odk.collect.android.pemutakhiran;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import com.rahadi.vsen.activities.DsrtImpActivity;
import com.rahadi.vsen.models.DsrtModel;
/**
* Created by Rahadi on 27/01/2018.
*/
public class DsrtActivity extends DsrtImpActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void onDsrtActionButtonClick(View v, DsrtModel model, String mode, boolean isPml) {
}
}
package org.odk.collect.android.pemutakhiran;
package org.odk.collect.android.pemutakhiran.activities;
import android.os.Bundle;
......
package org.odk.collect.android.pemutakhiran.activities;
import android.app.ProgressDialog;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;
import com.rahadi.vsen.activities.DsrtMinImpActivity;
import com.rahadi.vsen.daos.RutaDao;
import com.rahadi.vsen.listeners.OnGenerateCompletedListener;
import com.rahadi.vsen.models.KeyValueModel;
import com.rahadi.vsen.models.RutaModel;
import com.rahadi.vsen.providers.BSProviderAPI;
import com.rahadi.vsen.providers.RutaProviderAPI;
import org.odk.collect.android.pemutakhiran.tasks.GenerateTask;
import java.util.HashMap;
import java.util.List;
/**
* Created by Rahadi on 27/01/2018.
*/
public class DsrtActivity extends DsrtMinImpActivity implements OnGenerateCompletedListener {
ProgressDialog progressDialog;
List<RutaModel> rutaModels;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RutaDao rutaDao = new RutaDao();
Cursor b = rutaDao.getRutaCursor(null, RutaProviderAPI.Columns.BS_UUID + "=?",
new String[]{getBsUuid()}, null);
rutaModels = rutaDao.getRutaListFromCursor(b);
progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Menggenerate Kuesioner");
progressDialog.setCancelable(false);
progressDialog.setMessage("Harap Tunggu..");
progressDialog.setMax(rutaModels.size());
}
@Override
public void onGenerateMenuClicked(String bsUuid, String bsNks) {
progressDialog.show();
// TODO: 20/02/2018 RAHADI: dynamize
String formId = "VSEN18K.v2";
for (RutaModel r : rutaModels) {
String rutaUuid = r.getUuid();
String rutaName = r.getNamaKrt();
String filename = formId + "_" + bsNks + "_" + rutaName;
HashMap<String, KeyValueModel> keyValues = new HashMap<>();
keyValues.put(BSProviderAPI.Columns.CONTENT_TYPE, new KeyValueModel(BSProviderAPI.Columns.UUID, bsUuid));
keyValues.put(RutaProviderAPI.Columns.CONTENT_TYPE, new KeyValueModel(RutaProviderAPI.Columns.UUID, r.getUuid()));
GenerateTask task = new GenerateTask(formId, rutaUuid, rutaName, filename, keyValues,
DsrtActivity.this);
task.execute();
}
}
@Override
public void onGenerateSucceed(Uri instanceUri, String rutaUuid, String rutaName) {
int progress = progressDialog.getProgress() + 1;
progressDialog.setProgress(progress);
progressDialog.setMessage("Ruta: " + rutaName);
if (progress == progressDialog.getMax()) {
progressDialog.dismiss();
Toast.makeText(this, "Generate Selesai", Toast.LENGTH_LONG).show();
}
}
@Override
public void onGenerateFailed(Exception e) {
progressDialog.dismiss();
Toast.makeText(this, "Generate Gagal : " + e.getMessage(), Toast.LENGTH_LONG).show();
}
}
package org.odk.collect.android.pemutakhiran;
package org.odk.collect.android.pemutakhiran.activities;
import android.os.Bundle;
import android.view.MenuItem;
......
package org.odk.collect.android.pemutakhiran.tasks;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.daos.GenerateDao;
import com.rahadi.vsen.listeners.OnGenerateCompletedListener;
import com.rahadi.vsen.models.GenerateModel;
import com.rahadi.vsen.models.KeyValueModel;
import com.rahadi.vsen.providers.GenerateProviderAPI;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.dao.FormsDao;
import org.odk.collect.android.provider.FormsProviderAPI;
import org.odk.collect.android.provider.InstanceProviderAPI;
import org.odk.collect.android.utilities.FileUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
import timber.log.Timber;
/**
* Created by Rahadi on 20/02/2018.
*/
public class GenerateTask extends AsyncTask<Void, Void, Void> {
private String filename, formId, rutaUuid, rutaName;
private HashMap<String, KeyValueModel> keyValues;
private OnGenerateCompletedListener onGenerateCompletedListener;
public GenerateTask(String formId, String rutaUuid, String rutaName, String filename,
HashMap<String, KeyValueModel> keyValues,
OnGenerateCompletedListener onGenerateCompletedListener) {
this.filename = filename;
this.formId = formId;
this.rutaUuid = rutaUuid;
this.rutaName = rutaName;
this.keyValues = keyValues;
this.onGenerateCompletedListener = onGenerateCompletedListener;
}
@Override
protected Void doInBackground(Void... voids) {
try {
Cursor f = new FormsDao().getFormsCursor(
new String[]{FormsProviderAPI.FormsColumns.EMPTY_INSTANCE_FILE_PATH},
FormsProviderAPI.FormsColumns.JR_FORM_ID + "=?", new String[]{formId},
null);
String emptyInstancePath = f.getString(f.getColumnIndex(
FormsProviderAPI.FormsColumns.EMPTY_INSTANCE_FILE_PATH));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new File(emptyInstancePath));
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
Cursor g = new GenerateDao().getGenerateCursor(null,
GenerateProviderAPI.Columns.FORM_ID + "=?", new String[]{formId}, null);
List<GenerateModel> gms = new GenerateDao().getGenerateListFromCursor(g);
for (GenerateModel gm : gms) {
String value = null;
Uri uri = Uri.parse(gm.getTableUri());
String type = Vsen.getInstance().getContentResolver().getType(uri);
KeyValueModel kv = keyValues.get(type);
Cursor c = Vsen.getInstance().getContentResolver().query(uri, new String[]{gm.getCursorName()},
kv.getKey() + "=?", new String[]{kv.getValue()}, null);
if (c != null) {
if (c.moveToFirst()) {
value = c.getString(c.getColumnIndex(gm.getCursorName()));
}
c.close();
}
XPathExpression expr = xpath.compile(gm.getxPath());
Node node = (Node) expr.evaluate(doc, XPathConstants.NODE);
node.setTextContent(value);
}
String path = Collect.INSTANCES_PATH + File.separator + filename + File.separator + filename + ".xml";
int i = 2;
File newFile = null;
if (FileUtils.createFolder(Collect.INSTANCES_PATH + File.separator + filename)) {
newFile = new File(path);
while (newFile.exists()) {
path = Collect.INSTANCES_PATH + File.separator + filename + File.separator + filename + "_" + i + ".xml";
newFile = new File(path);
i++;
}
// Commit changes
// write the content into xml file
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(newFile);
transformer.transform(source, result);
ContentValues v = new ContentValues();
v.put(InstanceProviderAPI.InstanceColumns.DISPLAY_NAME, filename);
v.put(InstanceProviderAPI.InstanceColumns.JR_FORM_ID, formId);
v.put(InstanceProviderAPI.InstanceColumns.INSTANCE_FILE_PATH, newFile.getAbsolutePath());
v.put(InstanceProviderAPI.InstanceColumns.STATUS, InstanceProviderAPI.STATUS_INCOMPLETE);
Uri instaceUri = Collect.getInstance().getContentResolver().insert(InstanceProviderAPI.InstanceColumns.CONTENT_URI, v);
onGenerateCompletedListener.onGenerateSucceed(instaceUri, rutaUuid, rutaName);
}
} catch (Exception e) {
Timber.e(e);
onGenerateCompletedListener.onGenerateFailed(e);
}
return null;
}
}
......@@ -94,6 +94,7 @@ public class FormsProvider extends ContentProvider {
+ FormsColumns.LANGUAGE + " text, "
+ FormsColumns.SUBMISSION_URI + " text, "
+ FormsColumns.BASE64_RSA_PUBLIC_KEY + " text, "
+ FormsColumns.EMPTY_INSTANCE_FILE_PATH + " text, " // RAHADI
+ FormsColumns.JRCACHE_FILE_PATH + " text not null );");
}
......@@ -140,6 +141,7 @@ public class FormsProvider extends ContentProvider {
+ ((oldVersion != 3) ? ""
: (FormsColumns.BASE64_RSA_PUBLIC_KEY + ", "))
+ FormsColumns.JRCACHE_FILE_PATH
+ FormsColumns.EMPTY_INSTANCE_FILE_PATH
+ ") SELECT "
+ FormsColumns._ID
+ ", "
......@@ -171,7 +173,8 @@ public class FormsProvider extends ContentProvider {
+ " AS TEXT) ELSE NULL END, "
+ ((oldVersion != 3) ? ""
: (FormsColumns.BASE64_RSA_PUBLIC_KEY + ", "))
+ FormsColumns.JRCACHE_FILE_PATH + " FROM "
+ FormsColumns.JRCACHE_FILE_PATH
+ FormsColumns.EMPTY_INSTANCE_FILE_PATH + " FROM "
+ FORMS_TABLE_NAME);
// risky failures here...
......@@ -200,7 +203,8 @@ public class FormsProvider extends ContentProvider {
+ FormsColumns.SUBMISSION_URI + ", "
+ FormsColumns.JR_VERSION + ", "
+ FormsColumns.BASE64_RSA_PUBLIC_KEY + ", "
+ FormsColumns.JRCACHE_FILE_PATH + ") SELECT "
+ FormsColumns.JRCACHE_FILE_PATH
+ FormsColumns.EMPTY_INSTANCE_FILE_PATH + ") SELECT "
+ FormsColumns._ID + ", "
+ FormsColumns.DISPLAY_NAME
+ ", "
......@@ -220,7 +224,8 @@ public class FormsProvider extends ContentProvider {
+ FormsColumns.SUBMISSION_URI + ", "
+ FormsColumns.JR_VERSION + ", "
+ FormsColumns.BASE64_RSA_PUBLIC_KEY + ", "
+ FormsColumns.JRCACHE_FILE_PATH + " FROM "
+ FormsColumns.JRCACHE_FILE_PATH
+ FormsColumns.EMPTY_INSTANCE_FILE_PATH + " FROM "
+ TEMP_FORMS_TABLE_NAME);
db.execSQL("DROP TABLE IF EXISTS " + TEMP_FORMS_TABLE_NAME);
......@@ -720,6 +725,7 @@ public class FormsProvider extends ContentProvider {
sFormsProjectionMap.put(FormsColumns.JRCACHE_FILE_PATH,
FormsColumns.JRCACHE_FILE_PATH);
sFormsProjectionMap.put(FormsColumns.LANGUAGE, FormsColumns.LANGUAGE);
sFormsProjectionMap.put(FormsColumns.EMPTY_INSTANCE_FILE_PATH, FormsColumns.EMPTY_INSTANCE_FILE_PATH);
}
}
......@@ -57,6 +57,8 @@ public final class FormsProviderAPI {
public static final String JRCACHE_FILE_PATH = "jrcacheFilePath";
public static final String FORM_MEDIA_PATH = "formMediaPath";
//RAHADI
public static final String EMPTY_INSTANCE_FILE_PATH = "emptyInstanceFilePath"; // can be null
// this is null on create, and can only be set on an update.
public static final String LANGUAGE = "language";
......
......@@ -31,6 +31,11 @@
android:authorities="com.rahadi.vsen.providers.dsrt.log"
android:enabled="true"
android:exported="true" />
<provider
android:name=".providers.GenerateProvider"
android:authorities="com.rahadi.vsen.providers.generate"
android:enabled="true"
android:exported="true" />
</application>
<!--<application-->
......
package com.rahadi.vsen.activities;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.constraint.ConstraintLayout;
import android.support.design.widget.Snackbar;
......@@ -210,7 +211,13 @@ public abstract class BSImpActivity extends AppCompatActivity implements OnBSAda
}
private void loadData() {
blokSensusModels = new BlokSensusDao().getBlokSensusListFromCursor(new BlokSensusDao().getBlokSensusCursor());
String selection = BSProviderAPI.Columns.ID_PCL + "=?";
if (Vsen.getInstance().getUserSession().getPrivilege() == VsenAPI.PRIVILEGE_PML) {
selection = BSProviderAPI.Columns.ID_PML + "=?";
}
String[] selectionArgs = new String[]{Vsen.getInstance().getUserSession().getIdUser()};
Cursor c = new BlokSensusDao().getBlokSensusCursor(null, selection, selectionArgs, null);
blokSensusModels = new BlokSensusDao().getBlokSensusListFromCursor(c);
blokSensusAdapter.setBlokSensuses(blokSensusModels);
blokSensusAdapter.notifyDataSetChanged();
}
......
package com.rahadi.vsen.activities;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;