All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jsoftware.command.ListCommand Maven / Gradle / Ivy

package org.jsoftware.command;

import org.jsoftware.config.AbstractPatch;
import org.jsoftware.config.ApplyStrategy;
import org.jsoftware.config.Patch;

import java.io.IOException;
import java.util.List;


/**
 * Show list of patches
 * @author szalik
 */
public class ListCommand extends AbstractListCommand {

    @Override
    protected List generateList(List inList) throws IOException {
        ApplyStrategy strategy = configurationEntry.getApplyStarters();
        log.debug("Apply strategy is " + strategy.getClass().getSimpleName() + ", configurationId:" + configurationEntry.getId());
        List patchesToApply = strategy.filter(manager.getConnection(), inList);
        StringBuilder sb = new StringBuilder("Patch list:\n");
        for(Patch p : inList) {
            getConfigurationEntry().getPatchParser().parse(p, getConfigurationEntry());
            sb.append('\t');
            if (p.getDbState() == AbstractPatch.DbState.COMMITTED) sb.append('*');
            if (p.getDbState() == AbstractPatch.DbState.IN_PROGRESS) sb.append('P');
            if (p.getDbState() == AbstractPatch.DbState.NOT_AVAILABLE) {
                if (patchesToApply.contains(p)) sb.append('+');
                else sb.append('-');
            }
            sb.append(' ').append(p.getName());
            for(int a=p.getName().length(); a




© 2015 - 2025 Weber Informatics LLC | Privacy Policy