Java Code Examples for org.apache.commons.lang3.BooleanUtils

The following examples show how to use org.apache.commons.lang3.BooleanUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: moneta   Author: Derek-Ashmore   File: MonetaConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
protected void gatherTopicAttributes(XMLConfiguration config, Topic topic,
		int i) {
	String readOnlyStr;
	topic.setTopicName(config.getString("Topics.Topic(" + i + ")[@name]"));
	topic.setPluralName(config.getString("Topics.Topic(" + i + ")[@pluralName]"));
	topic.setDataSourceName(config.getString("Topics.Topic(" + i + ")[@dataSource]"));
	topic.setSchemaName(config.getString("Topics.Topic(" + i + ")[@schema]"));
	topic.setCatalogName(config.getString("Topics.Topic(" + i + ")[@catalog]"));
	topic.setTableName(config.getString("Topics.Topic(" + i + ")[@table]"));
	
	readOnlyStr = config.getString("Topics.Topic(" + i + ")[@readOnly]");
	Boolean bValue = BooleanUtils.toBooleanObject(readOnlyStr);
	if (bValue != null)  {
		topic.setReadOnly(bValue);
	}
}
 
Example #2
Source Project: o2oa   Author: o2oa   File: ActionCreateWithWorkPath4.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, String path0, String path1, String path2,
		String path3, String path4, JsonElement jsonElement) throws Exception {
	ActionResult<Wo> result = new ActionResult<>();
	Work work = null;
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		Business business = new Business(emc);
		work = emc.find(id, Work.class);
		if (null == work) {
			throw new ExceptionEntityNotExist(id, Work.class);
		}
		WoControl control = business.getControl(effectivePerson, work, WoControl.class);
		if (BooleanUtils.isNotTrue(control.getAllowSave())) {
			throw new ExceptionWorkAccessDenied(effectivePerson.getDistinguishedName(), work.getTitle(),
					work.getId());
		}
	}
	Wo wo = ThisApplication.context().applications()
			.postQuery(x_processplatform_service_processing.class,
					Applications.joinQueryUri("data", "work", work.getId(), path0, path1, path2, path3, path4),
					jsonElement, work.getJob())
			.getData(Wo.class);
	result.setData(wo);
	return result;
}
 
Example #3
Source Project: gvnix   Author: gvSIGAssociation   File: QuerydslUtilsBeanImpl.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public <T> BooleanExpression createBooleanExpression(
        PathBuilder<T> entityPath, String fieldName, Object searchObj,
        String operator) {
    Boolean value = BooleanUtils.toBooleanObject((String) searchObj);
    if (value != null) {
        if (StringUtils.equalsIgnoreCase(operator, OPERATOR_GOE)) {
            return entityPath.getBoolean(fieldName).goe(value);
        }
        else if (StringUtils.equalsIgnoreCase(operator, "gt")) {
            return entityPath.getBoolean(fieldName).gt(value);
        }
        else if (StringUtils.equalsIgnoreCase(operator, OPERATOR_LOE)) {
            return entityPath.getBoolean(fieldName).loe(value);
        }
        else if (StringUtils.equalsIgnoreCase(operator, "lt")) {
            return entityPath.getBoolean(fieldName).lt(value);
        }
    }
    return entityPath.get(fieldName).eq(searchObj);
}
 
Example #4
Source Project: o2oa   Author: o2oa   File: ActionMode.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson) throws Exception {
	ActionResult<Wo> result = new ActionResult<>();
	Wo wo = new Wo();
	if (BooleanUtils.isTrue(Config.person().getCodeLogin())) {
		wo.setCodeLogin(true);
	} else {
		wo.setCodeLogin(false);
	}
	if (BooleanUtils.isTrue(Config.person().getBindLogin())) {
		wo.setBindLogin(true);
	} else {
		wo.setBindLogin(false);
	}
	if (BooleanUtils.isTrue(Config.person().getFaceLogin())) {
		wo.setFaceLogin(true);
	} else {
		wo.setFaceLogin(false);
	}
	if (BooleanUtils.isTrue(Config.person().getCaptchaLogin())) {
		wo.setCaptchaLogin(true);
	} else {
		wo.setCaptchaLogin(false);
	}
	result.setData(wo);
	return result;
}
 
