Search in sources :

Example 11 with SoftFound

use of org.fagu.fmv.soft.find.SoftFound 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 12 with SoftFound

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

the class SoftFoundTestCase method testMultiple1.

/**
 */
@Test
public void testMultiple1() {
    SoftFound foundBadSoft = SoftFound.notFound();
    assertSame(foundBadSoft, SoftFound.multiple(foundBadSoft));
}
Also used : SoftFound(org.fagu.fmv.soft.find.SoftFound) Test(org.junit.Test)

Example 13 with SoftFound

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

the class VersionPolicyTestCase method testAllOSAllVersion_versionV3.

/**
 */
@Test
public void testAllOSAllVersion_versionV3() {
    SoftFound softFound = new VersionSoftPolicy().onAllPlatforms(allVersion()).toSoftFound(versionSoftInfo(Version.V3));
    assertTrue(softFound.isFound());
}
Also used : SoftFound(org.fagu.fmv.soft.find.SoftFound) Test(org.junit.Test)

Example 14 with SoftFound

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

the class VersionPolicyTestCase method testAllOS_versionNull.

/**
 */
@Test
public void testAllOS_versionNull() {
    SoftFound softFound = new VersionSoftPolicy().onAllPlatforms(allVersion()).toSoftFound(versionSoftInfo(null));
    assertFalse(softFound.isFound());
    assertEquals(FoundReasons.BAD_SOFT, softFound.getFoundReason());
    assertEquals("version not parsable", softFound.getReason());
}
Also used : SoftFound(org.fagu.fmv.soft.find.SoftFound) Test(org.junit.Test)

Example 15 with SoftFound

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

the class AutoRotate method isAutoRotateObsolete.

/**
 * @param soft
 * @return
 */
public static boolean isAutoRotateObsolete(Soft soft) {
    SoftFound softFound = soft.getFirstFound();
    FFInfo ffInfo = (FFInfo) softFound.getSoftInfo();
    // version
    Version version = ffInfo.getVersion();
    if (version != null) {
        return version.isUpperOrEqualsThan(new Version(2, 7));
    }
    // build number
    Integer builtVersion = ffInfo.getBuiltVersion();
    if (builtVersion != null) {
        return builtVersion.intValue() > 73010;
    }
    // build date
    Date builtDate = ffInfo.getBuiltDate();
    if (builtDate != null) {
        @SuppressWarnings("deprecation") Date minDate = new Date(2015 - 1900, 6 - 1, 12);
        return minDate.before(builtDate);
    }
    return false;
}
Also used : Version(org.fagu.version.Version) SoftFound(org.fagu.fmv.soft.find.SoftFound) FFInfo(org.fagu.fmv.ffmpeg.soft.FFInfo) Date(java.util.Date)

Aggregations

SoftFound (org.fagu.fmv.soft.find.SoftFound)22 Test (org.junit.Test)8 VersionSoftInfo (org.fagu.fmv.soft.find.info.VersionSoftInfo)5 Soft (org.fagu.fmv.soft.Soft)4 IOException (java.io.IOException)3 Date (java.util.Date)3 Founds (org.fagu.fmv.soft.find.Founds)3 VersionDateSoftInfo (org.fagu.fmv.soft.find.info.VersionDateSoftInfo)3 Ignore (org.junit.Ignore)3 HashMap (java.util.HashMap)2 StringJoiner (java.util.StringJoiner)2 Parser (org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser)2 SoftProvider (org.fagu.fmv.soft.find.SoftProvider)2 Version (org.fagu.version.Version)2 FileNotFoundException (java.io.FileNotFoundException)1 Path (java.nio.file.Path)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Arrays (java.util.Arrays)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1