private void initData() { header = new ArrayList<String>(); data = new ArrayList<List<String>>(); header.add("Thời gian"); header.add("Account"); for (int i = 0; i < fields.length; i++) { if (isFields[i]) { header.add(entityType.getDescriptionOfField(fields[i].getName())); } } int i = 0; while (i < myHistorys.size()) { List<String> row = new ArrayList<String>(); row.add(df.format(myHistorys.get(i).getDateStart())); row.add(myHistorys.get(i).getUsername()); int k = i; for (int j = 0; j < fields.length; j++) { if (isFields[j]) { k = i; boolean had = false; while (true) { if (k < myHistorys.size() && myHistorys.get(k).getDateStart().equals(myHistorys.get(i).getDateStart())) { if (myHistorys.get(k).getField().equals(fields[j].getName())) { had = true; row.add( entityType.getDataRealyOfField( fields[j].getName(), myHistorys.get(k).getData())); break; } k++; } else { break; } } if (!had) { if (i == 0) { row.add(""); } else { row.add(data.get(data.size() - 1).get(row.size())); } } } } i = k + 1; data.add(row); } }
private void loadHistory() { myHistorys = new ArrayList<MyHistory>(); List<Reference> references = referenceDAO.select( Reference.FIELD_OBJECT_TYPE, entityType.getEntityName(), IReferenceDAO.ASC, Reference.FIELD_OBJECT_ID_ACTUAL); if (references == null) { return; } for (int i = 0; i < references.size(); i++) { List<Integer> modifications = references.get(i).getModificationsIdActual(); if (modifications == null) { break; } for (int j = 0; j < modifications.size(); j++) { Modification modification = new ModificationDAO().getById(modifications.get(j)); MyHistory mh = new MyHistory(references.get(i), modification); myHistorys.add(mh); } } sortMyHistory(); initData(); data1 = data; loadTable(); }
private void checkFields() { fields = entityType.getClass().getDeclaredFields(); listFieldsChoise = new ArrayList<String>(); listIndexFieldsChoise = new ArrayList<Integer>(); isFields = new boolean[fields.length]; numberIsField = 0; for (int i = 0; i < fields.length; i++) { if (Modifier.isFinal(fields[i].getModifiers()) || Modifier.isStatic(fields[i].getModifiers()) || fields[i].getName().equals("id") || fields[i].getType().getCanonicalName().equals(List.class.getCanonicalName())) { isFields[i] = false; } else { isFields[i] = true; numberIsField++; listFieldsChoise.add(entityType.getDescriptionOfField(fields[i].getName())); listIndexFieldsChoise.add(i); } } }
@Override public void setEntity(IEntity entity) { idDepartment = entity.getId(); }