Tabnine Logo
PropertyTagEditingService
Code IndexAdd Tabnine to your IDE (free)

How to use
PropertyTagEditingService
in
ch.puzzle.itc.mobiliar.business.property.control

Best Java code snippets using ch.puzzle.itc.mobiliar.business.property.control.PropertyTagEditingService (Showing top 20 results out of 315)

origin: liimaorg/liima

private void createNewPropertyDescriptor(ForeignableOwner owner, PropertyDescriptorEntity descriptor, AbstractContext abstractContext, List<PropertyTagEntity> tags) {
  descriptor.setOwner(owner);
  abstractContext.addPropertyDescriptor(descriptor);
  entityManager.persist(descriptor);
  propertyTagEditingService.updateTags(tags, descriptor);
  entityManager.persist(abstractContext);
}
origin: liimaorg/liima

  private List<PropertyTagEntity> createPropertyTags(List<String> tags) {
    List<PropertyTagEntity> propertyTagEntities = new LinkedList<>();
    for (String tag : tags) {
      propertyTagEntities.add(propertyTagService.addPropertyTag((propertyTagService.createPropertyTagEntity(tag.trim()))));
    }
    return propertyTagEntities;
  }
}
origin: liimaorg/liima

/**
 * Deletes a PropertyTagEntity identified by its Id
 * @param propertyTagId
 * @return
 */
@HasPermission(permission = Permission.MANAGE_GLOBAL_TAGS)
public boolean deletePropertyTag(Integer propertyTagId) {
  return propertyTagService.deletePropertyTagById(propertyTagId);
}
origin: liimaorg/liima

private PropertyDescriptorEntity savePropertyDescriptorResourceType(ForeignableOwner editingOwner, Integer resourceTypeId, PropertyDescriptorEntity descriptor, String propertyTagsString) throws AMWException {
  ResourceTypeEntity attachedResourceType = entityManager.find(ResourceTypeEntity.class, resourceTypeId);
  ResourceTypeContextEntity resourceTypeContextEntity = attachedResourceType.getOrCreateContext(contextService.getGlobalResourceContextEntity());
  return propertyDescriptorService.savePropertyDescriptorForOwner(editingOwner, resourceTypeContextEntity, descriptor, propertyTagEditingService.convertToTags(propertyTagsString), attachedResourceType);
}
origin: liimaorg/liima

List<PropertyTagEntity> tags = propertyTagEditingService.convertToTags(propertyTypeTagsString);
propertyTagEditingService.updateTags(tags, result);
origin: liimaorg/liima

/**
 * Returns a list containing all existing LOCAL PropertyTagEntities
 * @param sortDesc
 * @return
 */
public List<PropertyTagEntity> loadAllLocalPropertyTagEntities(boolean sortDesc) {
  return loadAllPropertyTagEntities(sortDesc, PropertyTagType.LOCAL);
}
origin: liimaorg/liima

public List<PropertyTagEntity> getAllGlobalPropertyTags() {
  return propertyTagService.loadAllGlobalPropertyTagEntities(false);
}
origin: liimaorg/liima

/**
 * converts a comma separated String to PropertyTagEntities
 *
 * @param propertyTagsString
 * @return
 */
public List<PropertyTagEntity> convertToTags(String propertyTagsString) {
  List<PropertyTagEntity> ptes = new ArrayList<>();
  if (propertyTagsString != null && !propertyTagsString.isEmpty()) {
    String[] tagStrings = propertyTagsString.split(",");
    for (String tagString : tagStrings) {
      ptes.add(createPropertyTagEntity(tagString));
    }
  }
  return ptes;
}
origin: liimaorg/liima

private List<PropertyTagEntity> loadAllPropertyTagEntities(boolean sortDesc, PropertyTagType tagType) {
  CriteriaBuilder cb = entityManager.getCriteriaBuilder();
  CriteriaQuery<PropertyTagEntity> query = cb.createQuery(PropertyTagEntity.class);
  Root<PropertyTagEntity> root = query.from(PropertyTagEntity.class);
  if (tagType != null) {
    Predicate predicate = cb.equal(root.get("tagType"), tagType);
    query.where(predicate);
  }
  query.orderBy(getDefaultOrder(root, sortDesc));
  return entityManager.createQuery(query).getResultList();
}
origin: liimaorg/liima

