Search in sources :

Example 16 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class ProjectGroupManagerImpl method getAccountManagerGroupFor.

@Override
public BusinessGroup getAccountManagerGroupFor(CoursePropertyManager cpm, CourseNode courseNode, ICourse course, String groupName, String groupDescription, Identity identity) {
    BusinessGroup accountManagerGroup = null;
    try {
        Long groupKey = null;
        Property accountManagerGroupProperty = cpm.findCourseNodeProperty(courseNode, null, null, ProjectBrokerCourseNode.CONF_ACCOUNTMANAGER_GROUP_KEY);
        // Check if account-manager-group-key-property already exist
        if (accountManagerGroupProperty != null) {
            groupKey = accountManagerGroupProperty.getLongValue();
            log.debug("accountManagerGroupProperty=" + accountManagerGroupProperty + "  groupKey=" + groupKey);
        }
        log.debug("groupKey=" + groupKey);
        if (groupKey != null) {
            accountManagerGroup = businessGroupService.loadBusinessGroup(groupKey);
            log.debug("load businessgroup=" + accountManagerGroup);
            if (accountManagerGroup != null) {
                return accountManagerGroup;
            } else {
                if (accountManagerGroupProperty != null) {
                    cpm.deleteProperty(accountManagerGroupProperty);
                }
                groupKey = null;
                log.warn("ProjectBroker: Account-manager does no longer exist, create a new one", null);
            }
        } else {
            log.debug("No group for project-broker exist => create a new one");
            RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            accountManagerGroup = businessGroupService.createBusinessGroup(identity, groupName, groupDescription, -1, -1, false, false, re);
            int i = 2;
            while (accountManagerGroup == null) {
                // group with this name exist already, try another name
                accountManagerGroup = businessGroupService.createBusinessGroup(identity, groupName + " _" + i, groupDescription, -1, -1, false, false, re);
                i++;
            }
            log.debug("createAndPersistBusinessGroup businessgroup=" + accountManagerGroup);
            if (accountManagerGroupProperty != null) {
                accountManagerGroupProperty.setLongValue(accountManagerGroup.getKey());
                cpm.updateProperty(accountManagerGroupProperty);
            } else {
                saveAccountManagerGroupKey(accountManagerGroup.getKey(), cpm, courseNode);
            }
            log.debug("created account-manager default businessgroup=" + accountManagerGroup);
        }
    } catch (AssertException e) {
        log.error("", e);
        if (tryToRepareAccountManagerProperty(cpm, courseNode)) {
            accountManagerGroup = getAccountManagerGroupFor(cpm, courseNode, course, groupName, groupDescription, identity);
        }
    }
    return accountManagerGroup;
}
Also used : AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Property(org.olat.properties.Property)

Example 17 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class StatisticUpdateManagerImpl method getAndUpdateLastUpdated.

@Override
public long getAndUpdateLastUpdated(long lastUpdated) {
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, null, STATISTICS_PROPERTIES_CATEGORY, LAST_UPDATED_PROPERTY_NAME);
    if (p == null) {
        Property newp = pm.createPropertyInstance(null, null, null, STATISTICS_PROPERTIES_CATEGORY, LAST_UPDATED_PROPERTY_NAME, null, lastUpdated, null, null);
        pm.saveProperty(newp);
        return -1;
    } else {
        final long result = p.getLongValue();
        p.setLongValue(lastUpdated);
        pm.saveProperty(p);
        return result;
    }
}
Also used : PropertyManager(org.olat.properties.PropertyManager) Property(org.olat.properties.Property)

Example 18 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class StatisticUpdateManagerImpl method getLastUpdated.

@Override
public long getLastUpdated() {
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, null, STATISTICS_PROPERTIES_CATEGORY, LAST_UPDATED_PROPERTY_NAME);
    if (p == null) {
        return -1;
    } else {
        return p.getLongValue();
    }
}
Also used : PropertyManager(org.olat.properties.PropertyManager) Property(org.olat.properties.Property)

Example 19 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class EPSettingsManager method setSavedFilterSettings.

public void setSavedFilterSettings(Identity ident, List<EPFilterSettings> filterList) {
    Property p = propertyManager.findProperty(ident, null, null, EPORTFOLIO_CATEGORY, EPORTFOLIO_FILTER_SETTINGS);
    if (p == null) {
        p = propertyManager.createUserPropertyInstance(ident, EPORTFOLIO_CATEGORY, EPORTFOLIO_FILTER_SETTINGS, null, null, null, null);
    }
    // don't persist filters without a name
    for (Iterator<EPFilterSettings> iterator = filterList.iterator(); iterator.hasNext(); ) {
        EPFilterSettings epFilterSettings = iterator.next();
        if (!StringHelper.containsNonWhitespace(epFilterSettings.getFilterName())) {
            iterator.remove();
        }
    }
    XStream xStream = XStreamHelper.createXStreamInstance();
    xStream.aliasType("EPFilterSettings", EPFilterSettings.class);
    String filterListXML = xStream.toXML(filterList);
    p.setTextValue(filterListXML);
    propertyManager.saveProperty(p);
}
Also used : EPFilterSettings(org.olat.portfolio.model.EPFilterSettings) XStream(com.thoughtworks.xstream.XStream) Property(org.olat.properties.Property)

Example 20 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class PropTableDataModel method getValueAt.

/**
 * @see org.olat.core.gui.components.table.TableDataModel#getValueAt(int, int)
 */
public final Object getValueAt(int row, int col) {
    Property p = getObject(row);
    switch(col) {
        case 0:
            String cat = p.getCategory();
            return (cat == null ? "n/a" : cat);
        case 1:
            BusinessGroup grp = p.getGrp();
            return (grp == null ? "n/a" : grp.getKey().toString());
        case 2:
            String resType = p.getResourceTypeName();
            return (resType == null ? "n/a" : resType);
        case 3:
            String name = p.getName();
            return (name == null ? "n/a" : name);
        case 4:
            Float floatvalue = p.getFloatValue();
            Long longvalue = p.getLongValue();
            String stringvalue = p.getStringValue();
            String textvalue = p.getTextValue();
            String val;
            if (floatvalue != null)
                val = floatvalue.toString();
            else if (longvalue != null)
                val = longvalue.toString();
            else if (stringvalue != null)
                val = stringvalue;
            else if (textvalue != null)
                val = textvalue;
            else
                val = "n/a";
            return val;
        case 5:
            Date dateCD = p.getCreationDate();
            return (dateCD == null ? new Date() : dateCD);
        case 6:
            Date dateLM = p.getLastModified();
            return (dateLM == null ? new Date() : dateLM);
        default:
            return "error";
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) Property(org.olat.properties.Property) Date(java.util.Date)

Aggregations

Property (org.olat.properties.Property)270 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)62 PropertyManager (org.olat.properties.PropertyManager)48 Identity (org.olat.core.id.Identity)36 NarrowedPropertyManager (org.olat.properties.NarrowedPropertyManager)36 ArrayList (java.util.ArrayList)24 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)22 BusinessGroup (org.olat.group.BusinessGroup)18 File (java.io.File)16 ICourse (org.olat.course.ICourse)16 Translator (org.olat.core.gui.translator.Translator)14 AssertException (org.olat.core.logging.AssertException)14 CourseNode (org.olat.course.nodes.CourseNode)14 Forum (org.olat.modules.fo.Forum)14 ForumManager (org.olat.modules.fo.manager.ForumManager)14 Test (org.junit.Test)12 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)12 XStream (com.thoughtworks.xstream.XStream)10 HashMap (java.util.HashMap)10 List (java.util.List)10