Search in sources :

Example 11 with Properties

use of com.thoughtworks.go.domain.Properties in project gocd by gocd.

the class PropertiesService method listPropertiesForJob.

public RestfulAction listPropertiesForJob(JobIdentifier jobIdentifier, String type, String propertyKey) {
    Properties properties;
    Long buildId = jobIdentifier.getBuildId();
    if (propertyKey != null) {
        String value = propertyDao.value(buildId, propertyKey);
        if (value == null) {
            return PropertyAction.propertyNotFound(propertyKey);
        }
        properties = new Properties(new Property(propertyKey, value));
    } else {
        properties = propertyDao.list(jobIdentifier.getBuildId());
    }
    return listPropertiesAs(type, properties, jobIdentifier.getBuildName());
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Property(com.thoughtworks.go.domain.Property)

Example 12 with Properties

use of com.thoughtworks.go.domain.Properties in project gocd by gocd.

the class PropertySqlMapDao method addToHistory.

private static void addToHistory(LinkedHashMap<String, Properties> propHistory, Map<String, Object> flatMap) {
    String id = String.valueOf(flatMap.get("pipelineid"));
    String key = (String) flatMap.get("key");
    String value = (String) flatMap.get("value");
    if (!propHistory.containsKey(id)) {
        propHistory.put(id, new Properties());
    }
    propHistory.get(id).add(new Property(key, value));
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Property(com.thoughtworks.go.domain.Property)

Example 13 with Properties

use of com.thoughtworks.go.domain.Properties in project gocd by gocd.

the class PropertyDaoTest method shouldLoadPropertiesHistoryLimitToSpecifiedCount.

@Test
public void shouldLoadPropertiesHistoryLimitToSpecifiedCount() throws Exception {
    Pipeline oldPipeline = createPipelineWithJobProperty(PIPELINE1, property("key1", "value1"));
    Pipeline newPipeline = createPipelineWithJobProperty(PIPELINE1, property("key2", "value2"));
    List<Properties> history = propertyDao.loadHistory(PIPELINE1, STAGE1, PLAN1, newPipeline.getId(), 1);
    assertThat(history.size(), is(1));
    assertThat(history.get(0).toString(), history.get(0).getValue("key2"), is("value2"));
    history = propertyDao.loadHistory(PIPELINE1, STAGE1, PLAN1, newPipeline.getId(), Integer.MAX_VALUE);
    assertThat(history.size(), is(2));
    assertThat(history.get(0).toString(), history.get(0).getValue("key1"), is("value1"));
    assertThat(history.get(1).toString(), history.get(1).getValue("key2"), is("value2"));
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

Properties (com.thoughtworks.go.domain.Properties)13 Test (org.junit.Test)8 Property (com.thoughtworks.go.domain.Property)6 Pipeline (com.thoughtworks.go.domain.Pipeline)5 Csv (com.thoughtworks.go.util.Csv)2 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 JobPlan (com.thoughtworks.go.domain.JobPlan)1 XmlWriterContext (com.thoughtworks.go.domain.XmlWriterContext)1 PropertyDao (com.thoughtworks.go.server.dao.PropertyDao)1 JobDetailPresentationModel (com.thoughtworks.go.server.presentation.models.JobDetailPresentationModel)1 PropertiesService (com.thoughtworks.go.server.service.PropertiesService)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1