Search in sources :

Example 1 with RemoteProcessGroupDetails

use of org.apache.nifi.action.component.details.RemoteProcessGroupDetails in project nifi by apache.

the class DtoFactory method createComponentDetailsDto.

/**
 * Creates a ComponentDetailsDTO for the specified ComponentDetails.
 *
 * @param componentDetails details
 * @return dto
 */
private ComponentDetailsDTO createComponentDetailsDto(final ComponentDetails componentDetails) {
    if (componentDetails == null) {
        return null;
    }
    if (componentDetails instanceof FlowChangeExtensionDetails) {
        final ExtensionDetailsDTO processorDetails = new ExtensionDetailsDTO();
        processorDetails.setType(((ExtensionDetails) componentDetails).getType());
        return processorDetails;
    } else if (componentDetails instanceof FlowChangeRemoteProcessGroupDetails) {
        final RemoteProcessGroupDetailsDTO remoteProcessGroupDetails = new RemoteProcessGroupDetailsDTO();
        remoteProcessGroupDetails.setUri(((RemoteProcessGroupDetails) componentDetails).getUri());
        return remoteProcessGroupDetails;
    } else {
        throw new WebApplicationException(new IllegalArgumentException(String.format("Unrecognized type of component details encountered %s during serialization. ", componentDetails.toString())));
    }
}
Also used : RemoteProcessGroupDetailsDTO(org.apache.nifi.web.api.dto.action.component.details.RemoteProcessGroupDetailsDTO) RemoteProcessGroupDetails(org.apache.nifi.action.component.details.RemoteProcessGroupDetails) FlowChangeRemoteProcessGroupDetails(org.apache.nifi.action.component.details.FlowChangeRemoteProcessGroupDetails) WebApplicationException(javax.ws.rs.WebApplicationException) FlowChangeExtensionDetails(org.apache.nifi.action.component.details.FlowChangeExtensionDetails) FlowChangeRemoteProcessGroupDetails(org.apache.nifi.action.component.details.FlowChangeRemoteProcessGroupDetails) ExtensionDetailsDTO(org.apache.nifi.web.api.dto.action.component.details.ExtensionDetailsDTO)

Example 2 with RemoteProcessGroupDetails

use of org.apache.nifi.action.component.details.RemoteProcessGroupDetails in project nifi by apache.

the class StandardActionDAO method createAction.

