Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions configurationapp/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions configurationapp/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>configurationapp</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
4 changes: 4 additions & 0 deletions configurationapp/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding/<project>=UTF-8
5 changes: 5 additions & 0 deletions configurationapp/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions configurationapp/.settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
7 changes: 7 additions & 0 deletions configurationapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>

</dependencies>

<build>
Expand Down
2 changes: 2 additions & 0 deletions configurationapp/src/main/java/com/att/ConfigurationApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan("com.att")
public class ConfigurationApp {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.att.dao.configurations;

import com.att.data.configurations.ConfigValue;
import com.att.model.configurations.Cache;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
Expand All @@ -10,7 +13,10 @@

@Service
public class ConfigurationDao {

private class IdProvider {
//@Autowired private Cache cache;

private int currentId;

public IdProvider() {
Expand All @@ -33,16 +39,34 @@ public ConfigurationDao() {
currentConfigurations = new HashMap<>();
}

public List<ConfigValue> getConfigurationsForYearMonth(String yearMonth) {
return new ArrayList<>();
public List<ConfigValue> getConfigurations(Cache cache, String yearMonth) {
List<ConfigValue> configList = cache.getConfiguration(yearMonth);
return configList;
}

public void addConfiguration(String yearMonth, ConfigValue value) {
int newId = idProvider.getNextId();

public Cache addConfiguration(Cache cache, ConfigValue config) {
cache.addConfiguration(config);

return cache;
}

public Cache deleteConfiguration(Cache cache, ConfigValue config) {
List<ConfigValue> configList = cache.getConfiguration(config.getYearMonth());
List<ConfigValue> deleteList = new ArrayList<ConfigValue>();

for (int i=0; i<configList.size(); i++) {
if (configList.get(i).getConfigId() == config.getConfigId()) {
deleteList.add(configList.get(i));
}
}

configList.removeAll(deleteList);

return cache;
}

public void removeAllConfigurationsForYearMonth(String yearMonth) {


public void deleteAllConfigurations(Cache cache, String yearMonth) {
cache.removeConfiguration(yearMonth);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@
* Data Model
*/
public class ConfigValue {
private String yearMonth;
private String configName;
private int configId;

public ConfigValue(String name, int id) {
this.configId = id;
this.configName = name;
}

public ConfigValue() {

}

public void setConfigName(String name) {

public ConfigValue(String yearMonth, String configName, int configId) {
super();
this.yearMonth = yearMonth;
this.configName = configName;
this.configId = configId;
}

public ConfigValue(String yearMonth, String configName, String configId) {
super();
this.yearMonth = yearMonth;
this.configName = configName;
this.configId = Integer.parseInt(configId);
}


public void setConfigName(String name) {
this.configName = name;
}

Expand All @@ -31,4 +43,14 @@ public void setConfigId(int id) {
public int getConfigId() {
return this.configId;
}

public String getYearMonth() {
return yearMonth;
}

public void setYearMonth(String yearMonth) {
this.yearMonth = yearMonth;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.att.model.configurations;

import java.util.List;

public class AjaxResponseBody {

String data;

public String getData() {
return data;
}

public void setData(String data) {
this.data = data;
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.att.model.configurations;

import java.util.List;

import com.att.data.configurations.ConfigValue;

public interface Cache {
public void addConfiguration( ConfigValue configuration);
public List<ConfigValue> getConfiguration(String yearMonth);
public void removeConfiguration(String yearMonth);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.att.model.configurations;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.att.data.configurations.ConfigValue;

@Component
@Scope("session")
public class CacheImpl implements Cache {
private Map<String, List<ConfigValue>> cache = new HashMap<String, List<ConfigValue>>();

public void addConfiguration( ConfigValue config) {
List<ConfigValue> configList = cache.get(config.getYearMonth());

if (configList == null) {
configList = new ArrayList<ConfigValue>();
}

config.setConfigId(configList.size() + 1);
configList.add(config);

cache.put(config.getYearMonth(), configList);

}

public List<ConfigValue> getConfiguration(String yearMonth) {
return cache.get(yearMonth);
}

public void removeConfiguration(String yearMonth) {
cache.remove(yearMonth);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.att.model.configurations;

import org.hibernate.validator.constraints.NotBlank;

public class SearchCriteria {

@NotBlank(message = "username can't empty!")
String username;

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}
}
Loading