Search in sources :

Example 11 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class SecurityServiceImpl method updateToken.

@Override
public void updateToken(final String series, final String token, final Date lastUsed) {
    Entity persistentToken = getPersistentToken(series);
    if (Objects.nonNull(persistentToken)) {
        persistentToken.setField(PersistentTokenFields.TOKEN, token);
        persistentToken.setField(PersistentTokenFields.LAST_USED, lastUsed);
        getPersistentTokenDD().save(persistentToken);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity)

Example 12 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class SecurityServiceImpl method getUsers.

@Override
public List<QcadooUser> getUsers() {
    List<Entity> users = dataDefinitionService.get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER).find().addOrder(SearchOrders.asc(UserFields.USER_NAME)).list().getEntities();
    List<QcadooUser> qcadooUsers = Lists.newLinkedList();
    for (Entity user : users) {
        qcadooUsers.add(new QcadooUser(user));
    }
    return qcadooUsers;
}
Also used : Entity(com.qcadoo.model.api.Entity) QcadooUser(com.qcadoo.security.internal.api.QcadooUser)

Example 13 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class GroupRolesValidationServiceTest method stubGroupRoles.

private void stubGroupRoles(Entity group, String... roles) {
    List<Entity> rolesEntity = Lists.newArrayList();
    for (String role : roles) {
        Entity roleEntity = mock(Entity.class);
        given(roleEntity.getStringField(RoleFields.IDENTIFIER)).willReturn(role);
        rolesEntity.add(roleEntity);
    }
    given(group.getManyToManyField(GroupFields.ROLES)).willReturn(rolesEntity);
}
Also used : Entity(com.qcadoo.model.api.Entity)

Example 14 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class GroupRolesValidationServiceTest method stubCurrentUserRole.

private void stubCurrentUserRole(final String role) {
    Entity roleEntity = mock(Entity.class);
    given(roleEntity.getStringField(RoleFields.IDENTIFIER)).willReturn(role);
    given(currentUserEntityMock.getManyToManyField(UserFields.GROUP)).willReturn(Lists.newArrayList(roleEntity));
    given(securityService.hasRole(currentUserEntityMock, QcadooSecurityConstants.ROLE_SUPERADMIN)).willReturn(QcadooSecurityConstants.ROLE_SUPERADMIN.equals(role));
}
Also used : Entity(com.qcadoo.model.api.Entity)

Example 15 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class UserRoleValidationServiceTest method stubRoleTransition.

private void stubRoleTransition(final String from, final String to) {
    Entity fromRole = mock(Entity.class);
    given(fromRole.getStringField(RoleFields.IDENTIFIER)).willReturn(from);
    given(existingUserGroupMock.getManyToManyField(GroupFields.ROLES)).willReturn(Lists.newArrayList(fromRole));
    given(existingUserEntityMock.getBelongsToField(UserFields.GROUP)).willReturn(from == null ? null : existingUserGroupMock);
    given(securityService.hasRole(existingUserEntityMock, QcadooSecurityConstants.ROLE_SUPERADMIN)).willReturn(QcadooSecurityConstants.ROLE_SUPERADMIN.equals(from));
    Entity toRole = mock(Entity.class);
    given(toRole.getStringField(RoleFields.IDENTIFIER)).willReturn(to);
    given(userGroupMock.getManyToManyField(GroupFields.ROLES)).willReturn(Lists.newArrayList(toRole));
    given(userEntityMock.getBelongsToField(UserFields.GROUP)).willReturn(to == null ? null : userGroupMock);
    given(securityService.hasRole(userEntityMock, QcadooSecurityConstants.ROLE_SUPERADMIN)).willReturn(QcadooSecurityConstants.ROLE_SUPERADMIN.equals(to));
}
Also used : Entity(com.qcadoo.model.api.Entity)

Aggregations

Entity (com.qcadoo.model.api.Entity)2833 FormComponent (com.qcadoo.view.api.components.FormComponent)514 Test (org.junit.Test)491 BigDecimal (java.math.BigDecimal)376 DataDefinition (com.qcadoo.model.api.DataDefinition)337 FieldComponent (com.qcadoo.view.api.components.FieldComponent)210 LookupComponent (com.qcadoo.view.api.components.LookupComponent)188 Date (java.util.Date)185 List (java.util.List)149 GridComponent (com.qcadoo.view.api.components.GridComponent)141 Map (java.util.Map)124 Autowired (org.springframework.beans.factory.annotation.Autowired)114 Service (org.springframework.stereotype.Service)112 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)105 Transactional (org.springframework.transaction.annotation.Transactional)101 DefaultEntity (com.qcadoo.model.internal.DefaultEntity)100 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)95 Collectors (java.util.stream.Collectors)87 Lists (com.google.common.collect.Lists)75 SampleSimpleDatabaseObject (com.qcadoo.model.beans.sample.SampleSimpleDatabaseObject)75