Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DHFPROD-1740, Create 5.x FlowManager and refactor 4.x FlowManager to LegacyFlowManager #1791

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* This application configuration is an entry point to using the DHF from a set property
*/
@Configuration
@ComponentScan(basePackages = {"com.marklogic.hub.impl", "com.marklogic.hub.deploy.commands"})
@ComponentScan(basePackages = {"com.marklogic.hub.impl", "com.marklogic.hub.legacy.impl", "com.marklogic.hub.deploy.commands"})
@EnableAutoConfiguration
public class ApplicationConfig {

Expand Down
97 changes: 38 additions & 59 deletions marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,100 +16,79 @@

package com.marklogic.hub;

import com.marklogic.hub.legacy.flow.Flow;
import com.marklogic.hub.legacy.flow.FlowRunner;
import com.marklogic.hub.legacy.flow.FlowType;
import com.marklogic.hub.legacy.flow.impl.FlowImpl;
import org.w3c.dom.Element;
import com.fasterxml.jackson.databind.JsonNode;
import com.marklogic.hub.error.DataHubProjectException;
import com.marklogic.hub.flow.Flow;

import java.nio.file.Path;
import java.util.List;

/**
* Manages existing flows and creates flow runners to execute flows.
* Manages CRUD operations for flows
*/
public interface FlowManager {

/**
* Turns an XML document into a flow
* @param doc - the xml document representing a flow
* @return a Flow instance
* String value for the flow file extension
*/
static Flow flowFromXml(Element doc) {
return FlowImpl.fromXml(doc);
}
String FLOW_FILE_EXTENSION = ".flow.json";

/**
* retrieves a list of all the flows on the local files systems
* @return a list of Flows
* Retrieves a named flow
* @param flowName - name of the flow
* @return a flow object
*/
List<Flow> getLocalFlows();
Flow getFlow(String flowName);

/**
* retrieves a list of all the flows on the local files systems
* @param entityName - string name of the entity for the flow
* @return a list of Flows
* Returns a flow based on the provided name as JSON string
* @param flowName - name of the flow
* @return string json representation of the flow object
*/
List<Flow> getLocalFlowsForEntity(String entityName);
String getFlowAsJSON(String flowName);

/**
* retrieves a list of all the flows on the local files systems
* @param entityName - string name of the entity for the flow
* @param flowType - the FlowType enum, eg: ingest or harmonize
* @return a list of Flows
* Retrieves a list of flows installed on the MarkLogic server
* @return - a list of all flows
*/
List<Flow> getLocalFlowsForEntity(String entityName, FlowType flowType);
List<Flow> getFlows();

/**
* Obtains a flow from a property file
* @param propertiesFile - the Path to the property file
* @return - a flow object
* Retrieves a list of names of flows installed on the MarkLogic server
* @return - a list of names of all flows
*/
Flow getFlowFromProperties(Path propertiesFile);
List<String> getFlowNames();

/**
* Retrieves a list of flows installed on the MarkLogic server
* @param entityName - the entity from which to fetch the flows
* @return - a list of flows for the given entity
* Creates a flow
* @param flowName - name of the flow
*/
List<Flow> getFlows(String entityName);
Flow createFlow(String flowName);

/**
* Retrieves a named flow from a given entity
*
* @param entityName - the entity that the flow belongs to
* @param flowName - the name of the flow to get
* @return the flow
* Creates a flow from a given JSON string
* @param json - string representation of the flow
* @return - a Flow object
*/
Flow getFlow(String entityName, String flowName);
Flow createFlowFromJSON(String json);

/**
* Retrieves a named flow from a given entity
*
* @param entityName - the entity that the flow belongs to
* @param flowName - the name of the flow to get
* @param flowType - the type of flow (ingest/harmonize)
* @return the flow
* Creates a flow from a given JsonNode
* @param json - JsonNode representation of the flow
* @return - a Flow object
*/
Flow getFlow(String entityName, String flowName, FlowType flowType);
Flow createFlowFromJSON(JsonNode json);

/**
* Updates the indexes in the database based on the project
* @return - a list of names for all the flows that are legacy
* Deletes a flow
* @param flowName - name of the flow
*/

List<String> getLegacyFlows();
void deleteFlow(String flowName);

/**
* Sets the version that the legacy flow is to be updated from
* @param fromVersion - string representation of DHF version
* @return a list of updated flow names that were updated
* Saves a flow to disk
* @param flow - the flow object to be saved
*/
List<String> updateLegacyFlows(String fromVersion);
void saveFlow(Flow flow);


/**
* Creates and returns a new FlowRunner object using the FlowManager's hubconfig
* @return FlowRunner object with current hubconfig already set
*/
FlowRunner newFlowRunner();
}
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,13 @@ public interface HubConfig {
*/
Path getEntityDatabaseDir();

/**
* Gets the path for the flows directory
*
* @return the path for the flows directory
*/
Path getFlowsDir();

/**
* Returns the current AppConfig object attached to the HubConfig
* @return Returns current AppConfig object set for HubConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ public interface HubProject {
*/
Path getEntityDatabaseDir();

/**
* Gets the path for the flows directory
*
* @return the path for the flows directory
*/
Path getFlowsDir();

/**
* Gets the path for the hub staging modules
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.marklogic.client.io.Format;
import com.marklogic.client.io.StringHandle;
import com.marklogic.hub.EntityManager;
import com.marklogic.hub.FlowManager;
import com.marklogic.hub.legacy.LegacyFlowManager;
import com.marklogic.hub.HubConfig;
import com.marklogic.hub.deploy.util.HubFileFilter;
import com.marklogic.hub.error.LegacyFlowsException;
Expand Down Expand Up @@ -63,7 +63,7 @@ public class LoadUserModulesCommand extends LoadModulesCommand {
private EntityManager entityManager;

@Autowired
private FlowManager flowManager;
private LegacyFlowManager flowManager;

private DocumentPermissionsParser documentPermissionsParser = new DefaultDocumentPermissionsParser();
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.marklogic.hub.deploy.commands.*;
import com.marklogic.hub.deploy.util.HubDeployStatusListener;
import com.marklogic.hub.error.*;
import com.marklogic.hub.legacy.impl.LegacyFlowManagerImpl;
import com.marklogic.mgmt.ManageClient;
import com.marklogic.mgmt.admin.AdminManager;
import com.marklogic.mgmt.resource.appservers.ServerManager;
Expand Down Expand Up @@ -100,7 +101,7 @@ public class DataHubImpl implements DataHub {
private Versions versions;

@Autowired
private FlowManagerImpl flowManager;
private LegacyFlowManagerImpl flowManager;

private AdminManager _adminManager;

Expand Down
Loading