Search in sources :

Example 1 with I_AD_Archive

use of org.compiere.model.I_AD_Archive in project metasfresh-webui-api by metasfresh.

the class DocumentAttachments method deleteEntry.

public void deleteEntry(final DocumentId id) {
    final IPair<String, Integer> prefixAndId = toPrefixAndEntryId(id);
    final String idPrefix = prefixAndId.getLeft();
    final int entryId = prefixAndId.getRight();
    if (ID_PREFIX_Attachment.equals(idPrefix)) {
        attachmentsBL.deleteEntryForModel(recordRef, entryId);
        notifyRelatedDocumentTabsChanged();
    } else if (ID_PREFIX_Archive.equals(idPrefix)) {
        final I_AD_Archive archive = Services.get(IArchiveDAO.class).retrieveArchiveOrNull(Env.getCtx(), recordRef, entryId);
        if (archive == null) {
            throw new EntityNotFoundException(id.toJson());
        }
        InterfaceWrapperHelper.delete(archive);
    } else {
        throw new EntityNotFoundException(id.toJson());
    }
}
Also used : I_AD_Archive(org.compiere.model.I_AD_Archive) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException)

Example 2 with I_AD_Archive

use of org.compiere.model.I_AD_Archive in project metasfresh-webui-api by metasfresh.

the class DocumentAttachments method getEntry.

public IDocumentAttachmentEntry getEntry(final DocumentId id) {
    final IPair<String, Integer> prefixAndId = toPrefixAndEntryId(id);
    final String idPrefix = prefixAndId.getLeft();
    final int entryId = prefixAndId.getRight();
    if (ID_PREFIX_Attachment.equals(idPrefix)) {
        final AttachmentEntry entry = attachmentsBL.getEntryById(recordRef, entryId);
        if (entry == null) {
            throw new EntityNotFoundException(id.toJson());
        }
        return DocumentAttachmentEntry.of(id, entry);
    } else if (ID_PREFIX_Archive.equals(idPrefix)) {
        final I_AD_Archive archive = Services.get(IArchiveDAO.class).retrieveArchiveOrNull(Env.getCtx(), recordRef, entryId);
        if (archive == null) {
            throw new EntityNotFoundException(id.toJson());
        }
        return DocumentArchiveEntry.of(id, archive);
    } else {
        throw new EntityNotFoundException(id.toJson());
    }
}
Also used : I_AD_Archive(org.compiere.model.I_AD_Archive) AttachmentEntry(de.metas.attachments.AttachmentEntry) I_AD_AttachmentEntry(org.compiere.model.I_AD_AttachmentEntry) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException)

Aggregations

EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)2 I_AD_Archive (org.compiere.model.I_AD_Archive)2 AttachmentEntry (de.metas.attachments.AttachmentEntry)1 I_AD_AttachmentEntry (org.compiere.model.I_AD_AttachmentEntry)1