Example #5
Source Project: o2oa   Author: o2oa   File: ActionComplexAppointFormMobile.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, String formFlag) throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<Wo> result = new ActionResult<>();
		Business business = new Business(emc);
		WorkCompleted workCompleted = emc.find(id, WorkCompleted.class);
		if (null == workCompleted) {
			throw new ExceptionEntityNotExist(id, WorkCompleted.class);
		}
		Wo wo = this.get(business, effectivePerson, workCompleted, Wo.class);
		wo.setForm(this.getForm(business, formFlag));
		WorkCompletedControl control = wo.getControl();
		if (BooleanUtils.isNotTrue(control.getAllowVisit())) {
			throw new ExceptionWorkCompletedAccessDenied(effectivePerson.getDistinguishedName(), id);
		}
		result.setData(wo);
		return result;
	}
}
 
Example #6
Source Project: examples-javafx-repos1   Author: bekwam   File: SettingsDAOImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void load() throws IOException {

    File f = new File(getAbsolutePath());
    if( f.exists() ) {

        if( logger.isDebugEnabled() ) {
            logger.debug("[LOAD] " + f.getName() + " exists; loading");
        }
        FileReader fr = new FileReader(f);
        Properties props = new Properties();
        props.load(fr);
        settings.setRoundUp(BooleanUtils.toBoolean(props.getProperty("oldscores.roundUp")));
        fr.close();
    } else {
        if( logger.isDebugEnabled() ) {
            logger.debug("[LOAD " + f.getName() + " does not exist");
        }
    }

}
 
Example #7
Source Project: cuba   Author: cuba-platform   File: Scheduling.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public String printActiveScheduledTasks() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    StringBuilder sb = new StringBuilder();
    List<ScheduledTask> tasks = scheduling.getActiveTasks();
    for (ScheduledTask task : tasks) {
        sb.append(task).append(", lastStart=");
        if (task.getLastStartTime() != null) {
            sb.append(dateFormat.format(task.getLastStartTime()));
            if (BooleanUtils.isTrue(task.getSingleton()))
                sb.append(" on ").append(task.getLastStartServer());
        } else {
            sb.append("<never>");
        }
        sb.append("\n");
    }
    return sb.toString();
}
 
Example #8
Source Project: o2oa   Author: o2oa   File: WorkLogTree.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public WorkLogTree(List<WorkLog> list) throws Exception {

		for (WorkLog o : list) {
			this.nodes().add(new Node(o));
		}

		List<String> froms = ListTools.extractProperty(list, WorkLog.fromActivityToken_FIELDNAME, String.class, true,
				true);
		List<String> arriveds = ListTools.extractProperty(list, WorkLog.arrivedActivityToken_FIELDNAME, String.class,
				true, true);
		List<String> values = ListUtils.subtract(froms, arriveds);
		WorkLog begin = list.stream()
				.filter(o -> BooleanUtils.isTrue(o.getConnected()) && values.contains(o.getFromActivityToken()))
				.findFirst().orElse(null);
		if (null == begin) {
			throw new ExceptionBeginNotFound();
		}
		root = this.find(begin);
//		for (Node o : nodes) {
//			this.associate();
//		}
		this.associate();
	}
 
Example #9
Source Project: cuba   Author: cuba-platform   File: ListEditorPopupWindow.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected TextField createTextField(Datatype datatype) {
    TextField textField = uiComponents.create(TextField.class);
    textField.setDatatype(datatype);

    if (!BooleanUtils.isFalse(editable)) {
        FilterHelper.ShortcutListener shortcutListener = new FilterHelper.ShortcutListener("add", new KeyCombination(KeyCombination.Key.ENTER)) {
            @Override
            public void handleShortcutPressed() {
                _addValue(textField);
            }
        };
        filterHelper.addShortcutListener(textField, shortcutListener);
    }
    return textField;
}
 