private void addPropertyTag(String propertyTagName, PropertyTagType propertyTagType) {
  if (propertyTagName != null && !propertyTagName.isEmpty()) {
    PropertyTagEntity propertyTag = new PropertyTagEntity();
    propertyTag.setName(propertyTagName);
    propertyTag.setTagType(propertyTagType);
    propertyTagService.addPropertyTag(propertyTag);
  }
}
origin: liimaorg/liima

/**
 * Updates the Tags of the given tagHolder
 *
 * @param newTags
 * @param tagHolder
 */
public void updateTags(List<PropertyTagEntity> newTags, PropertyTagEntityHolder tagHolder){
  // add new tags
  for (PropertyTagEntity tag : newTags) {
    if (!hasName(tagHolder.getPropertyTags(),tag.getName())) {
      entityManager.persist(tag);
      tagHolder.addPropertyTag(tag);
    }
  }
  // remove missing tags
  if(tagHolder.getPropertyTags() != null) {
    List<PropertyTagEntity> toRemove = new ArrayList<>();
    for (PropertyTagEntity pt : tagHolder.getPropertyTags()) {
      if (!hasName(newTags,pt.getName())) {
        entityManager.remove(pt);
        toRemove.add(pt);
      }
    }
    // remove them
    for(PropertyTagEntity pt: toRemove){
      tagHolder.removePropertyTag(pt);
    }
  }
}
origin: liimaorg/liima

private PropertyDescriptorEntity savePropertyDescriptorResource(ForeignableOwner editingOwner, Integer resourceId, PropertyDescriptorEntity descriptor, String propertyTagsString) throws AMWException {
  ResourceEntity attachedResource = entityManager.find(ResourceEntity.class, Objects.requireNonNull(resourceId));
  ResourceContextEntity resourceContext = attachedResource.getOrCreateContext(contextService.getGlobalResourceContextEntity());
  ResourceTypeContextEntity resourceTypeContextEntity = attachedResource.getResourceType().getOrCreateContext(contextService.getGlobalResourceContextEntity());
  List<String> duplicatePropertyDescriptorNames = propertyValidationService.getDuplicatePropertyDescriptors(resourceContext, resourceTypeContextEntity, descriptor);
  if (!duplicatePropertyDescriptorNames.isEmpty()) {
    throw new AMWException("Failure - duplicate propertydescriptors: " + duplicatePropertyDescriptorNames);
  }
  return propertyDescriptorService.savePropertyDescriptorForOwner(editingOwner, resourceContext, descriptor, propertyTagEditingService.convertToTags(propertyTagsString), attachedResource);
}
origin: liimaorg/liima

List<PropertyTagEntity> tags = propertyTagEditingService.convertToTags(propertyTypeTagsString);
propertyTagEditingService.updateTags(tags,propertyTypeEntity);
origin: liimaorg/liima

/**
 * Returns a list containing all existing GLOBAL PropertyTagEntities
 * @param sortDesc
 * @return
 */
public List<PropertyTagEntity> loadAllGlobalPropertyTagEntities(boolean sortDesc) {
  return loadAllPropertyTagEntities(sortDesc, PropertyTagType.GLOBAL);
}
origin: liimaorg/liima

@Test
public void savePropertyDescriptorForResourceTypeShouldSaveWithOwner() throws ForeignableOwnerViolationException, AMWException {
  // given
  ForeignableOwner changingOwner = ForeignableOwner.AMW;
  Integer resourceTypeId = 1;
  PropertyDescriptorEntity descriptor = new PropertyDescriptorEntityBuilder().withId(2).build();
  String propertyTagsString = "propertyTagsString";
  ResourceTypeEntity resourceTypeEntityMock = mock(ResourceTypeEntity.class);
  ResourceTypeContextEntity resourceTypeContextEntityMock = mock(ResourceTypeContextEntity.class);
  when(entityManagerMock.find(ResourceTypeEntity.class, resourceTypeId)).thenReturn(resourceTypeEntityMock);
  when(resourceTypeEntityMock.getOrCreateContext(any(ContextEntity.class))).thenReturn(resourceTypeContextEntityMock);
  when(permissionBoundaryMock.hasPermission(Permission.IGNORE_FOREIGNABLE_OWNER)).thenReturn(false);
  List<PropertyTagEntity> propertyTags = new ArrayList<>();
  propertyTags.add(new PropertyTagEntity());
  when(propertyTagEditingServiceMock.convertToTags(propertyTagsString)).thenReturn(propertyTags);
  // when
  editor.savePropertyDescriptorForResourceType(changingOwner, resourceTypeId, descriptor,descriptor.foreignableFieldHashCode(), propertyTagsString);
  // then
  verify(propertyDescriptorServiceMock).savePropertyDescriptorForOwner(changingOwner, resourceTypeContextEntityMock, descriptor, propertyTags, resourceTypeEntityMock);
}
origin: liimaorg/liima

