<
DQM Connect, 2025.1
Documentation

Developer notes: FirstSpirit Service – DQM Connect


Examples

The DQM Connect module includes the "DQMConnectorVerificationService". This service ensures the correct employment of DQM functionalities in scripts and workflows.

The following methods are available:

// Returns true if the DQMConnect Modul 
// is configured correctly.
boolean dqmVerificationAvailable()

// Renders the transferred FirstSpirit element as 
// HTML and thus calls up the DQM API.
DQMVerificationResult fetchVerificationStatus(
   IDProvider idProvider, 
   DQMVerificationParameters parameters)

// Determines the FirstSpirit element from the 
// transmitted values, renders it as HTML
// and thus calls up the DQM API.
DQMVerificationResult fetchVerificationStatus(
   long projectId, 
   long elementId, 
   Store.Type storeType, 
   DQMVerificationParameters parameters)

// Calls up the DQM API with the transmitted HTML.
DQMVerificationResult fetchVerificationStatus(String previewHtml)

Using the “DQMVerificationParameter”, you can edit language settings and change the RenderMode.

The return type "DQMVerificationResult" includes a list of all detected issues. The entries are of the type "DqmCheckpoint" and are modeled after the DQM API return type.

Sample script

The following script runs the DQM check for the page/page references in the current context. It scans the context for prioritized issues in the category "Content presentation".

import de.espirit.firstspirit.agency.OperationAgent;
import de.espirit.firstspirit.agency.RenderingAgent;
import de.espirit.firstspirit.ui.operations.RequestOperation;
import de.espirit.firstspirit.access.ServicesBroker;
import com.espirit.modules.dqmconnect.DQMConnectorVerificationService;
import com.espirit.modules.dqmconnect.DQMVerificationParameters;
import java.util.function.Predicate;

service = context.requireSpecialist(ServicesBroker.TYPE)
   .getService(DQMConnectorVerificationService.class);

// Only works for Page and PageRef elements
idProvider = context.getStoreElement();
params = new DQMVerificationParameters(
    RenderingAgent.RenderMode.DEFAULT, /* optional */
   "EN");
response = service.fetchVerificationStatus(idProvider, params);
failures = response.failures();

hasContentPresentationIssues = failures.stream()
   .anyMatch(new Predicate() {
      boolean test(r) {
         return r.isPriority() && "Content presentation".equals(r.getCategory());
      }
});

message = context.requireSpecialist(OperationAgent.TYPE)
   .getOperation(RequestOperation.TYPE);
message.setTitle("Content presentation issues found:");
message.setKind(RequestOperation.Kind.INFO);
message.perform("" + hasContentPresentationIssues);

Sample integration into a workflow

The service can be integrated into workflows using scripts. If e.g. the release process shall be abandoned when tests of the "mobile" category return an error, the service can be used as follows:

import com.espirit.modules.dqmconnect.DQMConnectorVerificationService;
import com.espirit.modules.dqmconnect.DQMVerificationParameters;
import de.espirit.firstspirit.access.ServicesBroker;
import de.espirit.firstspirit.agency.OperationAgent;
import de.espirit.firstspirit.ui.operations.RequestOperation;
import de.espirit.firstspirit.agency.RenderingAgent.RenderMode;
import java.util.HashMap;
import java.util.ArrayList;

storeElement = context.getElement();
context.logInfo("Performing DQM Verification for " + storeElement.getUid());

servicesBroker = context.requireSpecialist(ServicesBroker.TYPE);
verificationService = servicesBroker.getService(DQMConnectorVerificationService.class);
parameters = new DQMVerificationParameters("DE");
result = verificationService.fetchVerificationStatus(storeElement, parameters);
failures = result.failures();

failuresByCategory = new HashMap();
for (checkPoint : failures) { 
  category = checkPoint.getCategory();
  if (!failuresByCategory.containsKey(category)) {
    failuresByCategory.put(category, new ArrayList());	
  }
  failuresByCategory.get(category).add(checkPoint);
}
mobileFailures = failuresByCategory.getOrDefault("Mobile", new ArrayList());

operationAgent = context.requireSpecialist(OperationAgent.TYPE);
requestOperation = operationAgent.getOperation(RequestOperation.TYPE);
if (!mobileFailures.isEmpty()) {
  requestOperation.perform("Got DQM Failures");
  context.doTransition("VerificationFailed");
} else {
  requestOperation.perform("DQM Verification OK");
  context.doTransition("Direkt freigeben");
}