Example #10
Source Project: geoportal-server-harvester   Author: Esri   File: AgsBrokerDefinitionAdaptor.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates instance of the adaptor.
 * @param def broker definition
 * @throws InvalidDefinitionException if invalid broker definition
 */
public AgsBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException {
  super(def);
  this.credAdaptor =new CredentialsDefinitionAdaptor(def);
  this.botsAdaptor = new BotsBrokerDefinitionAdaptor(def);
  if (StringUtils.trimToEmpty(def.getType()).isEmpty()) {
    def.setType(AgsConnector.TYPE);
  } else if (!AgsConnector.TYPE.equals(def.getType())) {
    throw new InvalidDefinitionException("Broker definition doesn't match");
  } else {
    try {
      hostUrl = new URL(get(P_HOST_URL));
    } catch (MalformedURLException ex) {
      throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL,get(P_HOST_URL)), ex);
    }
    enableLayers = BooleanUtils.toBoolean(get(P_ENABLE_LAYERS));
    emitXml = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_XML)), true);
    emitJson = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_JSON)), false);
  }
}
 
Example #11
ActionResult<JsonElement> execute(EffectivePerson effectivePerson, String id) throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<JsonElement> result = new ActionResult<>();
		Business business = new Business(emc);
		WorkCompleted workCompleted = emc.find(id, WorkCompleted.class);
		if (null == workCompleted) {
			throw new ExceptionEntityNotExist(id, WorkCompleted.class);
		}
		WoControl control = business.getControl(effectivePerson, workCompleted, WoControl.class);
		if (BooleanUtils.isNotTrue(control.getAllowVisit())) {
			throw new ExceptionWorkCompletedAccessDenied(effectivePerson.getDistinguishedName(),
					workCompleted.getTitle(), workCompleted.getId());
		}
		result.setData(XGsonBuilder.convert(workCompleted.getProperties().getData(), JsonElement.class));
		return result;
	}
}
 
Example #12
Source Project: sailfish-core   Author: exactpro   File: AbstractMessageFactory.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public IMessage createMessage(MsgMetaData metaData) {
    if (metaData.getMsgNamespace().equals(namespace)) {
        metaData.setDictionaryURI(dictionaryURI);
        metaData.setProtocol(getProtocol());

        if (dictionary != null) { //FIXME: Remove this check after removing init(String namespace, SailfishURI dictionaryURI) method
            IMessageStructure messageStructure = dictionary.getMessages().get(metaData.getMsgName());
            if (messageStructure != null) {
                Boolean isAdmin = getAttributeValue(messageStructure, ATTRIBUTE_IS_ADMIN);
                metaData.setAdmin(BooleanUtils.toBoolean(isAdmin));
            }
        }
    }
    IMessage message = new MapMessage(metaData);
    createComplexFields(message);
    return message;
}
 
Example #13
Source Project: o2oa   Author: o2oa   File: ActionOauthGet.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson, String name) throws Exception {
	ActionResult<Wo> result = new ActionResult<>();
	OauthClient oauthClient = null;
	if (ListTools.isNotEmpty(Config.token().getOauthClients())) {
		for (OauthClient o : Config.token().getOauthClients()) {
			if (BooleanUtils.isTrue(o.getEnable()) && StringUtils.equals(o.getName(), name)) {
				oauthClient = o;
			}
		}
	}
	if (null == oauthClient) {
		throw new ExceptionOauthNotExist(name);
	}
	Wo wo = new Wo();
	wo.setName(oauthClient.getName());
	wo.setRedirectUri(oauthClient.getAuthAddress());
	wo.setAuthAddress(oauthClient.getAuthAddress());
	wo.setAuthMethod(oauthClient.getAuthMethod());
	wo.setIcon(oauthClient.getIcon());
	String authParameter = this.fillAuthParameter(oauthClient.getAuthParameter(), oauthClient);
	logger.debug("auth parameter:{}.", authParameter);
	wo.setAuthParameter(authParameter);
	result.setData(wo);
	return result;
}
 
