Search in sources :

Example 1 with BaseUuidEntity

use of com.haulmont.cuba.core.entity.BaseUuidEntity in project cuba by cuba-platform.

the class UserSetHelper method removeIds.

public static String removeIds(Set<String> current, Collection entities) {
    Set<String> convertedSet = new HashSet<>();
    for (Object entity : entities) {
        convertedSet.add(((BaseUuidEntity) entity).getId().toString());
    }
    current.removeAll(convertedSet);
    if (current.isEmpty()) {
        return "NULL";
    }
    StringBuilder listOfId = new StringBuilder();
    Iterator it = current.iterator();
    while (it.hasNext()) {
        listOfId.append(it.next());
        if (it.hasNext()) {
            listOfId.append(',');
        }
    }
    return listOfId.toString();
}
Also used : Iterator(java.util.Iterator) BaseUuidEntity(com.haulmont.cuba.core.entity.BaseUuidEntity) HashSet(java.util.HashSet)

Example 2 with BaseUuidEntity

use of com.haulmont.cuba.core.entity.BaseUuidEntity in project cuba by cuba-platform.

the class UserSetHelper method createIdsString.

public static String createIdsString(Set<String> current, Collection entities) {
    Set<String> convertedSet = new HashSet<>();
    for (Object entity : entities) {
        convertedSet.add(((BaseUuidEntity) entity).getId().toString());
    }
    current.addAll(convertedSet);
    if (current.isEmpty()) {
        return "NULL";
    }
    StringBuilder listOfId = new StringBuilder();
    Iterator it = current.iterator();
    while (it.hasNext()) {
        listOfId.append(it.next());
        if (it.hasNext()) {
            listOfId.append(',');
        }
    }
    return listOfId.toString();
}
Also used : Iterator(java.util.Iterator) BaseUuidEntity(com.haulmont.cuba.core.entity.BaseUuidEntity) HashSet(java.util.HashSet)

Example 3 with BaseUuidEntity

use of com.haulmont.cuba.core.entity.BaseUuidEntity in project cuba by cuba-platform.

the class WebLookupField method initNullEntity.

protected void initNullEntity() {
    // noinspection IncorrectCreateEntity
    nullEntity = new BaseUuidEntity() {

        @Override
        public String getInstanceName() {
            if (nullOption instanceof Instance) {
                return InstanceUtils.getInstanceName((Instance) nullOption);
            }
            if (nullOption == null) {
                return "";
            } else {
                return nullOption.toString();
            }
        }

        // Used for captionProperty of null entity
        @Override
        public <T> T getValue(String s) {
            return (T) getInstanceName();
        }
    };
    component.setNullSelectionItemId(nullEntity);
}
Also used : Instance(com.haulmont.chile.core.model.Instance) BaseUuidEntity(com.haulmont.cuba.core.entity.BaseUuidEntity)

Aggregations

BaseUuidEntity (com.haulmont.cuba.core.entity.BaseUuidEntity)3 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 Instance (com.haulmont.chile.core.model.Instance)1