Skip to content

Commit

Permalink
Cleanup the expanded names functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
slacmshankar committed Jun 13, 2017
1 parent d61f1ff commit b13713c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
Expand Up @@ -210,7 +210,7 @@ public enum WAR_FILE { MGMT, RETRIEVAL, ETL, ENGINE }
* For automated PV submission, IOC engineers could add .VAL, fields, aliases etc.
* This method attempts to return all possible PV's that the archiver could know about.
* This is a lot of names; so we take in a consumer that potentially streams a name out as quickly as possible.
* @return
* @param func A consumer of pvNames
*/
public void getAllExpandedNames(Consumer<String> func);

Expand Down
Expand Up @@ -2009,28 +2009,34 @@ public void getAllExpandedNames(Consumer<String> func) {
// Add fields and the VAL field
for(String pvName : allPVs) {
func.accept(pvName);
func.accept(pvName + ".VAL");
PVTypeInfo typeInfo = this.getTypeInfoForPV(pvName);
if(typeInfo != null) {
for(String fieldName : typeInfo.getArchiveFields()) {
func.accept(pvName + "." + fieldName);
if(!PVNames.isField(pvName)) {
func.accept(pvName + ".VAL");
PVTypeInfo typeInfo = this.getTypeInfoForPV(pvName);
if(typeInfo != null) {
for(String fieldName : typeInfo.getArchiveFields()) {
func.accept(pvName + "." + fieldName);
}
}
}
}
List<String> allAliases = this.getAllAliases();
for(String pvName : allAliases) {
func.accept(pvName);
func.accept(pvName + ".VAL");
PVTypeInfo typeInfo = this.getTypeInfoForPV(pvName);
if(typeInfo != null) {
for(String fieldName : typeInfo.getArchiveFields()) {
func.accept(pvName + "." + fieldName);
if(!PVNames.isField(pvName)) {
func.accept(pvName + ".VAL");
PVTypeInfo typeInfo = this.getTypeInfoForPV(pvName);
if(typeInfo != null) {
for(String fieldName : typeInfo.getArchiveFields()) {
func.accept(pvName + "." + fieldName);
}
}
}
}
for(String pvName : this.getArchiveRequestsCurrentlyInWorkflow()) {
func.accept(pvName);
func.accept(pvName + ".VAL");
if(!PVNames.isField(pvName)) {
func.accept(pvName + ".VAL");
}
}
}

Expand Down
Expand Up @@ -41,8 +41,7 @@ public class UnarchivedPVsAction implements BPLAction {
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp, ConfigService configService) throws IOException {
logger.info("Determining PVs that are unarchived ");
LinkedList<String> pvNamesFromUser = PVsMatchingParameter.getPVNamesFromPostBody(req, configService);
Set<String> normalizedPVNames = new HashSet<String>(pvNamesFromUser);
Set<String> pvNamesFromUser = new HashSet<String>(PVsMatchingParameter.getPVNamesFromPostBody(req, configService));

Set<String> expandedNames = new HashSet<String>();
configService.getAllExpandedNames(new Consumer<String>(){
Expand All @@ -51,11 +50,11 @@ public void accept(String t) {
expandedNames.add(t);
} });

normalizedPVNames.removeAll(expandedNames);
pvNamesFromUser.removeAll(expandedNames);

resp.setContentType(MimeTypeConstants.APPLICATION_JSON);
try (PrintWriter out = resp.getWriter()) {
JSONValue.writeJSONString(new LinkedList<String>(normalizedPVNames), out);
JSONValue.writeJSONString(new LinkedList<String>(pvNamesFromUser), out);
}
}
}

0 comments on commit b13713c

Please sign in to comment.