@Override
public Action createAction(Action action) throws DataAccessException {
    if (action.getUserIdentity() == null) {
        throw new IllegalArgumentException("User cannot be null.");
    }
    if (action.getTimestamp() == null) {
        throw new IllegalArgumentException("Action timestamp cannot be null.");
    }
    PreparedStatement statement = null;
    ResultSet rs = null;
    try {
        // obtain a statement to insert to the action table
        statement = connection.prepareStatement(INSERT_ACTION, Statement.RETURN_GENERATED_KEYS);
        statement.setString(1, StringUtils.left(action.getUserIdentity(), 4096));
        statement.setString(2, action.getSourceId());
        statement.setString(3, StringUtils.left(action.getSourceName(), 1000));
        statement.setString(4, action.getSourceType().name());
        statement.setString(5, action.getOperation().name());
        statement.setTimestamp(6, new java.sql.Timestamp(action.getTimestamp().getTime()));
        // insert the action
        int updateCount = statement.executeUpdate();
        final FlowChangeAction createdAction = new FlowChangeAction();
        createdAction.setUserIdentity(action.getUserIdentity());
        createdAction.setSourceId(action.getSourceId());
        createdAction.setSourceName(action.getSourceName());
        createdAction.setSourceType(action.getSourceType());
        createdAction.setOperation(action.getOperation());
        createdAction.setTimestamp(action.getTimestamp());
        createdAction.setActionDetails(action.getActionDetails());
        createdAction.setComponentDetails(action.getComponentDetails());
        // get the action id
        rs = statement.getGeneratedKeys();
        if (updateCount == 1 && rs.next()) {
            createdAction.setId(rs.getInt(1));
        } else {
            throw new DataAccessException("Unable to insert action.");
        }
        // close the previous statement
        statement.close();
        // determine the type of component
        ComponentDetails componentDetails = createdAction.getComponentDetails();
        if (componentDetails instanceof FlowChangeExtensionDetails) {
            createExtensionDetails(createdAction.getId(), (ExtensionDetails) componentDetails);
        } else if (componentDetails instanceof FlowChangeRemoteProcessGroupDetails) {
            createRemoteProcessGroupDetails(createdAction.getId(), (RemoteProcessGroupDetails) componentDetails);
        }
        // determine the type of action
        ActionDetails details = createdAction.getActionDetails();
        if (details instanceof FlowChangeConnectDetails) {
            createConnectDetails(createdAction.getId(), (ConnectDetails) details);
        } else if (details instanceof FlowChangeMoveDetails) {
            createMoveDetails(createdAction.getId(), (MoveDetails) details);
        } else if (details instanceof FlowChangeConfigureDetails) {
            createConfigureDetails(createdAction.getId(), (ConfigureDetails) details);
        } else if (details instanceof FlowChangePurgeDetails) {
            createPurgeDetails(createdAction.getId(), (PurgeDetails) details);
        }
        return createdAction;
    } catch (SQLException sqle) {
        throw new DataAccessException(sqle);
    } finally {
        RepositoryUtils.closeQuietly(rs);
        RepositoryUtils.closeQuietly(statement);
    }
}
Also used : FlowChangeMoveDetails(org.apache.nifi.action.details.FlowChangeMoveDetails) MoveDetails(org.apache.nifi.action.details.MoveDetails) FlowChangePurgeDetails(org.apache.nifi.action.details.FlowChangePurgeDetails) SQLException(java.sql.SQLException) FlowChangeMoveDetails(org.apache.nifi.action.details.FlowChangeMoveDetails) PreparedStatement(java.sql.PreparedStatement) FlowChangeRemoteProcessGroupDetails(org.apache.nifi.action.component.details.FlowChangeRemoteProcessGroupDetails) FlowChangeRemoteProcessGroupDetails(org.apache.nifi.action.component.details.FlowChangeRemoteProcessGroupDetails) RemoteProcessGroupDetails(org.apache.nifi.action.component.details.RemoteProcessGroupDetails) FlowChangeConnectDetails(org.apache.nifi.action.details.FlowChangeConnectDetails) FlowChangeConfigureDetails(org.apache.nifi.action.details.FlowChangeConfigureDetails) FlowChangeExtensionDetails(org.apache.nifi.action.component.details.FlowChangeExtensionDetails) ResultSet(java.sql.ResultSet) FlowChangePurgeDetails(org.apache.nifi.action.details.FlowChangePurgeDetails) PurgeDetails(org.apache.nifi.action.details.PurgeDetails) ActionDetails(org.apache.nifi.action.details.ActionDetails) ComponentDetails(org.apache.nifi.action.component.details.ComponentDetails) DataAccessException(org.apache.nifi.admin.dao.DataAccessException) FlowChangeAction(org.apache.nifi.action.FlowChangeAction)

Aggregations

FlowChangeExtensionDetails (org.apache.nifi.action.component.details.FlowChangeExtensionDetails)2 FlowChangeRemoteProcessGroupDetails (org.apache.nifi.action.component.details.FlowChangeRemoteProcessGroupDetails)2 RemoteProcessGroupDetails (org.apache.nifi.action.component.details.RemoteProcessGroupDetails)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 FlowChangeAction (org.apache.nifi.action.FlowChangeAction)1 ComponentDetails (org.apache.nifi.action.component.details.ComponentDetails)1 ActionDetails (org.apache.nifi.action.details.ActionDetails)1 FlowChangeConfigureDetails (org.apache.nifi.action.details.FlowChangeConfigureDetails)1 FlowChangeConnectDetails (org.apache.nifi.action.details.FlowChangeConnectDetails)1 FlowChangeMoveDetails (org.apache.nifi.action.details.FlowChangeMoveDetails)1 FlowChangePurgeDetails (org.apache.nifi.action.details.FlowChangePurgeDetails)1 MoveDetails (org.apache.nifi.action.details.MoveDetails)1 PurgeDetails (org.apache.nifi.action.details.PurgeDetails)1 DataAccessException (org.apache.nifi.admin.dao.DataAccessException)1 ExtensionDetailsDTO (org.apache.nifi.web.api.dto.action.component.details.ExtensionDetailsDTO)1 RemoteProcessGroupDetailsDTO (org.apache.nifi.web.api.dto.action.component.details.RemoteProcessGroupDetailsDTO)1