NIFI-1876: - Introducing entities for allowable values and process group status.

Signed-off-by: Jeff Storck <jtswork@gmail.com>
Signed-off-by: jpercivall <joepercivall@yahoo.com>
This commit is contained in:
Matt Gilman 2016-08-09 15:35:10 -04:00 committed by jpercivall
parent 572dfed78a
commit e81147c92a
13 changed files with 67 additions and 177 deletions

View File

@ -36,12 +36,12 @@ public class ProcessGroupStatusSnapshotDTO implements Cloneable {
private String id;
private String name;
private Collection<ConnectionStatusSnapshotEntity> connectionStatus;
private Collection<ProcessorStatusSnapshotEntity> processorStatus;
private Collection<ProcessGroupStatusSnapshotEntity> processGroupStatus;
private Collection<RemoteProcessGroupStatusSnapshotEntity> remoteProcessGroupStatus;
private Collection<PortStatusSnapshotEntity> inputPortStatus;
private Collection<PortStatusSnapshotEntity> outputPortStatus;
private Collection<ConnectionStatusSnapshotEntity> connectionStatusSnapshots;
private Collection<ProcessorStatusSnapshotEntity> processorStatusSnapshots;
private Collection<ProcessGroupStatusSnapshotEntity> processGroupStatusSnapshots;
private Collection<RemoteProcessGroupStatusSnapshotEntity> remoteProcessGroupStatusSnapshots;
private Collection<PortStatusSnapshotEntity> inputPortStatusSnapshots;
private Collection<PortStatusSnapshotEntity> outputPortStatusSnapshots;
private Integer flowFilesIn = 0;
private Long bytesIn = 0L;
@ -121,11 +121,11 @@ public class ProcessGroupStatusSnapshotDTO implements Cloneable {
*/
@ApiModelProperty("The status of all conenctions in the process group.")
public Collection<ConnectionStatusSnapshotEntity> getConnectionStatusSnapshots() {
return connectionStatus;
return connectionStatusSnapshots;
}
public void setConnectionStatusSnapshots(Collection<ConnectionStatusSnapshotEntity> connectionStatus) {
this.connectionStatus = connectionStatus;
this.connectionStatusSnapshots = connectionStatus;
}
/**
@ -135,11 +135,11 @@ public class ProcessGroupStatusSnapshotDTO implements Cloneable {
*/
@ApiModelProperty("The status of all process groups in the process group.")
public Collection<ProcessGroupStatusSnapshotEntity> getProcessGroupStatusSnapshots() {
return processGroupStatus;
return processGroupStatusSnapshots;
}
public void setProcessGroupStatusSnapshots(Collection<ProcessGroupStatusSnapshotEntity> processGroupStatus) {
this.processGroupStatus = processGroupStatus;
this.processGroupStatusSnapshots = processGroupStatus;
}
/**
@ -149,11 +149,11 @@ public class ProcessGroupStatusSnapshotDTO implements Cloneable {
*/
@ApiModelProperty("The status of all remote process groups in the process group.")
public Collection<RemoteProcessGroupStatusSnapshotEntity> getRemoteProcessGroupStatusSnapshots() {
return remoteProcessGroupStatus;
return remoteProcessGroupStatusSnapshots;
}
public void setRemoteProcessGroupStatusSnapshots(final Collection<RemoteProcessGroupStatusSnapshotEntity> remoteProcessGroupStatus) {
this.remoteProcessGroupStatus = remoteProcessGroupStatus;
this.remoteProcessGroupStatusSnapshots = remoteProcessGroupStatus;
}
/**
@ -163,11 +163,11 @@ public class ProcessGroupStatusSnapshotDTO implements Cloneable {
*/
@ApiModelProperty("The status of all processors in the process group.")
public Collection<ProcessorStatusSnapshotEntity> getProcessorStatusSnapshots() {
return processorStatus;
return processorStatusSnapshots;
}
public void setProcessorStatusSnapshots(Collection<ProcessorStatusSnapshotEntity> processorStatus) {
this.processorStatus = processorStatus;
this.processorStatusSnapshots = processorStatus;
}
/**
@ -177,11 +177,11 @@ public class ProcessGroupStatusSnapshotDTO implements Cloneable {
*/
@ApiModelProperty("The status of all input ports in the process group.")
public Collection<PortStatusSnapshotEntity> getInputPortStatusSnapshots() {
return inputPortStatus;
return inputPortStatusSnapshots;
}
public void setInputPortStatusSnapshots(Collection<PortStatusSnapshotEntity> inputPortStatus) {
this.inputPortStatus = inputPortStatus;
this.inputPortStatusSnapshots = inputPortStatus;
}
/**
@ -191,11 +191,11 @@ public class ProcessGroupStatusSnapshotDTO implements Cloneable {
*/
@ApiModelProperty("The status of all output ports in the process group.")
public Collection<PortStatusSnapshotEntity> getOutputPortStatusSnapshots() {
return outputPortStatus;
return outputPortStatusSnapshots;
}
public void setOutputPortStatusSnapshots(Collection<PortStatusSnapshotEntity> outputPortStatus) {
this.outputPortStatus = outputPortStatus;
this.outputPortStatusSnapshots = outputPortStatus;
}
/**
@ -516,9 +516,9 @@ public class ProcessGroupStatusSnapshotDTO implements Cloneable {
other.setInputPortStatusSnapshots(copy(getInputPortStatusSnapshots()));
other.setOutputPortStatusSnapshots(copy(getOutputPortStatusSnapshots()));
if (processGroupStatus != null) {
if (processGroupStatusSnapshots != null) {
final List<ProcessGroupStatusSnapshotEntity> childGroups = new ArrayList<>();
for (final ProcessGroupStatusSnapshotEntity procGroupStatus : processGroupStatus) {
for (final ProcessGroupStatusSnapshotEntity procGroupStatus : processGroupStatusSnapshots) {
childGroups.add(procGroupStatus.clone());
}
other.setProcessGroupStatusSnapshots(childGroups);

View File

@ -166,6 +166,7 @@ import org.apache.nifi.web.api.entity.PortStatusEntity;
import org.apache.nifi.web.api.entity.ProcessGroupEntity;
import org.apache.nifi.web.api.entity.ProcessGroupFlowEntity;
import org.apache.nifi.web.api.entity.ProcessGroupStatusEntity;
import org.apache.nifi.web.api.entity.ProcessGroupStatusSnapshotEntity;
import org.apache.nifi.web.api.entity.ProcessorEntity;
import org.apache.nifi.web.api.entity.ProcessorStatusEntity;
import org.apache.nifi.web.api.entity.RemoteProcessGroupEntity;
@ -2026,7 +2027,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
public ProcessGroupStatusEntity getProcessGroupStatus(final String groupId, final boolean recursive) {
final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId);
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup);
final ProcessGroupStatusDTO dto = dtoFactory.createProcessGroupStatusDto(controllerFacade.getProcessGroupStatus(groupId));
final ProcessGroupStatusDTO dto = dtoFactory.createProcessGroupStatusDto(processGroup, controllerFacade.getProcessGroupStatus(groupId));
// prune the response as necessary
if (!recursive) {
@ -2042,7 +2043,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
}
private void pruneChildGroups(final ProcessGroupStatusSnapshotDTO snapshot) {
for (final ProcessGroupStatusSnapshotDTO childProcessGroupStatus : snapshot.getProcessGroupStatusSnapshots()) {
for (final ProcessGroupStatusSnapshotEntity childProcessGroupStatusEntity : snapshot.getProcessGroupStatusSnapshots()) {
final ProcessGroupStatusSnapshotDTO childProcessGroupStatus = childProcessGroupStatusEntity.getProcessGroupStatusSnapshot();
childProcessGroupStatus.setConnectionStatusSnapshots(null);
childProcessGroupStatus.setProcessGroupStatusSnapshots(null);
childProcessGroupStatus.setInputPortStatusSnapshots(null);

View File

@ -44,8 +44,8 @@ import org.apache.nifi.cluster.manager.exception.NoClusterCoordinatorException;
import org.apache.nifi.cluster.protocol.NodeIdentifier;
import org.apache.nifi.controller.ControllerService;
import org.apache.nifi.controller.reporting.ReportingTaskProvider;
import org.apache.nifi.registry.VariableRegistry;
import org.apache.nifi.controller.service.ControllerServiceProvider;
import org.apache.nifi.registry.VariableRegistry;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.api.dto.AllowableValueDTO;
import org.apache.nifi.web.api.dto.ControllerServiceDTO;
@ -54,6 +54,7 @@ import org.apache.nifi.web.api.dto.ProcessorDTO;
import org.apache.nifi.web.api.dto.PropertyDescriptorDTO;
import org.apache.nifi.web.api.dto.ReportingTaskDTO;
import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.entity.AllowableValueEntity;
import org.apache.nifi.web.api.entity.ControllerServiceEntity;
import org.apache.nifi.web.api.entity.ProcessorEntity;
import org.apache.nifi.web.api.entity.ReportingTaskEntity;
@ -477,12 +478,13 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration
for(String key : processorConfig.getDescriptors().keySet()){
PropertyDescriptorDTO descriptor = processorConfig.getDescriptors().get(key);
List<AllowableValueDTO> allowableValuesDTO = descriptor.getAllowableValues();
List<AllowableValueEntity> allowableValuesEntity = descriptor.getAllowableValues();
Map<String,String> allowableValues = new HashMap<>();
if(allowableValuesDTO != null) {
for (AllowableValueDTO value : allowableValuesDTO) {
allowableValues.put(value.getValue(), value.getDisplayName());
if(allowableValuesEntity != null) {
for (AllowableValueEntity allowableValueEntity : allowableValuesEntity) {
final AllowableValueDTO allowableValueDTO = allowableValueEntity.getAllowableValue();
allowableValues.put(allowableValueDTO.getValue(), allowableValueDTO.getDisplayName());
}
}

View File

@ -140,6 +140,7 @@ import org.apache.nifi.web.api.dto.status.ProcessorStatusSnapshotDTO;
import org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO;
import org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO;
import org.apache.nifi.web.api.entity.AccessPolicySummaryEntity;
import org.apache.nifi.web.api.entity.AllowableValueEntity;
import org.apache.nifi.web.api.entity.ConnectionStatusSnapshotEntity;
import org.apache.nifi.web.api.entity.FlowBreadcrumbEntity;
import org.apache.nifi.web.api.entity.PortStatusSnapshotEntity;
@ -2500,27 +2501,29 @@ public final class DtoFactory {
if (serviceDefinition == null) {
dto.setAllowableValues(null);
} else {
final List<AllowableValueDTO> allowableValues = new ArrayList<>();
final List<AllowableValueEntity> allowableValues = new ArrayList<>();
for (final String serviceIdentifier : controllerServiceProvider.getControllerServiceIdentifiers(serviceDefinition, groupId)) {
final ControllerServiceNode service = controllerServiceProvider.getControllerServiceNode(serviceIdentifier);
final String displayName = service.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser()) ? service.getName() : serviceIdentifier;
final boolean isServiceAuthorized = service.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
final String displayName = isServiceAuthorized ? service.getName() : serviceIdentifier;
final AllowableValueDTO allowableValue = new AllowableValueDTO();
allowableValue.setDisplayName(displayName);
allowableValue.setValue(serviceIdentifier);
allowableValues.add(allowableValue);
allowableValues.add(entityFactory.createAllowableValueEntity(allowableValue, isServiceAuthorized));
}
dto.setAllowableValues(allowableValues);
}
} else {
final List<AllowableValueDTO> allowableValues = new ArrayList<>();
final List<AllowableValueEntity> allowableValues = new ArrayList<>();
for (final AllowableValue allowableValue : propertyDescriptor.getAllowableValues()) {
final AllowableValueDTO allowableValueDto = new AllowableValueDTO();
allowableValueDto.setDisplayName(allowableValue.getDisplayName());
allowableValueDto.setValue(allowableValue.getValue());
allowableValueDto.setDescription(allowableValue.getDescription());
allowableValues.add(allowableValueDto);
allowableValues.add(entityFactory.createAllowableValueEntity(allowableValueDto, true));
}
dto.setAllowableValues(allowableValues);
}

View File

@ -31,6 +31,7 @@ import org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO;
import org.apache.nifi.web.api.dto.status.StatusHistoryDTO;
import org.apache.nifi.web.api.entity.AccessPolicyEntity;
import org.apache.nifi.web.api.entity.AccessPolicySummaryEntity;
import org.apache.nifi.web.api.entity.AllowableValueEntity;
import org.apache.nifi.web.api.entity.ConnectionEntity;
import org.apache.nifi.web.api.entity.ConnectionStatusEntity;
import org.apache.nifi.web.api.entity.ConnectionStatusSnapshotEntity;
@ -511,4 +512,11 @@ public final class EntityFactory {
}
return entity;
}
public AllowableValueEntity createAllowableValueEntity(final AllowableValueDTO dto, final boolean canRead) {
final AllowableValueEntity entity = new AllowableValueEntity();
entity.setCanRead(canRead);
entity.setAllowableValue(dto);
return entity;
}
}

View File

@ -525,7 +525,8 @@
});
}
if ($.isArray(allowableValues)) {
$.each(allowableValues, function (i, allowableValue) {
$.each(allowableValues, function (i, allowableValueEntity) {
var allowableValue = allowableValueEntity.allowableValue;
options.push({
text: allowableValue.displayName,
value: allowableValue.value,
@ -735,7 +736,8 @@
// create the read only options
var options = [];
$.each(allowableValues, function (i, allowableValue) {
$.each(allowableValues, function (i, allowableValueEntity) {
var allowableValue = allowableValueEntity.allowableValue;
options.push({
text: allowableValue.displayName,
value: allowableValue.value,
@ -1081,7 +1083,8 @@
// if there are allowable values, attempt to swap out for the display name
var allowableValues = nf.Common.getAllowableValues(propertyDescriptor);
if ($.isArray(allowableValues)) {
$.each(allowableValues, function (_, allowableValue) {
$.each(allowableValues, function (_, allowableValueEntity) {
var allowableValue = allowableValueEntity.allowableValue;
if (value === allowableValue.value) {
value = allowableValue.displayName;
return false;
@ -1147,7 +1150,8 @@
// check to see if we should provide a button for going to a controller service
if (identifiesControllerService && isConfigured && isOnCanvas) {
// ensure the configured value is referencing a valid service
$.each(propertyDescriptor.allowableValues, function (_, allowableValue) {
$.each(propertyDescriptor.allowableValues, function (_, allowableValueEntity) {
var allowableValue = allowableValueEntity.allowableValue;
if (allowableValue.value === dataContext.value) {
markup += '<div class="pointer go-to-service fa fa-long-arrow-right" title="Go To" style="margin-top: 2px" ></div>';
return false;

View File

@ -1619,28 +1619,6 @@ nf.Connection = (function () {
d3.selectAll('g.connection').call(sort);
},
/**
* Sets the connection status using the specified status.
*
* @param {array} connectionStatus
*/
setStatus: function (connectionStatus) {
if (nf.Common.isEmpty(connectionStatus)) {
return;
}
// update the connection status
$.each(connectionStatus, function (_, status) {
if (connectionMap.has(status.id)) {
var connection = connectionMap.get(status.id);
connection.status = status;
}
});
// update the visible connections
d3.selectAll('g.connection.visible').call(updateConnectionStatus);
},
/**
* Refreshes the connection in the UI.
*

View File

@ -144,25 +144,6 @@ nf.Graph = (function () {
};
},
/**
* Populates the status for the components specified. This will update the content
* of the existing components on the graph and will not cause them to be repainted.
* This operation must be very inexpensive due to the frequency it is called.
*
* @argument {object} aggregateSnapshot The status of the process group aggregated accross the cluster
*/
setStatus: function (aggregateSnapshot) {
// merge the port status together
var portStatus = combinePortStatus(aggregateSnapshot);
// set the component status
nf.Port.setStatus(portStatus);
nf.RemoteProcessGroup.setStatus(aggregateSnapshot.remoteProcessGroupStatusSnapshots);
nf.ProcessGroup.setStatus(aggregateSnapshot.processGroupStatusSnapshots);
nf.Processor.setStatus(aggregateSnapshot.processorStatusSnapshots);
nf.Connection.setStatus(aggregateSnapshot.connectionStatusSnapshots);
},
/**
* Clears all the components currently on the canvas. This function does not automatically refresh.
*/

View File

@ -630,28 +630,6 @@ nf.Port = (function () {
d3.select('#id-' + id).call(nf.CanvasUtils.position);
},
/**
* Sets the port status using the specified status.
*
* @param {array} portStatus Port status
*/
setStatus: function (portStatus) {
if (nf.Common.isEmpty(portStatus)) {
return;
}
// update the specified port status
$.each(portStatus, function (_, status) {
if (portMap.has(status.id)) {
var port = portMap.get(status.id);
port.status = status;
}
});
// update the visible ports
d3.selectAll('g.input-port.visible, g.output-port.visible').call(updatePortStatus);
},
/**
* Removes the specified port.
*

View File

@ -1108,28 +1108,6 @@ nf.ProcessGroup = (function () {
d3.select('#id-' + id).call(nf.CanvasUtils.position);
},
/**
* Sets the process group status using the specified status.
*
* @param {array} processGroupStatus Process group status
*/
setStatus: function (processGroupStatus) {
if (nf.Common.isEmpty(processGroupStatus)) {
return;
}
// update the specified process group status
$.each(processGroupStatus, function (_, status) {
if (processGroupMap.has(status.id)) {
var processGroup = processGroupMap.get(status.id);
processGroup.status = status;
}
});
// update the visible process groups
d3.selectAll('g.process-group.visible').call(updateProcessGroupStatus);
},
/**
* Removes the specified process group.
*

View File

@ -899,28 +899,6 @@ nf.Processor = (function () {
nf.Processor.remove(processorMap.keys());
},
/**
* Sets the processor status using the specified status.
*
* @param {array} processorStatus Processor status
*/
setStatus: function (processorStatus) {
if (nf.Common.isEmpty(processorStatus)) {
return;
}
// update the specified processor status
$.each(processorStatus, function (_, status) {
if (processorMap.has(status.id)) {
var processor = processorMap.get(status.id);
processor.status = status;
}
});
// update the visible processor status
d3.selectAll('g.processor.visible').call(updateProcessorStatus);
},
/**
* Returns the default color that should be used when drawing a processor.
*/

View File

@ -962,28 +962,6 @@ nf.RemoteProcessGroup = (function () {
d3.select('#id-' + id).call(nf.CanvasUtils.position);
},
/**
* Sets the remote process group status using the specified status.
*
* @param {array | object} remoteProcessGroupStatus Remote process group status
*/
setStatus: function (remoteProcessGroupStatus) {
if (nf.Common.isEmpty(remoteProcessGroupStatus)) {
return;
}
// update the specified process group status
$.each(remoteProcessGroupStatus, function (_, status) {
if (remoteProcessGroupMap.has(status.id)) {
var entry = remoteProcessGroupMap.get(status.id);
entry.status = status;
}
});
// only update the visible components
d3.selectAll('g.remote-process-group.visible').call(updateProcessGroupStatus);
},
/**
* Removes the specified process group.
*

View File

@ -2304,36 +2304,36 @@ nf.SummaryTable = (function () {
*/
var populateProcessGroupStatus = function (processorItems, connectionItems, processGroupItems, inputPortItems, outputPortItems, remoteProcessGroupItems, aggregateSnapshot) {
// add the processors to the summary grid
$.each(aggregateSnapshot.processorStatusSnapshots, function (i, procStatus) {
processorItems.push(procStatus);
$.each(aggregateSnapshot.processorStatusSnapshots, function (i, procStatusEntity) {
processorItems.push(procStatusEntity.processorStatusSnapshot);
});
// add the processors to the summary grid
$.each(aggregateSnapshot.connectionStatusSnapshots, function (i, connStatus) {
connectionItems.push(connStatus);
$.each(aggregateSnapshot.connectionStatusSnapshots, function (i, connStatusEntity) {
connectionItems.push(connStatusEntity.connectionStatusSnapshot);
});
// add the input ports to the summary grid
$.each(aggregateSnapshot.inputPortStatusSnapshots, function (i, portStatus) {
inputPortItems.push(portStatus);
$.each(aggregateSnapshot.inputPortStatusSnapshots, function (i, portStatusEntity) {
inputPortItems.push(portStatusEntity.portStatusSnapshot);
});
// add the input ports to the summary grid
$.each(aggregateSnapshot.outputPortStatusSnapshots, function (i, portStatus) {
outputPortItems.push(portStatus);
$.each(aggregateSnapshot.outputPortStatusSnapshots, function (i, portStatusEntity) {
outputPortItems.push(portStatusEntity.portStatusSnapshot);
});
// add the input ports to the summary grid
$.each(aggregateSnapshot.remoteProcessGroupStatusSnapshots, function (i, rpgStatus) {
remoteProcessGroupItems.push(rpgStatus);
$.each(aggregateSnapshot.remoteProcessGroupStatusSnapshots, function (i, rpgStatusEntity) {
remoteProcessGroupItems.push(rpgStatusEntity.remoteProcessGroupStatusSnapshot);
});
// add the process group status as well
processGroupItems.push(aggregateSnapshot);
// add any child group's status
$.each(aggregateSnapshot.processGroupStatusSnapshots, function (i, childProcessGroup) {
populateProcessGroupStatus(processorItems, connectionItems, processGroupItems, inputPortItems, outputPortItems, remoteProcessGroupItems, childProcessGroup);
$.each(aggregateSnapshot.processGroupStatusSnapshots, function (i, childProcessGroupEntity) {
populateProcessGroupStatus(processorItems, connectionItems, processGroupItems, inputPortItems, outputPortItems, remoteProcessGroupItems, childProcessGroupEntity.processGroupStatusSnapshot);
});
};