- add fnsku in cosmos Product.java
parent
ee37ff3cf4
commit
76b4ddbc6f
|
@ -25,6 +25,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||
public static final String PRODUCT_COLUMN_ITEM_PER_PACK = "itemPerPack";
|
||||
public static final String PRODUCT_COLUMN_INVENTORY = "inventory";
|
||||
public static final String PRODUCT_COLUMN_CATEGORY = "category";
|
||||
public static final String PRODUCT_COLUMN_FNSKU = "fnsku";
|
||||
|
||||
|
||||
/*
|
||||
* dimension table
|
||||
|
@ -94,6 +96,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||
+ PRODUCT_COLUMN_ITEM_PER_PACK + " INTEGER,"
|
||||
+ PRODUCT_COLUMN_INVENTORY + " INTEGER,"
|
||||
+ PRODUCT_COLUMN_CATEGORY + " TEXT,"
|
||||
+ PRODUCT_COLUMN_FNSKU + " TEXT,"
|
||||
+ "PRIMARY KEY (" + PRODUCT_COLUMN_ASIN + ", " + PRODUCT_COLUMN_MARKETPLACE + ", " + PRODUCT_COLUMN_SKU + ")"
|
||||
+ ")";
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ public class ProductRepository {
|
|||
values.put(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK, product.getItemPerPack());
|
||||
values.put(DatabaseHelper.PRODUCT_COLUMN_INVENTORY, product.getInventory());
|
||||
values.put(DatabaseHelper.PRODUCT_COLUMN_CATEGORY, product.getCategory());
|
||||
values.put(DatabaseHelper.PRODUCT_COLUMN_FNSKU, product.getFnsku() );
|
||||
database.insertWithOnConflict(DatabaseHelper.PRODUCT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||
}
|
||||
database.setTransactionSuccessful();
|
||||
|
@ -82,7 +83,7 @@ public class ProductRepository {
|
|||
values.put(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK, product.getItemPerPack());
|
||||
values.put(DatabaseHelper.PRODUCT_COLUMN_INVENTORY, product.getInventory());
|
||||
values.put(DatabaseHelper.PRODUCT_COLUMN_CATEGORY, product.getCategory());
|
||||
|
||||
values.put(DatabaseHelper.PRODUCT_COLUMN_FNSKU, product.getFnsku());
|
||||
database.insertWithOnConflict(DatabaseHelper.PRODUCT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||
close();
|
||||
});
|
||||
|
@ -92,12 +93,12 @@ public class ProductRepository {
|
|||
* Retrieve product by sku
|
||||
* */
|
||||
@SuppressLint("Range")
|
||||
public List<Product> getProductBySkuOrAsin(String sku, String marketplace) {
|
||||
String selection = "(" + DatabaseHelper.PRODUCT_COLUMN_SKU + "=? OR " + PRODUCT_COLUMN_ASIN + "=? )";
|
||||
String[] selectionArgs = {sku,sku};
|
||||
public List<Product> getProductBySkuOrAsin(String fnsku, String marketplace) {
|
||||
String selection = DatabaseHelper.PRODUCT_COLUMN_FNSKU + "=?";
|
||||
String[] selectionArgs = {fnsku};
|
||||
if( marketplace != null && ! marketplace.isEmpty() ){
|
||||
selection += " AND " + PRODUCT_COLUMN_MARKETPLACE + "=?";
|
||||
selectionArgs = new String[]{ sku, sku, marketplace };
|
||||
selectionArgs = new String[]{ fnsku, marketplace };
|
||||
}
|
||||
|
||||
Cursor cursor = database.query(DatabaseHelper.PRODUCT_TABLE_NAME,
|
||||
|
@ -125,7 +126,7 @@ public class ProductRepository {
|
|||
product.setItemPerPack(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK)));
|
||||
product.setInventory(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_INVENTORY)));
|
||||
product.setCategory(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_CATEGORY)));
|
||||
|
||||
product.setFnsku(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_FNSKU)));
|
||||
products.add( product );
|
||||
} while ( cursor.moveToNext() );
|
||||
cursor.close();
|
||||
|
@ -166,7 +167,7 @@ public class ProductRepository {
|
|||
product.setItemPerPack(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK)));
|
||||
product.setInventory(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_INVENTORY)));
|
||||
product.setCategory(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_CATEGORY)));
|
||||
|
||||
product.setFnsku(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_FNSKU)));
|
||||
cursor.close();
|
||||
close();
|
||||
return product;
|
||||
|
|
|
@ -37,6 +37,8 @@ public class InspectionReportItem implements Serializable {
|
|||
private List<InspectionItemCheckPoint> checkPoints;
|
||||
private List<InspectionItemDimension> dimensions;
|
||||
|
||||
private String fnsku;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -245,6 +247,14 @@ public class InspectionReportItem implements Serializable {
|
|||
this.dateAdded = dateAdded;
|
||||
}
|
||||
|
||||
public String getFnsku() {
|
||||
return fnsku;
|
||||
}
|
||||
|
||||
public void setFnsku(String fnsku) {
|
||||
this.fnsku = fnsku;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -19,6 +19,7 @@ public class Product implements Serializable {
|
|||
private long itemPerPack;
|
||||
private long inventory;
|
||||
private String category;
|
||||
private String fnsku;
|
||||
|
||||
public String getAsin() {
|
||||
return asin;
|
||||
|
@ -132,6 +133,14 @@ public class Product implements Serializable {
|
|||
this.category = category;
|
||||
}
|
||||
|
||||
public String getFnsku() {
|
||||
return fnsku;
|
||||
}
|
||||
|
||||
public void setFnsku(String fnsku) {
|
||||
this.fnsku = fnsku;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Product{" +
|
||||
|
@ -149,6 +158,7 @@ public class Product implements Serializable {
|
|||
", itemPerPack=" + itemPerPack +
|
||||
", inventory=" + inventory +
|
||||
", category='" + category + '\'' +
|
||||
", fnsku='" + fnsku + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,16 +210,19 @@ public class CheckPointAdapter extends
|
|||
imagePreview.setImageBitmap( bitmap );
|
||||
}
|
||||
|
||||
InspectionCheckPoint cp = checkPoints.stream().filter(c ->c.getTitle().equalsIgnoreCase(defaultSelectedItem)).findFirst().get();
|
||||
InspectionCheckPoint cp = checkPoints.stream().filter(c -> c.getTitle().equalsIgnoreCase(defaultSelectedItem)).findFirst().orElse( new InspectionCheckPoint());
|
||||
// set standard
|
||||
if( checkpointSkus != null ){
|
||||
InspectionCheckpointSku cpSku = checkpointSkus.stream()
|
||||
.filter( inspectionCheckpointSku -> inspectionCheckpointSku.getCheckpointId() == cp.getId() )
|
||||
.findFirst()
|
||||
.orElse( new InspectionCheckpointSku() );
|
||||
if( cpSku.getStandard() != null && ! cpSku.getStandard().isEmpty() ){
|
||||
standard.setText( cpSku.getStandard() );
|
||||
} else {
|
||||
((ViewGroup) standard.getParent() ).removeView( standard );
|
||||
}
|
||||
}
|
||||
|
||||
defectRecyclerView.setLayoutManager( new LinearLayoutManager( context ) );
|
||||
DefectsAdapter defectsAdapter = new DefectsAdapter(data, defectTypeOptions, defects, cp);
|
||||
defectRecyclerView.setAdapter( defectsAdapter );
|
||||
|
|
|
@ -108,7 +108,6 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
|||
// marketplace
|
||||
markerplace.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if( parent.getItemAtPosition( position ) != null ){
|
||||
|
@ -116,7 +115,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
|||
store.getReport().getItems().get(0).setMarketplace( marketplaceOption );
|
||||
System.out.println( marketplaceOption );
|
||||
populateProductDataOnSelection(
|
||||
store.getReport().getItems().get(0).getSku(),
|
||||
store.getReport().getItems().get(0).getFnsku(),
|
||||
marketplaceOption,
|
||||
false
|
||||
);
|
||||
|
@ -294,7 +293,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
|||
if( v.getId() == R.id.search_sku_btn ){
|
||||
if( sku.getText() != null ){
|
||||
populateProductDataOnSelection( sku.getText().toString(), "", true );
|
||||
populateSkuCheckpointsParams( sku.getText().toString() );
|
||||
populateSkuCheckpointsParams( store.getReport().getItems().get(0).getSku() );
|
||||
}
|
||||
}
|
||||
if( v.getId() == R.id.scan_sku_btn ){
|
||||
|
@ -318,15 +317,16 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
|||
}
|
||||
}
|
||||
|
||||
private void populateProductDataOnSelection( String sku, String marketplace , boolean populateMarketplace){
|
||||
private void populateProductDataOnSelection( String fnsku, String marketplace , boolean populateMarketplace){
|
||||
// setting the product details
|
||||
if( sku != null ){
|
||||
String skuStr = sku.trim();
|
||||
List<Product> products = new ProductRepository( getContext() ).getProductBySkuOrAsin( skuStr, marketplace );
|
||||
if( fnsku != null ){
|
||||
String fnskuStr = fnsku.trim();
|
||||
List<Product> products = new ProductRepository( getContext() ).getProductBySkuOrAsin( fnskuStr, marketplace );
|
||||
System.out.println( products );
|
||||
Product product = products.stream().findFirst().orElse( new Product() );
|
||||
store.getReport().getItems().get(0).setSku( product.getSku() );
|
||||
store.getReport().getItems().get(0).setAsin( product.getAsin() );
|
||||
store.getReport().getItems().get(0).setFnsku( fnskuStr );
|
||||
populateItem( products, populateMarketplace );
|
||||
store.setProducts( products );
|
||||
if( product.getCategory() != null ){
|
||||
|
@ -365,6 +365,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
|||
private void populateItem( List<Product> products , boolean populateMarketplace){
|
||||
if( populateMarketplace ){
|
||||
populateMarketplaces( products );
|
||||
System.out.println("in");
|
||||
}
|
||||
populateModelNumber(products );
|
||||
populateTitle( products );
|
||||
|
|
Loading…
Reference in New Issue