/** * Returns basic company entity id for current user * * @return company entity id * */ public Long getCompanyId() { if (getCompany() == null) { return null; } else { return getCompany().getId(); } }
public void disabledGridWhenCompanyIsAnOwner(final ViewDefinitionState view) { companyService.disabledGridWhenCompanyIsOwner(view, "operationGroups", "operations"); }
public void disabledGridWhenCompanyIsOwner(final ViewDefinitionState view, final String... references) { FormComponent companyForm = (FormComponent) view.getComponentByReference(L_FORM); Entity company = companyForm.getEntity(); Boolean isOwner = isCompanyOwner(company); disableGridComponents(view, !isOwner, references); }
private void disabledRibbonForOwnerOrExternal(final ViewDefinitionState view) { FormComponent companyForm = (FormComponent) view.getComponentByReference(L_FORM); Entity company = companyForm.getEntity(); Boolean isOwner = companyService.isCompanyOwner(companyForm.getEntity()); boolean isEnabled = !isOwner; String buttonMessage = "basic.company.isOwner"; if ((company != null) && !StringUtils.isEmpty(company.getStringField(CompanyFields.EXTERNAL_NUMBER))) { buttonMessage = "basic.company.isExternalNumber"; isEnabled = false; } companyService.disableButton(view, L_ACTIONS, L_DELETE, isEnabled, buttonMessage); }
public void disabledRibbonForOwnerOrExternal(final ViewDefinitionState view, final ComponentState state, final String[] args) { GridComponent grid = (GridComponent) view.getComponentByReference(L_GRID); List<Entity> companies = grid.getSelectedEntities(); boolean isEnabled = true; String buttonMessage = "basic.company.isOwner"; for (Entity company : companies) { Entity companyFromDB = companyService.getCompany(company.getId()); if (companyFromDB != null) { isEnabled = !companyService.isCompanyOwner(companyFromDB); if (!StringUtils.isEmpty(company.getStringField(CompanyFields.EXTERNAL_NUMBER))) { buttonMessage = "basic.company.isExternalNumber"; isEnabled = false; } } else { isEnabled = false; } if (!isEnabled) { break; } } companyService.disableButton(view, L_ACTIONS, L_DELETE, isEnabled, buttonMessage); }
public void disableBufferWhenCompanyIsOwner(final ViewDefinitionState view) { FormComponent companyForm = (FormComponent) view.getComponentByReference(L_FORM); Boolean isOwner = companyService.isCompanyOwner(companyForm.getEntity()); FieldComponent buffer = (FieldComponent) view.getComponentByReference(BUFFER); buffer.setEnabled(!isOwner); }
/** * Returns company entity * * @param companyId * companyId * * @return company */ @Transactional public Entity getCompany(final Long companyId) { return getCompanyDD().get(companyId); }
private void disabledRedirectToFilteredOrderProductionListButton(final ViewDefinitionState view) { FormComponent companyForm = (FormComponent) view.getComponentByReference(L_FORM); Entity company = companyForm.getEntity(); boolean isEnabled = (company.getId() != null); companyService.disableButton(view, L_ORDER_PRODUCTION, L_REDIRECT_TO_FILTERED_ORDER_PRODUCTION_LIST, isEnabled, null); }
public Optional<Entity> findCompanyByTax(final String tax, boolean useLike) { if(useLike) { return Optional.ofNullable(getCompanyDD().find().add(SearchRestrictions.ilike(CompanyFields.TAX, tax)) .setMaxResults(1).uniqueResult()); } else { return Optional.ofNullable(getCompanyDD().find().add(SearchRestrictions.eq(CompanyFields.TAX, tax)) .setMaxResults(1).uniqueResult()); } } }
private String createDelivery(Long warehouseId, Long supplierId, Collection<Entity> minimalStates) { Entity warehouse = flowService.getLocationById(warehouseId); Entity supplier = companyService.getCompany(supplierId); return createDeliveries(warehouse, supplier, Lists.newArrayList(minimalStates)); }
public void disabledGridWhenCompanyIsOwner(final ViewDefinitionState view) { companyService.disabledGridWhenCompanyIsOwner(view, "productsFamilies", "products"); }
public Optional<Entity> findCompanyByNumber(final String number) { return Optional.ofNullable(getCompanyDD().find().add(SearchRestrictions.eq(CompanyFields.NUMBER, number)) .setMaxResults(1).uniqueResult()); }
private Map<String, Object> createThirdColumn(final Entity requestForQuotation) { Map<String, Object> column = new LinkedHashMap<String, Object>(); Entity company = companyService.getCompany(); if (company != null) { column.put("supplyNegotiations.requestForQuotation.report.columnHeader.contracting", company.getStringField(NAME)); } if (requestForQuotation.getField("createDate") != null) { column.put("supplyNegotiations.requestForQuotation.report.columnHeader.createDate", getStringFromDate((Date) requestForQuotation.getField("createDate"))); } return column; }
public final Boolean isCompanyOwner(final Entity company) { Long companyId = company.getId(); if (companyId == null) { return Boolean.FALSE; } Entity companyFromDB = getCompanyDD().get(companyId); if (companyFromDB == null) { return Boolean.FALSE; } Entity parameter = parameterService.getParameter(); Entity owner = parameter.getBelongsToField(ParameterFields.COMPANY); if (owner == null) { return Boolean.FALSE; } return companyFromDB.getId().equals(owner.getId()); }
private Map<String, Object> createSecondColumn(final Entity delivery) { Map<String, Object> column = new LinkedHashMap<>(); Entity company = companyService.getCompany(); String deliveryAddress = delivery.getStringField(DeliveryFields.DELIVERY_ADDRESS); Date deliveryDate = delivery.getDateField(DeliveryFields.DELIVERY_DATE); if (company != null) { String name = company.getStringField(CompanyFields.NAME); column.put("deliveries.order.report.columnHeader.contracting", name); } if (deliveryAddress != null) { column.put("deliveries.order.report.columnHeader.deliveryAddress", deliveryAddress); } if (deliveryDate != null) { column.put("deliveries.order.report.columnHeader.deliveryDate", getStringFromDate(deliveryDate)); } return column; }
@Override public String getDeliveryAddressDefaultValue() { Entity parameter = parameterService.getParameter(); if (DefaultAddressType.OTHER.getStringValue().equals(parameter.getStringField(ParameterFieldsD.DEFAULT_ADDRESS))) { return parameter.getStringField(ParameterFieldsD.OTHER_ADDRESS); } else { return generateAddressFromCompany(companyService.getCompany()); } }
@Override public void addRestriction(final SearchCriteriaBuilder searchBuilder) { Entity ownerCompany = companyService.getCompany(); searchBuilder.add(SearchRestrictions.or(SearchRestrictions.belongsTo("workFor", ownerCompany), SearchRestrictions.isNotNull("laborHourlyCost"))); }
public void setSupplierToOwner(final ViewDefinitionState view) { FieldComponent supplierField = (FieldComponent) view.getComponentByReference(L_SUPPLIER); if (supplierField.getFieldValue() == null) { Entity company = companyService.getCompany(); if (company != null) { supplierField.setFieldValue(company.getId()); supplierField.requestComponentUpdateState(); } } }
Entity company = companyService.getCompany(); String additionalText = parameter.getStringField(ADDITIONAL_TEXT_IN_FOOTER);
public void setOwnerCompany(final ViewDefinitionState view) { FormComponent staffForm = (FormComponent) view.getComponentByReference(L_FORM); FieldComponent workForLookup = (FieldComponent) view.getComponentByReference(StaffFields.WORK_FOR); Entity ownerCompany = companyService.getCompany(); if ((staffForm.getEntityId() != null) || (workForLookup.getFieldValue() != null) || (ownerCompany == null)) { return; } workForLookup.setFieldValue(ownerCompany.getId()); workForLookup.requestComponentUpdateState(); }