protected T createInstance() { try { return tipo.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw SingularException.rethrow(e); } } }
protected T createInstance() { try { return tipo.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw SingularException.rethrow(e); } }
protected static <T> T newInstanceOf(Class<T> classe) { try { return classe.newInstance(); } catch (Exception e) { throw SingularException.rethrow("Erro instanciando entidade " + classe.getName(), e); } } }
protected static <T> T newInstanceOf(Class<T> targetClass) { try { return targetClass.newInstance(); } catch (Exception e) { throw SingularException.rethrow("Erro instanciando entidade " + targetClass.getName(), e); } } }
@Nonnull @Override public InputStream getContentAsInputStream() { try { return new FileInputStream(path); } catch (FileNotFoundException e) { throw SingularException.rethrow(e.getMessage(), e); } }
final void setProcessDefinition(ProcessDefinition<?> processDefinition) { if (processDefinitionRef != null) { throw SingularException.rethrow("Erro Interno"); } processDefinitionRef = RefProcessDefinition.of(processDefinition); }
public static int getInt(@Nonnull String value) throws NumberFormatException { if (value == null) { throw new NumberFormatException("Valor null"); } try { return Integer.parseInt(removeCharacterFromString(value.trim(), '.')); } catch (NumberFormatException e) { throw SingularException.rethrow("Valor inválido (" + value + ")!", e); } }
public T getOrException(@Nonnull ID id) { Optional<T> result = get(id); if (result.isPresent()) { return result.get(); } throw SingularException.rethrow("Não foi encontrado a entidade " + entityClass.getName() + " com ID=" + id); }
private InputStream getSchemaRelativeToBaseUri(String baseUri, String systemId) { try { URL url = new URL(baseUri + systemId); return urlToInputStream(url, "text/xml"); } catch (Exception e) { throw SingularException.rethrow(e.getMessage(), e); } }
protected MappingId parseId(String instanciaID) { if (instanciaID == null || instanciaID.length() < 1) { throw SingularException.rethrow("O ID da instância não pode ser nulo ou vazio"); } String parts[] = instanciaID.split("\\."); String sigla = parts[parts.length - 2]; String id = parts[parts.length - 1]; return new MappingId(sigla, Integer.parseInt(id)); }
@Nonnull public T findOrException(@Nonnull ID id) { Optional<T> result = find(Objects.requireNonNull(id)); if (result.isPresent()) { return result.get(); } throw SingularException.rethrow("Não foi encontrado a entidade " + entityClass.getName() + " com ID=" + id); }
@Override public AttachmentRef addAttachment(File file, long length, String name, String hashSha1) { try (FileInputStream fs = new FileInputStream(file)) { T attachment = attachmentDao.insert(fs, length, name, hashSha1); return createRef(attachment); } catch (IOException e) { throw SingularException.rethrow(e); } }
private void rollbackFilterState() { try { if (filterState != null && filterPanel != null && filterPanel.getInstanceModel().getObject() != null) { FormStateUtil.restoreState(filterPanel.getInstanceModel().getObject(), filterState); } } catch (Exception e) { throw SingularException.rethrow(e.getMessage(), e); } }
@Override public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { try { CharArrayWriter baos = new CharArrayWriter(0); DocumentationDefinitionResolver.get().renderDocumentationHTML(typeLoader.loadTypeOrException(stypeClass), baos); replaceComponentTagBody(markupStream, openTag, baos.toString()); } catch (Exception e) { throw SingularException.rethrow(e.getMessage(), e); } } };
public String getCustomLabel(SInstance instance) { SType<?> type = getType(instance); if (customLabel == null && type != null) { return getType(instance).getAttributeValue(SPackageBasic.ATR_LABEL); } if (type == null && displayFunction == null) { throw SingularException.rethrow("Não foi especificado label para coluna nem através do tipo nem através de displayFunction específica."); } return customLabel; }
public String getCustomLabel(SInstance instance) { SType<?> type = getType(instance); if (customLabel == null && type != null) { return getType(instance).getAttributeValue(SPackageBasic.ATR_LABEL); } if (type == null && displayFunction == null) { throw SingularException.rethrow("Não foi especificado label para coluna nem através do tipo nem através de displayFunction específica."); } return customLabel; }
@Override public void trigger(IScheduledJob scheduledJob) { try { quartzSchedulerFactory.triggerJob(new JobKey(scheduledJob.getId())); } catch (SchedulerException e) { throw SingularException.rethrow(e); } }
@Override public void trigger(IScheduledJob scheduledJob) { try { quartzSchedulerFactory.triggerJob(new JobKey(scheduledJob.getId())); } catch (SchedulerException e) { throw SingularException.rethrow(e); } }
@Override public AttachmentCopyContext<FileSystemAttachmentRef> copy(IAttachmentRef attachmentRef, SDocument document) { try (InputStream is = attachmentRef.getContentAsInputStream()){ return new AttachmentCopyContext<>(addAttachment(is, attachmentRef.getSize(), attachmentRef.getName(), attachmentRef.getHashSHA1())); } catch (Exception e) { throw SingularException.rethrow(e); } }
@Override public void schedule(IScheduledJob scheduledJob) { try { quartzSchedulerFactory.addTrigger( QuartzTriggerFactory.newTrigger() .withIdentity(scheduledJob.getId()) .forJob(scheduledJob::run) .withScheduleData(scheduledJob.getScheduleData()).build()); } catch (Exception e) { throw SingularException.rethrow(e); } }