Example #14
Source Project: openemm   Author: agnitas-org   File: ComCompanyServiceImpl.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
private void setupSettings(ComCompany company, CompanySettingsDto settingsDto) {
    company.setSalutationExtended(BooleanUtils.toInteger(settingsDto.isHasExtendedSalutation()));
    company.setStatAdmin(settingsDto.getExecutiveAdministrator());
    company.setContactTech(settingsDto.getTechnicalContacts());

    /* update export notify admin field if HasDataExportNotify checkbox true,
            otherwise set export notify admin value 0 */
    if (settingsDto.isHasDataExportNotify()) {
        company.setExportNotifyAdmin(settingsDto.getExecutiveAdministrator());
    } else {
        company.setExportNotifyAdmin(0);
    }
    company.setSecretKey(RandomStringUtils.randomAscii(32));
    company.setSector(settingsDto.getSector());
    company.setBusiness(settingsDto.getBusiness());
}
 
Example #15
Source Project: cuba   Author: cuba-platform   File: WebGroupBox.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean saveSettings(Element element) {
    if (!isSettingsEnabled()) {
        return false;
    }

    if (!settingsChanged) {
        return false;
    }

    Element groupBoxElement = element.element("groupBox");
    if (groupBoxElement != null) {
        element.remove(groupBoxElement);
    }
    groupBoxElement = element.addElement("groupBox");
    groupBoxElement.addAttribute("expanded", BooleanUtils.toStringTrueFalse(isExpanded()));
    return true;
}
 
Example #16
Source Project: commons-configuration   Author: apache   File: PropertyConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Convert the specified object into a Boolean. Internally the
 * {@code org.apache.commons.lang.BooleanUtils} class from the
 * <a href="https://commons.apache.org/lang/">Commons Lang</a>
 * project is used to perform this conversion. This class accepts some more
 * tokens for the boolean value of <b>true</b>, e.g. {@code yes} and
 * {@code on}. Please refer to the documentation of this class for more
 * details.
 *
 * @param value the value to convert
 * @return the converted value
 * @throws ConversionException thrown if the value cannot be converted to a boolean
 */
public static Boolean toBoolean(final Object value) throws ConversionException
{
    if (value instanceof Boolean)
    {
        return (Boolean) value;
    }
    else if (value instanceof String)
    {
        final Boolean b = BooleanUtils.toBooleanObject((String) value);
        if (b == null)
        {
            throw new ConversionException("The value " + value + " can't be converted to a Boolean object");
        }
        return b;
    }
    else
    {
        throw new ConversionException("The value " + value + " can't be converted to a Boolean object");
    }
}
 
Example #17
Source Project: AnyMock   Author: duxiaoman   File: HttpMockServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
private HttpInterfaceBO loadHttpInterfaceBO(HttpInterfaceKeyBO httpInterfaceKeyBO) {
    logger.info("Loading HTTP interface from redis...");
    HttpInterfaceBO httpInterfaceBO = httpInterfaceCacheManager.get(httpInterfaceKeyBO);
    if (httpInterfaceBO == null) {
        logger.info("Loading HTTP interface from DB...");
        httpInterfaceBO = httpInterfaceDao.queryByKey(httpInterfaceKeyBO);
        if (httpInterfaceBO == null) {
            throw new BizException(ResultCode.NOT_FOUND_HTTP_INTERFACE);
        }
        httpInterfaceCacheManager.set(httpInterfaceBO);
    }

    if (BooleanUtils.isNotTrue(httpInterfaceBO.getStart())) {
        throw new BizException(ResultCode.HTTP_INTERFACE_NOT_OPEN);
    }
    return httpInterfaceBO;
}
 
Example #18
Source Project: o2oa   Author: o2oa   File: ExternalDataSources.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public String log(String name) {
	int idx = 0;
	for (ExternalDataSource o : this) {
		idx++;
		if (BooleanUtils.isTrue(o.getEnable())) {
			String n = "s" + ("" + (1000 + idx)).substring(1);
			if (StringUtils.equals(n, name)) {
				String value = o.getLogLevel().toString();
				return "DefaultLevel=WARN, Tool=" + value + ", Enhance=" + value + ", METADATA=" + value
						+ ", Runtime=" + value + ", Query=" + value + ", DataCache=" + value + ", JDBC=" + value
						+ ", SQL=" + value;
			}
		}
	}
	return "DefaultLevel=WARN, Tool=WARN, Enhance=WARN, METADATA=WARN, Runtime=WARN, Query=WARN, DataCache=WARN, JDBC=ERROR, SQL=WARN";
}
 
