/** * constructor * * @param entityManager persistence entity manager */ public GenericLocalServiceBean(EntityManager entityManager) { this(entityManager, ENV.get("service.use.database.replication", false)); }
/** * @return Returns the presentationHelper. */ public <PH extends BeanPresentationHelper<T>> PH getPresentationHelper() { if (presentationHelper == null) { presentationHelper = ENV.get(BeanPresentationHelper.class).createHelper(this); } return (PH) presentationHelper; }
@Override protected IGenericService getGenService() { if (service == null) { IGenericService s = ENV.get(IGenericService.class); if (s != null) { service = s; } else { // EntityManager entityManager = (EntityManager) getSession(false); // service = new GenericLocalServiceBean(entityManager); service = new GenericLocalServiceBean(); } } return service; }
/** * getPresentation * * @return */ @Override public IPresentable getPresentation() { //TODO: create presentation helper through MultipleInheritanceProxy if (presentable == null) { presentable = ENV.get(BeanPresentationHelper.class).createPresentable(this); } return presentable; }
private Volatile<T> getVolatileValue() { if (value == null) value = new Volatile<T>(ENV.get("cache.expire.milliseconds.attributecover", 50)); return value; }
@Override public Object action() throws Exception { if (htmlFile.canRead()) { return String.valueOf(FileUtil.getFileData(htmlFile.getPath(), null)); } else if (pdfFile.canRead()) { String url = ENV.get("service.url") + "/" + helpFile + "pdf"; return /*url;//*/decorate(url, url); } else { return page("No help found (" + tooltip + ")"); } }
/** * constructor * * @param beanClass */ public BeanDefinition(Class<T> beanClass) { super((Class<T>) (ENV.get("beandef.ignore.anonymous.fields", true) ? getDefiningClass(beanClass) : beanClass)); name = beanClass == UNDEFINED.getClass() ? /*"undefined"*/StringUtil.STR_ANY : super.getName(); }
@Override public void run() { LOG.info("preparing backup of local database " + persistence.getConnectionUrl()); try { BeanContainer.instance().executeStmt( ENV.get("app.backup.statement", "backup to temp/database-daily-backup.zip"), true, null); } catch (Exception e) { LOG.error(e.toString()); } } });
@Override public Object action() throws Exception { return ENV.get(IPageBuilder.class).build(vsession.getValue(), bean, null, false); } });
@Override public Object action() throws Exception { //TODO: file selection, and ant-variable insertion... String var_start = ENV.get("export.var.start", "##"); String var_end = ENV.get("export.var.end", "##"); String content = String.valueOf(FileUtil.getFileData(exportFileName, null)); content = StringUtil.insertProperties(content, BeanUtil.toValueMap(((Bean) bean).getInstance()), var_start, var_end); String newFileName = FileUtil.getUniqueFileName(exportFileName); FileUtil.writeBytes(content.getBytes(), newFileName, false); String url = ENV.get("service.url") + "/" + newFileName; return decorate(url, url); }
@Override public boolean isEnabled() { return super.isEnabled() && hasMode(MODE_EDITABLE) && (hasSelection() || !ENV.get("app.event.fire.onselectionchange", false)); }
/** * {@inheritDoc} */ @Override public boolean isEnabled() { return super.isEnabled() && hasMode(MODE_CREATABLE) && (hasSelection() || !ENV.get("app.event.fire.onselectionchange", false)); }
@Override public Collection<TYPE> matchingObjects(Object prefix) { String input = Util.asString(prefix).trim(); TYPE exampleBean = createExampleBean(input, true); Collection<TYPE> values = BeanContainer.instance().getBeansByExample(exampleBean, true, 0, ENV.get("websocket.intputassist.maxitemcount", 20)); return values; }
@Commit private void initDeserializing() { v = new Volatile<T>(ENV.get("cache.expire.milliseconds.pathexpression", 500)); attributePath = splitChain(expression); }
/** * generatedValue * * @param attribute to be checked * @return true, if attribute is annotated as generated value or if environment "value.id.fill.uuid" is true and the * type is string or number. */ public static final boolean isGeneratedValue(IAttributeDefinition<?> attribute) { return attribute.generatedValue() || (attribute.id() && ENV.get("value.id.fill.uuid", true) && (String.class .isAssignableFrom(attribute.getType()) || NumberUtil.isNumber(attribute.getType()))); }
@Override public Object action() throws Exception { collector.shiftSortIndexes(); sortIndex = 0; isSortUpDirection = isSortUpDirection ? false : true; if (ENV.get("collector.sort.reload.data", false)) collector.getBeanFinder().getData(); else collector.sort(); return collector; }
@SuppressWarnings("static-access") public static Replication current() { if (Persistence.exists()) { return ENV.get(XmlUtil.class).loadXml(getPath(FILE_PERSISTENCE_BEAN), Replication.class); } else { return new Replication(); } }
@Override public COLLECTIONTYPE action() throws Exception { //TODO: fire refresh event searchStatus = Messages.getFormattedString("tsl2nano.searchdialog.searchrunning"); ENV.get(Profiler.class).starting(this, getName()); COLLECTIONTYPE result = (COLLECTIONTYPE) getBeanFinder().getData((String) getParameter(0)); searchStatus = Messages.getFormattedString("tsl2nano.searchdialog.searchresultcount", result.size()); if (openAction != null) { openAction.setDefault(true); } return result; }
@Override public String save() throws IOException { FileUtil.removeToBackup(getPath(getBeanFileName())); ENV.get(XmlUtil.class).saveXml(getPath(getBeanFileName()), this); saveJdbcProperties(); return null; }
/** * override this method to define additional attributes for your bean. this implementation evaluates the id of the * bean and return it's attributes if the id is another bean! */ public void defineAdditionalAttributes() { if (ENV.get("beandef.define.additional.attributes", true)) { BeanAttribute id = BeanContainer.getIdAttribute(bean.getClazz()); if (id != null && !BeanUtil.isStandardType(id.getDeclaringClass()) && bean.hasAttribute(id.getName())) { bean.combineRelationAttributes(id.getName()); } } }