Finish v1.44.00(469)

This commit is contained in:
Giuseppe Scorrano 2025-02-17 10:24:11 +01:00
commit c34e6723d8
84 changed files with 1314 additions and 528 deletions

View File

@ -10,8 +10,8 @@ apply plugin: 'com.google.gms.google-services'
android {
def appVersionCode = 468
def appVersionName = '1.43.03'
def appVersionCode = 469
def appVersionName = '1.44.00'
signingConfigs {
release {
@ -116,6 +116,11 @@ dependencies {
implementation 'com.google.firebase:firebase-perf'
implementation 'com.google.android.gms:play-services-basement:18.5.0'
//JJWT
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

View File

@ -120,6 +120,8 @@ import it.integry.integrywmsnative.view.dialogs.ask_unknown_barcode_notes.Dialog
import it.integry.integrywmsnative.view.dialogs.ask_unknown_barcode_notes.DialogAskUnknownBarcodeNotesModule;
import it.integry.integrywmsnative.view.dialogs.ask_vettore.DialogAskVettoreComponent;
import it.integry.integrywmsnative.view.dialogs.ask_vettore.DialogAskVettoreModule;
import it.integry.integrywmsnative.view.dialogs.basket_lu.DialogBasketLUComponent;
import it.integry.integrywmsnative.view.dialogs.basket_lu.DialogBasketLUModule;
import it.integry.integrywmsnative.view.dialogs.bind_product_barcode_with_package.DialogBindProductBarcodeWithPackageComponent;
import it.integry.integrywmsnative.view.dialogs.bind_product_barcode_with_package.DialogBindProductBarcodeWithPackageModule;
import it.integry.integrywmsnative.view.dialogs.choose_arts_from_lista_arts.DialogChooseArtsFromMtbAartListComponent;
@ -183,6 +185,7 @@ import it.integry.integrywmsnative.view.dialogs.update_available.DialogUpdateAva
DialogInputLUProdModule.class,
DialogScanArtModule.class,
DialogScanOrCreateLUModule.class,
DialogBasketLUModule.class,
ProdFabbisognoLineeProdModule.class,
VersamentoMerceModule.class,
DialogAskMagazzinoProssimitaModule.class,
@ -286,6 +289,8 @@ public interface MainApplicationComponent {
DialogScanOrCreateLUComponent.Factory dialogScanOrCreateLUComponent();
DialogBasketLUComponent.Factory dialogBasketLUComponent();
ProdFabbisognoLineeProdComponent.Factory prodFabbisognoLineeProdComponent();
VersamentoMerceComponent.Factory versamentoMerceComponent();

View File

@ -19,6 +19,8 @@ import it.integry.integrywmsnative.core.data_store.db.AppDatabase;
import it.integry.integrywmsnative.core.ean128.Ean128Service;
import it.integry.integrywmsnative.core.menu.MenuRESTConsumer;
import it.integry.integrywmsnative.core.menu.MenuService;
import it.integry.integrywmsnative.core.rest.AuthInterceptor;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.AziendaRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
@ -51,6 +53,7 @@ import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.sound.SoundAlertService;
import it.integry.integrywmsnative.core.update.UpdatesManager;
import it.integry.integrywmsnative.gest.contab_doc_interni.rest.DocInterniRESTConsumer;
import it.integry.integrywmsnative.gest.login.rest.AuthenticationRESTConsumer;
import it.integry.integrywmsnative.gest.prod_fabbisogno_linee_prod.rest.ProdFabbisognoLineeProdRESTConsumer;
import it.integry.integrywmsnative.view.dialogs.DialogProgressView;
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2View;
@ -96,8 +99,8 @@ public class MainApplicationModule {
@Provides
@Singleton
MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer) {
return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase, systemRESTConsumer);
MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer) {
return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase, systemRESTConsumer, authenticationRESTConsumer);
}
@Provides
@ -114,6 +117,13 @@ public class MainApplicationModule {
return new Ean128Service();
}
@Provides
@Singleton
RESTBuilder providesRESTBuilder(AuthInterceptor authInterceptor) {
return new RESTBuilder(authInterceptor);
}
@Provides
@Singleton
MenuService provideMenuService(MenuRESTConsumer menuRESTConsumer) {
@ -140,20 +150,20 @@ public class MainApplicationModule {
@Provides
@Singleton
OrdiniRESTConsumer provideOrdiniRESTConsumer(SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
return new OrdiniRESTConsumer(systemRESTConsumer, entityRESTConsumer);
OrdiniRESTConsumer provideOrdiniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
return new OrdiniRESTConsumer(restBuilder, systemRESTConsumer, entityRESTConsumer);
}
@Provides
@Singleton
GestSetupRESTConsumer provideGestSetupRESTConsumer() {
return new GestSetupRESTConsumer();
GestSetupRESTConsumer provideGestSetupRESTConsumer(RESTBuilder restBuilder) {
return new GestSetupRESTConsumer(restBuilder);
}
@Provides
@Singleton
ArticoloRESTConsumer provideArticoloRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
return new ArticoloRESTConsumer(systemRESTConsumer);
ArticoloRESTConsumer provideArticoloRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new ArticoloRESTConsumer(restBuilder, systemRESTConsumer);
}
@Provides
@ -170,47 +180,48 @@ public class MainApplicationModule {
@Provides
@Singleton
MenuRESTConsumer provideMenuRESTConsumer() {
return new MenuRESTConsumer();
MenuRESTConsumer provideMenuRESTConsumer(RESTBuilder restBuilder) {
return new MenuRESTConsumer(restBuilder);
}
@Provides
@Singleton
MagazzinoRESTConsumer provideMagazzinoRESTConsumer(ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
return new MagazzinoRESTConsumer(executorService, systemRESTConsumer);
MagazzinoRESTConsumer provideMagazzinoRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
return new MagazzinoRESTConsumer(restBuilder, executorService, systemRESTConsumer);
}
@Provides
@Singleton
MesRESTConsumer provideMesRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
return new MesRESTConsumer(systemRESTConsumer);
MesRESTConsumer provideMesRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new MesRESTConsumer(restBuilder, systemRESTConsumer);
}
@Provides
@Singleton
EntityRESTConsumer provideEntityRESTConsumer() {
return new EntityRESTConsumer();
EntityRESTConsumer provideEntityRESTConsumer(RESTBuilder restBuilder) {
return new EntityRESTConsumer(restBuilder);
}
@Provides
@Singleton
ColliMagazzinoRESTConsumer provideColliMagazzinoRESTConsumer(SystemRESTConsumer systemRESTConsumer,
ColliMagazzinoRESTConsumer provideColliMagazzinoRESTConsumer(RESTBuilder restBuilder,
SystemRESTConsumer systemRESTConsumer,
ArticoloRESTConsumer articoloRESTConsumer,
EntityRESTConsumer entityRESTConsumer,
SettingsManager settingsManager) {
return new ColliMagazzinoRESTConsumer(systemRESTConsumer, articoloRESTConsumer, entityRESTConsumer, settingsManager);
return new ColliMagazzinoRESTConsumer(restBuilder, systemRESTConsumer, articoloRESTConsumer, entityRESTConsumer, settingsManager);
}
@Provides
@Singleton
AziendaRESTConsumer provideAziendaRESTConsumer() {
return new AziendaRESTConsumer();
AziendaRESTConsumer provideAziendaRESTConsumer(RESTBuilder restBuilder) {
return new AziendaRESTConsumer(restBuilder);
}
@Provides
@Singleton
ProduzioneRESTConsumer provideProduzioneRESTConsumer() {
return new ProduzioneRESTConsumer();
ProduzioneRESTConsumer provideProduzioneRESTConsumer(RESTBuilder restBuilder) {
return new ProduzioneRESTConsumer(restBuilder);
}
@Provides
@ -221,56 +232,56 @@ public class MainApplicationModule {
@Provides
@Singleton
PrinterRESTConsumer providePrinterRESTConsumer() {
return new PrinterRESTConsumer();
PrinterRESTConsumer providePrinterRESTConsumer(RESTBuilder restBuilder) {
return new PrinterRESTConsumer(restBuilder);
}
@Provides
@Singleton
SystemRESTConsumer provideSystemRESTConsumer() {
return new SystemRESTConsumer();
SystemRESTConsumer provideSystemRESTConsumer(RESTBuilder restBuilder) {
return new SystemRESTConsumer(restBuilder);
}
@Provides
@Singleton
PVOrdiniAcquistoRESTConsumer providesPVOrdiniAcquistoRESTConsumer(MagazzinoRESTConsumer magazzinoRESTConsumer) {
return new PVOrdiniAcquistoRESTConsumer(magazzinoRESTConsumer);
PVOrdiniAcquistoRESTConsumer providesPVOrdiniAcquistoRESTConsumer(RESTBuilder restBuilder, MagazzinoRESTConsumer magazzinoRESTConsumer) {
return new PVOrdiniAcquistoRESTConsumer(restBuilder, magazzinoRESTConsumer);
}
@Provides
@Singleton
PosizioniRESTConsumer providesPosizioniRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
return new PosizioniRESTConsumer(systemRESTConsumer);
PosizioniRESTConsumer providesPosizioniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new PosizioniRESTConsumer(restBuilder, systemRESTConsumer);
}
@Provides
@Singleton
ProdFabbisognoLineeProdRESTConsumer providesProdFabbisognoLineeProdRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
return new ProdFabbisognoLineeProdRESTConsumer(systemRESTConsumer);
ProdFabbisognoLineeProdRESTConsumer providesProdFabbisognoLineeProdRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new ProdFabbisognoLineeProdRESTConsumer(restBuilder, systemRESTConsumer);
}
@Provides
@Singleton
DocInterniRESTConsumer provideDocInterniRESTConsumer(MagazzinoRESTConsumer magazzinoRESTConsumer) {
return new DocInterniRESTConsumer(magazzinoRESTConsumer);
DocInterniRESTConsumer provideDocInterniRESTConsumer(RESTBuilder restBuilder, MagazzinoRESTConsumer magazzinoRESTConsumer) {
return new DocInterniRESTConsumer(restBuilder, magazzinoRESTConsumer);
}
@Provides
@Singleton
GiacenzaRESTConsumer provideGiacenzaRESTConsumer(ArticoloRESTConsumer articoloRESTConsumer) {
return new GiacenzaRESTConsumer(articoloRESTConsumer);
GiacenzaRESTConsumer provideGiacenzaRESTConsumer(RESTBuilder restBuilder, ArticoloRESTConsumer articoloRESTConsumer) {
return new GiacenzaRESTConsumer(restBuilder, articoloRESTConsumer);
}
@Provides
@Singleton
ImballiRESTConsumer provideImballiRESTConsumer(ExecutorService executorService) {
return new ImballiRESTConsumer(executorService);
ImballiRESTConsumer provideImballiRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
return new ImballiRESTConsumer(restBuilder, executorService);
}
@Provides
@Singleton
VettoriRESTConsumer provideVettoriRESTConsumer(ExecutorService executorService) {
return new VettoriRESTConsumer(executorService);
VettoriRESTConsumer provideVettoriRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
return new VettoriRESTConsumer(restBuilder, executorService);
}
@Provides
@ -281,50 +292,50 @@ public class MainApplicationModule {
@Provides
@Singleton
ProductionLinesRESTConsumer provideProductionLinesRESTConsumer() {
return new ProductionLinesRESTConsumer();
ProductionLinesRESTConsumer provideProductionLinesRESTConsumer(RESTBuilder restBuilder) {
return new ProductionLinesRESTConsumer(restBuilder);
}
@Provides
@Singleton
DocumentRESTConsumer provideDocumentiRESTConsumer() {
return new DocumentRESTConsumer();
DocumentRESTConsumer provideDocumentiRESTConsumer(RESTBuilder restBuilder) {
return new DocumentRESTConsumer(restBuilder);
}
@Provides
@Singleton
ColliAccettazioneRESTConsumer provideColliAccettazioneRESTConsumer() {
return new ColliAccettazioneRESTConsumer();
ColliAccettazioneRESTConsumer provideColliAccettazioneRESTConsumer(RESTBuilder restBuilder) {
return new ColliAccettazioneRESTConsumer(restBuilder);
}
@Provides
@Singleton
ColliSpedizioneRESTConsumer provideColliSpedizioneRESTConsumer() {
return new ColliSpedizioneRESTConsumer();
ColliSpedizioneRESTConsumer provideColliSpedizioneRESTConsumer(RESTBuilder restBuilder) {
return new ColliSpedizioneRESTConsumer(restBuilder);
}
@Provides
@Singleton
ColliLavorazioneRESTConsumer provideColliLavorazioneRESTConsumer(SettingsManager settingsManager) {
return new ColliLavorazioneRESTConsumer(settingsManager);
ColliLavorazioneRESTConsumer provideColliLavorazioneRESTConsumer(RESTBuilder restBuilder, SettingsManager settingsManager) {
return new ColliLavorazioneRESTConsumer(restBuilder, settingsManager);
}
@Provides
@Singleton
MagazzinoAutomaticoRESTConsumer provideMagazzinoAutomaticoRESTConsumer() {
return new MagazzinoAutomaticoRESTConsumer();
MagazzinoAutomaticoRESTConsumer provideMagazzinoAutomaticoRESTConsumer(RESTBuilder restBuilder) {
return new MagazzinoAutomaticoRESTConsumer(restBuilder);
}
@Provides
@Singleton
MagazzinoBufferRESTConsumer provideMagazzinoBufferRESTConsumer() {
return new MagazzinoBufferRESTConsumer();
MagazzinoBufferRESTConsumer provideMagazzinoBufferRESTConsumer(RESTBuilder restBuilder) {
return new MagazzinoBufferRESTConsumer(restBuilder);
}
@Provides
@Singleton
MaterialiRESTConsumer provideMaterialiRESTConsumer(ExecutorService executorService) {
return new MaterialiRESTConsumer(executorService);
MaterialiRESTConsumer provideMaterialiRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
return new MaterialiRESTConsumer(restBuilder, executorService);
}
@Provides

View File

@ -0,0 +1,21 @@
package it.integry.integrywmsnative.core.authentication;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
public class JwtUtils {
private final static String SIGNING_KEY = "gICy3bjD56i/YFnBZZKe5ibiz3Snsp08nybGGziCV4ZcvyXBbyqWUnJ2wTrRXhOuf/xdljPXX0yBaqdAgvKthQ==";
public static Claims parseJwt(String token) {
Jws<Claims> jws = Jwts.parserBuilder()
.setSigningKey(Keys.hmacShaKeyFor(Decoders.BASE64.decode(SIGNING_KEY)))
.build()
.parseClaimsJws(token);
return jws.getBody();
}
}

View File

@ -19,6 +19,7 @@ import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityThread;
import it.integry.integrywmsnative.gest.login.rest.AuthenticationRESTConsumer;
@Singleton
public class MainContext {
@ -27,14 +28,16 @@ public class MainContext {
private final MenuService menuService;
private final AppDatabase appDatabase;
private final SystemRESTConsumer systemRESTConsumer;
private final AuthenticationRESTConsumer authenticationRESTConsumer;
private Listener mListener;
public MainContext(Context applicationContext, MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer) {
public MainContext(Context applicationContext, MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer) {
this.applicationContext = applicationContext;
this.menuService = menuService;
this.appDatabase = appDatabase;
this.systemRESTConsumer = systemRESTConsumer;
this.authenticationRESTConsumer = authenticationRESTConsumer;
}
public void init() {
@ -46,14 +49,16 @@ public class MainContext {
}
this.initDeviceId(() -> {
this.initDBData(() -> {
this.initMenu(() -> {
//this.initAuthSession(() -> {
this.initDeviceId(() -> {
this.initDBData(() -> {
this.initMenu(() -> {
if (mListener != null) mListener.onContextInitialized();
if (mListener != null) mListener.onContextInitialized();
});
});
});
});
//});
this.initServerStatusChecker();
@ -61,6 +66,14 @@ public class MainContext {
}
private void initAuthSession(Runnable onComplete) {
this.authenticationRESTConsumer.me(obj -> {
onComplete.run();
}, ex -> {
if (mListener != null) mListener.onError(new SpannedString(ex.getMessage()));
});
}
private void initDeviceId(Runnable onComplete) {
if (SettingsManager.i().getUserSession().getDeviceId() != null) {
onComplete.run();

View File

@ -0,0 +1,7 @@
package it.integry.integrywmsnative.core.exception;
public class UnauthorizedAccessException extends Exception {
public UnauthorizedAccessException() {
super("Accesso non autorizzato. Si prega di effettuare nuovamente l'accesso e riprovare");
}
}

View File

@ -16,8 +16,14 @@ import retrofit2.Response;
@Singleton
public class MenuRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public MenuRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void retrieveMenu(String rootCodOpz, RunnableArgs<StbMenu> onComplete, RunnableArgs<Exception> onFailed) {
MenuRESTConsumerService menuRESTConsumerService = RESTBuilder.getService(MenuRESTConsumerService.class);
MenuRESTConsumerService menuRESTConsumerService = restBuilder.getService(MenuRESTConsumerService.class);
menuRESTConsumerService.retrieveMenuConfig(rootCodOpz).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<StbMenu>> call, Response<ServiceRESTResponse<StbMenu>> response) {

View File

@ -0,0 +1,64 @@
package it.integry.integrywmsnative.core.rest;
import androidx.annotation.NonNull;
import java.io.IOException;
import io.jsonwebtoken.Claims;
import it.integry.integrywmsnative.core.authentication.JwtUtils;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.gest.login.rest.RefreshRESTConsumer;
import okhttp3.Interceptor;
import okhttp3.Response;
public class AuthInterceptor implements Interceptor {
private final RefreshRESTConsumer refreshRESTConsumer;
public AuthInterceptor(RefreshRESTConsumer refreshRESTConsumer) {
this.refreshRESTConsumer = refreshRESTConsumer;
}
@NonNull
@Override
public Response intercept(@NonNull Chain chain) throws IOException {
var originalRequest = chain.request();
if(SettingsManager.i().getUserSession() != null) {
var accessToken = SettingsManager.i().getUserSession().getAccessToken();
var accessTokenExpiryDate = SettingsManager.i().getUserSession().getAccessTokenExpiryDate();
if (accessToken != null && (accessTokenExpiryDate == null || UtilityDate.getNowTime().isAfter(accessTokenExpiryDate))) {
// Make the token refresh request
try {
var response = refreshRESTConsumer.makeSynchronousRefreshTokenRequest();
Claims claims = JwtUtils.parseJwt(response.getAccessToken());
SettingsManager.i().getUserSession()
.setAccessToken(response.getAccessToken())
.setAccessTokenExpiryDate(UtilityDate.toLocalDateTime(claims.getExpiration()))
.setRefreshToken(response.getRefreshToken())
.setRefreshTokenExpiryDate(response.getExpiryDate());
SettingsManager.update();
} catch (Exception e) {
throw new RuntimeException(e);
}
// Add the access token to the request header
var authorizedRequest = originalRequest.newBuilder()
.header("Authorization", "Bearer " + SettingsManager.i().getUserSession().getAccessToken())
.build();
return chain.proceed(authorizedRequest);
} else
return chain.proceed(originalRequest);
} else
return chain.proceed(originalRequest);
}
}

View File

@ -1,10 +1,9 @@
package it.integry.integrywmsnative.core.rest;
import android.util.Base64;
import java.io.IOException;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.Request;
@ -20,25 +19,32 @@ public class HttpInterceptor implements Interceptor {
public Response intercept(Chain chain) throws IOException {
final String PROFILE_DB = SettingsManager.i().getUserSession() == null ? null : SettingsManager.i().getUserSession().getProfileDB();
final String USERNAME = SettingsManager.i().getUser().getUsername();
final String PASSWORD = SettingsManager.i().getUser().getPassword();
final String DEVICE_ID = SettingsManager.i().getUserSession().getDeviceId();
final String APP_TOKEN = "fa3a21af-606b-4129-a22b-aedc2a52c7b6";
String accessToken = null;
if(SettingsManager.i().getUserSession().getAccessTokenExpiryDate() != null &&
UtilityDate.getNowTime().isBefore(SettingsManager.i().getUserSession().getAccessTokenExpiryDate())) {
accessToken = SettingsManager.i().getUserSession().getAccessToken();
}
final Request request = chain.request();
final HttpUrl url = request.url().newBuilder()
.addQueryParameter("profileDb", PROFILE_DB)
.build();
String string = "Basic " + Base64.encodeToString((USERNAME + ":" + PASSWORD).getBytes(), Base64.NO_WRAP);
final Request newRequest = chain.request().newBuilder()
.addHeader("Authorization", string)
Request.Builder builder = chain.request().newBuilder()
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "*/*")
.addHeader("username", USERNAME != null ? USERNAME : "")
.addHeader("password", PASSWORD != null ? PASSWORD : "")
.addHeader("device_id", DEVICE_ID != null ? DEVICE_ID : "")
.url(url).build();
.addHeader("x-app-token", APP_TOKEN);
if(accessToken != null)
builder
.addHeader("Authorization", "Bearer " + accessToken);
var newRequest = builder
.url(url)
.build();
return chain.proceed(newRequest);
}

View File

@ -6,6 +6,7 @@ import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
@ -20,29 +21,35 @@ import retrofit2.converter.gson.GsonConverterFactory;
* Created by GiuseppeS on 06/03/2018.
*/
@Singleton
public class RESTBuilder {
private static final boolean ADD_LOGGER_INTERCEPTOR = false;
private final boolean ADD_LOGGER_INTERCEPTOR = false;
private final AuthInterceptor authInterceptor;
public static <T> T getService(final Class<T> service) {
public RESTBuilder(AuthInterceptor authInterceptor) {
this.authInterceptor = authInterceptor;
}
public <T> T getService(final Class<T> service) {
return getService(service, SettingsManager.i().getServer().getProtocol(), SettingsManager.i().getServer().getHost(), SettingsManager.i().getServer().getPort(), true);
}
public static <T> T getService(final Class<T> service, int timeout) {
public <T> T getService(final Class<T> service, int timeout) {
return getService(service, SettingsManager.i().getServer().getProtocol(), SettingsManager.i().getServer().getHost(), SettingsManager.i().getServer().getPort(), true, true, timeout);
}
public static <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors) {
public <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors) {
return getService(service, protocol, host, port, addInterceptors, true, 60);
}
public static <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors, boolean addEmsApi) {
public <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors, boolean addEmsApi) {
return getService(service, protocol, host, port, addInterceptors, addEmsApi, 60);
}
public static <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors, boolean addEmsApi, int timeout) {
public <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors, boolean addEmsApi, int timeout) {
OkHttpClient.Builder clientBuilder = getDefaultHttpClient();
clientBuilder.connectTimeout(timeout, TimeUnit.SECONDS);
@ -51,6 +58,7 @@ public class RESTBuilder {
clientBuilder.retryOnConnectionFailure(true);
clientBuilder.addInterceptor(authInterceptor);
if (addInterceptors) clientBuilder.addInterceptor(new HttpInterceptor());
if (ADD_LOGGER_INTERCEPTOR) clientBuilder.addInterceptor(new HttpLoggerInterceptor());
@ -71,15 +79,6 @@ public class RESTBuilder {
}
public static String getDefaultHost() {
return SettingsManager.i().getServer().getHost();
}
public static int getDefaultPort() {
return SettingsManager.i().getServer().getPort();
}
public static OkHttpClient.Builder getDefaultHttpClient() {
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {

View File

@ -35,15 +35,17 @@ import retrofit2.Response;
@Singleton
public class ArticoloRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer systemRESTConsumer;
public ArticoloRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
public ArticoloRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.systemRESTConsumer = systemRESTConsumer;
}
public void retrieveAvailableUntMis(RunnableArgs<List<MtbUntMis>> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumerService
.retrieveAvailableUntMis()
.enqueue(new ManagedErrorCallback<>() {
@ -60,7 +62,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
}
public void retrieveAvailableGruppiMerceologici(RunnableArgs<List<MtbGrup>> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumerService
.retrieveAvailableGruppiMerceologici()
.enqueue(new ManagedErrorCallback<>() {
@ -77,7 +79,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
}
public void searchByBarcode(String barcodeProd, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
var request = new SearchArticoloByBarcodeRequestDTO()
.setBarcode(barcodeProd)
@ -101,7 +103,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
}
public void findIfIsKit(MtbAart mtbAart, RunnableArgs<MtbAart> onComplete, RunnableArgs<Exception> onFailed){
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumerService
.findIfIsKit(mtbAart)
@ -121,17 +123,12 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
}
public void getByCodMarts(List<String> codMartToFind, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
getByCodMartsStatic(codMartToFind, onComplete, onFailed);
}
public static void getByCodMartsStatic(List<String> codMartToFind, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
var codMarts = Stream.of(codMartToFind)
.withoutNulls()
.distinct().toList();
ArticoloRESTConsumerService articoloRESTConsumer = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumer = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumer
.getByCodMart(new RetrieveArticoloByCodMartRequestDTO()
.setCodMarts(codMarts))
@ -151,7 +148,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
public void getStatoPartita(String codMart, String partitaMag, RunnableArgs<List<StatoArticoloDTO>> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumer = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumer = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumer.getStatoPartita(codMart, partitaMag).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<StatoArticoloDTO>>> call, Response<ServiceRESTResponse<List<StatoArticoloDTO>>> response) {
@ -242,7 +239,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
public void updateBarcodeImballo(String codMart, String newBarcodeImballo, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
var request = new UpdateBarcodeImballoRequestDTO()
.setCodMart(codMart)
@ -267,7 +264,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
public void saveArticolo(ArticoloDTO articoloToSave, RunnableArgs<String> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
var request = new SaveArticoloRequestDTO()
.setArtToSave(articoloToSave);

View File

@ -15,8 +15,14 @@ import retrofit2.Response;
@Singleton
public class AziendaRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public AziendaRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void retrieveAzienda(RunnableArgs<Azienda> onComplete, RunnableArgs<Exception> onFailed) {
AziendaRESTConsumerService aziendaRESTConsumerService = RESTBuilder.getService(AziendaRESTConsumerService.class);
AziendaRESTConsumerService aziendaRESTConsumerService = restBuilder.getService(AziendaRESTConsumerService.class);
aziendaRESTConsumerService.retrieveDefaultAzienda().enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Azienda>> call, Response<ServiceRESTResponse<Azienda>> response) {

View File

@ -26,8 +26,14 @@ import retrofit2.Response;
@Singleton
public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements ColliCaricoRESTConsumerInterface {
private final RESTBuilder restBuilder;
public ColliAccettazioneRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class);
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.createUDC(createUDCRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -46,7 +52,7 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements
@Override
public void closeUDC(CloseUDCRequestDTO closeUDCRequestDTO, RunnableArgs<CloseUDCResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class);
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.closeUDC(closeUDCRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -64,7 +70,7 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements
@Override
public void insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class);
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.insertUDCRow(insertUDCRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -82,7 +88,7 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements
@Override
public void editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class);
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.editUDCRow(editUDCRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -100,7 +106,7 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements
@Override
public void deleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class);
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.deleteUDCRow(deleteUDCRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -117,7 +123,7 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements
}
public void checkBarcodeUl(String barcodeUl, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed){
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class);
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.checkIfBarcodeUlAlreadyRegistered(barcodeUl)
.enqueue(new ManagedErrorCallback<>() {

View File

@ -43,15 +43,17 @@ import retrofit2.Response;
public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements ColliCaricoRESTConsumerInterface, ColliScaricoRESTConsumerInterface {
private final RESTBuilder restBuilder;
private final SettingsManager settingsManager;
public ColliLavorazioneRESTConsumer(SettingsManager settingsManager) {
public ColliLavorazioneRESTConsumer(RESTBuilder restBuilder, SettingsManager settingsManager) {
this.restBuilder = restBuilder;
this.settingsManager = settingsManager;
}
@Override
public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class);
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.createUDC(createUDCRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -69,7 +71,7 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
@Override
public void closeUDC(CloseUDCRequestDTO closeUDCRequestDTO, RunnableArgs<CloseUDCResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class);
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.closeUDC(closeUDCRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -87,7 +89,7 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
@Override
public void insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class);
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.insertUDCRow(insertUDCRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -105,7 +107,7 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
@Override
public void editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class);
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.editUDCRow(editUDCRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -122,7 +124,7 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
}
public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class);
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.createUDS(createUDSRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -141,7 +143,7 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
@Override
public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class);
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.closeUDS(closeUDSRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -159,7 +161,7 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
@Override
public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class);
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -176,7 +178,7 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
}
public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class);
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -194,7 +196,7 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
@Override
public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class);
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -212,7 +214,7 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
@Override
public void deleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class);
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.deleteUDCRow(deleteUDCRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -251,7 +253,7 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
createUDSFromArtRequestDTO
.setCodJfas(posizione.getPosizione());
}
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class);
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.createUDSFromArt(createUDSFromArtRequestDTO)
.enqueue(new ManagedErrorCallback<>() {

View File

@ -53,15 +53,17 @@ import retrofit2.Response;
@Singleton
public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer mSystemRESTConsumer;
private final ArticoloRESTConsumer mArticoloRESTConsumer;
private final EntityRESTConsumer mEntityRESTConsumer;
private final SettingsManager mSettingsManager;
public ColliMagazzinoRESTConsumer(SystemRESTConsumer systemRESTConsumer,
public ColliMagazzinoRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer,
ArticoloRESTConsumer articoloRESTConsumer,
EntityRESTConsumer entityRESTConsumer,
SettingsManager settingsManager) {
this.restBuilder = restBuilder;
this.mSystemRESTConsumer = systemRESTConsumer;
this.mArticoloRESTConsumer = articoloRESTConsumer;
this.mEntityRESTConsumer = entityRESTConsumer;
@ -285,7 +287,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public void getBySSCC(String ssccString, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.getColloByBarcode(ssccString, onlyResiduo, throwExcIfNull).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
@ -310,10 +312,6 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
fillMtbAartsOfMtbColtsStatic(mtbColts, onComplete, onFailed);
}
public static void fillMtbAartsOfMtbColtsStatic(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
List<String> codMarts = new ArrayList<>();
for (MtbColt mtbColt : mtbColts) {
@ -325,7 +323,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
ArticoloRESTConsumer.getByCodMartsStatic(codMarts, arts -> {
mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
if (arts != null && !arts.isEmpty()) {
for (MtbColt mtbColt : mtbColts) {
@ -385,7 +383,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
testata.setMtbColr(new ObservableArrayList<>());
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.getColloInGiac(onlyResiduo, throwExcIfNull, testata)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -425,7 +423,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbColtsToMove(Collections.singletonList(mtbColtToMoveClone))
.setCreateDocAutomatically(createDocAutomatically);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService
.spostaUL(spostaUlRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -460,7 +458,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbColt(mtbColtClone)
.setCodTcol(codTcol);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService
.updateTipoUL(updateTipoULRequest)
.enqueue(new ManagedErrorCallback<>() {
@ -495,13 +493,13 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public static void retrieveBasketColli(RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
public void retrieveBasketColli(RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.getColliInBasket(SettingsManager.i().getUserSession().getDepo().getCodMdep()).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<MtbColt>>> call, Response<ServiceRESTResponse<List<MtbColt>>> response) {
analyzeAnswer(response, "getColliInBasket", mtbColts -> {
fillMtbAartsOfMtbColtsStatic(mtbColts, onComplete, onFailed);
fillMtbAartsOfMtbColts(mtbColts, onComplete, onFailed);
}, onFailed);
}
@ -522,7 +520,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setNewNumCnf(newNumCnf)
.setNewQtaCol(newQtaTot);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.creaRettificaCollo(
SettingsManager.i().getUserSession().getDepo().getCodMdep(),
rettificaULDTO
@ -557,7 +555,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setDestinationMtbColt(mtbColtDestClone)
.setFlagForceUseRefs(flagForceUseRefs);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> call, Response<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> response) {
@ -583,7 +581,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbPartitaMag(null);
}
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
@ -608,7 +606,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbPartitaMag(null);
}
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.versamentoAutomaticoUL(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<VersamentoAutomaticoULResponseDTO>> call, Response<ServiceRESTResponse<VersamentoAutomaticoULResponseDTO>> response) {
@ -656,7 +654,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone();
sourceMtbColtClone.setMtbColr(new ObservableArrayList<>());
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.confirmGiacenzaUL(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
@ -704,7 +702,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
CanULBeDeletedRequestDTO canULBeDeletedRequestDTO = new CanULBeDeletedRequestDTO()
.setMtbColt(mtbColt);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.canULBeDeleted(canULBeDeletedRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -722,7 +720,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public void deleteUL(DeleteULRequestDTO deleteULRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.deleteUL(deleteULRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -745,7 +743,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
return;
}
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.printUL(printULRequestDTO)
.enqueue(new ManagedErrorCallback<>() {

View File

@ -28,9 +28,14 @@ import retrofit2.Response;
@Singleton
public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements ColliScaricoRESTConsumerInterface {
private final RESTBuilder restBuilder;
public ColliSpedizioneRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class);
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.createUDS(createUDSRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -48,7 +53,7 @@ public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements Co
}
public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class);
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.closeUDS(closeUDSRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -66,7 +71,7 @@ public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements Co
}
public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class);
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -83,7 +88,7 @@ public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements Co
}
public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class);
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -100,7 +105,7 @@ public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements Co
}
public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class);
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -118,7 +123,7 @@ public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements Co
}
public void duplicateUDS(DuplicateUDSRequestDTO duplicateUDSRequestDTO, RunnableArgs<DuplicateUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class);
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.duplicateUDS(duplicateUDSRequestDTO)
.enqueue(new ManagedErrorCallback<>() {

View File

@ -19,9 +19,14 @@ import retrofit2.Response;
@Singleton
public class DocumentRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public DocumentRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void createDocsFromColli(List<LoadColliDTO> listColli, RunnableArgs<List<DtbDoct>> onComplete, RunnableArgs<Exception> onFailed) {
DocumentiRESTConsumerService documentiRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class);
DocumentiRESTConsumerService documentiRESTConsumerService = restBuilder.getService(DocumentiRESTConsumerService.class);
documentiRESTConsumerService.createDocsFromColli(listColli).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<DtbDoct>>> call, Response<ServiceRESTResponse<List<DtbDoct>>> response) {
@ -36,7 +41,7 @@ public class DocumentRESTConsumer extends _BaseRESTConsumer {
}
public void createDocFromColli(LoadColliDTO loadColliDTO, RunnableArgs<DtbDoct> onComplete, RunnableArgs<Exception> onFailed) {
DocumentiRESTConsumerService documentiRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class);
DocumentiRESTConsumerService documentiRESTConsumerService = restBuilder.getService(DocumentiRESTConsumerService.class);
documentiRESTConsumerService.createDocFromColli(loadColliDTO).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<DtbDoct>> call, Response<ServiceRESTResponse<DtbDoct>> response) {
@ -51,7 +56,7 @@ public class DocumentRESTConsumer extends _BaseRESTConsumer {
}
public void checkDocument(String fornitore, String numDoc, String dataDoc, String tipoDoc, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class);
var inventarioRESTConsumerService = restBuilder.getService(DocumentiRESTConsumerService.class);
inventarioRESTConsumerService.checkDocument(fornitore, numDoc,tipoDoc, dataDoc)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -67,7 +72,7 @@ public class DocumentRESTConsumer extends _BaseRESTConsumer {
}
public void loadDocumentAvailableArts(String codDtip, String codMgrp, String codAnagForn, RunnableArgs<RetrieveDocumentoArtsResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class);
var inventarioRESTConsumerService = restBuilder.getService(DocumentiRESTConsumerService.class);
inventarioRESTConsumerService.retrieveArts(codDtip, codMgrp, codAnagForn)
.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -25,6 +25,11 @@ import retrofit2.Response;
@Singleton
public class EntityRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public EntityRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public <T extends EntityBase> void processEntity(T entityToSave, final ISimpleOperationCallback<T> callback, Class<T> type) {
@ -32,7 +37,7 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
if (callback != null) callback.onFailed(ex);
};
EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class);
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
service
.processEntity(entityToSave)
.enqueue(new ManagedErrorCallback<>() {
@ -75,7 +80,7 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
if (onFailed != null) onFailed.run(ex);
};
EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class);
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
Call<List<ServiceRESTResponse<JsonObject>>> request = service.processEntityList(singleTransaction, entitiesToSave);
request.enqueue(new ManagedErrorCallback<>() {
@Override
@ -124,7 +129,7 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
@Deprecated
public <T extends EntityBase> void selectEntity(T entityToSave, final ISimpleOperationCallback<List<T>> callback, Class type) {
EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class);
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
Call<ServiceRESTResponse<JsonObject>> request = service.processEntity(entityToSave);
request.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -20,8 +20,14 @@ import retrofit2.Response;
@Singleton
public class GestSetupRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public GestSetupRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void getValue(String gestName, String sectionName, String keySection, RunnableArgs<GestSetupDTO> onComplete, RunnableArgs<Exception> onFailed) {
GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class);
GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
service.getGestSetupValue(gestName, sectionName, keySection)
.enqueue(new ManagedErrorCallback<>() {
@ -48,7 +54,7 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
}
public void getValue(String gestName, String sectionName, String keySection, String codMdep, RunnableArgs<GestSetupDTO> onComplete, RunnableArgs<Exception> onFailed) {
GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class);
GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
service.getGestSetupValue(gestName, sectionName, keySection, codMdep).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<GestSetupDTO>> call, Response<ServiceRESTResponse<GestSetupDTO>> response) {
@ -76,7 +82,7 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
public void getValues(String codMdep, List<StbGestSetupReader> stbGestSetupList, RunnableArgs<List<StbGestSetupReader>> onComplete, RunnableArgs<Exception> onFailed) {
var stbGestSetups = stbGestSetupList.stream().map(x -> (StbGestSetup) x).collect(Collectors.toList());
GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class);
GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
service.getGestSetupValues(codMdep, stbGestSetups).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<StbGestSetup>>> call, Response<ServiceRESTResponse<List<StbGestSetup>>> response) {

View File

@ -27,15 +27,17 @@ import retrofit2.Response;
@Singleton
public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ArticoloRESTConsumer mArticoloRESTConsumer;
public GiacenzaRESTConsumer(ArticoloRESTConsumer articoloRESTConsumer) {
public GiacenzaRESTConsumer(RESTBuilder restBuilder, ArticoloRESTConsumer articoloRESTConsumer) {
this.restBuilder = restBuilder;
this.mArticoloRESTConsumer = articoloRESTConsumer;
}
public void getGiacenzeInPosizione(MtbDepoPosizione posizione, RunnableArgs<List<MvwSitArtUdcDetInventario>> onComplete, RunnableArgs<Exception> onFailed) {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class);
GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
giacenzaRESTConsumerService.retrieveAvailableItems(posizione.getPosizione()).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> call, Response<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> response) {
@ -77,7 +79,7 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
}
public void getGiacenzeInPosizione(List<String> posizioni, boolean withTestataCollo, RunnableArgs<List<ArtsInGiacenzaDTO>> onComplete, RunnableArgs<Exception> onFailed) {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class);
GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
giacenzaRESTConsumerService.retrieveAvailableItems(posizioni, withTestataCollo).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> call, Response<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> response) {
@ -119,7 +121,7 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
}
public void getGiacenzeByArticolo(String codMart, String partitaMag, RunnableArgs<List<MvwSitArtUdcDetInventario>> onComplete, RunnableArgs<Exception> onFailed) {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class);
GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
var serviceRESTResponseCall =
UtilityString.isNullOrEmpty(partitaMag) ?
giacenzaRESTConsumerService.retrieveAvailableItemsByArt(codMart) :
@ -163,7 +165,7 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
public void getInstantItemSituation(String codMdep, String codMart, String partitaMag, String codJcom, RunnableArgs<InstantItemSituationResponseDto> onComplete, RunnableArgs<Exception> onFailed) {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class);
GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
giacenzaRESTConsumerService.retrieveInstantItemSituation(codMdep, codMart, partitaMag, codJcom)
.enqueue(new ManagedErrorCallback<>() {

View File

@ -20,15 +20,17 @@ import retrofit2.Response;
@Singleton
public class ImballiRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
public ImballiRESTConsumer(ExecutorService executorService) {
public ImballiRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.executorService = executorService;
}
public List<ObservableMtbTcol> retrieveImballiSyncronized(MtbTCol.FlagUiUlEnum tipoImballo) throws Exception {
ImballiRESTConsumerService service = RESTBuilder.getService(ImballiRESTConsumerService.class);
ImballiRESTConsumerService service = restBuilder.getService(ImballiRESTConsumerService.class);
Response<ServiceRESTResponse<List<MtbTCol>>> response = service.retrieveImballi(tipoImballo)
.execute();
@ -50,7 +52,7 @@ public class ImballiRESTConsumer extends _BaseRESTConsumer {
public void registraCaricoSyncronized(String codAnag, List<ImballoQuantityDTO> imballi) throws Exception {
ImballiRESTConsumerService service = RESTBuilder.getService(ImballiRESTConsumerService.class);
ImballiRESTConsumerService service = restBuilder.getService(ImballiRESTConsumerService.class);
Response<ServiceRESTResponse<Void>> response = service.registraCarico(
new RegistraCaricoImballiRequestDTO()
.setCodAnag(codAnag)
@ -73,7 +75,7 @@ public class ImballiRESTConsumer extends _BaseRESTConsumer {
public void registraScaricoSyncronized(String codVettore, List<ImballoQuantityDTO> imballi) throws Exception {
ImballiRESTConsumerService service = RESTBuilder.getService(ImballiRESTConsumerService.class);
ImballiRESTConsumerService service = restBuilder.getService(ImballiRESTConsumerService.class);
Response<ServiceRESTResponse<Void>> response = service.registraScarico(
new RegistraScaricoImballiRequestDTO()
.setCodVettore(codVettore)

View File

@ -4,6 +4,7 @@ import androidx.annotation.NonNull;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
@ -20,9 +21,15 @@ import retrofit2.Response;
@Singleton
public class InventarioRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
@Inject
public InventarioRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void loadInventario(long inventoryId, RunnableArgs<RetrieveInventarioResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class);
var inventarioRESTConsumerService = restBuilder.getService(InventarioRESTConsumerService.class);
inventarioRESTConsumerService.retrieve(inventoryId)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -39,7 +46,7 @@ public class InventarioRESTConsumer extends _BaseRESTConsumer {
public void loadInventarioArts(long inventoryId, RunnableArgs<RetrieveInventarioArtsResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class);
var inventarioRESTConsumerService = restBuilder.getService(InventarioRESTConsumerService.class);
inventarioRESTConsumerService.retrieveArts(inventoryId)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -55,7 +62,7 @@ public class InventarioRESTConsumer extends _BaseRESTConsumer {
}
public List<MtbInvent> makeSynchronousRetrieveRequest() throws Exception {
var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class, 120);
var inventarioRESTConsumerService = restBuilder.getService(InventarioRESTConsumerService.class, 120);
var response = inventarioRESTConsumerService.retrieve()
.execute();
@ -70,7 +77,7 @@ public class InventarioRESTConsumer extends _BaseRESTConsumer {
var request = new InsertInventarioRequestDTO()
.setMtbInvent(inventarioToInsert);
var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class, 300);
var inventarioRESTConsumerService = restBuilder.getService(InventarioRESTConsumerService.class, 300);
inventarioRESTConsumerService
.insert(inventarioToInsert.getIdInventario(), request)
.enqueue(new ManagedErrorCallback<>() {

View File

@ -17,8 +17,15 @@ import retrofit2.Response;
@Singleton
public class MagazzinoAutomaticoRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public MagazzinoAutomaticoRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void pickItems(MtbDepoPosizione posizione, MagazzinoAutomaticoPickItemsRequestDTO magazzinoAutomaticoPickItemsRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = RESTBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class);
MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = restBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class);
magazzinoAutomaticoRESTConsumerService.pickItems(posizione.getPosizione(), magazzinoAutomaticoPickItemsRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -36,7 +43,7 @@ public class MagazzinoAutomaticoRESTConsumer extends _BaseRESTConsumer {
public void putItems(MtbDepoPosizione posizione, MagazzinoAutomaticoPutItemsRequestDTO magazzinoAutomaticoPutItemsRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = RESTBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class);
MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = restBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class);
magazzinoAutomaticoRESTConsumerService.putItems(posizione.getPosizione(), magazzinoAutomaticoPutItemsRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -17,8 +17,14 @@ import retrofit2.Response;
@Singleton
public class MagazzinoBufferRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public MagazzinoBufferRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void isVersamentoStarted(MtbDepoPosizione posizione, MagazzinoBufferVersamentoMaterialeRequestDTO magazzinoBufferVersamentoMaterialeRequestDTO, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = RESTBuilder.getService(MagazzinoBufferRESTConsumerService.class);
MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = restBuilder.getService(MagazzinoBufferRESTConsumerService.class);
magazzinoBufferRESTConsumerService.isVersamentoStarted(posizione.getPosizione(), magazzinoBufferVersamentoMaterialeRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -34,7 +40,7 @@ public class MagazzinoBufferRESTConsumer extends _BaseRESTConsumer {
}
public void startVersamentoMateriale(MtbDepoPosizione posizione, MagazzinoBufferVersamentoMaterialeRequestDTO magazzinoBufferVersamentoMaterialeRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = RESTBuilder.getService(MagazzinoBufferRESTConsumerService.class);
MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = restBuilder.getService(MagazzinoBufferRESTConsumerService.class);
magazzinoBufferRESTConsumerService.startVersamentoMateriale(posizione.getPosizione(), magazzinoBufferVersamentoMaterialeRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -50,7 +56,7 @@ public class MagazzinoBufferRESTConsumer extends _BaseRESTConsumer {
}
public void endVersamentoMateriale(MtbDepoPosizione posizione, MagazzinoBufferVersamentoMaterialeCloseRequestDTO magazzinoBufferVersamentoMaterialeCloseRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = RESTBuilder.getService(MagazzinoBufferRESTConsumerService.class);
MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = restBuilder.getService(MagazzinoBufferRESTConsumerService.class);
magazzinoBufferRESTConsumerService.endVersamentoMateriale(posizione.getPosizione(), magazzinoBufferVersamentoMaterialeCloseRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -21,16 +21,18 @@ import retrofit2.Response;
@Singleton
public class MagazzinoRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
private final SystemRESTConsumer mSystemRESTConsumer;
private final SystemRESTConsumer systemRESTConsumer;
public MagazzinoRESTConsumer(ExecutorService executorService, SystemRESTConsumer mSystemRESTConsumer) {
public MagazzinoRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.executorService = executorService;
this.mSystemRESTConsumer = mSystemRESTConsumer;
this.systemRESTConsumer = systemRESTConsumer;
}
public void saveTerminalinoWMS(SaveDTO saveDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class);
MagazzinoRESTConsumerService service = restBuilder.getService(MagazzinoRESTConsumerService.class);
service.saveTerminalinoWMS(saveDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -47,7 +49,7 @@ public class MagazzinoRESTConsumer extends _BaseRESTConsumer {
public MtbPartitaMag retrievePartitaMagSyncronized(String partitaMag, String codMart) throws Exception {
MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class);
MagazzinoRESTConsumerService service = restBuilder.getService(MagazzinoRESTConsumerService.class);
Response<ServiceRESTResponse<MtbPartitaMag>> response = service.retrievePartitaMag(codMart, partitaMag)
.execute();
@ -66,7 +68,7 @@ public class MagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public void retrieveAllPartitaMag(List<String> codMarts, Date dataScad, RunnableArgs<List<MtbPartitaMag>> onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class);
MagazzinoRESTConsumerService service = restBuilder.getService(MagazzinoRESTConsumerService.class);
service.retrieveAllPartitaMag(codMarts, UtilityDate.formatDate(dataScad, UtilityDate.COMMONS_DATE_FORMATS.YMD_SLASH))
.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -12,14 +12,16 @@ import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRe
@Singleton
public class MaterialiRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
public MaterialiRESTConsumer(ExecutorService executorService) {
public MaterialiRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.executorService = executorService;
}
public MtbColt makeSynchronousRecuperaRequest(RecuperaMaterialiRequestDTO request) throws Exception {
var materialiRESTConsumerService = RESTBuilder.getService(MaterialiRESTConsumerService.class);
var materialiRESTConsumerService = restBuilder.getService(MaterialiRESTConsumerService.class);
var response = materialiRESTConsumerService.recupera(request)
.execute();

View File

@ -23,14 +23,16 @@ import retrofit2.Response;
@Singleton
public class MesRESTConsumer extends _BaseRESTConsumer {
private final SystemRESTConsumer mSystemRESTConsumer;
private final RESTBuilder restBuilder;
private final SystemRESTConsumer systemRESTConsumer;
public MesRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
this.mSystemRESTConsumer = systemRESTConsumer;
public MesRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.systemRESTConsumer = systemRESTConsumer;
}
public void getOrdiniLavorazioneMateriale(String codJfas, String idMateriale, RunnableArgs<List<OrdineLavorazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) {
MesRESTConsumerService mesRESTConsumerService = RESTBuilder.getService(MesRESTConsumerService.class);
MesRESTConsumerService mesRESTConsumerService = restBuilder.getService(MesRESTConsumerService.class);
mesRESTConsumerService.getOrdiniLavorazioneMateriale(codJfas, idMateriale)
.enqueue(new ManagedErrorCallback<>() {
@ -47,7 +49,7 @@ public class MesRESTConsumer extends _BaseRESTConsumer {
}
public void getOrdiniLavorazione(String flagEvaso, String codJfas, String codAnag, RunnableArgs<List<OrdineLavorazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) {
MesRESTConsumerService mesRESTConsumerService = RESTBuilder.getService(MesRESTConsumerService.class);
MesRESTConsumerService mesRESTConsumerService = restBuilder.getService(MesRESTConsumerService.class);
mesRESTConsumerService.getOrdiniLavorazione(null, flagEvaso, codJfas, codAnag)
.enqueue(new ManagedErrorCallback<>() {
@ -65,7 +67,7 @@ public class MesRESTConsumer extends _BaseRESTConsumer {
public void getOrdiniLavorazione(String flagEvaso, RunnableArgs<List<OrdineLavorazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) {
MesRESTConsumerService mesRESTConsumerService = RESTBuilder.getService(MesRESTConsumerService.class);
MesRESTConsumerService mesRESTConsumerService = restBuilder.getService(MesRESTConsumerService.class);
mesRESTConsumerService.getOrdiniLavorazione(flagEvaso)
.enqueue(new ManagedErrorCallback<>() {
@ -85,7 +87,7 @@ public class MesRESTConsumer extends _BaseRESTConsumer {
Type typeOfObjectsList = new TypeToken<ArrayList<JtbFasi>>() {
}.getType();
this.mSystemRESTConsumer.processSql(
this.systemRESTConsumer.processSql(
"SELECT * FROM jtb_fasi WHERE cod_jfas_parent = " + UtilityDB.valueToString(codJfasParent),
typeOfObjectsList,
onComplete,

View File

@ -38,16 +38,19 @@ import retrofit2.Response;
@Singleton
public class OrdiniRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer mSystemRESTConsumer;
private final EntityRESTConsumer mEntityRESTConsumer;
public OrdiniRESTConsumer(SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
public OrdiniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
this.restBuilder = restBuilder;
this.mSystemRESTConsumer = systemRESTConsumer;
this.mEntityRESTConsumer = entityRESTConsumer;
}
public void getSuggestedPickingList(String codMdep, List<SitArtOrdDTO> sitArtOrdList, RunnableArgs<List<PickingObjectDTO>> onComplete, RunnableArgs<Exception> onFailed) {
OrdiniRESTConsumerService service = RESTBuilder.getService(OrdiniRESTConsumerService.class, 90);
OrdiniRESTConsumerService service = restBuilder.getService(OrdiniRESTConsumerService.class, 90);
service
.getSuggestedPickingList(codMdep, sitArtOrdList)
.enqueue(new ManagedErrorCallback<>() {
@ -124,7 +127,7 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
public void getOrdiniInevasi(String codMdep, GestioneEnum gestione, RunnableArgs<List<OrdineUscitaInevasoDTO>> onComplete, RunnableArgs<Exception> onFailed) {
OrdiniRESTConsumerService service = RESTBuilder.getService(OrdiniRESTConsumerService.class);
OrdiniRESTConsumerService service = restBuilder.getService(OrdiniRESTConsumerService.class);
service.getOrdiniInevasi(codMdep, gestione.getText())
.enqueue(new ManagedErrorCallback<>() {
@ -156,7 +159,7 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
.setIdViaggio(x.getIdViaggio()))
.toList();
OrdiniRESTConsumerService service = RESTBuilder.getService(OrdiniRESTConsumerService.class, 90);
OrdiniRESTConsumerService service = restBuilder.getService(OrdiniRESTConsumerService.class, 90);
service.getArticoliFromOrdini(codMdep, getPickingListDTOs).enqueue(new ManagedErrorCallback<>() {
@Override
@ -179,7 +182,6 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
});
}
public void getBancaliGiaRegistrati(List<OrdineInevasoDTO> orders, GestioneEnum gestione, int segno, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
String whereCondGestione = "";

View File

@ -28,14 +28,16 @@ import retrofit2.Response;
@Singleton
public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final MagazzinoRESTConsumer magazzinoRESTConsumer;
public PVOrdiniAcquistoRESTConsumer(MagazzinoRESTConsumer magazzinoRESTConsumer) {
public PVOrdiniAcquistoRESTConsumer(RESTBuilder restBuilder, MagazzinoRESTConsumer magazzinoRESTConsumer) {
this.restBuilder = restBuilder;
this.magazzinoRESTConsumer = magazzinoRESTConsumer;
}
public void retrieveArticoli(String codAlis, String codMdep, RunnableArgs<OrdiniAcquistoGrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) {
PVOrdiniAcquistoRESTConsumerService ordiniARestService = RESTBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300);
PVOrdiniAcquistoRESTConsumerService ordiniARestService = restBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300);
ordiniARestService.retrieveArticoli(codAlis, codMdep, null)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -55,7 +57,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
}
public void retrieveArticolo(String codAlis, String codMdep, String barcode, RunnableArgs<OrdiniAcquistoGrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) {
PVOrdiniAcquistoRESTConsumerService ordiniARestService = RESTBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300);
PVOrdiniAcquistoRESTConsumerService ordiniARestService = restBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300);
ordiniARestService.retrieveArticoli(codAlis, codMdep, barcode)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -90,7 +92,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
saveDTO.setGestione("O");
saveDTO.setOrdineDTO(ordineDTO);
PVOrdiniAcquistoRESTConsumerService ordiniARestService = RESTBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300);
PVOrdiniAcquistoRESTConsumerService ordiniARestService = restBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300);
ordiniARestService.save(codMdep, saveDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -23,16 +23,18 @@ import retrofit2.Response;
@Singleton
public class PosizioniRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer mSystemRESTConsumer;
public PosizioniRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
public PosizioniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.mSystemRESTConsumer = systemRESTConsumer;
}
public void getAvailablePosizioni(RunnableArgs<List<MtbDepoPosizione>> onComplete, RunnableArgs<Exception> onFailed) {
String codMdep = null;
PosizioniRESTConsumerService posizioniRESTConsumerService = RESTBuilder.getService(PosizioniRESTConsumerService.class);
PosizioniRESTConsumerService posizioniRESTConsumerService = restBuilder.getService(PosizioniRESTConsumerService.class);
posizioniRESTConsumerService.getAvailablePosizioni(codMdep).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, Response<ServiceRESTResponse<List<MtbDepoPosizione>>> response) {

View File

@ -5,7 +5,6 @@ import androidx.annotation.NonNull;
import com.annimon.stream.Stream;
import java.util.HashMap;
import java.util.List;
import javax.inject.Singleton;
@ -19,7 +18,6 @@ import it.integry.integrywmsnative.core.rest.model.JasperDTO;
import it.integry.integrywmsnative.core.rest.model.JasperPairDTO;
import it.integry.integrywmsnative.core.rest.model.ReportTypeDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.gest.spedizione.model.PrintOrderCloseDTO;
import retrofit2.Call;
import retrofit2.Response;
@ -27,31 +25,10 @@ import retrofit2.Response;
@Singleton
public class PrinterRESTConsumer extends _BaseRESTConsumer {
public enum Type {
PRIMARIA,
SECONDARIA
}
private final RESTBuilder restBuilder;
public void getAvailablePrinters(String codMdep, Type printerType, RunnableArgs<List<String>> onComplete, RunnableArgs<Exception> onFailed) {
String printerTypeStr = printerType != null ? printerType.toString() : null;
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
printerService.getAvailablePrinters(codMdep, printerTypeStr).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<String>>> call, Response<ServiceRESTResponse<List<String>>> response) {
analyzeAnswer(response, "GetAvailablePrinters", printerList -> {
printerList = Stream.of(printerList).filter(x -> !UtilityString.isNullOrEmpty(x)).toList();
onComplete.run(printerList);
}, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<List<String>>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
public PrinterRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void printCollo(MtbColt testataColloToPrint, Runnable onComplete, RunnableArgs<Exception> onFailed) {
@ -61,7 +38,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
return;
}
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class);
printerService
.printCollo(testataColloToPrint)
.enqueue(new ManagedErrorCallback<>() {
@ -92,7 +69,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
Stream.of(params)
.forEach(x -> jasperDTO.getParams().add(new JasperPairDTO(x.getKey(), x.getValue())));
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class);
printerService
.processPrintReport(printerName, quantity, jasperDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -120,7 +97,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
Stream.of(params)
.forEach(x -> reportTypeDTO.getParams().add(new JasperPairDTO(x.getKey(), x.getValue())));
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class);
printerService
.printReportType(reportTypeDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -152,7 +129,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
return;
}
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class, 240);
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class, 240);
Call<ServiceRESTResponse<Object>> callable = printerService.printClosedOrders(codMdep, dto);
callable.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -20,8 +20,14 @@ import retrofit2.Response;
@Singleton
public class ProductionLinesRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public ProductionLinesRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void avviaLineaDiProduzione(String codJfas, Integer hrNum, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class);
ProductionLinesRESTConsumerService restService = restBuilder.getService(ProductionLinesRESTConsumerService.class);
Call<ServiceRESTResponse<JsonObject>> callable = restService.avviaLineaDiProduzione(codJfas, hrNum);
callable.enqueue(new ManagedErrorCallback<>() {
@Override
@ -39,7 +45,7 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer {
}
public void arrestaLineaDiProduzione(String codJfas, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class);
ProductionLinesRESTConsumerService restService = restBuilder.getService(ProductionLinesRESTConsumerService.class);
Call<ServiceRESTResponse<JsonObject>> callable = restService.arrestaLineaDiProduzione(codJfas);
callable.enqueue(new ManagedErrorCallback<>() {
@Override
@ -57,7 +63,7 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer {
}
public void avviaProduzioneArticoloSuLinea(String codJfas, String codMart, String partitaMag, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class, 300);
ProductionLinesRESTConsumerService restService = restBuilder.getService(ProductionLinesRESTConsumerService.class, 300);
Call<ServiceRESTResponse<JsonObject>> callable = restService.avviaProduzioneArticoloSuLinea(codJfas, codMart, partitaMag);
callable.enqueue(new ManagedErrorCallback<>() {
@Override
@ -75,7 +81,7 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer {
}
public void getStatoLinee(String codMdep, RunnableArgs<List<ProdLineStatusDTO>> onComplete, RunnableArgs<Exception> onFailed) {
ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class);
ProductionLinesRESTConsumerService restService = restBuilder.getService(ProductionLinesRESTConsumerService.class);
Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> callable = restService.getStatoLinee(codMdep);
callable.enqueue(new ManagedErrorCallback<>() {
@Override
@ -92,7 +98,7 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer {
public void getLineDetails(ProdLineStatusDTO lineaProd, RunnableArgs<ProdLineStatusDTO> onComplete, RunnableArgs<Exception> onFailed) {
ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class);
ProductionLinesRESTConsumerService restService = restBuilder.getService(ProductionLinesRESTConsumerService.class);
Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> callable = restService.getStatoLinee(lineaProd.getCodMdepLav());
callable.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -13,14 +13,18 @@ import retrofit2.Call;
import retrofit2.Response;
@Singleton
public class ProduzioneRESTConsumer extends _BaseRESTConsumer{
public class ProduzioneRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public ProduzioneRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void caricoProdFin(CaricoProdFinDTO caricoProdFin, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ProduzioneRESTConsumerService service = RESTBuilder.getService(ProduzioneRESTConsumerService.class);
ProduzioneRESTConsumerService service = restBuilder.getService(ProduzioneRESTConsumerService.class);
service.caricoProdFin(caricoProdFin)
.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -36,9 +36,14 @@ import retrofit2.Response;
@Singleton
public class SystemRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public SystemRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void retrieveUpdatesInfo(final RunnableArgs<LatestAppVersionInfoDTO> onSuccess, final RunnableArgs<Exception> onFailed) {
SystemRESTConsumerService systemRESTConsumerService = RESTBuilder.getService(SystemRESTConsumerService.class);
SystemRESTConsumerService systemRESTConsumerService = restBuilder.getService(SystemRESTConsumerService.class);
systemRESTConsumerService.retrieveUpdatesInfo()
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -63,7 +68,7 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
RegisterDeviceRequestDTO registerDeviceRequestDTO = new RegisterDeviceRequestDTO()
.setApp("WMS");
SystemRESTConsumerService systemRESTConsumerService = RESTBuilder.getService(SystemRESTConsumerService.class);
SystemRESTConsumerService systemRESTConsumerService = restBuilder.getService(SystemRESTConsumerService.class);
systemRESTConsumerService.registerDevice(registerDeviceRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -80,10 +85,10 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
}
public <T> void processSql(String nativeSql, final Type clazz, final RunnableArgs<T> onComplete, final RunnableArgs<Exception> onFailed) {
NativeSqlRequestDTO nativeSqlDTO = new NativeSqlRequestDTO();
nativeSqlDTO.nativeSql = nativeSql;
NativeSqlRequestDTO nativeSqlDTO = new NativeSqlRequestDTO()
.setNativeSql(nativeSql);
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
service
.processSql(nativeSqlDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -112,7 +117,7 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
public void getAvailableCodMdeps(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
service.getAvailableCodMdeps().enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> call, Response<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> response) {
@ -158,7 +163,7 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
public void sendMail(MailRequestDTO mailDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
service.sendMail(mailDTO).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<String>> call, Response<ServiceRESTResponse<String>> response) {

View File

@ -15,15 +15,17 @@ import retrofit2.Response;
@Singleton
public class VettoriRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
public VettoriRESTConsumer(ExecutorService executorService) {
public VettoriRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.executorService = executorService;
}
public List<VtbVett> retrieveRecentlyUsedInOrdersSyncronized(GestioneEnum gestione) throws Exception {
var service = RESTBuilder.getService(VettoriRESTConsumerService.class);
var service = restBuilder.getService(VettoriRESTConsumerService.class);
Response<ServiceRESTResponse<List<VtbVett>>> response = service.retrieveRecentlyUsedInOrders(gestione)
.execute();

View File

@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.List;
import it.integry.integrywmsnative.core.exception.InvalidLicenseException;
import it.integry.integrywmsnative.core.exception.UnauthorizedAccessException;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.rest.CommonRESTException;
import it.integry.integrywmsnative.core.rest.model.EsitoType;
@ -65,7 +66,10 @@ public abstract class _BaseRESTConsumer {
throw new Exception(response.message());
}
} else {
if (response.code() == 404) {
if (response.code() == 401) {
Log.e(logTitle, "Errore " + response.code() + ": Accesso non autorizzato. Si prega di controllare le credenziali e riprovare");
throw new UnauthorizedAccessException();
} else if (response.code() == 404) {
Log.e(logTitle, "Errore " + response.code() + ": risorsa non trovata (" + response.raw().request().url() + ")");
throw new Exception("Errore " + response.code() + ": risorsa non trovata (" + logTitle + ")");
} else if (response.code() == 550)

View File

@ -6,7 +6,6 @@ import java.net.ConnectException;
import it.integry.integrywmsnative.core.exception.InvalidConnectionException;
import it.integry.integrywmsnative.core.exception.NoPrintersFoundException;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import retrofit2.Call;
import retrofit2.Callback;
@ -15,7 +14,7 @@ public abstract class ManagedErrorCallback<T> implements Callback<T> {
@Override
public void onFailure(Call<T> call, Throwable t) {
if (t instanceof ConnectException connectException) {
t = new InvalidConnectionException(RESTBuilder.getDefaultHost(), RESTBuilder.getDefaultPort(), connectException);
t = new InvalidConnectionException(call.request().url().host(), call.request().url().port(), connectException);
} else if (t.getMessage() != null && t.getMessage().contains("Printer not found")) {
t = new NoPrintersFoundException();
}

View File

@ -2,6 +2,15 @@ package it.integry.integrywmsnative.core.rest.model;
public class NativeSqlRequestDTO {
public String nativeSql;
private String nativeSql;
public String getNativeSql() {
return nativeSql;
}
public NativeSqlRequestDTO setNativeSql(String nativeSql) {
this.nativeSql = nativeSql;
return this;
}
}

View File

@ -1,5 +1,7 @@
package it.integry.integrywmsnative.core.settings;
import java.time.LocalDateTime;
import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO;
public class SettingsModel {
@ -62,28 +64,9 @@ public class SettingsModel {
}
public static class User {
private String username;
private String password;
private String fullname;
public String getUsername() {
return username;
}
public User setUsername(String username) {
this.username = username;
return this;
}
public String getPassword() {
return password;
}
public User setPassword(String password) {
this.password = password;
return this;
}
public String getFullname() {
return fullname;
}
@ -95,18 +78,51 @@ public class SettingsModel {
}
public static class UserSession {
private String accessToken;
private LocalDateTime accessTokenExpiryDate;
private String refreshToken;
private LocalDateTime refreshTokenExpiryDate;
private String deviceId;
private String profileDB;
private AvailableCodMdepsDTO depo;
private Integer defaultOrdinamentoPickingAccettazione = 0;
private Integer defaultOrdinamentoPickingAccettazioneBolle = 0;
public String getAccessToken() {
return accessToken;
}
public UserSession setAccessToken(String accessToken) {
this.accessToken = accessToken;
return this;
}
public String getRefreshToken() {
return refreshToken;
}
public UserSession setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
return this;
}
public LocalDateTime getRefreshTokenExpiryDate() {
return refreshTokenExpiryDate;
}
public UserSession setRefreshTokenExpiryDate(LocalDateTime refreshTokenExpiryDate) {
this.refreshTokenExpiryDate = refreshTokenExpiryDate;
return this;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
public UserSession setDeviceId(String deviceId) {
this.deviceId = deviceId;
return this;
}
public String getProfileDB() {
@ -144,6 +160,15 @@ public class SettingsModel {
this.defaultOrdinamentoPickingAccettazioneBolle = defaultOrdinamentoPickingAccettazioneBolle;
return this;
}
public LocalDateTime getAccessTokenExpiryDate() {
return accessTokenExpiryDate;
}
public UserSession setAccessTokenExpiryDate(LocalDateTime accessTokenExpiryDate) {
this.accessTokenExpiryDate = accessTokenExpiryDate;
return this;
}
}
public Server getServer() {

View File

@ -11,6 +11,7 @@ import java.io.File;
import javax.inject.Singleton;
import it.integry.integrywmsnative.BuildConfig;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.system.LatestAppVersionInfoDTO;
import it.integry.integrywmsnative.core.settings.SettingsManager;
@ -40,23 +41,12 @@ public class UpdatesManager {
if (latestData == null)
return;
if(latestData.getLatestVersionCode() <= BuildConfig.VERSION_CODE)
return;
showDialog(latestData, () -> {
installAPK(currentDownloadUrl);
});
// AppUpdater appUpdater = new AppUpdater(mContext)
// .setDisplay(Display.DIALOG)
// .setUpdateFrom(UpdateFrom.JSON)
// .setUpdateJSON(currentVersionUrl)
// .setButtonDoNotShowAgain(null)
// .setButtonUpdateClickListener((dialog, which) -> {
// installAPK(currentDownloadUrl);
// });
//
// if (latestData.isForced())
// appUpdater.setButtonDismiss(null);
//
// appUpdater.start();
}, ex -> UtilityExceptions.defaultException(mContext, ex));
}

View File

@ -88,7 +88,7 @@ public class UtilityLogger {
}
return !callerNew.isEmpty() ? callerNew.toString() : caller;
return callerNew.length() > 0 ? callerNew.toString() : caller;
}

View File

@ -2,6 +2,7 @@ package it.integry.integrywmsnative.gest.accettazione_bolla_elenco;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.BolleAccettazioneRESTConsumer;
@Module(subcomponents = {MainAccettazioneBollaElencoComponent.class})
@ -9,8 +10,8 @@ public class MainAccettazioneBollaElencoModule {
@Provides
BolleAccettazioneRESTConsumer providesBolleAccettazioneRESTConsumer() {
return new BolleAccettazioneRESTConsumer();
BolleAccettazioneRESTConsumer providesBolleAccettazioneRESTConsumer(RESTBuilder restBuilder) {
return new BolleAccettazioneRESTConsumer(restBuilder);
}

View File

@ -22,9 +22,14 @@ import retrofit2.Response;
@Singleton
public class BolleAccettazioneRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public BolleAccettazioneRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void retrieveBolleDaAccettare(RunnableArgs<List<TestataBollaAccettazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) {
BolleAccettazioneRESTConsumerService service = RESTBuilder.getService(BolleAccettazioneRESTConsumerService.class);
BolleAccettazioneRESTConsumerService service = restBuilder.getService(BolleAccettazioneRESTConsumerService.class);
service.retrieveElencoBolle()
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -40,7 +45,7 @@ public class BolleAccettazioneRESTConsumer extends _BaseRESTConsumer {
}
public void retrievePickingListBolle(List<TestataBollaAccettazioneDTO> bolle, RunnableArgs<List<SitBollaAccettazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) {
BolleAccettazioneRESTConsumerService service = RESTBuilder.getService(BolleAccettazioneRESTConsumerService.class);
BolleAccettazioneRESTConsumerService service = restBuilder.getService(BolleAccettazioneRESTConsumerService.class);
var request = new RetrieveElencoArticoliAccettazioneBollaRequestDTO()
.setBolle(bolle);

View File

@ -23,13 +23,17 @@ import retrofit2.Response;
@Singleton
public class AccettazioneBollaPickingRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
@Inject
public AccettazioneBollaPickingRESTConsumer() {
public AccettazioneBollaPickingRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void retrieveAlreadyRegisteredUDC(List<TestataBollaAccettazioneDTO> bolle, RunnableArgs<List<AlreadyRegisteredUDCDTO>> onComplete, RunnableArgs<Exception> onFailed) {
AccettazioneBollaPickingRESTConsumerService service = RESTBuilder.getService(AccettazioneBollaPickingRESTConsumerService.class);
AccettazioneBollaPickingRESTConsumerService service = restBuilder.getService(AccettazioneBollaPickingRESTConsumerService.class);
var request = new RetrieveAlreadyRegisteredULAccettazioneBollaRequestDTO()
.setBolle(bolle);

View File

@ -2,14 +2,15 @@ package it.integry.integrywmsnative.gest.accettazione_ordini_elenco;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.gest.accettazione_ordini_elenco.rest.OrdiniAccettazioneRESTConsumer;
@Module(subcomponents = {MainAccettazioneOrdiniElencoComponent.class})
public class MainAccettazioneOrdiniElencoModule {
@Provides
OrdiniAccettazioneRESTConsumer providesOrdiniAccettazioneRESTConsumer() {
return new OrdiniAccettazioneRESTConsumer();
OrdiniAccettazioneRESTConsumer providesOrdiniAccettazioneRESTConsumer(RESTBuilder restBuilder) {
return new OrdiniAccettazioneRESTConsumer(restBuilder);
}
@Provides

View File

@ -22,9 +22,14 @@ import retrofit2.Response;
@Singleton
public class OrdiniAccettazioneRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public OrdiniAccettazioneRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void getOrdiniInevasi(String codMdep, RunnableArgs<List<OrdineAccettazioneInevasoDTO>> onComplete, RunnableArgs<Exception> onFailed) {
OrdiniAccettazioneRESTConsumerService service = RESTBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
OrdiniAccettazioneRESTConsumerService service = restBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
service.listOrdiniInevasi(codMdep, "A").enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<OrdineAccettazioneInevasoDTO>>> call, Response<ServiceRESTResponse<List<OrdineAccettazioneInevasoDTO>>> response) {
@ -47,7 +52,7 @@ public class OrdiniAccettazioneRESTConsumer extends _BaseRESTConsumer {
.setNumero(x.getNumero()))
.toList();
OrdiniAccettazioneRESTConsumerService service = RESTBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
OrdiniAccettazioneRESTConsumerService service = restBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
service.getArticoliFromOrdiniAccettazione(getPickingListDTOs).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<SitArtOrdDTO>>> call, Response<ServiceRESTResponse<List<SitArtOrdDTO>>> response) {

View File

@ -3,6 +3,7 @@ package it.integry.integrywmsnative.gest.accettazione_ordini_picking;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.ean128.Ean128Service;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliAccettazioneRESTConsumer;
@ -17,8 +18,8 @@ import it.integry.integrywmsnative.view.bottom_sheet__lu_content.BottomSheetFrag
public class AccettazioneOrdiniPickingModule {
@Provides
AccettazioneOrdiniPickingRESTConsumer providesAccettazionePickingRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
return new AccettazioneOrdiniPickingRESTConsumer(systemRESTConsumer);
AccettazioneOrdiniPickingRESTConsumer providesAccettazionePickingRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new AccettazioneOrdiniPickingRESTConsumer(restBuilder, systemRESTConsumer);
}
@Provides

View File

@ -24,15 +24,17 @@ import retrofit2.Response;
@Singleton
public class AccettazioneOrdiniPickingRESTConsumer extends _BaseRESTConsumer {
private final SystemRESTConsumer mSystemRestConsumer;
private final RESTBuilder restBuilder;
private final SystemRESTConsumer systemRestConsumer;
@Inject
public AccettazioneOrdiniPickingRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
this.mSystemRestConsumer = systemRESTConsumer;
public AccettazioneOrdiniPickingRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.systemRestConsumer = systemRESTConsumer;
}
public void getBancaliGiaRegistrati(List<OrdineAccettazioneInevasoDTO> ordiniToShow, RunnableArgs<List<AlreadyRegisteredUDCDTO>> onComplete, RunnableArgs<Exception> onFailed) {
AccettazioneOrdiniPickingRESTConsumerService service = RESTBuilder.getService(AccettazioneOrdiniPickingRESTConsumerService.class);
AccettazioneOrdiniPickingRESTConsumerService service = restBuilder.getService(AccettazioneOrdiniPickingRESTConsumerService.class);
var request = new RetrieveAlreadyRegisteredULAccettazioneOrdineRequestDTO()
.setOrdini(ordiniToShow);

View File

@ -21,14 +21,16 @@ import retrofit2.Response;
@Singleton
public class DocInterniRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final MagazzinoRESTConsumer magazzinoRESTConsumer;
public DocInterniRESTConsumer(MagazzinoRESTConsumer magazzinoRESTConsumer) {
public DocInterniRESTConsumer(RESTBuilder restBuilder, MagazzinoRESTConsumer magazzinoRESTConsumer) {
this.restBuilder = restBuilder;
this.magazzinoRESTConsumer = magazzinoRESTConsumer;
}
public void getDocInterniSetup(RunnableArgs<DocInterniSetupDTO> onComplete, RunnableArgs<Exception> onFailed) {
DocInterniRESTConsumerService service = RESTBuilder.getService(DocInterniRESTConsumerService.class);
DocInterniRESTConsumerService service = restBuilder.getService(DocInterniRESTConsumerService.class);
service.getSetupDocInterni().enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<DocInterniSetupDTO>> call, Response<ServiceRESTResponse<DocInterniSetupDTO>> response) {
@ -43,7 +45,7 @@ public class DocInterniRESTConsumer extends _BaseRESTConsumer {
}
public void retrieveLotti(String codProd, RunnableArgs<List<RetrieveLottiDTO>> onComplete, RunnableArgs<Exception> onFailed) {
DocInterniRESTConsumerService service = RESTBuilder.getService(DocInterniRESTConsumerService.class);
DocInterniRESTConsumerService service = restBuilder.getService(DocInterniRESTConsumerService.class);
service.retrieveLotti(codProd)
.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -5,6 +5,7 @@ import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.data_store.db.respository_new.InventarioRepository;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.rest.consumers.InventarioRESTConsumer;
@ -13,8 +14,8 @@ public class ElencoInventariModule {
@Provides
@Singleton
InventarioRESTConsumer providesInventarioRESTConsumer() {
return new InventarioRESTConsumer();
InventarioRESTConsumer providesInventarioRESTConsumer(RESTBuilder restBuilder) {
return new InventarioRESTConsumer(restBuilder);
}
@Provides

View File

@ -18,6 +18,7 @@ import it.integry.integrywmsnative.SplashActivity;
import it.integry.integrywmsnative.core.di.BindableBoolean;
import it.integry.integrywmsnative.core.di.BindableString;
import it.integry.integrywmsnative.core.expansion.BaseActivity;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityWindow;
@ -104,18 +105,39 @@ public class LoginActivity extends BaseActivity implements LoginViewModel.Listen
}
@Override
public void onLoginCompleted(String protocol, String host, int port, String fullName, List<String> availableProfiles) {
public void onLoginCompleted(String fullName) {
this.onLoadingEnded();
runOnUiThread(() -> DialogSimpleMessageView.makeSuccessDialog(
"Benvenuto",
Html.fromHtml("Ciao <b>" + fullName + "</b>, la Integry le augura di svolgere al meglio il suo lavoro"),
null,
() -> showProfileDBSelectionDialog(protocol, host, port, availableProfiles))
"Benvenuto",
Html.fromHtml("Ciao <b>" + fullName + "</b>, la Integry le augura di svolgere al meglio il suo lavoro"),
null,
this::startSplashActivity)
.show(getSupportFragmentManager(), "tag"));
}
@Override
public void requestProfileSelection(List<String> availableProfiles, RunnableArgs<String> onComplete) {
// setup the alert builder
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.action_choose_profile_db);
// add a list
String[] profiles = new String[availableProfiles.size()];
profiles = availableProfiles
.toArray(profiles);
builder.setItems(profiles, (dialog, which) -> {
//SettingsManager.i().getUserSession().setProfileDB(availableProfiles.get(which));
onComplete.run(availableProfiles.get(which));
});
// create and show the alert dialog
AlertDialog dialog = builder.create();
dialog.show();
}
@Override
public void onError(Exception ex) {
@ -123,45 +145,6 @@ public class LoginActivity extends BaseActivity implements LoginViewModel.Listen
loginButtonEnabled.set(true);
}
private void showProfileDBSelectionDialog(final String protocol, final String host, final int port, final List<String> availableProfiles) {
Runnable onComplete = () -> {
FirebaseInstallations.getInstance().getId().addOnCompleteListener(fid -> {
SettingsManager.i().getUserSession().setDeviceId(fid.getResult());
SettingsManager.update();
systemRESTConsumer.registerDevice(this::startSplashActivity, this::onError);
});
};
loginButtonEnabled.set(true);
if (availableProfiles != null && availableProfiles.size() == 1) {
SettingsManager.i().getUserSession().setProfileDB(availableProfiles.get(0));
mViewmodel.loadDepo(codAzienda.get(), protocol, host, port, username.get(), password.get(), onComplete);
} else {
// setup the alert builder
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.action_choose_profile_db);
// add a list
String[] profiles = new String[availableProfiles.size()];
profiles = availableProfiles
.toArray(profiles);
builder.setItems(profiles, (dialog, which) -> {
SettingsManager.i().getUserSession().setProfileDB(availableProfiles.get(which));
mViewmodel.loadDepo(codAzienda.get(), protocol, host, port, username.get(), password.get(), onComplete);
});
// create and show the alert dialog
AlertDialog dialog = builder.create();
dialog.show();
}
}
private void startSplashActivity() {
finish();

View File

@ -1,11 +1,16 @@
package it.integry.integrywmsnative.gest.login;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.rest.AuthInterceptor;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.gest.login.rest.LoginRESTConsumer;
import it.integry.integrywmsnative.gest.login.rest.AuthenticationRESTConsumer;
import it.integry.integrywmsnative.gest.login.rest.RefreshRESTConsumer;
import it.integry.integrywmsnative.gest.login.viewmodel.LoginViewModel;
@Module(subcomponents = LoginComponent.class)
@ -13,13 +18,25 @@ public class LoginModule {
@Provides
@Singleton
LoginRESTConsumer provideLoginRESTConsumer() {
return new LoginRESTConsumer();
AuthenticationRESTConsumer provideAuthenticationRESTConsumer(RESTBuilder restBuilder) {
return new AuthenticationRESTConsumer(restBuilder);
}
@Provides
LoginViewModel providesSpedizioneViewModel(SystemRESTConsumer systemRESTConsumer, LoginRESTConsumer loginRESTConsumer) {
return new LoginViewModel(systemRESTConsumer, loginRESTConsumer);
@Singleton
AuthInterceptor provideAuthInterceptor(RefreshRESTConsumer refreshRESTConsumer) {
return new AuthInterceptor(refreshRESTConsumer);
}
@Provides
@Singleton
RefreshRESTConsumer provideRefreshRESTConsumer(ExecutorService executorService) {
return new RefreshRESTConsumer(executorService);
}
@Provides
LoginViewModel providesLoginViewModel(SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer) {
return new LoginViewModel(systemRESTConsumer, authenticationRESTConsumer);
}
}

View File

@ -0,0 +1,146 @@
package it.integry.integrywmsnative.gest.login.dto;
import java.util.HashMap;
public class AuthTokenClaimsDTO {
private long deviceId;
private User userDTO;
private HashMap<String, AuthTokenProfileDetails> profilesData;
public long getDeviceId() {
return deviceId;
}
public AuthTokenClaimsDTO setDeviceId(long deviceId) {
this.deviceId = deviceId;
return this;
}
public User getUserDTO() {
return userDTO;
}
public AuthTokenClaimsDTO setUserDTO(User userDTO) {
this.userDTO = userDTO;
return this;
}
public HashMap<String, AuthTokenProfileDetails> getProfilesData() {
return profilesData;
}
public AuthTokenClaimsDTO setProfilesData(HashMap<String, AuthTokenProfileDetails> profilesData) {
this.profilesData = profilesData;
return this;
}
public class User {
private String username;
private Object email;
private String fullname;
private int keyGroup;
private boolean attivo;
private String type;
public String getUsername() {
return username;
}
public User setUsername(String username) {
this.username = username;
return this;
}
public Object getEmail() {
return email;
}
public User setEmail(Object email) {
this.email = email;
return this;
}
public String getFullname() {
return fullname;
}
public User setFullname(String fullname) {
this.fullname = fullname;
return this;
}
public int getKeyGroup() {
return keyGroup;
}
public User setKeyGroup(int keyGroup) {
this.keyGroup = keyGroup;
return this;
}
public boolean isAttivo() {
return attivo;
}
public User setAttivo(boolean attivo) {
this.attivo = attivo;
return this;
}
public String getType() {
return type;
}
public User setType(String type) {
this.type = type;
return this;
}
}
public static class AuthTokenProfileDetails {
private AuthTokenDepoDetails defaultDepo;
public AuthTokenDepoDetails getDefaultDepo() {
return defaultDepo;
}
public AuthTokenProfileDetails setDefaultDepo(AuthTokenDepoDetails defaultDepo) {
this.defaultDepo = defaultDepo;
return this;
}
}
public static class AuthTokenDepoDetails {
private String codMdep;
private String descrizione;
private String codJfas;
public String getCodMdep() {
return codMdep;
}
public AuthTokenDepoDetails setCodMdep(String codMdep) {
this.codMdep = codMdep;
return this;
}
public String getDescrizione() {
return descrizione;
}
public AuthTokenDepoDetails setDescrizione(String descrizione) {
this.descrizione = descrizione;
return this;
}
public String getCodJfas() {
return codJfas;
}
public AuthTokenDepoDetails setCodJfas(String codJfas) {
this.codJfas = codJfas;
return this;
}
}
}

View File

@ -0,0 +1,48 @@
package it.integry.integrywmsnative.gest.login.dto;
import java.time.LocalDateTime;
public class AuthenticationJwtResponseDTO {
private String accessToken;
private String refreshToken;
private LocalDateTime expiryDate;
private long expireIn;
public String getAccessToken() {
return accessToken;
}
public AuthenticationJwtResponseDTO setAccessToken(String accessToken) {
this.accessToken = accessToken;
return this;
}
public String getRefreshToken() {
return refreshToken;
}
public AuthenticationJwtResponseDTO setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
return this;
}
public LocalDateTime getExpiryDate() {
return expiryDate;
}
public AuthenticationJwtResponseDTO setExpiryDate(LocalDateTime expiryDate) {
this.expiryDate = expiryDate;
return this;
}
public long getExpireIn() {
return expireIn;
}
public AuthenticationJwtResponseDTO setExpireIn(long expireIn) {
this.expireIn = expireIn;
return this;
}
}

View File

@ -4,6 +4,7 @@ public class LoginRequestDTO {
private String username;
private String password;
private String deviceId;
public String getUsername() {
return username;
@ -22,4 +23,13 @@ public class LoginRequestDTO {
this.password = password;
return this;
}
public String getDeviceId() {
return deviceId;
}
public LoginRequestDTO setDeviceId(String deviceId) {
this.deviceId = deviceId;
return this;
}
}

View File

@ -0,0 +1,14 @@
package it.integry.integrywmsnative.gest.login.dto;
public class RefreshRequestDTO {
private String refreshToken;
public String getRefreshToken() {
return refreshToken;
}
public RefreshRequestDTO setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
return this;
}
}

View File

@ -0,0 +1,114 @@
package it.integry.integrywmsnative.gest.login.rest;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.CommonConst;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.gest.login.dto.AuthenticationJwtResponseDTO;
import it.integry.integrywmsnative.gest.login.dto.LoginAziendaDTO;
import it.integry.integrywmsnative.gest.login.dto.LoginRequestDTO;
import retrofit2.Call;
import retrofit2.Response;
@Singleton
public class AuthenticationRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
@Inject
public AuthenticationRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void retrieveServerData(String codAzienda, RunnableArgs<LoginAziendaDTO> onComplete, RunnableArgs<Exception> onFailed) {
String protocol = CommonConst.Login.Azienda.protocol;
String host = CommonConst.Login.Azienda.host;
int port = CommonConst.Login.Azienda.port;
AuthenticationRESTConsumerService service = restBuilder.getService(AuthenticationRESTConsumerService.class, protocol, host, port, false, true);
service.loginAzienda(codAzienda).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Response<ServiceRESTResponse<LoginAziendaDTO>> response) {
analyzeAnswer(response, "LoginAzienda", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Exception e) {
onFailed.run(e);
}
});
}
public void me(RunnableArgs<Object> onComplete, RunnableArgs<Exception> onFailed) {
AuthenticationRESTConsumerService service = restBuilder.getService(AuthenticationRESTConsumerService.class);
service.me()
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
analyzeAnswer(response, "me", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<Object>> call, Exception e) {
onFailed.run(e);
}
});
}
public void authenticate(String protocol, String host, int port, String username, String password, String profileDb, String deviceSalt, RunnableArgs<AuthenticationJwtResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
AuthenticationRESTConsumerService service = restBuilder.getService(AuthenticationRESTConsumerService.class, protocol, host, port, false);
LoginRequestDTO loginRequestDTO = new LoginRequestDTO()
.setUsername(username)
.setPassword(password)
.setDeviceId(deviceSalt);
service
.loginNew(profileDb, loginRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<AuthenticationJwtResponseDTO>> call, Response<ServiceRESTResponse<AuthenticationJwtResponseDTO>> response) {
analyzeAnswer(response, "login", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<AuthenticationJwtResponseDTO>> call, final Exception e) {
onFailed.run(e);
}
});
}
public void retrieveAvailableProfiles(String protocol, String host, int port, String username, String password, RunnableArgs<List<String>> onComplete, RunnableArgs<Exception> onFailed) {
AuthenticationRESTConsumerService service = restBuilder.getService(AuthenticationRESTConsumerService.class, protocol, host, port, false);
service.retreiveAvailableProfiles(username, password)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<String>>> call, Response<ServiceRESTResponse<List<String>>> response) {
analyzeAnswer(response, "retrieveAvailableProfiles", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<List<String>>> call, Exception e) {
onFailed.run(e);
}
});
}
}

View File

@ -1,17 +1,20 @@
package it.integry.integrywmsnative.gest.login.rest;
import java.util.List;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.gest.login.dto.LoginAziendaDTO;
import it.integry.integrywmsnative.gest.login.dto.LoginResponseDTO;
import it.integry.integrywmsnative.gest.login.dto.AuthenticationJwtResponseDTO;
import it.integry.integrywmsnative.gest.login.dto.LoginRequestDTO;
import it.integry.integrywmsnative.gest.login.dto.LoginResponseDTO;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
public interface LoginRESTConsumerService {
public interface AuthenticationRESTConsumerService {
@GET("loginAziendaWms")
@ -20,4 +23,13 @@ public interface LoginRESTConsumerService {
@POST("loginWeb")
Call<ServiceRESTResponse<LoginResponseDTO>> login(@Body LoginRequestDTO loginRequestDTO);
@POST("auth/login")
Call<ServiceRESTResponse<AuthenticationJwtResponseDTO>> loginNew(@Query("profileDb") String profileDb, @Body LoginRequestDTO loginRequestDTO);
@GET("auth/me")
Call<ServiceRESTResponse<Object>> me();
@GET("users/availableProfiles")
Call<ServiceRESTResponse<List<String>>> retreiveAvailableProfiles(@Query("username") String username, @Query("password") String password);
}

View File

@ -1,66 +0,0 @@
package it.integry.integrywmsnative.gest.login.rest;
import androidx.annotation.NonNull;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.CommonConst;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.gest.login.dto.LoginAziendaDTO;
import it.integry.integrywmsnative.gest.login.dto.LoginRequestDTO;
import it.integry.integrywmsnative.gest.login.dto.LoginResponseDTO;
import retrofit2.Call;
import retrofit2.Response;
@Singleton
public class LoginRESTConsumer extends _BaseRESTConsumer {
public void retrieveServerData(String codAzienda, RunnableArgs<LoginAziendaDTO> onComplete, RunnableArgs<Exception> onFailed) {
String protocol = CommonConst.Login.Azienda.protocol;
String host = CommonConst.Login.Azienda.host;
int port = CommonConst.Login.Azienda.port;
LoginRESTConsumerService service = RESTBuilder.getService(LoginRESTConsumerService.class, protocol, host, port, false, true);
service.loginAzienda(codAzienda).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Response<ServiceRESTResponse<LoginAziendaDTO>> response) {
analyzeAnswer(response, "LoginAzienda", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<LoginAziendaDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
}
public void authenticate(String protocol, String host, int port, String username, String password, RunnableArgs<LoginResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
LoginRESTConsumerService service = RESTBuilder.getService(LoginRESTConsumerService.class, protocol, host, port, false);
LoginRequestDTO loginRequestDTO = new LoginRequestDTO()
.setUsername(username)
.setPassword(password);
service.login(loginRequestDTO).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<LoginResponseDTO>> call, Response<ServiceRESTResponse<LoginResponseDTO>> response) {
analyzeAnswer(response, "Login", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<LoginResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
}
}

View File

@ -0,0 +1,95 @@
package it.integry.integrywmsnative.gest.login.rest;
import com.google.gson.Gson;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.rest.HttpInterceptor;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityGson;
import it.integry.integrywmsnative.gest.login.dto.AuthenticationJwtResponseDTO;
import it.integry.integrywmsnative.gest.login.dto.RefreshRequestDTO;
import okhttp3.OkHttpClient;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
@Singleton
public class RefreshRESTConsumer extends _BaseRESTConsumer {
private final ExecutorService executorService;
public RefreshRESTConsumer(ExecutorService executorService) {
this.executorService = executorService;
}
public AuthenticationJwtResponseDTO makeSynchronousRefreshTokenRequest() throws Exception {
RefreshRESTConsumerService service = getService(
RefreshRESTConsumerService.class,
SettingsManager.i().getServer().getProtocol(),
SettingsManager.i().getServer().getHost(),
SettingsManager.i().getServer().getPort(),
true,
true,
30);
RefreshRequestDTO refreshRequest = new RefreshRequestDTO()
.setRefreshToken(SettingsManager.i().getUserSession().getRefreshToken());
Response<ServiceRESTResponse<AuthenticationJwtResponseDTO>> response = service
.refresh(refreshRequest)
.execute();
return analyzeAnswer(response, "refreshToken");
}
public void makeRefreshTokenRequest(final Runnable onComplete, final RunnableArgs<Exception> onError) {
executorService.execute(() -> {
try {
makeSynchronousRefreshTokenRequest();
if (onComplete != null)
onComplete.run();
} catch (Exception ex) {
if (onError != null) onError.run(ex);
}
});
}
private <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors, boolean addEmsApi, int timeout) {
OkHttpClient.Builder clientBuilder = RESTBuilder.getDefaultHttpClient();
clientBuilder.connectTimeout(timeout, TimeUnit.SECONDS);
clientBuilder.readTimeout(timeout, TimeUnit.SECONDS);
clientBuilder.writeTimeout(timeout, TimeUnit.SECONDS);
clientBuilder.retryOnConnectionFailure(true);
if (addInterceptors) clientBuilder.addInterceptor(new HttpInterceptor());
OkHttpClient client = clientBuilder.build();
String endpoint = protocol + "://" + host + (port > 0 ? ":" + port : "") + "/" + (addEmsApi ? "ems-api/" : "");
Gson gson = UtilityGson.createObject();
Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create(gson))
.baseUrl(endpoint)
.client(client)
.build();
return retrofit.create(service);
}
}

View File

@ -0,0 +1,17 @@
package it.integry.integrywmsnative.gest.login.rest;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.gest.login.dto.AuthenticationJwtResponseDTO;
import it.integry.integrywmsnative.gest.login.dto.RefreshRequestDTO;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
public interface RefreshRESTConsumerService {
@POST("auth/refresh")
Call<ServiceRESTResponse<AuthenticationJwtResponseDTO>> refresh(@Body RefreshRequestDTO refreshRequestDTO);
}

View File

@ -1,41 +1,86 @@
package it.integry.integrywmsnative.gest.login.viewmodel;
import com.annimon.stream.Stream;
import com.google.firebase.installations.FirebaseInstallations;
import com.google.gson.Gson;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.stream.Collectors;
import javax.inject.Inject;
import it.integry.integrywmsnative.core.authentication.JwtUtils;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.RunnableArgsss;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.core.utility.UtilityServer;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.gest.login.dto.AuthTokenClaimsDTO;
import it.integry.integrywmsnative.gest.login.exception.InvalidServerCodAziendaException;
import it.integry.integrywmsnative.gest.login.exception.InvalidUserDepositException;
import it.integry.integrywmsnative.gest.login.rest.LoginRESTConsumer;
import it.integry.integrywmsnative.gest.login.rest.AuthenticationRESTConsumer;
public class LoginViewModel {
private final SystemRESTConsumer mSystemRESTConsumer;
private final LoginRESTConsumer mLoginRESTConsumer;
private final AuthenticationRESTConsumer mAuthenticationRESTConsumer;
private Listener mListener;
@Inject
public LoginViewModel(SystemRESTConsumer systemRESTConsumer, LoginRESTConsumer loginRESTConsumer) {
public LoginViewModel(SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer) {
this.mSystemRESTConsumer = systemRESTConsumer;
this.mLoginRESTConsumer = loginRESTConsumer;
this.mAuthenticationRESTConsumer = authenticationRESTConsumer;
}
public void login(String codAzienda, String username, String password) {
this.sendOnLoadingStarted();
mLoginRESTConsumer.retrieveServerData(codAzienda, value -> {
retrieveServerData(codAzienda, (protocol, host, port) -> {
UtilityServer.isEmsApiAvailable(protocol, host, port, () -> {
FirebaseInstallations.getInstance().getId().addOnCompleteListener(fid -> {
retrieveAvailableProfiles(protocol, host, port, username, password, selectedProfile -> {
SettingsManager.i().createUserSession();
authenticate(protocol, host, port, username, password, selectedProfile, fid.getResult(), fullName -> {
SettingsManager.i().getUser()
.setFullname(fullName);
SettingsManager.i().getServer()
.setCodAzienda(codAzienda)
.setProtocol(protocol)
.setHost(host)
.setPort(port);
loadDepo(() -> {
SettingsManager.update();
this.sendOnLoginCompleted(fullName);
});
});
});
});
}, this::sendError);
});
}
private void retrieveServerData(String codAzienda, RunnableArgsss<String, String, Integer> onComplete) {
mAuthenticationRESTConsumer.retrieveServerData(codAzienda, value -> {
final String serverEndpoint = value.getEndpointRestApi();
@ -52,40 +97,59 @@ public class LoginViewModel {
final String host = u.getHost();
final int port = u.getPort();
UtilityServer.isEmsApiAvailable(protocol, host, port, () -> {
onComplete.run(protocol, host, port);
mLoginRESTConsumer.authenticate(protocol, host, port, username, password, loginDTO -> {
SettingsManager.i().createUserSession();
SettingsManager.i().getUser().setFullname(!UtilityString.isNullOrEmpty(loginDTO.getFullName()) ? loginDTO.getFullName() : username);
List<String> availableProfiles = null;
if(loginDTO.getAvailableProfiles() != null && !loginDTO.getAvailableProfiles().isEmpty()) {
availableProfiles = Stream.of(loginDTO.getAvailableProfiles())
.sorted()
.toList();
}
this.sendOnLoginCompleted(protocol, host, port, loginDTO.getFullName(), availableProfiles);
}, this::sendError);
}, this::sendError);
}, ex -> {
this.sendError(new InvalidServerCodAziendaException(codAzienda, ex));
});
}
private void retrieveAvailableProfiles(String protocol, String host, int port, String username, String password, RunnableArgs<String> onComplete) {
mAuthenticationRESTConsumer.retrieveAvailableProfiles(protocol, host, port, username, password, availableProfiles -> {
public void loadDepo(String codAzienda, String protocol, String host, int port, String username, String password, Runnable onComplete) {
if (availableProfiles == null || availableProfiles.isEmpty()) {
this.sendError(new Exception("Non è stato trovato alcun profilo per l'utente: " + username));
return;
}
SettingsManager.i().getServer().setCodAzienda(codAzienda);
SettingsManager.i().getServer().setProtocol(protocol);
SettingsManager.i().getServer().setHost(host);
SettingsManager.i().getServer().setPort(port);
if (availableProfiles.size() == 1) {
onComplete.run(availableProfiles.get(0));
SettingsManager.i().getUser().setUsername(username);
SettingsManager.i().getUser().setPassword(password);
} else {
availableProfiles = availableProfiles.stream()
.sorted()
.collect(Collectors.toList());
this.sendRequestProfileSelection(availableProfiles, onComplete);
}
}, this::sendError);
}
private void authenticate(String protocol, String host, int port, String username, String password, String profileDb, String deviceSalt, RunnableArgs<String> onComplete) {
mAuthenticationRESTConsumer.authenticate(protocol, host, port, username, password, profileDb, deviceSalt, sessionData -> {
var claims = JwtUtils.parseJwt(sessionData.getAccessToken());
var detailsMap = claims.get("details", LinkedHashMap.class);
Gson gson = new Gson();
String jsonString = gson.toJson(detailsMap);
AuthTokenClaimsDTO claimsDetails = gson.fromJson(jsonString, AuthTokenClaimsDTO.class);
SettingsManager.i().getUserSession()
.setProfileDB(profileDb)
.setDeviceId(deviceSalt)
.setAccessToken(sessionData.getAccessToken())
.setAccessTokenExpiryDate(UtilityDate.toLocalDateTime(claims.getExpiration()))
.setRefreshToken(sessionData.getRefreshToken())
.setRefreshTokenExpiryDate(sessionData.getExpiryDate());
onComplete.run(UtilityString.isNull(claimsDetails.getUserDTO().getFullname(), claimsDetails.getUserDTO().getUsername()));
}, this::sendError);
}
public void loadDepo(Runnable onComplete) {
this.mSystemRESTConsumer.getAvailableCodMdeps(availableCodMdeps -> {
SettingsManager.iDB().setAvailableCodMdep(availableCodMdeps);
@ -97,7 +161,6 @@ public class LoginViewModel {
SettingsManager.i().getUserSession().setDepo(availableCodMdeps.get(0));
if (onComplete != null) onComplete.run();
}, this::sendError);
}
@ -111,9 +174,14 @@ public class LoginViewModel {
if (this.mListener != null) mListener.onLoadingEnded();
}
private void sendOnLoginCompleted(String protocol, String host, int port, String fullName, List<String> availableProfiles) {
private void sendOnLoginCompleted(String fullName) {
if (this.mListener != null)
mListener.onLoginCompleted(protocol, host, port, fullName, availableProfiles);
mListener.onLoginCompleted(fullName);
}
private void sendRequestProfileSelection(List<String> availableProfiles, RunnableArgs<String> onComplete) {
if (this.mListener != null)
mListener.requestProfileSelection(availableProfiles, onComplete);
}
private void sendError(Exception ex) {
@ -128,7 +196,9 @@ public class LoginViewModel {
public interface Listener extends ILoadingListener {
void onError(Exception ex);
void onLoginCompleted(String protocol, String host, int port, String fullName, List<String> availableProfiles);
void onLoginCompleted(String fullName);
void requestProfileSelection(List<String> availableProfiles, RunnableArgs<String> onComplete);
}
}

View File

@ -4,6 +4,7 @@ import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.OrdiniRESTConsumer;
@ -14,8 +15,8 @@ public class OrdiniUscitaElencoModule {
@Singleton
@Provides
OrdiniUscitaElencoRESTConsumer providesOrdiniUscitaElencoRESTConsumer() {
return new OrdiniUscitaElencoRESTConsumer();
OrdiniUscitaElencoRESTConsumer providesOrdiniUscitaElencoRESTConsumer(RESTBuilder restBuilder) {
return new OrdiniUscitaElencoRESTConsumer(restBuilder);
}
@Provides

View File

@ -20,8 +20,14 @@ import retrofit2.Response;
@Singleton
public class OrdiniUscitaElencoRESTConsumer extends _BaseRESTConsumer {
private RESTBuilder restBuilder;
public OrdiniUscitaElencoRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void getOrdiniFromCommessaCollo(String codMdep, MtbColt testataCollo, RunnableArgs<List<DtbOrdt>> onComplete, RunnableArgs<Exception> onFailed) {
OrdiniUscitaElencoRESTConsumerService service = RESTBuilder.getService(OrdiniUscitaElencoRESTConsumerService.class);
OrdiniUscitaElencoRESTConsumerService service = restBuilder.getService(OrdiniUscitaElencoRESTConsumerService.class);
service.getOrdiniInCommessaCollo(
testataCollo.getDataColloS(),
testataCollo.getNumCollo(),

View File

@ -2,14 +2,15 @@ package it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione.rest.ProdOrdineProduzioneRESTConsumer;
@Module(subcomponents = ProdOrdineProduzioneElencoComponent.class)
public class ProdOrdineProduzioneElencoModule {
@Provides
ProdOrdineProduzioneRESTConsumer providesProdOrdineProduzioneRESTConsumer() {
return new ProdOrdineProduzioneRESTConsumer();
ProdOrdineProduzioneRESTConsumer providesProdOrdineProduzioneRESTConsumer(RESTBuilder restBuilder) {
return new ProdOrdineProduzioneRESTConsumer(restBuilder);
}
@Provides

View File

@ -23,8 +23,14 @@ import retrofit2.Response;
@Singleton
public class ProdOrdineProduzioneRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public ProdOrdineProduzioneRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void getOrdiniInevasi(String codMdep, RunnableArgs<List<OrdineAccettazioneInevasoDTO>> onComplete, RunnableArgs<Exception> onFailed) {
OrdiniAccettazioneRESTConsumerService service = RESTBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
OrdiniAccettazioneRESTConsumerService service = restBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
service.listOrdiniInevasi(codMdep, "P").enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<OrdineAccettazioneInevasoDTO>>> call, Response<ServiceRESTResponse<List<OrdineAccettazioneInevasoDTO>>> response) {
@ -47,7 +53,7 @@ public class ProdOrdineProduzioneRESTConsumer extends _BaseRESTConsumer {
.setNumero(x.getNumero()))
.toList();
OrdiniAccettazioneRESTConsumerService service = RESTBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
OrdiniAccettazioneRESTConsumerService service = restBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
service.getArticoliFromOrdiniAccettazione(getPickingListDTOs).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<SitArtOrdDTO>>> call, Response<ServiceRESTResponse<List<SitArtOrdDTO>>> response) {

View File

@ -70,7 +70,7 @@ public class DialogAskMagazzinoProssimitaAdapter extends ArrayAdapter<JtbFasi> i
}
}
if (prefix == null || prefix.isEmpty()) {
if (prefix == null || prefix.length() == 0) {
synchronized (lock) {
results.values = mDatasetAllItems;
results.count = mDatasetAllItems.size();

View File

@ -25,15 +25,17 @@ import retrofit2.Response;
@Singleton
public class ProdFabbisognoLineeProdRESTConsumer extends _BaseRESTConsumer {
private final SystemRESTConsumer mSystemRESTConsumer;
private final RESTBuilder restBuilder;
private final SystemRESTConsumer systemRESTConsumer;
public ProdFabbisognoLineeProdRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
this.mSystemRESTConsumer = systemRESTConsumer;
public ProdFabbisognoLineeProdRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.systemRESTConsumer = systemRESTConsumer;
}
public void loadFabbisogno(String numOrd, String codMdep, RunnableArgs<List<ProdFabbisognoLineeProdDTO>> onComplete, RunnableArgs<Exception> onFailed) {
ProdFabbisognoLineeProdRESTConsumerService prodFabbisognoLineeProdRESTConsumerService = RESTBuilder.getService(ProdFabbisognoLineeProdRESTConsumerService.class);
ProdFabbisognoLineeProdRESTConsumerService prodFabbisognoLineeProdRESTConsumerService = restBuilder.getService(ProdFabbisognoLineeProdRESTConsumerService.class);
prodFabbisognoLineeProdRESTConsumerService.loadFabbisogno(numOrd, codMdep)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -73,7 +75,7 @@ public class ProdFabbisognoLineeProdRESTConsumer extends _BaseRESTConsumer {
Type typeOfObjectsList = new TypeToken<ArrayList<ProdFabbisognoLineeProdDTO>>() {}.getType();
this.mSystemRESTConsumer.processSql(sql, typeOfObjectsList, onComplete, onFailed);
this.systemRESTConsumer.processSql(sql, typeOfObjectsList, onComplete, onFailed);
}
}

View File

@ -2,6 +2,7 @@ package it.integry.integrywmsnative.gest.prod_rientro_merce.order_detail;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer;
@ -13,12 +14,13 @@ import it.integry.integrywmsnative.gest.prod_rientro_merce.order_detail.rest.Pro
public class ProdRientroMerceOrderDetailModule {
@Provides
ProdRientroMerceOrderDetailRESTConsumer provideProdRientroMerceOrderDetailRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
return new ProdRientroMerceOrderDetailRESTConsumer(systemRESTConsumer);
ProdRientroMerceOrderDetailRESTConsumer provideProdRientroMerceOrderDetailRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new ProdRientroMerceOrderDetailRESTConsumer(restBuilder, systemRESTConsumer);
}
@Provides
ProdRientroMerceOrderDetailViewModel provideProdRientroMerceOrderDetailViewModel(
RESTBuilder restBuilder,
ProdRientroMerceOrderDetailRESTConsumer prodRientroMerceOrderDetailRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
PrinterRESTConsumer printerRESTConsumer,

View File

@ -151,7 +151,7 @@ public class ProdRientroMerceOrderDetailViewModel {
.setCodJfas(pickedQuantityDTO.getCodJfas())
.setCodAnag(currentOrder.getCodAnag())
.setCodMdep(currentOrder.getCodMdep())
.setPreparatoDa(SettingsManager.i().getUser().getUsername())
.setPreparatoDa(SettingsManager.i().getUser().getFullname())
.setEffettuaCaricoProdotto(SettingsManager.iDB().isProduzioneGeneraDocCar())
.setCreaCaricoDaCollo(true)
.setCodDtipCar(SettingsManager.iDB().getProduzioneCodDtipCar())

View File

@ -33,10 +33,12 @@ import retrofit2.Response;
@Singleton
public class ProdRientroMerceOrderDetailRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer systemRESTConsumer;
@Inject
public ProdRientroMerceOrderDetailRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
public ProdRientroMerceOrderDetailRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.systemRESTConsumer = systemRESTConsumer;
}
@ -111,7 +113,7 @@ public class ProdRientroMerceOrderDetailRESTConsumer extends _BaseRESTConsumer {
public void importColliDaProduzione(ImportColliDaProduzioneRequestDTO importColliDaProduzioneRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ProdRientroMerceOrderDetailRESTConsumerService service = RESTBuilder.getService(ProdRientroMerceOrderDetailRESTConsumerService.class);
ProdRientroMerceOrderDetailRESTConsumerService service = restBuilder.getService(ProdRientroMerceOrderDetailRESTConsumerService.class);
service.importColliDaProduzione(Collections.singletonList(importColliDaProduzioneRequestDTO))
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -132,7 +134,7 @@ public class ProdRientroMerceOrderDetailRESTConsumer extends _BaseRESTConsumer {
public void deleteColloDaProduzione(MtbColt mtbColtToDelete, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ProdRientroMerceOrderDetailRESTConsumerService service = RESTBuilder.getService(ProdRientroMerceOrderDetailRESTConsumerService.class);
ProdRientroMerceOrderDetailRESTConsumerService service = restBuilder.getService(ProdRientroMerceOrderDetailRESTConsumerService.class);
service.deleteColloDaProduzione(mtbColtToDelete).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {

View File

@ -4,6 +4,7 @@ import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
@ -17,8 +18,8 @@ public class RettificaGiacenzeModule {
@Provides
@Singleton
RettificaGiacenzeRESTConsumer providesRettificaGiacenzeRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
return new RettificaGiacenzeRESTConsumer(systemRESTConsumer);
RettificaGiacenzeRESTConsumer providesRettificaGiacenzeRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new RettificaGiacenzeRESTConsumer(restBuilder, systemRESTConsumer);
}

View File

@ -32,10 +32,12 @@ import retrofit2.Response;
@Singleton
public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer {
private final SystemRESTConsumer mSystemRestConsumer;
private final RESTBuilder restBuilder;
private final SystemRESTConsumer systemRestConsumer;
public RettificaGiacenzeRESTConsumer(SystemRESTConsumer systemRestConsumer) {
mSystemRestConsumer = systemRestConsumer;
public RettificaGiacenzeRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRestConsumer) {
this.restBuilder = restBuilder;
this.systemRestConsumer = systemRestConsumer;
}
public void loadListaFornitori(RunnableArgs<ArrayList<FornitoreDTO>> onComplete, RunnableArgs<Exception> onFailed) {
@ -44,14 +46,14 @@ public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer {
Type typeOfObjectsList = new TypeToken<ArrayList<FornitoreDTO>>() {
}.getType();
mSystemRestConsumer.<ArrayList<FornitoreDTO>>processSql(sql, typeOfObjectsList, value -> {
systemRestConsumer.<ArrayList<FornitoreDTO>>processSql(sql, typeOfObjectsList, value -> {
if (onComplete != null) onComplete.run(value);
}, onFailed);
}
public void searchArtForn(String codAlis, String codArtForOrDescr, RunnableArgs<List<SearchArticoloByCodArtFornOrDescrizioneResponseDTO>> onComplete, RunnableArgs<Exception> onError) {
final RettificaGiacenzeRESTConsumerService service = RESTBuilder.getService(RettificaGiacenzeRESTConsumerService.class);
final RettificaGiacenzeRESTConsumerService service = restBuilder.getService(RettificaGiacenzeRESTConsumerService.class);
service.searchByCodArtFornOrDescrizione(new SearchArticoloByCodArtFornOrDescrizioneRequestDTO()
.setCodAlis(codAlis)
.setCodArtFornOrDescrizione(codArtForOrDescr))
@ -74,7 +76,7 @@ public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer {
public void searchArtInt(String codMartOrBarcodeOrDescr, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onError) {
final RettificaGiacenzeRESTConsumerService service = RESTBuilder.getService(RettificaGiacenzeRESTConsumerService.class);
final RettificaGiacenzeRESTConsumerService service = restBuilder.getService(RettificaGiacenzeRESTConsumerService.class);
service.searchByCodMartOrBarcode(new SearchArticoloByBarcodeOrCodMartRequestDTO()
.setCodMartOrBarcode(codMartOrBarcodeOrDescr))
.enqueue(new ManagedErrorCallback<>() {
@ -110,7 +112,7 @@ public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer {
var request = new SaveDocFromPickingRequestDTO()
.setColliFromMtbColts(Collections.singletonList(mtbColt));
final RettificaGiacenzeRESTConsumerService service = RESTBuilder.getService(RettificaGiacenzeRESTConsumerService.class);
final RettificaGiacenzeRESTConsumerService service = restBuilder.getService(RettificaGiacenzeRESTConsumerService.class);
service.saveDocFromPickingPvm(request)
.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -72,7 +72,7 @@ public class DialogAskCliente_Page1_Cliente_ArrayAdapter extends ArrayAdapter<Di
}
}
if (prefix == null || prefix.isEmpty()) {
if (prefix == null || prefix.length() == 0) {
synchronized (lock) {
results.values = mDatasetAllItems;
results.count = mDatasetAllItems.size();

View File

@ -67,7 +67,7 @@ public class DialogAskCliente_Page1_Commessa_ArrayAdapter extends ArrayAdapter<S
}
}
if (prefix == null || prefix.isEmpty()) {
if (prefix == null || prefix.length() == 0) {
synchronized (lock) {
results.values = mDatasetAllItems;
results.count = mDatasetAllItems.size();

View File

@ -89,7 +89,7 @@ public class DialogAskCliente_Page2_ArrayAdapter extends ArrayAdapter<DialogAskC
}
}
if (prefix == null || prefix.isEmpty()) {
if (prefix == null || prefix.length() == 0) {
synchronized (lock) {
results.values = mDatasetAllItems;
results.count = mDatasetAllItems.size();

View File

@ -0,0 +1,14 @@
package it.integry.integrywmsnative.view.dialogs.basket_lu;
import dagger.Subcomponent;
@Subcomponent
public interface DialogBasketLUComponent {
@Subcomponent.Factory
interface Factory {
DialogBasketLUComponent create();
}
void inject(DialogBasketLUView dialogBasketLUView);
}

View File

@ -0,0 +1,22 @@
package it.integry.integrywmsnative.view.dialogs.basket_lu;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.view.dialogs.basket_lu.pages.page1.DialogBasketLU_Page1_ViewModel;
import it.integry.integrywmsnative.view.dialogs.basket_lu.pages.page2.DialogBasketLU_Page2_ViewModel;
@Module(subcomponents = DialogBasketLUComponent.class)
public class DialogBasketLUModule {
@Provides
DialogBasketLU_Page1_ViewModel providesDialogBasketLUPage1ViewModel(ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer) {
return new DialogBasketLU_Page1_ViewModel(colliMagazzinoRESTConsumer);
}
@Provides
DialogBasketLU_Page2_ViewModel providesDialogBasketLUPage2ViewModel() {
return new DialogBasketLU_Page2_ViewModel();
}
}

View File

@ -14,16 +14,25 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import it.integry.integrywmsnative.MainApplication;
import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.expansion.BaseDialogFragment;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.databinding.DialogBasketLuBinding;
import it.integry.integrywmsnative.view.dialogs.basket_lu.interfaces.IDialogBasketLUViewModel;
import it.integry.integrywmsnative.view.dialogs.basket_lu.pages.page1.DialogBasketLU_Page1_ViewModel;
import it.integry.integrywmsnative.view.dialogs.basket_lu.pages.page2.DialogBasketLU_Page2_ViewModel;
public class DialogBasketLUView extends BaseDialogFragment {
@Inject
DialogBasketLU_Page1_ViewModel dialogBasketLUPage1ViewModel;
@Inject
DialogBasketLU_Page2_ViewModel dialogBasketLUPage2ViewModel;
private final RunnableArgs<MtbColt> mOnComplete;
private DialogBasketLuBinding mBindings;
@ -31,6 +40,11 @@ public class DialogBasketLUView extends BaseDialogFragment {
public DialogBasketLUView(RunnableArgs<MtbColt> onComplete) {
mOnComplete = onComplete;
MainApplication.appComponent
.dialogBasketLUComponent()
.create()
.inject(this);
}
@NonNull
@ -51,9 +65,9 @@ public class DialogBasketLUView extends BaseDialogFragment {
}
private void initViewPager(Dialog dialog) {
List<Map.Entry<Integer, Class<?>>> views = new ArrayList<>();
views.add(new AbstractMap.SimpleEntry<>(R.layout.dialog_basket_lu__page1, DialogBasketLU_Page1_ViewModel.class));
views.add(new AbstractMap.SimpleEntry<>(R.layout.dialog_basket_lu__page2, DialogBasketLU_Page2_ViewModel.class));
List<Map.Entry<Integer, IDialogBasketLUViewModel>> views = new ArrayList<>();
views.add(new AbstractMap.SimpleEntry<>(R.layout.dialog_basket_lu__page1, dialogBasketLUPage1ViewModel));
views.add(new AbstractMap.SimpleEntry<>(R.layout.dialog_basket_lu__page2, dialogBasketLUPage2ViewModel));
DialogBasketLU_ViewPagerAdapter viewPagerAdapter = new DialogBasketLU_ViewPagerAdapter(requireContext(), views);
mBindings.viewpager.setAdapter(viewPagerAdapter);

View File

@ -24,12 +24,12 @@ public class DialogBasketLU_ViewPagerAdapter extends PagerAdapter implements Vie
private final Context mContext;
private final List<Map.Entry<Integer, Class<?>>> mDatasetLayout;
private final List<Map.Entry<Integer, IDialogBasketLUViewModel>> mDatasetLayout;
private final List<Map.Entry<ViewDataBinding, IDialogBasketLUViewModel>> mDatasetViews;
private DeactivatableViewPager viewPager;
public DialogBasketLU_ViewPagerAdapter(Context context, List<Map.Entry<Integer, Class<?>>> datasetLayouts) {
public DialogBasketLU_ViewPagerAdapter(Context context, List<Map.Entry<Integer, IDialogBasketLUViewModel>> datasetLayouts) {
this.mContext = context;
this.mDatasetLayout = datasetLayouts;
this.mDatasetViews = new ArrayList<>();
@ -45,32 +45,28 @@ public class DialogBasketLU_ViewPagerAdapter extends PagerAdapter implements Vie
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
ViewDataBinding mBinding = DataBindingUtil.inflate(inflater, viewId, null, false);
Class<?> viewModelClass = mDatasetLayout.get(position).getValue();
IDialogBasketLUViewModel viewModel = null;
// Class<?> viewModelClass = mDatasetLayout.get(position).getValue();
IDialogBasketLUViewModel viewModel = mDatasetLayout.get(position).getValue();
try {
viewModel = (IDialogBasketLUViewModel) viewModelClass.newInstance();
viewModel.setBinding(mBinding);
viewModel.setContext(mContext);
viewModel.setOnDone(data -> {
int newIndex = viewPager.getCurrentItem() + 1;
// viewModel = (IDialogBasketLUViewModel) viewModelClass.newInstance();
viewModel.setBinding(mBinding);
viewModel.setContext(mContext);
viewModel.setOnDone(data -> {
int newIndex = viewPager.getCurrentItem() + 1;
if(newIndex <= getCount()) {
this.mDatasetViews.get(newIndex).getValue().setInputData(data);
this.mDatasetViews.get(newIndex).getValue().onPreShow();
viewPager.setCurrentItem(newIndex, true);
}
});
viewModel.setOnPrev(() -> {
int newIndex = viewPager.getCurrentItem() - 1;
if(newIndex <= getCount()) {
this.mDatasetViews.get(newIndex).getValue().setInputData(data);
this.mDatasetViews.get(newIndex).getValue().onPreShow();
viewPager.setCurrentItem(newIndex, true);
}
});
viewModel.setOnPrev(() -> {
int newIndex = viewPager.getCurrentItem() - 1;
if(newIndex >= 0) {
viewPager.setCurrentItem(newIndex, true);
}
});
} catch (IllegalAccessException | InstantiationException e) {
e.printStackTrace();
}
if(newIndex >= 0) {
viewPager.setCurrentItem(newIndex, true);
}
});
mBinding.setVariable(it.integry.integrywmsnative.BR.viewmodel, viewModel);

View File

@ -9,6 +9,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import java.util.List;
import javax.inject.Inject;
import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbColt;
@ -26,6 +28,13 @@ public class DialogBasketLU_Page1_ViewModel extends DialogBasketLU_BaseViewModel
private List<MtbColt> availableMtbColts;
private DialogBasketLU_Page1_ListAdapter mAdapter;
private final ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer;
@Inject
public DialogBasketLU_Page1_ViewModel(ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer) {
this.colliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
}
@Override
public void setContext(Context context) {
this.mContext = context;
@ -47,7 +56,7 @@ public class DialogBasketLU_Page1_ViewModel extends DialogBasketLU_BaseViewModel
mBinding.constraintLayout.setMaxHeight((int) (mContext.getResources().getDisplayMetrics().heightPixels * 0.75));
ColliMagazzinoRESTConsumer.retrieveBasketColli(mtbColts -> {
colliMagazzinoRESTConsumer.retrieveBasketColli(mtbColts -> {
availableMtbColts = mtbColts;
if(mtbColts != null && !mtbColts.isEmpty()) initRecyclerView(availableMtbColts);

View File

@ -104,7 +104,7 @@ public class DialogInputPesoLUView extends BaseDialogFragment {
List<String> codTcolDescriptions = codTcolList.stream()
.map(codTcol -> codTcol.getCodTcol() + " - " + codTcol.getDescrizione())
.toList();
.collect(Collectors.toList());
if (codTcol.get() != null) {
Optional<String> newCodTcol = this.codTcolList.stream()

View File

@ -2,6 +2,8 @@ package it.integry.integrywmsnative.view.dialogs.scan_or_create_lu;
import com.annimon.stream.Stream;
import javax.inject.Inject;
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
import it.integry.integrywmsnative.core.CommonConst;
import it.integry.integrywmsnative.core.exception.AlreadyAttachedDocumentToLUException;
@ -40,6 +42,7 @@ public class DialogScanOrCreateLUViewModel {
private Listener mListener;
@Inject
public DialogScanOrCreateLUViewModel(PosizioniRESTConsumer mPosizioniRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, ColliLavorazioneRESTConsumer mColliLavorazioneRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
this.mPosizioniRESTConsumer = mPosizioniRESTConsumer;
this.mBarcodeRESTConsumer = barcodeRESTConsumer;

View File

@ -140,7 +140,6 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.card.MaterialCardView
android:id="@+id/new_card"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"