Search in sources :

Example 1 with VersionSoftInfo

use of org.fagu.fmv.soft.find.info.VersionSoftInfo in project fmv by f-agu.

the class IMSoftProvider method createSoftExecutor.

/**
 * @see org.fagu.fmv.soft.find.SoftProvider#createSoftExecutor(org.fagu.fmv.soft.Soft, java.io.File, java.util.List)
 */
@Override
public SoftExecutor createSoftExecutor(Soft soft, File execFile, List<String> parameters) {
    if (SOFT_MAGICK_NAME.equalsIgnoreCase(FilenameUtils.getBaseName(soft.getFile().getName()))) {
        SoftInfo softInfo = soft.getFirstInfo();
        if (softInfo instanceof VersionSoftInfo) {
            VersionSoftInfo versionSoftInfo = (VersionSoftInfo) softInfo;
            Optional<Version> version = versionSoftInfo.getVersion();
            if (version.isPresent() && version.get().isUpperOrEqualsThan(V7)) {
                List<String> newParams = new ArrayList<>(parameters);
                newParams.add(0, getName());
                return new SoftExecutor(this, execFile, newParams);
            }
        }
    }
    return super.createSoftExecutor(soft, execFile, parameters);
}
Also used : VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) SoftInfo(org.fagu.fmv.soft.find.SoftInfo) VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) VersionSoftPolicy.minVersion(org.fagu.fmv.soft.find.policy.VersionSoftPolicy.minVersion) Version(org.fagu.version.Version) ArrayList(java.util.ArrayList) SoftExecutor(org.fagu.fmv.soft.SoftExecutor)

Example 2 with VersionSoftInfo

use of org.fagu.fmv.soft.find.info.VersionSoftInfo in project fmv by f-agu.

the class JavaSoftProviderTestCase method assertInfo.

/**
 * @param parser
 * @param expectedVersion
 * @throws IOException
 */
private void assertInfo(Parser parser, Version expectedVersion) throws IOException {
    SoftFound softFound = parser.closeAndParse("", 0);
    VersionSoftInfo softInfo = (VersionSoftInfo) softFound.getSoftInfo();
    assertEquals(expectedVersion, softInfo.getVersion().orElse(null));
}
Also used : VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) SoftFound(org.fagu.fmv.soft.find.SoftFound)

Example 3 with VersionSoftInfo

use of org.fagu.fmv.soft.find.info.VersionSoftInfo in project fmv by f-agu.

the class PdfInfoSoftProviderTestCase method assertInfo.

/**
 * @param parser
 * @param expectedVersion
 * @throws IOException
 */
private void assertInfo(Parser parser, Version expectedVersion) throws IOException {
    SoftFound softFound = parser.closeAndParse("", 0);
    VersionSoftInfo softInfo = (VersionSoftInfo) softFound.getSoftInfo();
    assertEquals(expectedVersion, softInfo.getVersion().orElse(null));
}
Also used : VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) SoftFound(org.fagu.fmv.soft.find.SoftFound)

Example 4 with VersionSoftInfo

use of org.fagu.fmv.soft.find.info.VersionSoftInfo in project fmv by f-agu.

the class SoftInfoContributor method content.

// *********************************************
/**
 * @return
 */
private Map<String, String> content() {
    Map<String, String> map = new HashMap<>();
    for (Soft soft : Softs.getInfoContributors()) {
        String msg = null;
        if (soft.isFound()) {
            StringBuilder buf = new StringBuilder(100);
            SoftInfo softInfo = soft.getFirstInfo();
            if (softInfo instanceof VersionSoftInfo) {
                ((VersionSoftInfo) softInfo).getVersion().ifPresent(v -> buf.append(v).append(", "));
            }
            if (softInfo instanceof VersionDateSoftInfo) {
                ((VersionDateSoftInfo) softInfo).getDate().ifPresent(d -> {
                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                    buf.append(dateFormat.format(d)).append(", ");
                });
            }
            buf.append(soft.getFile().getAbsolutePath());
            msg = buf.toString();
        } else {
            StringJoiner joiner = new StringJoiner(" ; ");
            for (SoftFound softFound : soft.getFounds()) {
                StringBuilder buf = new StringBuilder();
                FoundReason foundReason = softFound != null ? softFound.getFoundReason() : FoundReasons.NOT_FOUND;
                buf.append(foundReason.name());
                String reason = softFound.getReason();
                if (reason != null) {
                    buf.append(": ").append(reason);
                }
                joiner.add(buf.toString());
            }
            msg = joiner.toString();
        }
        map.put(soft.getName(), msg);
    }
    return map;
}
Also used : VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) SoftInfo(org.fagu.fmv.soft.find.SoftInfo) VersionDateSoftInfo(org.fagu.fmv.soft.find.info.VersionDateSoftInfo) VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) FoundReason(org.fagu.fmv.soft.find.FoundReason) HashMap(java.util.HashMap) SoftFound(org.fagu.fmv.soft.find.SoftFound) VersionDateSoftInfo(org.fagu.fmv.soft.find.info.VersionDateSoftInfo) Soft(org.fagu.fmv.soft.Soft) SimpleDateFormat(java.text.SimpleDateFormat) StringJoiner(java.util.StringJoiner)

Example 5 with VersionSoftInfo

use of org.fagu.fmv.soft.find.info.VersionSoftInfo in project fmv by f-agu.

the class VersionSoftPolicy method toSoftFound.

/**
 * @see org.fagu.fmv.soft.find.SoftPolicy#toSoftFound(org.fagu.fmv.soft.find.SoftInfo)
 */
@Override
public SoftFound toSoftFound(Object object) {
    VersionSoftInfo versionSoftInfo = (VersionSoftInfo) object;
    if (list.isEmpty()) {
        throw new IllegalStateException("No validator defined !");
    }
    // system properties
    SoftFound byPropertiesFound = byProperties(versionSoftInfo);
    if (byPropertiesFound != null && byPropertiesFound.isFound()) {
        return byPropertiesFound;
    }
    // defined
    return byDefined(versionSoftInfo);
}
Also used : VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) SoftFound(org.fagu.fmv.soft.find.SoftFound)

Aggregations

VersionSoftInfo (org.fagu.fmv.soft.find.info.VersionSoftInfo)6 SoftFound (org.fagu.fmv.soft.find.SoftFound)5 SoftInfo (org.fagu.fmv.soft.find.SoftInfo)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 StringJoiner (java.util.StringJoiner)1 Soft (org.fagu.fmv.soft.Soft)1 SoftExecutor (org.fagu.fmv.soft.SoftExecutor)1 FoundReason (org.fagu.fmv.soft.find.FoundReason)1 VersionDateSoftInfo (org.fagu.fmv.soft.find.info.VersionDateSoftInfo)1 VersionSoftPolicy.minVersion (org.fagu.fmv.soft.find.policy.VersionSoftPolicy.minVersion)1 Version (org.fagu.version.Version)1