private void saveExistingPropertyDescriptor(PropertyDescriptorEntity descriptor, List<PropertyTagEntity> tags, ResourceTypeEntity resourceType) {
  PropertyDescriptorEntity oldDescriptor = entityManager.find(PropertyDescriptorEntity.class, descriptor.getId());
  List<Integer> encryptedPropertyIds = new ArrayList<>();
  if (oldDescriptor.isEncrypt()) {
    encryptedPropertyIds.add(oldDescriptor.getId());
  }
  PropertyDescriptorEntity mergedDescriptor = entityManager.merge(descriptor);
  propertyTagEditingService.updateTags(tags, mergedDescriptor);
  boolean canDecrypt = false;
  // decryption required - check permission
  if (!mergedDescriptor.isEncrypt() && encryptedPropertyIds.contains(mergedDescriptor.getId())) {
    // context?
    canDecrypt = permissionService.hasPermission(Permission.RESOURCETYPE_PROPERTY_DECRYPT, null, Action.ALL, null, resourceType);
  }
  manageChangeOfEncryptedPropertyDescriptor(mergedDescriptor, encryptedPropertyIds, canDecrypt);
}
origin: liimaorg/liima

@Test
public void savePropertyDescriptorForResourceShouldDelegatePropertyTagEditingService() throws ForeignableOwnerViolationException, AMWException {
  // given
  ForeignableOwner changingOwner = ForeignableOwner.AMW;
  Integer resourceId = 1;
  PropertyDescriptorEntity descriptor = new PropertyDescriptorEntityBuilder().withId(2).build();
  String propertyTagsString = "propertyTagsString";
  ResourceEntity resourceEntityMock = mock(ResourceEntity.class);
  ResourceTypeEntity resourceTypeEntityMock = mock(ResourceTypeEntity.class);
  ResourceContextEntity resourceContextEntityMock = mock(ResourceContextEntity.class);
  ResourceTypeContextEntity resourceTypeContextEntityMock = mock(ResourceTypeContextEntity.class);
  when(entityManagerMock.find(ResourceEntity.class, resourceId)).thenReturn(resourceEntityMock);
  when(resourceEntityMock.getOrCreateContext(any(ContextEntity.class))).thenReturn(resourceContextEntityMock);
  when(resourceEntityMock.getResourceType()).thenReturn(resourceTypeEntityMock);
  when(resourceTypeEntityMock.getOrCreateContext(any(ContextEntity.class))).thenReturn(resourceTypeContextEntityMock);
  List<String> emptyList = new ArrayList<>();
  when(propertyValidationServiceMock.getDuplicatePropertyDescriptors(resourceContextEntityMock, resourceTypeContextEntityMock, descriptor)).thenReturn(emptyList);
  // when
  editor.savePropertyDescriptorForResource(changingOwner, resourceId, descriptor, descriptor.foreignableFieldHashCode(), propertyTagsString);
  // then
  verify(propertyTagEditingServiceMock).convertToTags(propertyTagsString);
}
origin: liimaorg/liima

private void saveExistingPropertyDescriptor(PropertyDescriptorEntity descriptor, List<PropertyTagEntity> tags, ResourceEntity resource) {
  PropertyDescriptorEntity oldDescriptor = entityManager.find(PropertyDescriptorEntity.class, descriptor.getId());
  List<Integer> encryptedPropertyIds = new ArrayList<>();
  if (oldDescriptor.isEncrypt()) {
    encryptedPropertyIds.add(oldDescriptor.getId());
  }
  PropertyDescriptorEntity mergedDescriptor = entityManager.merge(descriptor);
  propertyTagEditingService.updateTags(tags, mergedDescriptor);
  boolean canDecrypt = false;
  // decryption required - check permission
  if (!mergedDescriptor.isEncrypt() && encryptedPropertyIds.contains(mergedDescriptor.getId())) {
    // context?
    canDecrypt = permissionService.hasPermission(Permission.RESOURCE_PROPERTY_DECRYPT, null, Action.ALL, resource.getResourceGroup(), null);
  }
  manageChangeOfEncryptedPropertyDescriptor(mergedDescriptor, encryptedPropertyIds, canDecrypt);
}
origin: liimaorg/liima