Example #19
Source Project: o2oa   Author: o2oa   File: HttpToken.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public EffectivePerson who(HttpServletRequest request, HttpServletResponse response, String key) throws Exception {
	EffectivePerson effectivePerson = this.who(this.getToken(request), key);
	effectivePerson.setRemoteAddress(this.remoteAddress(request));
	effectivePerson.setUserAgent(this.userAgent(request));
	effectivePerson.setUri(request.getRequestURI());
	/* 加入调试标记 */
	Object debugger = request.getHeader(HttpToken.X_Debugger);
	if (null != debugger && BooleanUtils.toBoolean(Objects.toString(debugger))) {
		effectivePerson.setDebugger(true);
	} else {
		effectivePerson.setDebugger(false);
	}
	setAttribute(request, effectivePerson);
	setToken(request, response, effectivePerson);
	return effectivePerson;
}
 
Example #20
Source Project: uyuni   Author: uyuni-project   File: ChannelSoftwareHandler.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns whether the channel may be managed by the given user.
 * @param loggedInUser The current user
 * @param channelLabel The label for the channel in question
 * @param login The login for the user in question
 * @return whether the channel may be managed by the given user.
 * @throws FaultException thrown if
 *   - The loggedInUser doesn't have permission to perform this action
 *   - The login, sessionKey, or channelLabel is invalid
 *
 * @xmlrpc.doc Returns whether the channel may be managed by the given user.
 * @xmlrpc.param #session_key()
 * @xmlrpc.param #param_desc("string", "channelLabel", "label of the channel")
 * @xmlrpc.param #param_desc("string", "login", "login of the target user")
 * @xmlrpc.returntype #param_desc("int", "status", "1 if manageable, 0 if not")
 */
public int isUserManageable(User loggedInUser, String channelLabel,
        String login) throws FaultException {
    User target = XmlRpcUserHelper.getInstance().lookupTargetUser(
            loggedInUser, login);

    Channel channel = lookupChannelByLabel(loggedInUser.getOrg(), channelLabel);
    if (!channel.isCustom()) {
        throw new InvalidChannelException(
                "Manageable flag is relevant for custom channels only.");
    }
    //Verify permissions
    if (!(UserManager.verifyChannelAdmin(loggedInUser, channel) ||
          loggedInUser.hasRole(RoleFactory.CHANNEL_ADMIN))) {
        throw new PermissionCheckFailureException();
    }

    boolean flag = ChannelManager.verifyChannelManage(target, channel.getId());
    return BooleanUtils.toInteger(flag);
}
 
Example #21
Source Project: TypeScript-Microservices   Author: PacktPublishing   File: JavaMSF4JServerCodegen.java    License: MIT License 6 votes vote down vote up
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
    super.postProcessModelProperty(model, property);
    if("null".equals(property.example)) {
        property.example = null;
    }

    //Add imports for Jackson
    if(!BooleanUtils.toBoolean(model.isEnum)) {
        model.imports.add("JsonProperty");

        if(BooleanUtils.toBoolean(model.hasEnums)) {
            model.imports.add("JsonValue");
        }
    }
}
 
Example #22
Source Project: bird-java   Author: liuxx001   File: AuthorizePipe.java    License: MIT License 6 votes vote down vote up
@Override
protected Mono<Void> doExecute(ServerWebExchange exchange, PipeChain chain, RouteDefinition routeDefinition) {
    BirdSession session = authorizeManager.parseSession(exchange);

    if(StringUtils.equalsIgnoreCase(routeDefinition.getRpcType(), RpcTypeEnum.DUBBO.getName())){
        if(BooleanUtils.isNotTrue(routeDefinition.getAnonymous())){
            if(session == null){
                return jsonResult(exchange,JsonResult.error(CommonErrorCode.UNAUTHORIZED,"需登录后才能访问"));
            }else {
                String[] permissions = StringUtils.split(routeDefinition.getPermissions(),",");
                if(!authorizeManager.checkPermissions(session,permissions,BooleanUtils.isTrue(routeDefinition.getCheckAll()))){
                    return jsonResult(exchange,JsonResult.error(CommonErrorCode.UNAUTHORIZED,"当前用户权限不足"));
                }
            }
        }
    }

    SessionContext.setSession(session);
    return chain.execute(exchange);
}
 
