stmt.setString(1, metadef.getId().toString()); res = stmt.executeQuery();
stmt.setString(1, propertyDefinition.getId().toString()); res = stmt.executeQuery();
stmt.setString(1, metadef.getId().toString()); res = stmt.executeQuery();
stmt.setString(1, propertyDefinition.getId().toString()); res = stmt.executeQuery();
/** * 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; }
/** * 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; }
stmt.setString(2, propDef.getId().toString()); stmt.setString(3, id.toString()); stmt.setInt(4, mappingType);
stmt.setString(2, entry.getValue().getId().toString()); stmt.setString(3, id.toString()); stmt.setInt(4, mappingType);
/** * @see org.opencms.db.I_CmsHistoryDriver#deletePropertyDefinition(org.opencms.db.CmsDbContext, org.opencms.file.CmsPropertyDefinition) */ public void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef) throws CmsDataAccessException { try { if ((internalCountProperties(dbc, metadef, CmsProject.ONLINE_PROJECT_ID) != 0) || (internalCountProperties(dbc, metadef, CmsUUID.getOpenCmsUUID()) != 0)) { // HACK: to get an offline project throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_ERROR_DELETING_PROPERTYDEF_1, metadef.getName())); } // delete the historical property definition Query q = m_sqlManager.createQuery(dbc, C_PROPERTYDEF_DELETE_HISTORY); q.setParameter(1, metadef.getId().toString()); @SuppressWarnings("unchecked") List<CmsDAOHistoryPropertyDef> res = q.getResultList(); for (CmsDAOHistoryPropertyDef hpd : res) { m_sqlManager.remove(dbc, hpd); } } catch (PersistenceException e) { throw new CmsDataAccessException( Messages.get().container(Messages.ERR_GENERIC_SQL_1, Messages.ERR_JPA_PERSITENCE_1), e); } }
/** * @see org.opencms.db.I_CmsHistoryDriver#deletePropertyDefinition(org.opencms.db.CmsDbContext, org.opencms.file.CmsPropertyDefinition) */ public void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef) throws CmsDataAccessException { Connection conn = null; PreparedStatement stmt = null; try { if ((internalCountProperties(dbc, metadef, CmsProject.ONLINE_PROJECT_ID) != 0) || (internalCountProperties(dbc, metadef, CmsUUID.getOpenCmsUUID()) != 0)) { // HACK: to get an offline project throw new CmsDbConsistencyException( Messages.get().container(Messages.ERR_ERROR_DELETING_PROPERTYDEF_1, metadef.getName())); } // delete the historical property definition conn = m_sqlManager.getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, "C_PROPERTYDEF_DELETE_HISTORY"); stmt.setString(1, metadef.getId().toString()); stmt.executeUpdate(); } 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, null); } }
q.setParameter(1, metadef.getId().toString()); @SuppressWarnings("unchecked") List<I_CmsDAOPropertyDef> res = q.getResultList();
/** * @see org.opencms.db.I_CmsHistoryDriver#deletePropertyDefinition(org.opencms.db.CmsDbContext, org.opencms.file.CmsPropertyDefinition) */ public void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef) throws CmsDataAccessException { Connection conn = null; PreparedStatement stmt = null; try { if ((internalCountProperties(dbc, metadef, CmsProject.ONLINE_PROJECT_ID) != 0) || (internalCountProperties(dbc, metadef, CmsUUID.getOpenCmsUUID()) != 0)) { // HACK: to get an offline project throw new CmsDbConsistencyException(Messages.get().container( Messages.ERR_ERROR_DELETING_PROPERTYDEF_1, metadef.getName())); } // delete the historical property definition conn = m_sqlManager.getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, "C_PROPERTYDEF_DELETE_HISTORY"); stmt.setString(1, metadef.getId().toString()); stmt.executeUpdate(); } 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, null); } }
size += getMemorySize(propDef.getId());
stmt.setString(1, metadef.getId().toString()); stmt.executeUpdate(); m_sqlManager.closeAll(dbc, null, stmt, null);
size += getMemorySize(propDef.getId());
stmt.setString(1, metadef.getId().toString()); stmt.executeUpdate(); m_sqlManager.closeAll(dbc, null, stmt, null);
hp.setPropertyDefId(propDef.getId().toString()); hp.setPropertyMappingId(id.toString()); hp.setPropertyMappingType(mappingType);
q.setParameter(1, id.toString()); q.setParameter(2, Integer.valueOf(mappingType)); q.setParameter(3, propertyDefinition.getId().toString()); @SuppressWarnings("unchecked") List<I_CmsDAOProperties> res = q.getResultList(); p.setPropertyDefId(propertyDefinition.getId().toString()); p.setPropertyMappingId(id.toString()); p.setPropertyMappingType(mappingType); q.setParameter(1, propertyDefinition.getId().toString()); q.setParameter(2, id.toString()); q.setParameter(3, Integer.valueOf(mappingType));
dbc, dbc.currentProject().getUuid(), propDef.getId(), folder.getRootPath(), value);
dbc, dbc.currentProject().getUuid(), propDef.getId(), folder.getRootPath(), value);