Search in sources :

Example 56 with Activity

use of com.google.api.ads.admanager.axis.v202205.Activity in project googleads-java-lib by googleads.

the class GetAllActivities method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    // Get the ActivityService.
    ActivityServiceInterface activityService = adManagerServices.get(session, ActivityServiceInterface.class);
    // Create a statement to get all activities.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get activities by statement.
        ActivityPage page = activityService.getActivitiesByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Activity activity : page.getResults()) {
                System.out.printf("%d) Activity with ID %d, name '%s', and type '%s' was found.%n", i++, activity.getId(), activity.getName(), activity.getType());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : ActivityPage(com.google.api.ads.admanager.axis.v202205.ActivityPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) ActivityServiceInterface(com.google.api.ads.admanager.axis.v202205.ActivityServiceInterface) Activity(com.google.api.ads.admanager.axis.v202205.Activity)

Example 57 with Activity

use of com.google.api.ads.admanager.axis.v202205.Activity in project olca-modules by GreenDelta.

the class ProcessImport method checkImport.

private void checkImport(DataSet ds) {
    if (!valid(ds)) {
        log.warn("invalid data set -> not imported");
        return;
    }
    Activity activity = Spold2.getActivity(ds);
    try {
        String refId = RefId.forProcess(ds);
        boolean contains = dao.contains(refId);
        if (contains) {
            log.info("process '" + activity.id + "' is already in the database");
            return;
        }
        log.info("import process: " + activity.name);
        runImport(ds, refId);
    } catch (Exception e) {
        log.error("Failed to import process", e);
    }
}
Also used : Activity(spold2.Activity)

Example 58 with Activity

use of com.google.api.ads.admanager.axis.v202205.Activity in project olca-modules by GreenDelta.

the class ProcessImport method runImport.

private void runImport(DataSet ds, String refId) {
    Activity activity = Spold2.getActivity(ds);
    Process p = new Process();
    // map meta data
    p.refId = refId;
    p.name = getProcessName(ds);
    p.processType = activity.type == 2 ? ProcessType.LCI_RESULT : ProcessType.UNIT_PROCESS;
    p.description = Stream.of(RichText.join(activity.generalComment), activity.includedActivitiesStart, activity.includedActivitiesEnd, RichText.join(activity.allocationComment)).filter(Objects::nonNull).collect(Collectors.joining("\n\n"));
    // map the process category
    Category category = null;
    for (Classification clazz : Spold2.getClassifications(ds)) {
        category = index.getProcessCategory(clazz.id);
        if (category != null)
            break;
    }
    p.category = category;
    // tags
    if (!activity.tags.isEmpty()) {
        var tags = activity.tags.toArray(new String[0]);
        p.tags = String.join(",", tags);
    }
    if (config.withParameters) {
        handleParameters(ds, p);
    }
    // create inputs and outputs
    createProductExchanges(ds, p);
    createElementaryExchanges(ds, p);
    p.exchangeDqSystem = dqSystem;
    new DocImportMapper(config.db).map(ds, p);
    new ProcessDao(config.db).insert(p);
    index.putProcessId(refId, p.id);
    flushLinkQueue(p);
}
Also used : Category(org.openlca.core.model.Category) Classification(spold2.Classification) Objects(java.util.Objects) ProcessDao(org.openlca.core.database.ProcessDao) Activity(spold2.Activity) Process(org.openlca.core.model.Process)

Aggregations

Activity (org.eclipse.bpmn2.Activity)21 FlowElement (org.eclipse.bpmn2.FlowElement)12 ArrayList (java.util.ArrayList)9 CallActivity (org.eclipse.bpmn2.CallActivity)9 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)9 SubProcess (org.eclipse.bpmn2.SubProcess)9 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)8 EventDefinition (org.eclipse.bpmn2.EventDefinition)8 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)8 RootElement (org.eclipse.bpmn2.RootElement)8 SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)8 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)8 Entry (java.util.Map.Entry)7 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)7 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)7 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)7 TimerEventDefinition (org.eclipse.bpmn2.TimerEventDefinition)7 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)7 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)6 Escalation (org.eclipse.bpmn2.Escalation)6