@Test
public void savePropertyDescriptorForResourceShouldVerifyIfEditableByOwner() throws ForeignableOwnerViolationException, AMWException {
  // given
  ForeignableOwner changingOwner = ForeignableOwner.AMW;
  Integer resourceId = 1;
  PropertyDescriptorEntity descriptor = new PropertyDescriptorEntityBuilder().withId(2).build();
  String propertyTagsString = "propertyTagsString";
  ResourceEntity resourceEntityMock = mock(ResourceEntity.class);
  ResourceTypeEntity resourceTypeEntityMock = mock(ResourceTypeEntity.class);
  ResourceContextEntity resourceContextEntityMock = mock(ResourceContextEntity.class);
  ResourceTypeContextEntity resourceTypeContextEntityMock = mock(ResourceTypeContextEntity.class);
  when(entityManagerMock.find(ResourceEntity.class, resourceId)).thenReturn(resourceEntityMock);
  when(resourceEntityMock.getOrCreateContext(any(ContextEntity.class))).thenReturn(resourceContextEntityMock);
  when(resourceEntityMock.getResourceType()).thenReturn(resourceTypeEntityMock);
  when(resourceTypeEntityMock.getOrCreateContext(any(ContextEntity.class))).thenReturn(resourceTypeContextEntityMock);
  List<String> emptyList = new ArrayList<>();
  when(propertyValidationServiceMock.getDuplicatePropertyDescriptors(resourceContextEntityMock, resourceTypeContextEntityMock, descriptor)).thenReturn(emptyList);
  when(permissionBoundaryMock.hasPermission(Permission.IGNORE_FOREIGNABLE_OWNER)).thenReturn(false);
  List<PropertyTagEntity> propertyTags = new ArrayList<>();
  propertyTags.add(new PropertyTagEntity());
  when(propertyTagEditingServiceMock.convertToTags(propertyTagsString)).thenReturn(propertyTags);
  // when
  editor.savePropertyDescriptorForResource(changingOwner, resourceId, descriptor, descriptor.foreignableFieldHashCode(), propertyTagsString);
  // then
  verify(foreignableServiceMock).verifyEditableByOwner(changingOwner, descriptor.foreignableFieldHashCode(),descriptor);
}
origin: liimaorg/liima

@Test
public void savePropertyDescriptorForOwnerWhenDescriptorIdIsNullShouldCreateNewPropertyDescriptorForOwner() throws AMWException {
  // given
  ForeignableOwner changingOwner = ForeignableOwner.AMW;
  AbstractContext abstractContextMock = mock(AbstractContext.class);
  PropertyDescriptorEntity descriptor = new PropertyDescriptorEntityBuilder().build();
  List<PropertyTagEntity> tags = new ArrayList<>();
  ResourceEntity resourceEntityMock = mock(ResourceEntity.class);
  when(propertyValidationServiceMock.isValidTechnicalKey(descriptor.getPropertyName())).thenReturn(true);
  Assert.assertNull(descriptor.getId());
  // when
  service.savePropertyDescriptorForOwner(changingOwner, abstractContextMock, descriptor, tags, resourceEntityMock);
  // then
  verify(abstractContextMock).addPropertyDescriptor(descriptor);
  verify(entityManagerMock).persist(descriptor);
  verify(propertyTagEditingServiceMock).updateTags(tags, descriptor);
  verify(entityManagerMock).persist(abstractContextMock);
}
ch.puzzle.itc.mobiliar.business.property.controlPropertyTagEditingService

Most used methods

  • convertToTags
    converts a comma separated String to PropertyTagEntities
  • updateTags
    Updates the Tags of the given tagHolder
  • addPropertyTag
    Persists a new PropertyTag. If the PropertyTag to be persisted has PropertyTagType.GLOBAL, it assure
  • createPropertyTagEntity
    creates a (local) PropertyTagEntity from a given String
  • deletePropertyTagById
    Deletes a PropertyTagEntity with the given id
  • getDefaultOrder
  • hasName
  • loadAllGlobalPropertyTagEntities
    Returns a list containing all existing GLOBAL PropertyTagEntities
  • loadAllPropertyTagEntities

Popular in Java

  • Making http requests using okhttp
  • runOnUiThread (Activity)
  • getSystemService (Context)
  • getExternalFilesDir (Context)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JOptionPane (javax.swing)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now