public int validateDate(FormItem formItem) { Date dt = ((CurrentTimeItem) formItem).getValueAsDate(); if (dt == null) dt = DocFlow.getCurrentDate(); trimDate(dt); Date now = DocFlow.getCurrentDate(); trimDate(now); long ldt = dt.getTime(); long lnow = now.getTime(); ldt = trimDate(ldt); lnow = trimDate(lnow); if (ldt > lnow) return -1; String dayadds[] = docType.getDelayinterval().split(","); int warring = Integer.parseInt(dayadds[0]); int error = Integer.parseInt(dayadds[1]); int fatalerror = Integer.parseInt(dayadds[2]); long dayms = 1000 * 60 * 60 * 24; long errordate = lnow - (dayms * error); long fatalerrordate = lnow - (dayms * fatalerror); long warringdate = lnow - (dayms * warring); if (ldt <= fatalerrordate) return -2; if (ldt <= errordate) return 2; if (ldt <= warringdate) return 1; return 0; }
@SuppressWarnings("deprecation") private void setData(HashMap<String, String> values) { Set<String> keys = formitemMap.keySet(); if (values == null) { values = new HashMap<String, String>(); } for (String key : keys) { Object obj = values == null ? null : values.get(key); FieldDefinitionItem item = formitemMap.get(key); if (item == null) continue; if (!item.getFieldDef().isFieldReadOnly()) item.getFormItem().setCanEdit(true); // .setAttribute("readOnly", // false); if (item.getFormItem() instanceof CurrentTimeItem) { if (obj != null) { try { Long lng = Long.parseLong(obj.toString()); item.getFormItem().setValue(new Date(lng.longValue())); } catch (Exception e) { try { Date dt = new Date(obj.toString()); item.getFormItem().setValue(dt); } catch (Exception e2) { item.getFormItem().setValue(DocFlow.getCurrentDate()); } } } else item.getFormItem().setValue(DocFlow.getCurrentDate()); } if (item.getFormItem() instanceof CheckboxItem) { try { Integer lng = Integer.parseInt(obj.toString()); item.getFormItem().setValue(lng.intValue() == 1); } catch (Exception e) { // TODO: handle exception } } Object val = obj; if (val == null && item.getFieldDef().getDefaultValue() != null && item.getFieldDef().getDefaultValue().trim().length() > 0) { val = item.getFieldDef().getDefaultValue().trim(); if (val.toString().startsWith("$")) val = null; } if (item.getFieldDef().getFieldType() == FieldDefinition.FT_DATE && item.getFormItem() instanceof CurrentTimeItem && val != null) { try { Long lng = Long.parseLong(val.toString()); val = new Date(lng); } catch (Exception e) { // TODO: handle exception } } if (item.getFieldDef().getFieldType() == FieldDefinition.FT_BOOLEAN && item.getFormItem() instanceof CheckboxItem) { try { if (val == null) val = new Boolean(false); else { Long lng = Long.parseLong(val.toString()); val = new Boolean(lng == 1); } } catch (Exception e) { // TODO: handle exception } } item.getFormItem().setValue(val); // if (item.getFieldDef().isCalculateOnSet()) // setCalculatorCalculate(item); } if (dataComplete != null && newData) { newData = false; dataComplete.settingDataComplete(); } }
public void setCurrentDate() { diStart.setValue(DocFlow.getCurrentDate()); diEnd.setValue(new Date(DocFlow.currenttime + (1000 * 60 * 60 * 24))); }