Example #23
Source Project: TypeScript-Microservices   Author: PacktPublishing   File: JavaJerseyServerCodegen.java    License: MIT License 6 votes vote down vote up
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
    super.postProcessModelProperty(model, property);
    if("null".equals(property.example)) {
        property.example = null;
    }

    //Add imports for Jackson
    if(!BooleanUtils.toBoolean(model.isEnum)) {
        model.imports.add("JsonProperty");

        if(BooleanUtils.toBoolean(model.hasEnums)) {
            model.imports.add("JsonValue");
        }
    }
}
 
Example #24
Source Project: cuba   Author: cuba-platform   File: CategoryAttrsFrame.java    License: Apache License 2.0 6 votes vote down vote up
protected void initDataTypeColumn() {
    categoryAttrsTable.removeGeneratedColumn("dataType");
    categoryAttrsTable.addGeneratedColumn("dataType", new Table.ColumnGenerator<CategoryAttribute>() {
        @Override
        public Component generateCell(CategoryAttribute attribute) {
            Label dataTypeLabel = factory.createComponent(Label.class);
            String labelContent;
            if (BooleanUtils.isTrue(attribute.getIsEntity())) {
                Class clazz = attribute.getJavaClassForEntity();

                if (clazz != null) {
                    MetaClass metaClass = metadata.getSession().getClass(clazz);
                    labelContent = messageTools.getEntityCaption(metaClass);
                } else {
                    labelContent = "classNotFound";
                }
            } else {
                labelContent = getMessage(attribute.getDataType().name());
            }

            dataTypeLabel.setValue(labelContent);
            return dataTypeLabel;
        }
    });
}
 
Example #25
Source Project: o2oa   Author: o2oa   File: ActionClean.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
private List<String> list(Business business, Boolean cleanWork, Boolean cleanWorkCompleted, Boolean cleanCms)
		throws Exception {
	EntityManager em = business.entityManagerContainer().get(Entry.class);
	CriteriaBuilder cb = em.getCriteriaBuilder();
	CriteriaQuery<String> cq = cb.createQuery(String.class);
	Root<Entry> root = cq.from(Entry.class);
	Predicate p = cb.disjunction();
	if (BooleanUtils.isTrue(cleanWork)) {
		p = cb.or(p, cb.equal(root.get(Entry_.type), Entry.TYPE_WORK));
	}
	if (BooleanUtils.isTrue(cleanWorkCompleted)) {
		p = cb.or(p, cb.equal(root.get(Entry_.type), Entry.TYPE_WORKCOMPLETED));
	}
	if (BooleanUtils.isTrue(cleanCms)) {
		p = cb.or(p, cb.equal(root.get(Entry_.type), Entry.TYPE_CMS));
	}
	cq.select(root.get(Entry_.id)).where(p);
	List<String> os = em.createQuery(cq).setMaxResults(BATCHSIZE).getResultList();
	return os;
}
 
Example #26
Source Project: apiman   Author: apiman   File: SystemResourceImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @see ISystemResource#exportData(java.lang.String)
 */
@Override
public Response exportData(String download) throws NotAuthorizedException {
    securityContext.checkAdminPermissions();

    if (BooleanUtils.toBoolean(download)) {
        try {
            DownloadBean dbean = downloadManager.createDownload(DownloadType.exportJson, "/system/export"); //$NON-NLS-1$
            return Response.ok(dbean, MediaType.APPLICATION_JSON).build();
        } catch (StorageException e) {
            throw new SystemErrorException(e);
        }
    } else {
        return exportData();
    }
}
 
