/** * Creates the CMIS property definition for an OpenCms resource property definition.<p> * * @param cmsDef the OpenCms property definition * * @return the CMIS property definition */ PropertyDefinition<?> createOpenCmsPropertyDefinition(CmsPropertyDefinition cmsDef) { return createPropDef( PROPERTY_PREFIX + cmsDef.getName(), cmsDef.getName(), cmsDef.getName(), PropertyType.STRING, Cardinality.SINGLE, Updatability.READWRITE, false, false); }
/** * Returns a clone of this Objects instance.<p> * * @return a clone of this instance */ @Override public Object clone() { return new CmsPropertyDefinition(m_id, m_name, m_type); }
stmt.setString(2, propDef.getId().toString()); stmt.setString(3, id.toString()); stmt.setInt(4, mappingType);
CmsPropertyDefinition.checkPropertyName(name);
stmt.setString(2, entry.getValue().getId().toString()); stmt.setString(3, id.toString()); stmt.setInt(4, mappingType);
CmsPropertyDefinition.checkPropertyName(name);
/** * Returns the count of properties for a property definition.<p> * * @param dbc the current database context * @param propertyDefinition the property definition to test * @param projectId the ID of the current project * * @return the amount of properties for a property definition * @throws CmsDataAccessException if something goes wrong */ protected int internalCountProperties(CmsDbContext dbc, CmsPropertyDefinition propertyDefinition, CmsUUID projectId) throws CmsDataAccessException { int count = 0; try { // create statement Query q = m_sqlManager.createQuery(dbc, projectId, C_PROPERTIES_READALL_COUNT); q.setParameter(1, propertyDefinition.getId().toString()); try { count = CmsDataTypeUtil.numberToInt((Number)q.getSingleResult()); } catch (NoResultException e) { throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_COUNTING_PROPERTIES_1, propertyDefinition.getName())); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } return count; }
/** * Gets a list of names of OpenCms property definitions.<p> * * @return the list of OpenCms property names */ public List<String> getCmsPropertyNames() { refresh(); List<String> result = new ArrayList<String>(); for (CmsPropertyDefinition propDef : m_cmsPropertyDefinitions) { result.add(propDef.getName()); } return result; }
/** * Returns a clone of this Objects instance.<p> * * @return a clone of this instance */ @Override public Object clone() { return new CmsPropertyDefinition(m_id, m_name, m_type); }
hp.setPropertyDefId(propDef.getId().toString()); hp.setPropertyMappingId(id.toString()); hp.setPropertyMappingType(mappingType);
/** * Returns the amount of properties for a propertydefinition.<p> * * @param dbc the current database context * @param metadef the propertydefinition to test * @param projectId the ID of the current project * * @return the amount of properties for a propertydefinition * @throws CmsDataAccessException if something goes wrong */ protected int internalCountProperties(CmsDbContext dbc, CmsPropertyDefinition metadef, CmsUUID projectId) throws CmsDataAccessException { int returnValue; try { // create statement Query q = m_sqlManager.createQuery(dbc, projectId, C_PROPERTIES_READALL_COUNT); q.setParameter(1, metadef.getId().toString()); try { returnValue = CmsDataTypeUtil.numberToInt((Number)q.getSingleResult()); } catch (NoResultException e) { throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_NO_PROPERTIES_FOR_PROPERTYDEF_1, metadef.getName())); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } return returnValue; }
/** * Gets the names of all available properties.<p> * * @param cms the CMS context * * @return the list of all property names * * @throws CmsException if something goes wrong */ private List<String> getPropertyNames(CmsObject cms) throws CmsException { List<CmsPropertyDefinition> propDefs = cms.readAllPropertyDefinitions(); List<String> result = new ArrayList<String>(); for (CmsPropertyDefinition propDef : propDefs) { result.add(propDef.getName()); } return result; }
/** * @see org.opencms.db.I_CmsVfsDriver#readPropertyDefinitions(org.opencms.db.CmsDbContext, CmsUUID) */ public List readPropertyDefinitions(CmsDbContext dbc, CmsUUID projectId) throws CmsDataAccessException { ArrayList propertyDefinitions = new ArrayList(); ResultSet res = null; PreparedStatement stmt = null; Connection conn = null; try { conn = m_sqlManager.getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, projectId, "C_PROPERTYDEF_READALL"); res = stmt.executeQuery(); while (res.next()) { propertyDefinitions.add(new CmsPropertyDefinition( new CmsUUID(res.getString(m_sqlManager.readQuery("C_PROPERTYDEF_ID"))), res.getString(m_sqlManager.readQuery("C_PROPERTYDEF_NAME")), CmsPropertyDefinition.CmsPropertyType.valueOf(res.getInt(m_sqlManager.readQuery("C_PROPERTYDEF_TYPE"))))); } } catch (SQLException e) { throw new CmsDbSqlException(Messages.get().container( Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)), e); } finally { m_sqlManager.closeAll(dbc, conn, stmt, res); } return propertyDefinitions; }
dbc, dbc.currentProject().getUuid(), propDef.getId(), folder.getRootPath(), value);
/** * Creates the HTML String for the active properties overview of the current resource.<p> * * @return the HTML output String for active properties of the resource */ public String buildActivePropertiesList() { StringBuffer retValue = new StringBuffer(256); List<CmsPropertyDefinition> propertyDef = new ArrayList<CmsPropertyDefinition>(); try { // get all property definitions propertyDef = getCms().readAllPropertyDefinitions(); } catch (CmsException e) { // should usually never happen if (LOG.isInfoEnabled()) { LOG.info(e.getLocalizedMessage()); } } Iterator<CmsPropertyDefinition> j = propertyDef.iterator(); int i = 0; while (j.hasNext()) { CmsPropertyDefinition curProperty = j.next(); retValue.append(CmsEncoder.escapeXml(curProperty.getName())); if ((i + 1) < propertyDef.size()) { retValue.append("<br>"); } i++; } return retValue.toString(); }
/** * @see org.opencms.db.I_CmsVfsDriver#readPropertyDefinitions(org.opencms.db.CmsDbContext, CmsUUID) */ public List<CmsPropertyDefinition> readPropertyDefinitions(CmsDbContext dbc, CmsUUID projectId) throws CmsDataAccessException { ArrayList<CmsPropertyDefinition> propertyDefinitions = new ArrayList<CmsPropertyDefinition>(); ResultSet res = null; PreparedStatement stmt = null; Connection conn = null; try { conn = m_sqlManager.getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, projectId, "C_PROPERTYDEF_READALL"); res = stmt.executeQuery(); while (res.next()) { propertyDefinitions.add( new CmsPropertyDefinition( new CmsUUID(res.getString(m_sqlManager.readQuery("C_PROPERTYDEF_ID"))), res.getString(m_sqlManager.readQuery("C_PROPERTYDEF_NAME")), CmsPropertyDefinition.CmsPropertyType.valueOf( res.getInt(m_sqlManager.readQuery("C_PROPERTYDEF_TYPE"))))); } } catch (SQLException e) { throw new CmsDbSqlException( Messages.get().container(Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)), e); } finally { m_sqlManager.closeAll(dbc, conn, stmt, res); } return propertyDefinitions; }
dbc, dbc.currentProject().getUuid(), propDef.getId(), folder.getRootPath(), value);