public static Msg<String> updateAdressLibrary(Context context, Addresslibrary al) { DSLContext create = context.getJc().getDefaultClient().getContext(); Msg<String> msg = new Msg<String>(); try { create .update(ADDRESSLIBRARY) .set(ADDRESSLIBRARY.NAME, al.getName()) .set(ADDRESSLIBRARY.PROVINCIAL, al.getProvincial()) .set(ADDRESSLIBRARY.CITY, al.getCity()) .set(ADDRESSLIBRARY.DISTRICT, al.getDistrict()) .set(ADDRESSLIBRARY.TEL, al.getTel()) .set(ADDRESSLIBRARY.ADDRESS, al.getAddress()) .set(ADDRESSLIBRARY.TYPE, al.getType()) .set(ADDRESSLIBRARY.USERID, al.getUserid()) .set(ADDRESSLIBRARY.ISDEFAULT, al.getIsdefault()) .where(ADDRESSLIBRARY.ADDRESSLIBRARYID.eq(al.getAddresslibraryid())) .execute(); } catch (Exception e) { e.printStackTrace(); msg.setResult(false); return msg; } msg.setResult(true); return msg; }
private void updateChargePointInternal(DSLContext ctx, ChargePointForm form, Integer addressPk) { ctx.update(CHARGE_BOX) .set(CHARGE_BOX.DESCRIPTION, form.getDescription()) .set(CHARGE_BOX.LOCATION_LATITUDE, form.getLocationLatitude()) .set(CHARGE_BOX.LOCATION_LONGITUDE, form.getLocationLongitude()) .set(CHARGE_BOX.NOTE, form.getNote()) .set(CHARGE_BOX.ADDRESS_PK, addressPk) .where(CHARGE_BOX.CHARGE_BOX_PK.equal(form.getChargeBoxPk())) .execute(); }
public static Msg<String> updateDeAdressLibrary(Context context, String alid) { DSLContext create = context.getJc().getDefaultClient().getContext(); Msg<String> msg = new Msg<String>(); try { create .update(ADDRESSLIBRARY) .set(ADDRESSLIBRARY.ISDEFAULT, 0) .where(ADDRESSLIBRARY.ADDRESSLIBRARYID.ne(alid)) .execute(); } catch (Exception e) { e.printStackTrace(); msg.setResult(false); return msg; } msg.setResult(true); return msg; }
public static Msg<String> delAdressLibrary(Context context, Addresslibrary al) { DSLContext create = context.getJc().getDefaultClient().getContext(); Msg<String> msg = new Msg<String>(); try { create .update(ADDRESSLIBRARY) .set(ADDRESSLIBRARY.ISDEL, 1) .where(ADDRESSLIBRARY.ADDRESSLIBRARYID.eq(al.getAddresslibraryid())) .execute(); } catch (Exception e) { e.printStackTrace(); msg.setResult(false); return msg; } msg.setResult(true); return msg; }
@Override public void updateBook(BookModel bookModel) { create .update(BOOK) .set(BOOK.TITLE, bookModel.getTitle()) .set(BOOK.DATE_PUBLISH, bookModel.getDatePublish()) .set(BOOK.SHORT_DESCRIPTION, bookModel.getShortDescription()) .where(BOOK.ID_BOOK.equal(bookModel.getIdBook())) .execute(); List<Integer> existsAuthors = create .select(AUTHOR_BOOK.ID_AUTHOR) .from(AUTHOR_BOOK) .where(AUTHOR_BOOK.ID_BOOK.equal(bookModel.getIdBook())) .fetchInto(Integer.class); logger.debug("Existing authors: " + existsAuthors); List<Integer> newAuthors = new ArrayList<>(); List<Integer> authors = new ArrayList<>(); /** */ for (String idAuthor : bookModel.getAuthors()) { int id = Integer.valueOf(idAuthor); authors.add(id); if (!existsAuthors.contains(id)) { newAuthors.add(id); } } existsAuthors.removeAll(authors); logger.debug("New authors: " + newAuthors); if (!newAuthors.isEmpty()) { InsertValuesStep2<AuthorBookRecord, Integer, Integer> insertStep = create.insertInto(AUTHOR_BOOK, AUTHOR_BOOK.ID_AUTHOR, AUTHOR_BOOK.ID_BOOK); InsertValuesStep2<AuthorBookRecord, Integer, Integer> valuesStep = null; for (Integer idAuthor : newAuthors) { valuesStep = insertStep.values(idAuthor, bookModel.getIdBook()); } valuesStep.execute(); } logger.debug("Old authors: " + existsAuthors); if (!existsAuthors.isEmpty()) { create.delete(AUTHOR_BOOK).where(AUTHOR_BOOK.ID_AUTHOR.in(existsAuthors)).execute(); } }
@Override public void deleteBook(int idBook) { create.update(BOOK).set(BOOK.STATUS, false).where(BOOK.ID_BOOK.equal(idBook)).execute(); }