public Long getNextId() { return delegatorInterface.getNextSeqId(ATTACHMENT_ENTITY_NAME); } }
private DelegatorInterface mockDelegatorInterfaceImpl() throws GenericEntityException { final DelegatorInterface delegator = Mockito.mock(DelegatorInterface.class); Mockito.when(delegator.getNextSeqId(anyString())).thenAnswer(new Answer<Long>() { private final AtomicLong counter = new AtomicLong(10000L); @Override public Long answer(final InvocationOnMock invocation) throws Throwable { return counter.getAndIncrement(); } }); Mockito.when(delegator.countByCondition(anyString(), anyString(), any(EntityCondition.class), any(EntityFindOptions.class))) .thenAnswer(new Answer<Integer>() { @Override public Integer answer(final InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); assertNull("Counting by field not implemented", args[1]); return findByCondition((String)args[0], (EntityCondition)args[2], null, null).size(); } }); return delegator; }
@Nullable public Function<String, String> get(final String entityName) { final ModelEntity table = delegatorInterface.getModelEntity(entityName); return (table != null) ? new FieldTypeResolverFunction(table) : null; } }
public GenericValue createValue(final String entityName, final Map<String, Object> fields) { try { final Map<String, Object> params = (fields == null) ? new HashMap<String, Object>(2) : new HashMap<String, Object>(fields); if (params.get("id") == null) { final Long id = delegatorInterface.getNextSeqId(entityName); params.put("id", id); } final GenericValue v = delegatorInterface.makeValue(entityName, params); v.create(); return v; } catch (final GenericEntityException ex) { throw new DataAccessException(ex); } }
GroupEntityConditionFactory(OfBizDelegator ofBizDelegator) { final ModelEntity modelEntity = ofBizDelegator.getDelegatorInterface().getModelEntity(GroupAttributeEntity.ENTITY); attributeTableName = modelEntity.getTableName(ofBizDelegator.getDelegatorInterface().getEntityHelperName(GroupAttributeEntity.ENTITY)); }
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); }
private GenericValue makeUpdatedEntry(CacheKey cacheKey, Integer type) throws GenericEntityException { final FieldMap fieldMap = cacheKey.toFieldMap(); final List<GenericValue> list = genericDelegator.findByAnd(PROPERTY_ENTRY, fieldMap); if (list == null || list.isEmpty()) { final Long id = genericDelegator.getNextSeqId(PROPERTY_ENTRY); return genericDelegator.makeValue(PROPERTY_ENTRY, fieldMap .add(ID, id) .add(TYPE, type)); } final GenericValue existingPropertyEntry = (list.size() == 1) ? list.get(0) : selectMaximumIdAndRemoveOthers(list); removeOrphanedValueIfTypeChanged(type, existingPropertyEntry); return existingPropertyEntry; }
public int removeByAnd(final String entityName, final Map map) throws DataAccessException { try { return delegatorInterface.removeByAnd(entityName, map); } catch (final GenericEntityException e) { throw new DataAccessException(e); } }
private int getItemCount() { int itemCount = 0; try { itemCount = genericDelegator.countByCondition(entityName, null, entityCondition, null); } catch (GenericEntityException e) { log.error("Exception thrown trying to count rows", e); } return itemCount; }
public List<GenericValue> findByCondition(final String entityName, final EntityCondition entityCondition, final Collection<String> fieldsToSelect, final List<String> orderBy) { try { return delegatorInterface.findByCondition(entityName, entityCondition, fieldsToSelect, orderBy); } catch (final GenericEntityException e) { throw new DataAccessException(e); } }
public int getProjectsWithDefaultUnassignedCount() throws GenericEntityException { if (projectsWithDefaultUnassignedCount == -1) { projectsWithDefaultUnassignedCount = genericDelegator.findByAnd("Project", FieldMap.build("assigneetype", new Long(ProjectAssigneeTypes.UNASSIGNED))).size(); projectsWithDefaultUnassignedCount += genericDelegator.findByAnd("Project", FieldMap.build("assigneetype", null)).size(); } return projectsWithDefaultUnassignedCount; }
public List<GenericValue> findAll(final String s) { try { return delegatorInterface.findAll(s); } catch (final GenericEntityException e) { throw new DataAccessException(e); } }
@Override public long getIssueCount() { try { return ofBizDelegator.getDelegatorInterface().countAll(Entity.Name.ISSUE); } catch (GenericEntityException e) { throw new RuntimeException(e); } }
public List<GenericValue> findByLike(final String s, final Map<String, ?> map, final List<String> orderBy) throws DataAccessException { try { return delegatorInterface.findByLike(s, map, orderBy); } catch (final GenericEntityException e) { throw new DataAccessException(e); } }
@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."); } }
UserEntityConditionFactory(OfBizDelegator ofBizDelegator) { final ModelEntity modelEntity = ofBizDelegator.getDelegatorInterface().getModelEntity(UserAttributeEntity.ENTITY); attributeTableName = modelEntity.getTableName(ofBizDelegator.getDelegatorInterface().getEntityHelperName(UserAttributeEntity.ENTITY)); }
private void removeEntryAndValue(Long id, Integer type) throws GenericEntityException { final FieldMap byId = FieldMap.build(ID, id); genericDelegator.removeByAnd(mapper(type).getEntityName(), byId); genericDelegator.removeByAnd(PROPERTY_ENTRY, byId); }
private Collection<String> getKeys(final FieldMap fieldMap) { try { final EntityCondition condition = new EntityFieldMap(fieldMap, AND); final List<GenericValue> keyGVs = genericDelegator.findByCondition(PROPERTY_ENTRY, condition, SELECT_KEY, null); if (keyGVs == null || keyGVs.isEmpty()) { return ImmutableSet.of(); } final Set<String> keys = new HashSet<String>(keyGVs.size()); for (GenericValue keyGV : keyGVs) { keys.add(keyGV.getString(PROPERTY_KEY)); } return keys; } catch (GenericEntityException gee) { throw new PropertyImplementationException(gee); } }
public List<GenericValue> findByAnd(final String entityName, final List<EntityCondition> expressions) throws DataAccessException { // cannot check EntityCondition instances as they don't give us a where condition try { return delegatorInterface.findByAnd(entityName, expressions); } catch (final GenericEntityException e) { throw new DataAccessException(e); } }
public List<GenericValue> findAll(final String s, final List sortOrder) throws DataAccessException { try { return delegatorInterface.findAll(s, sortOrder); } catch (final GenericEntityException e) { throw new DataAccessException(e); } }