@Override protected void fromObject(Logo l, StoreQuery<?> q) { // TODO fix it // q.addValue(OFC_LOGO.ID, l.getId()); q.addValue(OFC_LOGO.POS, l.getId()); // q.addValue(OFC_LOGO.POSITION, l.getPosition().name()); q.addValue(OFC_LOGO.IMAGE, l.getImage()); // q.addValue(OFC_LOGO.CONTENT_TYPE, l.getContentType()); }
// Generic type safety... private final <Z extends UDTRecord<?>> void addAddressValue(StoreQuery<?> q, Field<Z> field) throws Exception { Class<? extends Z> addressType = field.getType(); Class<?> countryType = addressType.getMethod("getCountry").getReturnType(); Class<?> streetType = addressType.getMethod("getStreet").getReturnType(); Object country = null; try { countryType.getMethod("valueOf", String.class).invoke(countryType, "Germany"); } catch (NoSuchMethodException e) { country = "Germany"; } Object street = streetType.newInstance(); Z address = addressType.newInstance(); streetType.getMethod("setStreet", String.class).invoke(street, "Bahnhofstrasse"); streetType.getMethod("setNo", String.class).invoke(street, "1"); addressType.getMethod("setCountry", countryType).invoke(address, country); addressType.getMethod("setCity", String.class).invoke(address, "Calw"); addressType.getMethod("setStreet", streetType).invoke(address, street); q.addValue(field, address); }
@Override protected void fromObject(Logo l, StoreQuery<?> q) { q.addValue(OFC_LOGO.POS, l.getPosition()); q.addValue(OFC_LOGO.IMAGE, l.getImage()); }