private boolean isIndexPresent() throws SQLException, GenericEntityException { final Connection connection = getDatabaseConnection(); try { DelegatorInterface delegatorInterface = getOfBizDelegator().getDelegatorInterface(); GenericHelper helper = delegatorInterface.getEntityHelper(ENTITY_NAME); DatabaseUtil dbUtil = new DatabaseUtil(helper.getHelperName()); final Map<String,Set<String>> indexInfo = dbUtil.getIndexInfo(ImmutableSet.of(TABLE_NAME), new ArrayList<String>(), true); Set<String> indexes = new HashSet<String>(); for (Set<String> i : indexInfo.values()) { indexes.addAll(i); } return indexes.contains(INDEX_NAME.toUpperCase()); } finally { connection.close(); } }
private void kickOfbizInTheGuts() { DelegatorInterface delegatorInterface = ComponentAccessor.getComponent(DelegatorInterface.class); Map<String,ModelEntity> modelEntities = delegatorInterface.getModelEntityMapByGroup("default"); try { GenericHelper helper = delegatorInterface.getEntityHelper("ProjectKey"); // This will loop over all entities and add any that are missing - just like we do on startup. helper.checkDataSource(modelEntities, null, true); } catch (GenericEntityException ex) { throw new DataAccessException(ex); } } }
private EntityListIterator getListIterator(int pageNumber) throws GenericEntityException { GenericHelper helper = genericDelegator.getEntityHelper(entityName); ModelEntity modelEntity = genericDelegator.getModelEntity(entityName); EntityFindOptions entityFindOptions = new EntityFindOptions(); entityFindOptions.setOffset(pageNumber * pageSize); entityFindOptions.setMaxResults(pageSize); return helper.findListIteratorByCondition(modelEntity, entityCondition, null, null, orderBy, entityFindOptions); }
final GenericHelper entityHelper = delegatorInterface.getEntityHelper(entityName); final ModelEntity modelEntity = delegatorInterface.getModelEntity(entityName);
final GenericHelper entityHelper = delegatorInterface.getEntityHelper(entityName);
final GenericHelper entityHelper = delegatorInterface.getEntityHelper(entityName);
final GenericHelper entityHelper = delegatorInterface.getEntityHelper(entityName);
@Override public void doUpgrade(boolean setupMode) throws Exception { if(isIndexPresent()) { DelegatorInterface delegatorInterface = getOfBizDelegator().getDelegatorInterface(); GenericHelper helper = delegatorInterface.getEntityHelper(ENTITY_NAME); DatabaseUtil dbUtil = new DatabaseUtil(helper.getHelperName()); ModelEntity issueEntity = delegatorInterface.getModelEntity(ENTITY_NAME); ModelIndex issueKeyIndex = new ModelIndex(); issueKeyIndex.setName(INDEX_NAME); final String error = dbUtil.deleteDeclaredIndex(issueEntity, issueKeyIndex); if ( error != null) { throw new RuntimeException(String.format("There was a problem dropping index issue_key: %s " + "-- You should drop this index manually and restart JIRA instance.", error)); } } else { log.info("Index issue_key not present. Skipping this task."); } }