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);
}
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));
}
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));
}
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;
}
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);
}
Aggregations