protected <T extends Site.Page> Page generateChild( Confluence confluence, T child, String spaceKey, String parentPageTitle, String titlePrefix) { java.net.URI source = child.getUri(getProject(), getFileExt()); getLog() .info( String.format( "generateChild spacekey=[%s] parentPageTtile=[%s]\n%s", spaceKey, parentPageTitle, child.toString())); try { if (!isSnapshot() && isRemoveSnapshots()) { final String snapshot = titlePrefix.concat("-SNAPSHOT"); boolean deleted = ConfluenceUtils.removePage(confluence, spaceKey, parentPageTitle, snapshot); if (deleted) { getLog().info(String.format("Page [%s] has been removed!", snapshot)); } } final String pageName = String.format("%s - %s", titlePrefix, child.getName()); Page p = ConfluenceUtils.getOrCreatePage(confluence, spaceKey, parentPageTitle, pageName); if (source != null /*&& source.isFile() && source.exists() */) { final MiniTemplator t = new MiniTemplator.Builder() .setSkipUndefinedVars(true) .build(Site.processUri(source), getCharset()); addProperties(t); p.setContent(t.generateOutput()); } p = confluence.storePage(p); for (String label : child.getComputedLabels()) { confluence.addLabelByName(label, Long.parseLong(p.getId())); } child.setName(pageName); return p; } catch (Exception e) { final String msg = "error loading template"; getLog().error(msg, e); // throw new MavenReportException(msg, e); return null; } }
/** * Constructs a new Loadable of the Class or Class/Category represented by this * AbstractReferenceManufacturer * * <p>This should remain protected (vs. public) as it is for "internal use only"; it serves as a * convenience method to wrap the .newInstance call and the possible Exceptions. Other classes * should use constructObject(String) * * @param key The identifier of the Loadable to be constructed * @return The new Loadable of the Class or Class/Category represented by this * AbstractReferenceManufacturer * @throws IllegalArgumentException if the given identifier is null or empty (length is zero) */ @Override public T buildObject(String key) { if (key == null || key.equals("")) { throw new IllegalArgumentException("Cannot build empty name"); } T obj = factory.newInstance(); obj.setName(key); return obj; }
protected <T extends MaterialAvatar> void checkNameAndHashCode(T avatar) { final String NAME = "test1"; avatar.setName(NAME); avatar.initialize(); final String HASH_CODE = JsAvatar.md5(NAME); assertEquals(avatar.getName(), NAME); assertTrue(avatar.getElement().hasAttribute("data-jdenticon-hash")); assertEquals(avatar.getElement().getAttribute("data-jdenticon-hash"), HASH_CODE); }
@Override public T map(SQLiteStatement stmt) throws SQLiteException { T data = newObject(); data.setId(stmt.columnInt(0)); data.setName(stmt.columnString(1)); data.setCreatedTime(stmt.columnLong(2)); data.setUpdateTime(stmt.columnLong(3)); data.setDeleted(stmt.columnInt(4) == 1); return data; }
public static <T extends ServiceConfiguration, C extends ComponentId> T lookupByName( final Class<C> type, final String name) { if (!ComponentId.class.isAssignableFrom(type)) { throw new PersistenceException( "Unknown configuration type passed: " + type.getCanonicalName()); } final T example = (T) ServiceBuilders.lookup(type).newInstance(); example.setName(name); return lookup(example); }
protected <T extends CPPASTDeclarator> T copy(T copy, CopyStyle style) { copy.setName(name == null ? null : name.copy(style)); copy.setInitializer(initializer == null ? null : initializer.copy(style)); copy.setNestedDeclarator(nested == null ? null : nested.copy(style)); ((CPPASTDeclarator) copy).isPackExpansion = isPackExpansion; for (IASTPointerOperator pointer : getPointerOperators()) { copy.addPointerOperator(pointer.copy(style)); } return super.copy(copy, style); }
/** * Create a copy of a CDOMObject duplicating any references to the old object. (e.g. Spell, Domain * etc) * * <p>Package protected rather than private for testing only * * @param cdo The original object being copied. * @param newName The name that should be given to the new object. * @return The newly created CDOMObject. */ @SuppressWarnings("unchecked") <T extends CDOMObject> T cloneInMasterLists(T cdo, String newName) { T newObj; try { newObj = (T) cdo.clone(); newObj.setName(newName); getListContext().cloneInMasterLists(cdo, newObj); } catch (CloneNotSupportedException e) { Logging.errorPrint("Failed to clone " + cdo, e); return null; } return newObj; }
public T build(T parent, String code, String name) { try { T t = clTask.newInstance(); t.setParent(parent); t.setCode(code); t.setName(name); return t; } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } throw new RuntimeException("x"); }
/** * Create a value descriptor of given type and name and initializes it. * * @param type The class type. * @param name The name * @param <T> The type. * @return The initialized descriptor. */ private <T extends ValueDescriptor> T createValue(Class<T> type, String name) { if (name != null) { this.arrayValueDescriptor = null; } String valueName; if (arrayValueDescriptor != null) { valueName = "[" + getListValue(this.arrayValueDescriptor).size() + "]"; } else { valueName = name; } T valueDescriptor = visitorHelper.getValueDescriptor(type); valueDescriptor.setName(valueName); return valueDescriptor; }
/** * Returns the singleton application object matching the given {@code applicationClass} within * the given {@code database}. */ @SuppressWarnings("unchecked") public static <T extends Application> T getInstanceUsing( Class<T> applicationClass, Database database) { ObjectType type = database.getEnvironment().getTypeByClass(applicationClass); Query<T> query = Query.from(applicationClass).where("_type = ?", type.getId()).using(database); T app = query.first(); if (app == null) { DistributedLock lock = DistributedLock.Static.getInstance(database, applicationClass.getName()); lock.lock(); try { app = query.clone().noCache().first(); if (app == null) { app = (T) type.createObject(null); app.setName(type.getDisplayName()); app.saveImmediately(); return app; } } finally { lock.unlock(); } } String oldName = app.getName(); String newName = type.getDisplayName(); if (!ObjectUtils.equals(oldName, newName)) { app.setName(newName); app.save(); } return app; }
public <T extends Field> T addField(String fieldName, T field) { Validate.notNull(field); field.setName(fieldName); final String caption = AnnotationUtils.getFieldCaption(MODEL_CLASS, fieldName); final RowConstraints row = new RowConstraints(); row.setFillHeight(Boolean.TRUE); row.setValignment(VPos.TOP); getGridPane().getRowConstraints().addAll(row); getGridPane() .addRow( getController().getFields().size(), new Label(caption), getController().registerField(field, fieldName).getUI()); return field; }
@Override public T cursorToEntity(Cursor cursor, int index) { T entity = null; try { entity = getEntityClass().newInstance(); int i = index; entity.setId(cursor.getLong(i)); i++; entity.setName(cursor.getString(i)); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return entity; }
public void setConfig(T config) { this.config = config; if (config != null && config.isSetName()) { config.setName(config.getName().trim()); } if (settings != null) settings.release(); if (!config.isSetSettings()) config.addNewSettings(); settings = new XmlBeansSettingsImpl( this, parent == null ? SoapUI.getSettings() : parent.getSettings(), this.config.getSettings()); }
public <T extends ServiceConfiguration> T remove(final T config) { final EntityTransaction db = Entities.get(config.getClass()); try { final T searchConfig = (T) config.getClass().newInstance(); searchConfig.setName(config.getName()); final T exists = Entities.uniqueResult(searchConfig); Entities.delete(exists); db.commit(); EventRecord.here( ServiceConfigurations.class, EventClass.COMPONENT, EventType.COMPONENT_DEREGISTERED, config.toString()) .info(); } catch (final NoSuchElementException ex) { db.rollback(); } catch (final PersistenceException ex) { LOG.debug(ex); EventRecord.here( ServiceConfigurations.class, EventClass.COMPONENT, EventType.COMPONENT_DEREGISTERED, "FAILED", config.toString()) .error(); db.rollback(); throw ex; } catch (final Throwable ex) { LOG.debug(ex); EventRecord.here( ServiceConfigurations.class, EventClass.COMPONENT, EventType.COMPONENT_DEREGISTERED, "FAILED", config.toString()) .error(); db.rollback(); throw new PersistenceException( "Service configuration removal failed for: " + LogUtil.dumpObject(config), ex); } return config; }
@Override protected void readAttributes(XMLStreamReader reader, T object) { object.setName(reader.getAttributeValue(null, NodeValidate.s_nameField)); object.setDescription(reader.getAttributeValue(null, NodeValidate.s_descName)); object.setLocation(reader.getAttributeValue(null, NodeValidate.s_locationField)); object.setLocationExpressionLanguage( reader.getAttributeValue(null, NodeValidate.s_locExprLangName)); object.setFieldName(reader.getAttributeValue(null, NodeValidate.s_fieldName)); Integer value = XMIReaderUtil.convertToInteger(reader.getAttributeValue(null, NodeValidate.s_minName)); if (value != null) { object.setMinOccurs(value); } value = XMIReaderUtil.convertToInteger(reader.getAttributeValue(null, NodeValidate.s_maxName)); if (value != null) { object.setMaxOccurs(value); } }
public void setName(String name) { String old = getName(); name = name.trim(); config.setName(name); notifyPropertyChanged(NAME_PROPERTY, old, name); }