List of usage examples for org.apache.commons.lang BooleanUtils isTrue
public static boolean isTrue(Boolean bool)
Checks if a Boolean
value is true
, handling null
by returning false
.
BooleanUtils.isTrue(Boolean.TRUE) = true BooleanUtils.isTrue(Boolean.FALSE) = false BooleanUtils.isTrue(null) = false
From source file:com.haulmont.cuba.gui.components.filter.condition.PropertyCondition.java
@Override protected void updateText() { Metadata metadata = AppBeans.get(Metadata.class); MetadataTools metadataTools = metadata.getTools(); String nameToUse = name;//from w w w . j a va 2 s. co m boolean useCrossDataStoreRefId = false; String thisStore = metadataTools.getStoreName(datasource.getMetaClass()); MetaPropertyPath propertyPath = datasource.getMetaClass().getPropertyPath(name); if (propertyPath != null) { String refIdProperty = metadataTools.getCrossDataStoreReferenceIdProperty(thisStore, propertyPath.getMetaProperty()); if (refIdProperty != null) { useCrossDataStoreRefId = true; int lastdDot = nameToUse.lastIndexOf('.'); if (lastdDot == -1) { nameToUse = refIdProperty; } else { nameToUse = nameToUse.substring(0, lastdDot + 1) + refIdProperty; } } } if (operator == Op.DATE_INTERVAL) { text = dateIntervalConditionToJpql(nameToUse); return; } StringBuilder sb = new StringBuilder(); if (operator == Op.NOT_IN) { sb.append("(("); } sb.append(entityAlias).append(".").append(nameToUse); if (Param.Type.ENTITY == param.getType() && !useCrossDataStoreRefId) { com.haulmont.chile.core.model.MetaClass metaClass = metadata.getClassNN(param.getJavaClass()); String primaryKeyName = metadataTools.getPrimaryKeyName(metaClass); sb.append(".").append(primaryKeyName); } if (operator != Op.NOT_EMPTY) sb.append(" ").append(operator.forJpql()); if (!operator.isUnary()) { sb.append(" :").append(param.getName()); if (operator == Op.ENDS_WITH || operator == Op.STARTS_WITH || operator == Op.CONTAINS || operator == Op.DOES_NOT_CONTAIN) { sb.append(" ESCAPE '").append(QueryUtils.ESCAPE_CHARACTER).append("' "); } if (operator == Op.NOT_IN) { sb.append(") or (").append(entityAlias).append(".").append(nameToUse).append(" is null)) "); } } if (operator == Op.NOT_EMPTY) { sb.append(BooleanUtils.isTrue((Boolean) param.getValue()) ? " is not null" : " is null"); } text = sb.toString(); }
From source file:jp.primecloud.auto.api.component.AttachComponent.java
/** * * ??????//from w ww . j ava2 s . c o m * * @param farmNo ? * @param componentNo ??? * @param instanceNo ? * @return AttachComponentResponse */ @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AttachComponentResponse attachComponent(@QueryParam(PARAM_NAME_FARM_NO) String farmNo, @QueryParam(PARAM_NAME_COMPONENT_NO) String componentNo, @QueryParam(PARAM_NAME_INSTANCE_NO) String instanceNo) { AttachComponentResponse response = new AttachComponentResponse(); try { // ? // FarmNo ApiValidate.validateFarmNo(farmNo); // ComponentNo ApiValidate.validateComponentNo(componentNo); // InstanceNo ApiValidate.validateInstanceNo(instanceNo); // ??? Component component = componentDao.read(Long.parseLong(componentNo)); if (component == null) { // ?????? throw new AutoApplicationException("EAPI-100000", "Component", PARAM_NAME_COMPONENT_NO, componentNo); } if (BooleanUtils.isFalse(component.getFarmNo().equals(Long.parseLong(farmNo)))) { //??????? throw new AutoApplicationException("EAPI-100022", "Component", farmNo, PARAM_NAME_COMPONENT_NO, componentNo); } // ? Instance instance = instanceDao.read(Long.parseLong(instanceNo)); if (instance == null) { // ???? throw new AutoApplicationException("EAPI-100000", "Instance", "InstanceNo", instanceNo); } if (BooleanUtils.isFalse(instance.getFarmNo().equals(Long.parseLong(farmNo)))) { //????? throw new AutoApplicationException("EAPI-100022", "Instance", farmNo, PARAM_NAME_INSTANCE_NO, instanceNo); } // ? Image image = imageDao.read(instance.getImageNo()); List<Long> componentTypeNos = new ArrayList<Long>(); for (String componentTypeNo : image.getComponentTypeNos().split(",")) { componentTypeNos.add(Long.parseLong(componentTypeNo.trim())); } // ????? if (!componentTypeNos.contains(component.getComponentTypeNo())) { // ?????????????? throw new AutoApplicationException("EAPI-100003", componentNo, instanceNo); } // ????????? ComponentType componentType = componentTypeDao.read(component.getComponentTypeNo()); List<ComponentInstance> instanceComponents = componentInstanceDao .readByInstanceNo(Long.parseLong(instanceNo)); for (ComponentInstance componentInstance : instanceComponents) { if (componentInstance.getComponentNo().equals(Long.parseLong(componentNo))) { // ???ComponentInstance????? continue; } Component tmpComponent = componentDao.read(componentInstance.getComponentNo()); ComponentType componentType2 = componentTypeDao.read(tmpComponent.getComponentTypeNo()); ComponentInstanceStatus status = ComponentInstanceStatus.fromStatus(componentInstance.getStatus()); if (StringUtils.equals(componentType.getLayer(), componentType2.getLayer()) && (BooleanUtils.isTrue(componentInstance.getAssociate()) || status != ComponentInstanceStatus.STOPPED)) { // ? ?? ????? ??? ????????????? throw new AutoApplicationException("EAPI-100009", componentNo, instanceNo); } } // ??????????? List<Long> instanceNos = new ArrayList<Long>(); List<ComponentInstance> componentInstances = componentInstanceDao .readByComponentNo(Long.parseLong(componentNo)); for (ComponentInstance componentInstance : componentInstances) { instanceNos.add(componentInstance.getInstanceNo()); } // ??????? instanceNos.add(Long.valueOf(instanceNo)); // ?????? componentService.associateInstances(Long.parseLong(componentNo), instanceNos); response.setSuccess(true); } catch (Throwable e) { String message = ""; if (e instanceof AutoException || e instanceof AutoApplicationException) { message = e.getMessage(); } else { message = MessageUtils.getMessage("EAPI-000000"); } log.error(message, e); response.setMessage(message); response.setSuccess(false); } return response; }
From source file:com.haulmont.cuba.core.app.scheduling.RunnerBean.java
protected ScheduledExecution registerExecutionStart(ScheduledTask task, long now) { if (!BooleanUtils.isTrue(task.getLogStart()) && !BooleanUtils.isTrue(task.getSingleton()) && task.getSchedulingType() != SchedulingType.FIXED_DELAY) return null; log.trace("{}: registering execution start", task); Transaction tx = persistence.createTransaction(); try {//from ww w .ja v a 2 s .co m EntityManager em = persistence.getEntityManager(); ScheduledExecution execution = metadata.create(ScheduledExecution.class); execution.setTask(em.getReference(ScheduledTask.class, task.getId())); execution.setStartTime(new Date(now)); execution.setServer(serverInfo.getServerId()); em.persist(execution); tx.commit(); return execution; } finally { tx.end(); } }
From source file:com.haulmont.restapi.service.EntitiesControllerManager.java
public EntitiesSearchResult loadEntitiesList(String entityName, @Nullable String viewName, @Nullable Integer limit, @Nullable Integer offset, @Nullable String sort, @Nullable Boolean returnNulls, @Nullable Boolean returnCount, @Nullable Boolean dynamicAttributes, @Nullable String modelVersion) { entityName = restControllerUtils.transformEntityNameIfRequired(entityName, modelVersion, JsonTransformationDirection.FROM_VERSION); MetaClass metaClass = restControllerUtils.getMetaClass(entityName); checkCanReadEntity(metaClass);//from w w w .ja va2 s . co m String queryString = "select e from " + entityName + " e"; String json = _loadEntitiesList(queryString, viewName, limit, offset, sort, returnNulls, dynamicAttributes, modelVersion, metaClass, new HashMap<>()); json = restControllerUtils.transformJsonIfRequired(entityName, modelVersion, JsonTransformationDirection.TO_VERSION, json); Long count = null; if (BooleanUtils.isTrue(returnCount)) { LoadContext ctx = LoadContext.create(metaClass.getJavaClass()) .setQuery(LoadContext.createQuery(queryString)); count = dataManager.getCount(ctx); } return new EntitiesSearchResult(json, count); }
From source file:com.sun.socialsite.web.rest.opensocial.ProfileCreator.java
protected void createProfile(JSONObject json) throws SocialSiteException { Person person = jsonConverter.convertToObject(json.toString(), Person.class); ProfileManager profileManager = Factory.getSocialSite().getProfileManager(); Profile profile = profileManager.getProfileByUserId(person.getId()); if (profile != null) { log.debug(String.format("Person (%s) -> Existing Profile (%s)", person.getId(), profile.getUserId())); } else if (StringUtils.isNotEmpty(person.getId())) { profile = new Profile(); profile.setUserId(person.getId()); // Update the fields which reside directly in the profile object. // TODO: should this really be necessary? // Or should profile.update(...) do this automatically? Name name = person.getName(); if (name != null) { if (StringUtils.isNotEmpty(name.getGivenName())) profile.setFirstName(name.getGivenName()); if (StringUtils.isNotEmpty(name.getFamilyName())) profile.setLastName(name.getFamilyName()); if (StringUtils.isNotEmpty(name.getFormatted())) profile.setDisplayName(name.getFormatted()); }/*from w w w . j a v a 2 s. c om*/ List<ListField> emails = person.getEmails(); if (emails != null) { for (ListField email : emails) { if (BooleanUtils.isTrue(email.getPrimary())) { profile.setPrimaryEmail(email.getValue()); } else { String msg = String.format("TODO: handle ListValue[primary=%s,value=%s", email.getPrimary(), email.getValue()); log.debug(msg); } } if (profile.getPrimaryEmail() == null) { // We never found an explicit primary email, so just choose one arbitrarily profile.setPrimaryEmail(emails.get(0).getValue()); } } profileManager.saveProfile(profile, false); Factory.getSocialSite().flush(); // Update fields which reside in ProfileProperty objects profile.update(Profile.Format.OPENSOCIAL, json); Factory.getSocialSite().flush(); log.debug("newProfile=" + profile); } else { log.debug("Cannot auto-create a profile for a person with no ID"); } }
From source file:jp.primecloud.auto.ui.ServerTable.java
ServerTable(String caption, Container container, final MyCloudTabs sender) { super(caption, container); this.sender = sender; setVisibleColumns(new Object[] {}); setWidth("100%"); if (this.isEnabled()) { setHeight("100%"); }/*from w w w.j a v a 2s .c o m*/ setPageLength(0); setSortDisabled(true); setColumnReorderingAllowed(false); setColumnCollapsingAllowed(false); setSelectable(true); setMultiSelect(false); setImmediate(true); setStyleName("server-table"); setNullSelectionAllowed(false); setCacheRate(0.1); addGeneratedColumn("no", new ColumnGenerator() { public Component generateCell(Table source, Object itemId, Object columnId) { InstanceDto p = (InstanceDto) itemId; Label nlbl = new Label(String.valueOf(p.getInstance().getInstanceNo())); return nlbl; } }); addGeneratedColumn("name", new ColumnGenerator() { public Component generateCell(Table source, Object itemId, Object columnId) { InstanceDto p = (InstanceDto) itemId; PlatformDto platformDto = p.getPlatform(); //???? Icons icon = CommonUtils.getPlatformIcon(platformDto); Label nlbl = new Label("<img src=\"" + VaadinUtils.getIconPath(ServerTable.this, icon) + "\"><div>" + p.getInstance().getInstanceName() + "</div>", Label.CONTENT_XHTML); nlbl.setHeight(COLUMN_HEIGHT); return nlbl; } }); addGeneratedColumn("fqdn", new ColumnGenerator() { public Component generateCell(Table source, Object itemId, Object columnId) { InstanceDto p = (InstanceDto) itemId; Label nlbl = new Label(p.getInstance().getFqdn()); return nlbl; } }); addGeneratedColumn("publicIp", new ColumnGenerator() { public Component generateCell(Table source, Object itemId, Object columnId) { InstanceDto p = (InstanceDto) itemId; Boolean showPublicIp = BooleanUtils.toBooleanObject(Config.getProperty("ui.showPublicIp")); Label ipaddr; if (BooleanUtils.isTrue(showPublicIp)) { //ui.showPublicIp = true???PublicIp ipaddr = new Label(p.getInstance().getPublicIp()); } else { //ui.showPublicIp = false???PrivateIp ipaddr = new Label(p.getInstance().getPrivateIp()); } return ipaddr; } }); addGeneratedColumn("status", new ColumnGenerator() { public Component generateCell(Table source, Object itemId, Object columnId) { InstanceDto p = (InstanceDto) itemId; String a = p.getInstance().getStatus().substring(0, 1).toUpperCase() + p.getInstance().getStatus().substring(1).toLowerCase(); Icons icon = Icons.fromName(a); Label slbl = new Label( "<img src=\"" + VaadinUtils.getIconPath(ServerTable.this, icon) + "\"><div>" + a + "</div>", Label.CONTENT_XHTML); slbl.setHeight(COLUMN_HEIGHT); return slbl; } }); addGeneratedColumn("services", new ColumnGenerator() { public Component generateCell(Table source, Object itemId, Object columnId) { InstanceDto p = (InstanceDto) itemId; String context = "<div>"; for (ComponentDto dto : sender.getComponents(p.getComponentInstances())) { ComponentType componentType = dto.getComponentType(); String name = componentType.getComponentTypeNameDisp(); Icons nameIcon = Icons.fromName(componentType.getComponentTypeName()); // Master if (MySQLConstants.COMPONENT_TYPE_NAME.equals(componentType.getComponentTypeName())) { Long masterInstanceNo = null; for (InstanceConfig config : dto.getInstanceConfigs()) { if (MySQLConstants.CONFIG_NAME_MASTER_INSTANCE_NO.equals(config.getConfigName())) { if (StringUtils.isEmpty(config.getConfigValue())) { masterInstanceNo = config.getInstanceNo(); break; } } } if (masterInstanceNo != null) { if (masterInstanceNo.equals(p.getInstance().getInstanceNo())) { name = name + "_master"; nameIcon = Icons.MYSQL_MASTER; } else { name = name + "_slave"; nameIcon = Icons.MYSQL_SLAVE; } } else { name = name + "_slave"; nameIcon = Icons.MYSQL_SLAVE; } } context = context + "<img style=\"width: 5px;\" src=\" " + VaadinUtils.getIconPath(ServerTable.this, Icons.fromName("SPACER")) + "\" >" + "<img src=\"" + VaadinUtils.getIconPath(ServerTable.this, nameIcon) + "\" + " + " title=\"" + name + "\">"; } context = context + "</div>"; Label slayout = new Label(context, Label.CONTENT_XHTML); slayout.setHeight(COLUMN_HEIGHT); return slayout; } }); // addGeneratedColumn("operation", new ColumnGenerator() { // public Component generateCell(Table source, Object itemId, Object columnId) { // // List<Button> list = new ArrayList<Button>(); // // CssLayout blayout = new CssLayout(); // // blayout.setWidth("100%"); // blayout.setHeight(COLUMN_HEIGHT); // blayout.setMargin(false); // // InstanceDto p = (InstanceDto) itemId; // // Button playButton = new Button(ViewProperties.getCaption("button.startServer")); // playButton.setDescription(ViewProperties.getCaption("description.startServer")); // playButton.addStyleName("borderless"); // playButton.setIcon(Icons.PLAY.resource()); // playButton.setEnabled(false); // playButton.addListener(Button.ClickEvent.class, ServerTable.this, "playButtonClick"); // blayout.addComponent(playButton); // list.add(playButton); // // Button stopButton = new Button(ViewProperties.getCaption("button.stopServer")); // stopButton.setDescription(ViewProperties.getCaption("description.stopServer")); // stopButton.addStyleName("borderless"); // stopButton.setIcon(Icons.STOP.resource()); // stopButton.setEnabled(false); // stopButton.addListener(Button.ClickEvent.class, ServerTable.this, "stopButtonClick"); // blayout.addComponent(stopButton); // list.add(stopButton); // // Button editButton = new Button(ViewProperties.getCaption("button.editServer")); // editButton.setDescription(ViewProperties.getCaption("description.editServer")); // editButton.addStyleName("borderless"); // editButton.setIcon(Icons.EDIT.resource()); // editButton.setEnabled(false); // editButton.addListener(Button.ClickEvent.class, ServerTable.this, "editButtonClick"); // blayout.addComponent(editButton); // list.add(editButton); // // Button delButton = new Button(ViewProperties.getCaption("button.deleteServer")); // delButton.setDescription(ViewProperties.getCaption("description.deleteServer")); // delButton.addStyleName("borderless"); // delButton.setIcon(Icons.DELETE.resource()); // delButton.setEnabled(false); // delButton.addListener(Button.ClickEvent.class, ServerTable.this, "delButtonClick"); // blayout.addComponent(delButton); // list.add(delButton); // // map.put(p.getInstance().getInstanceNo(), list); // // return blayout; // } // // }); //??? setColumnHeaders(CAPNAME); //????StyleName setCellStyleGenerator(new Table.CellStyleGenerator() { public String getStyle(Object itemId, Object propertyId) { if (propertyId == null) { return ""; } else { return propertyId.toString().toLowerCase(); } } }); // setColumnExpandRatio("name", 100); setColumnExpandRatio("fqdn", 100); addListener(Table.ValueChangeEvent.class, sender, "tableRowSelected"); // alwaysRecalculateColumnWidths = true; }
From source file:jp.primecloud.auto.service.impl.ComponentServiceImpl.java
/** * {@inheritDoc}//ww w .j a v a 2s . c om */ @Override public List<ComponentDto> getComponents(Long farmNo) { // ??? List<Component> components = new ArrayList<Component>(); List<Component> allComponents = componentDao.readByFarmNo(farmNo); for (Component component : allComponents) { // ??? if (BooleanUtils.isTrue(component.getLoadBalancer())) { continue; } components.add(component); } // ???? List<Long> componentNos = new ArrayList<Long>(); for (Component component : components) { componentNos.add(component.getComponentNo()); } // ?????? Map<Long, List<ComponentInstance>> componentInstanceMap = new LinkedHashMap<Long, List<ComponentInstance>>(); for (Long componentNo : componentNos) { componentInstanceMap.put(componentNo, new ArrayList<ComponentInstance>()); } List<ComponentInstance> tmpComponentInstances = componentInstanceDao.readInComponentNos(componentNos); for (ComponentInstance componentInstance : tmpComponentInstances) { // ????????? if (BooleanUtils.isNotTrue(componentInstance.getAssociate())) { ComponentInstanceStatus status = ComponentInstanceStatus.fromStatus(componentInstance.getStatus()); if (status == ComponentInstanceStatus.STOPPED) { continue; } } componentInstanceMap.get(componentInstance.getComponentNo()).add(componentInstance); } Farm farm = farmDao.read(farmNo); List<Instance> instances = instanceDao.readByFarmNo(farmNo); Map<Long, Instance> instanceMap = new HashMap<Long, Instance>(); for (Instance instance : instances) { instanceMap.put(instance.getInstanceNo(), instance); } List<ComponentDto> dtos = new ArrayList<ComponentDto>(); for (Component component : components) { ComponentType componentType = componentTypeDao.read(component.getComponentTypeNo()); List<InstanceConfig> instanceConfigs = instanceConfigDao.readByComponentNo(component.getComponentNo()); List<ComponentConfig> componentConfigs = componentConfigDao .readByComponentNo(component.getComponentNo()); List<ComponentInstance> componentInstances = componentInstanceMap.get(component.getComponentNo()); List<ComponentInstanceDto> componentInstanceDtos = new ArrayList<ComponentInstanceDto>(); // ??????? for (ComponentInstance componentInstance : componentInstances) { Instance instance = instanceMap.get(componentInstance.getInstanceNo()); ComponentInstanceStatus status = getComponentInstanceStatus(farm, componentInstance, instance); componentInstance.setStatus(status.toString()); } // ???? ComponentStatus componentStatus = getComponentStatus(componentInstances); // DTO??URL? for (ComponentInstance componentInstance : componentInstances) { ComponentInstanceDto componentInstanceDto = new ComponentInstanceDto(); componentInstanceDto.setComponentInstance(componentInstance); Instance instance = instanceMap.get(componentInstance.getInstanceNo()); // for (Instance tmpInstance : instances) { // if (componentInstance.getInstanceNo().equals(tmpInstance.getInstanceNo())) { // instance = tmpInstance; // break; // } // } String url; Boolean showPublicIp = BooleanUtils.toBooleanObject(Config.getProperty("ui.showPublicIp")); if (BooleanUtils.isTrue(showPublicIp)) { //ui.showPublicIp = true ???URL?PublicIp url = createUrl(instance.getPublicIp(), component.getComponentTypeNo()); } else { //ui.showPublicIp = false ???URL?PrivateIp url = createUrl(instance.getPrivateIp(), component.getComponentTypeNo()); } componentInstanceDto.setUrl(url); componentInstanceDtos.add(componentInstanceDto); } // // TODO: ???????? // for (ComponentInstanceDto componentInstanceDto : componentInstances) { // ComponentInstance componentInstance = componentInstanceDto.getComponentInstance(); // ComponentInstanceStatus status = ComponentInstanceStatus.fromStatus(componentInstance.getStatus()); // if (BooleanUtils.isTrue(componentInstance.getEnabled())) { // if (status == ComponentInstanceStatus.STOPPED) { // Instance instance = instanceMap.get(componentInstance.getInstanceNo()); // InstanceStatus instanceStatus = InstanceStatus.fromStatus(instance.getStatus()); // if (instanceStatus == InstanceStatus.WARNING) { // // ?Waring??????Warning?? // componentInstance.setStatus(ComponentInstanceStatus.WARNING.toString()); // } else if (BooleanUtils.isTrue(farm.getScheduled())) { // // ??????Starting?? // componentInstance.setStatus(ComponentInstanceStatus.STARTING.toString()); // } // } else if (status == ComponentInstanceStatus.RUNNING // && BooleanUtils.isTrue(componentInstance.getConfigure())) { // if (BooleanUtils.isTrue(farm.getScheduled())) { // // ???Running??????Configuring?? // componentInstance.setStatus(ComponentInstanceStatus.CONFIGURING.toString()); // } // } // } else { // if (status == ComponentInstanceStatus.RUNNING || status == ComponentInstanceStatus.WARNING) { // if (BooleanUtils.isTrue(farm.getScheduled())) { // // ??????Stopping?? // componentInstance.setStatus(ComponentInstanceStatus.STOPPING.toString()); // } // } // } // } // // ???? // ComponentStatus componentStatus; // Set<ComponentInstanceStatus> statuses = new HashSet<ComponentInstanceStatus>(); // for (ComponentInstanceDto componentInstanceDto : componentInstances) { // statuses.add(ComponentInstanceStatus // .fromStatus(componentInstanceDto.getComponentInstance().getStatus())); // } // if (statuses.contains(ComponentInstanceStatus.WARNING)) { // componentStatus = ComponentStatus.WARNING; // } else if (statuses.contains(ComponentInstanceStatus.CONFIGURING)) { // componentStatus = ComponentStatus.CONFIGURING; // } else if (statuses.contains(ComponentInstanceStatus.RUNNING)) { // if (statuses.contains(ComponentInstanceStatus.STARTING)) { // componentStatus = ComponentStatus.CONFIGURING; // } else if (statuses.contains(ComponentInstanceStatus.STOPPING)) { // componentStatus = ComponentStatus.CONFIGURING; // } else { // componentStatus = ComponentStatus.RUNNING; // } // } else if (statuses.contains(ComponentInstanceStatus.STARTING)) { // componentStatus = ComponentStatus.STARTING; // } else if (statuses.contains(ComponentInstanceStatus.STOPPING)) { // componentStatus = ComponentStatus.STOPPING; // } else { // componentStatus = ComponentStatus.STOPPED; // } // Collections.sort(componentInstanceDtos, Comparators.COMPARATOR_COMPONENT_INSTANCE_DTO); ComponentDto dto = new ComponentDto(); dto.setComponent(component); dto.setComponentType(componentType); dto.setComponentConfigs(componentConfigs); dto.setComponentInstances(componentInstanceDtos); dto.setInstanceConfigs(instanceConfigs); dto.setStatus(componentStatus.toString()); dtos.add(dto); } // Collections.sort(dtos, Comparators.COMPARATOR_COMPONENT_DTO); return dtos; }
From source file:com.evolveum.midpoint.web.component.data.paging.NavigatorPanel.java
private void initNavigation() { IModel<Integer> model = new AbstractReadOnlyModel<Integer>() { @Override/*from w ww . j ava 2s . co m*/ public Integer getObject() { int count = (int) pageable.getPageCount(); if (count < PAGING_SIZE) { return count; } return PAGING_SIZE; } }; Loop navigation = new Loop(ID_NAVIGATION, model) { @Override protected void populateItem(final LoopItem item) { final NavigatorPageLink pageLink = new NavigatorPageLink(ID_PAGE_LINK, computePageNumber(item.getIndex())) { @Override public void onClick(AjaxRequestTarget target) { pageLinkPerformed(target, getPageNumber()); } }; item.add(pageLink); item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { return pageable.getCurrentPage() == pageLink.getPageNumber() ? "active" : ""; } })); } }; navigation.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return BooleanUtils.isTrue(showPageListingModel.getObject()); } }); add(navigation); }
From source file:com.haulmont.cuba.gui.app.security.user.browse.UserBrowser.java
public void copy() { Set<User> selected = usersTable.getSelected(); if (!selected.isEmpty()) { User selectedUser = selected.iterator().next(); selectedUser = dataSupplier.reload(selectedUser, "user.edit"); User newUser = metadata.create(User.class); if (selectedUser.getUserRoles() != null) { List<UserRole> userRoles = new ArrayList<>(); for (UserRole oldUserRole : selectedUser.getUserRoles()) { Role oldRole = dataSupplier.reload(oldUserRole.getRole(), "_local"); if (BooleanUtils.isTrue(oldRole.getDefaultRole())) { continue; }/* ww w . j a v a 2 s . co m*/ UserRole role = metadata.create(UserRole.class); role.setUser(newUser); role.setRole(oldRole); userRoles.add(role); } newUser.setUserRoles(userRoles); } newUser.setGroup(selectedUser.getGroup()); AbstractEditor editor = openEditor("sec$User.edit", newUser, OpenType.THIS_TAB, ParamsMap.of("initCopy", true)); editor.addCloseListener(actionId -> { if (Window.COMMIT_ACTION_ID.equals(actionId)) { usersDs.refresh(); } usersTable.requestFocus(); }); } }
From source file:com.evolveum.midpoint.task.quartzimpl.work.WorkStateManager.java
public boolean canRun(Supplier<Boolean> canRunSupplier) { return canRunSupplier == null || BooleanUtils.isTrue(canRunSupplier.get()); }