Example #27
Source Project: o2oa   Author: o2oa   File: V2Base.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
protected <O extends AbstractWo, W extends RelateFilterWi> void relate(Business business, List<O> wos, W wi)
		throws Exception {
	if (!wi.isEmptyRelate()) {
		List<String> jobs = ListTools.extractProperty(wos, TaskCompleted.job_FIELDNAME, String.class, true, true);
		if (BooleanUtils.isTrue(wi.getRelateWork())) {
			this.relateWork(business, wos, jobs);
		}
		if (BooleanUtils.isTrue(wi.getRelateWorkCompleted())) {
			this.relateWorkCompleted(business, wos, jobs);
		}
		if (BooleanUtils.isTrue(wi.getRelateTask())) {
			this.relateTask(business, wos, jobs);
		}
		if (BooleanUtils.isTrue(wi.getRelateRead())) {
			this.relateRead(business, wos, jobs);
		}
		if (BooleanUtils.isTrue(wi.getRelateReadCompleted())) {
			this.relateReadCompleted(business, wos, jobs);
		}
		if (BooleanUtils.isTrue(wi.getRelateReview())) {
			this.relateReview(business, wos, jobs);
		}
	}
}
 
Example #28
Source Project: o2oa   Author: o2oa   File: WebServerTools.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private static void createIndexPage() throws Exception {
	if (null != Config.nodes().webServers()) {
		StringBuffer buffer = new StringBuffer();
		buffer.append("<!DOCTYPE html>");
		buffer.append("<html>");
		buffer.append("<head>");
		buffer.append("<meta charset=\"UTF-8\">");
		buffer.append("<title>o2 index</title>");
		buffer.append("	</head>");
		buffer.append("<body>");
		for (Entry<String, WebServer> en : Config.nodes().webServers().entrySet()) {
			WebServer o = en.getValue();
			if (BooleanUtils.isTrue(o.getEnable())) {
				String url = BooleanUtils.isTrue(o.getSslEnable()) ? "https://" : "http://";
				url += en.getKey();
				if (BooleanUtils.isTrue(o.getSslEnable())) {
					if (o.getPort() != 443) {
						url += ":" + o.getPort();
					}
				} else {
					if (o.getPort() != 80) {
						url += ":" + o.getPort();
					}
				}
				buffer.append("<a href=\"" + url + "\">" + url + "</a><br/>");
			}

		}
		buffer.append("</body>");
		buffer.append("</html>");
		File file = new File(Config.base(), "index.html");
		FileUtils.write(file, buffer.toString(), DefaultCharset.name);
	}
}
 
Example #29
Source Project: o2oa   Author: o2oa   File: ManualProcessor.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private List<TaskCompleted> listJoinInquireTaskCompleted(AeiObjects aeiObjects, List<String> identities)
		throws Exception {
	return aeiObjects.getJoinInquireTaskCompleteds().stream().filter(o -> {
		return StringUtils.equals(aeiObjects.getWork().getActivityToken(), o.getActivityToken())
				&& identities.contains(o.getIdentity()) && BooleanUtils.isTrue(o.getJoinInquire());
	}).collect(Collectors.toList());
}
 
Example #30
Source Project: o2oa   Author: o2oa   File: Attachment.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/** 更新运行方法 */

	@Override
	public String path() throws Exception {
		if (null == this.workCreateTime) {
			throw new Exception("workCreateTime can not be null.");
		}
		if (StringUtils.isEmpty(job)) {
			throw new Exception("job can not be empty.");
		}
		if (StringUtils.isEmpty(id)) {
			throw new Exception("id can not be empty.");
		}
		String str = DateTools.format(workCreateTime, DateTools.formatCompact_yyyyMMdd);
		if (BooleanUtils.isTrue(this.getDeepPath())) {
			str += PATHSEPARATOR;
			str += StringUtils.substring(this.job, 0, 2);
			str += PATHSEPARATOR;
			str += StringUtils.substring(this.job, 2, 4);
		}
		str += PATHSEPARATOR;
		str += this.job;
		str += PATHSEPARATOR;
		str += this.id;
		str += StringUtils.isEmpty(this.extension) ? "" : ("." + this.extension);
		return str;
	}