001// Generated by delombok at Mon Oct 12 22:59:35 BST 2020
002/*
003 *  Licensed to the Apache Software Foundation (ASF) under one
004 *  or more contributor license agreements.  See the NOTICE file
005 *  distributed with this work for additional information
006 *  regarding copyright ownership.  The ASF licenses this file
007 *  to you under the Apache License, Version 2.0 (the
008 *  "License"); you may not use this file except in compliance
009 *  with the License.  You may obtain a copy of the License at
010 *
011 *        http://www.apache.org/licenses/LICENSE-2.0
012 *
013 *  Unless required by applicable law or agreed to in writing,
014 *  software distributed under the License is distributed on an
015 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 *  KIND, either express or implied.  See the License for the
017 *  specific language governing permissions and limitations
018 *  under the License.
019 */
020package org.apache.isis.extensions.commandreplay.secondary.mixins;
021
022import java.util.Optional;
023import javax.inject.Inject;
024import org.apache.isis.applib.annotation.Action;
025import org.apache.isis.applib.annotation.MemberOrder;
026import org.apache.isis.applib.annotation.SemanticsOf;
027import org.apache.isis.extensions.commandlog.impl.IsisModuleExtCommandLogImpl;
028import org.apache.isis.extensions.commandlog.impl.jdo.CommandJdo;
029import org.apache.isis.extensions.commandlog.impl.jdo.ReplayState;
030import org.apache.isis.extensions.commandreplay.secondary.config.SecondaryConfig;
031
032@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE, domainEvent = CommandJdo_exclude.ActionDomainEvent.class)
033public class CommandJdo_exclude {
034    @java.lang.SuppressWarnings("all")
035    private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(CommandJdo_exclude.class);
036
037
038    public static class ActionDomainEvent extends IsisModuleExtCommandLogImpl.ActionDomainEvent<CommandJdo_exclude> {
039    }
040
041    final CommandJdo commandJdo;
042
043    @MemberOrder(name = "executeIn", sequence = "2")
044    public CommandJdo act() {
045        commandJdo.setReplayState(ReplayState.EXCLUDED);
046        return commandJdo;
047    }
048
049    public boolean hideAct() {
050        return !secondaryConfig.isPresent() || !secondaryConfig.get().isConfigured();
051    }
052
053    public String disableAct() {
054        final boolean notInError = commandJdo.getReplayState() == null || !commandJdo.getReplayState().isFailed();
055        return notInError ? "This command is not in error, so cannot be excluded." : null;
056    }
057
058    @Inject
059    Optional<SecondaryConfig> secondaryConfig;
060
061    @java.lang.SuppressWarnings("all")
062    public CommandJdo_exclude(final CommandJdo commandJdo) {
063        this.commandJdo = commandJdo;
064    }
065}