use of com.axelor.meta.CallMethod in project axelor-open-suite by axelor.
the class ImportDateTime method importDate.
@CallMethod
public String importDate(String inputDate) {
String patDate = "(" + dt + "|TODAY)(\\[(" + String.format(pat, 4, "y") + "?" + String.format(pat, 2, "M") + "?" + String.format(pat, 2, "d") + "?" + ")\\])?";
try {
if (!Strings.isNullOrEmpty(inputDate) && inputDate.matches(patDate)) {
List<String> dates = Arrays.asList(inputDate.split("\\["));
inputDate = dates.get(0).equals("TODAY") ? Beans.get(AppBaseService.class).getTodayDate(Optional.ofNullable(AuthUtils.getUser()).map(User::getActiveCompany).orElse(null)).toString() : dates.get(0);
if (dates.size() > 1) {
LocalDateTime localDate = LocalDate.parse(inputDate, DateTimeFormatter.ISO_DATE).atStartOfDay();
Matcher matcher = Pattern.compile(String.format(pat, 4, "y")).matcher(dates.get(1));
if (matcher.find())
localDate = updateYear(localDate, matcher.group());
matcher = Pattern.compile(String.format(pat, 2, "M")).matcher(dates.get(1));
if (matcher.find())
localDate = updateMonth(localDate, matcher.group());
matcher = Pattern.compile(String.format(pat, 2, "d")).matcher(dates.get(1));
if (matcher.find())
localDate = updateDay(localDate, matcher.group());
return localDate.toString();
} else
return inputDate;
} else
return null;
} catch (Exception e) {
return null;
}
}
use of com.axelor.meta.CallMethod in project axelor-open-suite by axelor.
the class WkfDisplayServiceImpl method getInstanceUrl.
@Override
@CallMethod
public String getInstanceUrl(WkfInstance wkfInstance) {
try {
ProcessEngine engine = engineService.getEngine();
String processInstanceId = wkfInstance.getInstanceId();
List<String> activeIds = getActivityIds(processInstanceId);
Map<String, Integer> activityCountMap = new HashMap<>();
getActivityPassCount(wkfInstance.getInstanceId(), activityCountMap);
WkfProcess wkfProcess = wkfInstance.getWkfProcess();
BpmnModelInstance modelInstance = engine.getRepositoryService().getBpmnModelInstance(wkfProcess.getProcessId());
Iterator<Process> processIter = modelInstance.getModelElementsByType(Process.class).iterator();
HistoricVariableInstanceQuery variableQuery = engine.getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(processInstanceId);
while (processIter.hasNext()) {
Process process = processIter.next();
if (process.getId().equals(wkfProcess.getName())) {
continue;
}
HistoricVariableInstance variableInstance = variableQuery.variableName(process.getId()).singleResult();
if (variableInstance != null) {
activeIds.addAll(getActivityIds((String) variableInstance.getValue()));
getActivityPassCount((String) variableInstance.getValue(), activityCountMap);
}
}
String activityCount = activityCountMap.keySet().stream().map(it -> it + ":" + activityCountMap.get(it)).collect(Collectors.joining(","));
log.trace("Active node ids: {}", activeIds);
String url = String.format(engineService.getWkfViewerUrl(), "instanceId=" + wkfInstance.getInstanceId(), Joiner.on(",").join(activeIds), activityCount);
log.debug("Url created: {}", url);
return url;
} catch (Exception e) {
}
return null;
}
use of com.axelor.meta.CallMethod in project axelor-open-suite by axelor.
the class ProductCompanyServiceImpl method get.
@Override
@CallMethod
public Object get(Product originalProduct, String fieldName, Company company) throws AxelorException {
Mapper mapper = Mapper.of(Product.class);
Product product = findAppropriateProductCompany(originalProduct, fieldName, company);
return mapper.get(product, fieldName);
}
use of com.axelor.meta.CallMethod in project axelor-open-suite by axelor.
the class ProductCompanyServiceImpl method set.
@Override
@CallMethod
public void set(Product originalProduct, String fieldName, Object fieldValue, Company company) throws AxelorException {
Mapper mapper = Mapper.of(Product.class);
Product product = findAppropriateProductCompany(originalProduct, fieldName, company);
mapper.set(product, fieldName, fieldValue);
}
Aggregations