Search in sources :

Example 1 with IProjectProperty

use of org.hudsonci.api.model.IProjectProperty in project hudson-2.x by hudson.

the class MatrixProjectTest method testDoResetProjectPropertyOneProperty.

@Test
public void testDoResetProjectPropertyOneProperty() throws IOException {
    final IProjectProperty filterProperty = createMock(StringProjectProperty.class);
    String input = MatrixProject.TOUCH_STONE_COMBINATION_FILTER_PROPERTY_NAME;
    MatrixProject project = new MatrixProjectMock("parent") {

        public IProjectProperty getProperty(String key) {
            if (MatrixProject.TOUCH_STONE_COMBINATION_FILTER_PROPERTY_NAME.equals(key)) {
                return filterProperty;
            } else {
                return null;
            }
        }
    };
    filterProperty.resetValue();
    replay(filterProperty);
    project.doResetProjectProperty(input);
    verify(filterProperty);
}
Also used : IProjectProperty(org.hudsonci.api.model.IProjectProperty) Test(org.junit.Test)

Example 2 with IProjectProperty

use of org.hudsonci.api.model.IProjectProperty in project hudson-2.x by hudson.

the class CascadingUtil method getProjectProperty.

/**
     * Returns project property by specified key.
     *
     * @param currentJob job that should be analyzed.
     * @param key key.
     * @param clazz required property class.
     * If class is not null and property was not found, property of given class will be created.
     * @return {@link org.hudsonci.api.model.IProjectProperty} instance or null.
     * @throws IllegalArgumentException if currentJob is null.
     */
@SuppressWarnings("unchecked")
public static <T extends IProjectProperty> T getProjectProperty(ICascadingJob currentJob, String key, Class<T> clazz) {
    if (currentJob == null) {
        throw new IllegalArgumentException("Job cannot be null");
    }
    IProjectProperty t = (IProjectProperty) currentJob.getProjectProperties().get(key);
    if (null == t && null != clazz) {
        try {
            t = clazz.getConstructor(ICascadingJob.class).newInstance(currentJob);
            t.setKey(key);
            currentJob.putProjectProperty(key, t);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }
    }
    return (T) t;
}
Also used : IProjectProperty(org.hudsonci.api.model.IProjectProperty) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with IProjectProperty

use of org.hudsonci.api.model.IProjectProperty in project hudson-2.x by hudson.

the class Job method clearCascadingProject.

/**
     * Removes cascading project data, marks all project properties as non-overridden and saves configuration
     *
     * @throws java.io.IOException if configuration couldn't be saved.
     */
private void clearCascadingProject() throws IOException {
    CascadingUtil.unlinkProjectFromCascadingParents(cascadingProject, name);
    this.cascadingProject = null;
    this.cascadingProjectName = null;
    for (IProjectProperty property : jobProperties.values()) {
        property.onCascadingProjectChanged();
    }
}
Also used : IProjectProperty(org.hudsonci.api.model.IProjectProperty)

Example 4 with IProjectProperty

use of org.hudsonci.api.model.IProjectProperty in project hudson-2.x by hudson.

the class Job method getCascadingJobProperties.

/**
     * @return list of cascading {@link JobProperty} instances. Includes {@link ParametersDefinitionProperty} and
     *         children of {@link JobProperty} from external plugins.
     */
private CopyOnWriteList getCascadingJobProperties() {
    CopyOnWriteList result = new CopyOnWriteList();
    CopyOnWriteList<ParametersDefinitionProperty> definitionProperties = getParameterDefinitionProperties();
    if (null != cascadingJobProperties && !cascadingJobProperties.isEmpty()) {
        for (String key : cascadingJobProperties) {
            IProjectProperty projectProperty = CascadingUtil.getProjectProperty(this, key);
            Object value = projectProperty.getValue();
            if (null != value) {
                result.add(value);
            }
        }
    }
    if (null != definitionProperties && !definitionProperties.isEmpty()) {
        result.addAll(definitionProperties.getView());
    }
    return result;
}
Also used : IProjectProperty(org.hudsonci.api.model.IProjectProperty) CopyOnWriteList(hudson.util.CopyOnWriteList) JSONObject(net.sf.json.JSONObject)

Example 5 with IProjectProperty

use of org.hudsonci.api.model.IProjectProperty in project hudson-2.x by hudson.

the class Job method buildProjectProperties.

/**
     * Initializes and builds project properties. Also converts legacy properties to IProjectProperties.
     * Subclasses should inherit and override this behavior.
     *
     * @throws IOException if any.
     */
protected void buildProjectProperties() throws IOException {
    initProjectProperties();
    for (Map.Entry<String, IProjectProperty> entry : jobProperties.entrySet()) {
        IProjectProperty property = entry.getValue();
        property.setKey(entry.getKey());
        property.setJob(this);
    }
    convertLogRotatorProperty();
    convertJobProperties();
}
Also used : IProjectProperty(org.hudsonci.api.model.IProjectProperty) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Aggregations

IProjectProperty (org.hudsonci.api.model.IProjectProperty)9 Test (org.junit.Test)2 CopyOnWriteList (hudson.util.CopyOnWriteList)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 JSONObject (net.sf.json.JSONObject)1 ExternalProjectProperty (org.hudsonci.model.project.property.ExternalProjectProperty)1