/** * Makes a deep copy of the source entity. All referenced entities and collections will be copied as well. */ @SuppressWarnings("unchecked") public <T extends Entity> T deepCopy(T source) { CachingEntitiesHolder entityFinder = new CachingEntitiesHolder(); Entity destination = entityFinder.create(source.getClass(), source.getId()); deepCopy(source, destination, entityFinder); return (T) destination; }
@Override public <E extends Entity> E reload(E entity, View view, @Nullable MetaClass metaClass, boolean loadDynamicAttributes) { MetadataTools metadataTools = AppBeans.get(MetadataTools.class); E clone = metadataTools.deepCopy(entity);
@Override public Report copyReport(Report source) { source = reloadEntity(source, REPORT_EDIT_VIEW_NAME); Report copiedReport = metadata.getTools().deepCopy(source); copiedReport.setId(uuidSource.createUuid()); copiedReport.setName(generateReportName(source.getName())); copiedReport.setCode(null); for (ReportTemplate copiedTemplate : copiedReport.getTemplates()) { copiedTemplate.setId(uuidSource.createUuid()); } storeReportEntity(copiedReport); return copiedReport; }