Skip to content

Commit

Permalink
Merge pull request #176 from NCI-Agency/GH-11
Browse files Browse the repository at this point in the history
Move dictionary to anet.yml
  • Loading branch information
VassilIordanov authored Sep 27, 2017
2 parents 9b1b554 + cb4ea98 commit 3cfbc04
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 102 deletions.
84 changes: 84 additions & 0 deletions anet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,87 @@ logging:
currentLogFilename: ./logs/anet.log
archivedLogFilenamePattern: ./logs/anet-%d.log.zip
archivedFileCount: 2

dictionary:
PRINCIPAL_PERSON_TITLE: Afghan Partner
ADVISOR_PERSON_TITLE: NATO Member
PRINCIPAL_POSITION_NAME: Afghan Tashkil
ADVISOR_POSITION_NAME: NATO Billet
ADVISOR_POSITION_TYPE_TITLE: NATO Advisor
SUPER_USER_POSITION_TYPE_TITLE: ANET Super User
ADMINISTRATOR_POSITION_TYPE_TITLE: ANET Administrator
PRINCIPAL_ORG_NAME: Afghan Government Organization
ADVISOR_ORG_NAME: Advisor Organization
POAM_LONG_NAME: Plan of Action and Milestones / Pillars
POAM_SHORT_NAME: PoAM
NAV_BAR_ALL_ADVISOR_ORGS: All EFs / AOs
pinned_ORGs:
- Key Leader Engagement
countries:
- Afghanistan
- Albania
- Armenia
- Australia
- Austria
- Azerbaijan
- Belgium
- Bosnia-Herzegovina
- Bulgaria
- Croatia
- Czech Republic
- Denmark
- Estonia
- Finland
- Georgia
- Germany
- Greece
- Hungary
- Iceland
- Italy
- Latvia
- Lithuania
- Luxembourg
- Macedonia
- Mongolia
- Montenegro
- Netherlands
- New Zealand
- Norway
- Poland
- Portugal
- Romania
- Slovakia
- Slovenia
- Spain
- Sweden
- Turkey
- Ukraine
- United Kingdom
- United States of America
ranks:
- CIV
- CTR
- OR-1
- OR-2
- OR-3
- OR-4
- OR-5
- OR-6
- OR-7
- OR-8
- OR-9
- WO-1
- WO-2
- WO-3
- WO-4
- WO-5
- OF-1
- OF-2
- OF-3
- OF-4
- OF-5
- OF-6
- OF-7
- OF-8
- OF-9
- OF-10
9 changes: 2 additions & 7 deletions client/src/pages/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import dict from 'dictionary'
import API from 'api'
import {Person, Organization} from 'models'

import dictionary from 'resources/dictionary.json'

export default class App extends Page {
static PagePropTypes = {
Expand All @@ -25,14 +24,12 @@ export default class App extends Page {
static childContextTypes = {
app: PropTypes.object,
currentUser: PropTypes.instanceOf(Person),
// dictionary: PropTypes.object,
}

getChildContext() {
return {
app: this,
currentUser: this.state.currentUser,
// dictionary: this.state.dictionary,
}
}

Expand All @@ -43,7 +40,6 @@ export default class App extends Page {
currentUser: new Person(),
settings: {},
organizations: [],
// dictionary: {}
}

this.state = this.processData(window.ANET_DATA)
Expand Down Expand Up @@ -83,10 +79,9 @@ export default class App extends Page {
})

//Fetch the dictionary.
// @vassil dictionary.json temporarily moved to resouces. Difficulties to load from /dictionary.json when deployed as the files is moved under PUBLIC_URL
// API.fetch('/dictonary.json').then(dictionary =>
API.fetch('/api/admin/dictionary').then(dictionary =>
dict.setDictionary(dictionary)
// )
)
}

processData(data) {
Expand Down
92 changes: 0 additions & 92 deletions client/src/resources/dictionary.json

This file was deleted.

4 changes: 3 additions & 1 deletion src/main/java/mil/dds/anet/AnetApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature;
import org.json.JSONObject;
import org.skife.jdbi.v2.DBI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -113,6 +114,7 @@ public void run(AnetConfiguration configuration, Environment environment) {
final DBIFactory factory = new DBIFactory();
final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "mssql");

logger.info("dictionary: {}", new JSONObject(configuration.getDictionary()).toString(2));

//We want to use our own custom DB logger in order to clean up the logs a bit.
jdbi.setSQLLog(new AnetDbLogger());
Expand Down Expand Up @@ -176,7 +178,7 @@ public void run(AnetConfiguration configuration, Environment environment) {
PositionResource positionResource = new PositionResource(engine);
ApprovalStepResource asResource = new ApprovalStepResource(engine);
ReportResource reportResource = new ReportResource(engine, configuration);
AdminResource adminResource = new AdminResource(engine);
AdminResource adminResource = new AdminResource(engine, configuration);
HomeResource homeResource = new HomeResource(engine);
SavedSearchResource savedSearchResource = new SavedSearchResource(engine);
final TagResource tagResource = new TagResource(engine);
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/mil/dds/anet/config/AnetConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class AnetConfiguration extends Configuration {
private String emailFromAddr;
private String serverUrl;

private Map<String, Object> dictionary;

@NotNull
private Map<String,String> waffleConfig = new HashMap<String,String>();

Expand Down Expand Up @@ -104,6 +106,14 @@ public void setServerUrl(String serverUrl) {
this.serverUrl = serverUrl;
}

public Map<String, Object> getDictionary() {
return dictionary;
}

public void setDictionary(Map<String, Object> dictionary) {
this.dictionary = dictionary;
}

public static class SmtpConfiguration {
private String hostname;
private Integer port = 587;
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/mil/dds/anet/resources/AdminResource.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
package mil.dds.anet.resources;

import java.util.List;
import java.util.Map;

import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import mil.dds.anet.AnetObjectEngine;
import mil.dds.anet.beans.AdminSetting;
import mil.dds.anet.config.AnetConfiguration;
import mil.dds.anet.database.AdminDao;
import mil.dds.anet.graphql.GraphQLFetcher;
import mil.dds.anet.graphql.IGraphQLResource;
import mil.dds.anet.views.AbstractAnetBean;

@Path("/api/admin")
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
public class AdminResource implements IGraphQLResource {

private AdminDao dao;

public AdminResource(AnetObjectEngine engine) {
private AnetConfiguration config;

public AdminResource(AnetObjectEngine engine, AnetConfiguration config) {
this.dao = engine.getAdminDao();
this.config = config;
}

@GET
Expand All @@ -44,6 +51,12 @@ public Response save(List<AdminSetting> settings) {
return Response.ok().build();
}

@GET
@Path("/dictionary")
public Map<String, Object> getDictionary() {
return config.getDictionary();
}

@Override
public String getDescription() {
return "Admin Resources";
Expand Down

0 comments on commit 3cfbc04

Please sign in to comment.