@Override public JAXBElement<?> map(ArrayItem item, JAXBElement<?> origin) { JAXBElement<?> source = origin; if (origin == null) { if (item instanceof ExtentItem) { source = factory.createPhysicalDescriptionTypeExtent(null); } else if (item instanceof NoteItem) { NoteItem noteItem = (NoteItem) item; NoteType noteType = factory.createNoteType(); noteType.setAtType(noteItem.getType()); source = factory.createPhysicalDescriptionTypeNote(noteType); } else { throw new IllegalStateException("unsupported array item: " + item.getClass()); } } if (item instanceof ExtentItem) { ExtentItem extentItem = (ExtentItem) item; JAXBElement<String> extentSource = (JAXBElement<String>) source; // delete with empty string to prevent XML nil extentSource.setValue(extentItem.getValue() != null ? extentItem.getValue() : ""); } else if (item instanceof NoteItem && !((NoteItem) item).ignore) { NoteItem noteItem = (NoteItem) item; NoteType noteType = (NoteType) source.getValue(); noteType.setValue(noteItem.getValue()); } return source; }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (ACTIVITY_EDIT == requestCode) { if (RESULT_OK == resultCode) { // Toast.makeText(getApplicationContext(), "result", Toast.LENGTH_LONG).show(); NoteItem noteItem = new NoteItem(); String strAction = data.getStringExtra("ACTION"); noteItem.m_nLocalId = data.getIntExtra("NOTE_LOCAL_ID", -1); // delete if (strAction.equalsIgnoreCase("DELETE")) { m_itemAdapter.deleteNoteItem(noteItem.m_nLocalId); return; } noteItem.m_nId = data.getIntExtra("NOTE_ID", -1); noteItem.m_nType = data.getIntExtra("NOTE_TYPE", 1); noteItem.m_strTitle = data.getStringExtra("NOTE_TITLE"); noteItem.setSetAt(data.getStringExtra("NOTE_SET_AT")); noteItem.setUpdatedAt(data.getStringExtra("NOTE_UPDATED_AT")); // new if (strAction.equalsIgnoreCase("NEW")) { // created at noteItem.setCreatedAt(data.getStringExtra("NOTE_CREATED_AT")); m_itemAdapter.addNoteItem(noteItem); // update } else if (strAction.equalsIgnoreCase("UPDATE")) { m_itemAdapter.updateNoteItem(noteItem); } } } }
private void updateTreatmentItem( List<ArrayItem> oldies, List<NoteItem> notes, String treatment, String type) { if (treatment != null) { NoteItem ni = getPreservationItem(oldies, type); if (ni == null) { ni = new NoteItem(null, treatment, type); notes.add(ni); } ni.setValue(treatment); ni.ignore = false; } else { NoteItem ni = getPreservationItem(oldies, type); if (ni != null) { ni.setValue(treatment); } } }
public static String getPreservationStateOfArt(List<ArrayItem> items) { NoteItem ni = getPreservationItem(items, PRESERVATION_STATE_OF_ART); return ni != null ? ni.getValue() : null; }
public static String getPreservationTreatment(List<ArrayItem> items) { NoteItem ni = getPreservationItem(items, PRESERVATION_TREATMENT); return ni != null ? ni.getValue() : null; }