Java Code Examples for org.apache.commons.lang3.StringUtils#lowerCase()

The following examples show how to use org.apache.commons.lang3.StringUtils#lowerCase() . 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
private List<Wo> list(Business business, EffectivePerson effectivePesron, Wi wi) throws Exception {
	List<Wo> wos = new ArrayList<>();
	if (StringUtils.isEmpty(wi.getKey())) {
		return wos;
	}
	List<String> personIds = business.expendGroupRoleToPerson(wi.getGroupList(), wi.getRoleList());
	String str = StringUtils.lowerCase(StringTools.escapeSqlLikeKey(wi.getKey()));
	EntityManager em = business.entityManagerContainer().get(Person.class);
	CriteriaBuilder cb = em.getCriteriaBuilder();
	CriteriaQuery<Person> cq = cb.createQuery(Person.class);
	Root<Person> root = cq.from(Person.class);
	Predicate p = cb.like(cb.lower(root.get(Person_.name)), "%" + str + "%", StringTools.SQL_ESCAPE_CHAR);
	p = cb.or(p, cb.like(cb.lower(root.get(Person_.unique)), "%" + str + "%", StringTools.SQL_ESCAPE_CHAR));
	p = cb.or(p, cb.like(cb.lower(root.get(Person_.pinyin)), str + "%", StringTools.SQL_ESCAPE_CHAR));
	p = cb.or(p, cb.like(cb.lower(root.get(Person_.pinyinInitial)), str + "%", StringTools.SQL_ESCAPE_CHAR));
	p = cb.or(p, cb.like(cb.lower(root.get(Person_.mobile)), str + "%", StringTools.SQL_ESCAPE_CHAR));
	p = cb.or(p, cb.like(cb.lower(root.get(Person_.distinguishedName)), str + "%", StringTools.SQL_ESCAPE_CHAR));
	if (ListTools.isNotEmpty(personIds)) {
		p = cb.and(p, root.get(Person_.id).in(personIds));
	}
	p = cb.and(p, business.personPredicateWithTopUnit(effectivePesron));
	List<Person> os = em.createQuery(cq.select(root).where(p)).getResultList();
	wos = Wo.copier.copy(os);
	wos = business.person().sort(wos);
	return wos;
}
 
Example 2
public Attachment(String storage, String name, String person, String folder) throws Exception {
	if (StringUtils.isEmpty(storage)) {
		throw new Exception("storage can not be empty.");
	}
	if (StringUtils.isEmpty(name)) {
		throw new Exception("name can not be empty.");
	}
	if (StringUtils.isEmpty(person)) {
		throw new Exception("person can not be empty.");
	}
	this.storage = storage;
	Date now = new Date();
	this.setCreateTime(now);
	this.lastUpdateTime = now;
	this.name = name;
	this.extension = StringUtils.lowerCase(FilenameUtils.getExtension(name));
	this.person = person;
	this.lastUpdatePerson = person;
	this.folder = folder;
	if (null == this.extension) {
		throw new Exception("extension can not be null.");
	}
}
 
Example 3
Source Project: FEBS-Cloud   File: FebsUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 驼峰转下划线
 *
 * @param value 待转换值
 * @return 结果
 */
public static String camelToUnderscore(String value) {
    if (StringUtils.isBlank(value)) {
        return value;
    }
    String[] arr = StringUtils.splitByCharacterTypeCamelCase(value);
    if (arr.length == 0) {
        return value;
    }
    StringBuilder result = new StringBuilder();
    IntStream.range(0, arr.length).forEach(i -> {
        if (i != arr.length - 1) {
            result.append(arr[i]).append("_");
        } else {
            result.append(arr[i]);
        }
    });
    return StringUtils.lowerCase(result.toString());
}
 
Example 4
public Membership addOrUpdateCourseSetMembership(final String userId, String role, final String courseSetEid, final String status) throws IdNotFoundException {
	String lcUserId = StringUtils.lowerCase(userId);
	CourseSetCmImpl cs = (CourseSetCmImpl)getObjectByEid(courseSetEid, CourseSetCmImpl.class.getName());
	MembershipCmImpl member =getMembership(lcUserId, cs);
	if(member == null) {
		// Add the new member
	    member = new MembershipCmImpl(lcUserId, role, cs, status);
	    member.setCreatedBy(authn.getUserEid());
	    member.setCreatedDate(new Date());
		getHibernateTemplate().save(member);
	} else {
		// Update the existing member
		member.setRole(role);
		member.setStatus(status);
		member.setLastModifiedBy(authn.getUserEid());
		member.setLastModifiedDate(new Date());
		getHibernateTemplate().update(member);
	}
	return member;
}
 
Example 5
private List<Wo> list(EffectivePerson effectivePerson, Business business, Wi wi) throws Exception {
	List<Wo> wos = new ArrayList<>();
	if (StringUtils.isEmpty(wi.getKey())) {
		return wos;
	}
	List<String> unitIds = business.expendUnitToUnit(wi.getUnitList());
	/** 去掉指定范围本身,仅包含下级 */
	unitIds.removeAll(ListTools.extractProperty(business.unit().pick(wi.getUnitList()), JpaObject.id_FIELDNAME,
			String.class, true, true));
	String str = StringUtils.lowerCase(StringTools.escapeSqlLikeKey(wi.getKey()));
	EntityManager em = business.entityManagerContainer().get(Unit.class);
	CriteriaBuilder cb = em.getCriteriaBuilder();
	CriteriaQuery<Unit> cq = cb.createQuery(Unit.class);
	Root<Unit> root = cq.from(Unit.class);
	Predicate p = cb.like(root.get(Unit_.pinyinInitial), str + "%", StringTools.SQL_ESCAPE_CHAR);
	if (ListTools.isNotEmpty(unitIds)) {
		p = cb.and(p, root.get(Unit_.id).in(unitIds));
	}
	if (StringUtils.isNotEmpty(wi.getType())) {
		p = cb.and(p, cb.isMember(wi.getType(), root.get(Unit_.typeList)));
	}
	List<Unit> os = em.createQuery(cq.select(root).where(p)).getResultList();
	wos = Wo.copier.copy(os);
	for (Wo wo : wos) {
		wo.setWoSupNestedUnitList(Wo.copier.copy(business.unit().listSupNestedObject(wo)));
		wo.setSubDirectUnitCount(
				business.entityManagerContainer().countEqual(Unit.class, Unit.superior_FIELDNAME, wo.getId()));
		wo.setSubDirectIdentityCount(
				business.entityManagerContainer().countEqual(Identity.class, Identity.unit_FIELDNAME, wo.getId()));
	}
	wos = business.unit().sort(wos);
	return wos;
}
 
Example 6
Source Project: o2oa   File: Role.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public void onPersist() throws Exception {
	this.pinyin = StringUtils.lowerCase(PinyinHelper.convertToPinyinString(name, "", PinyinFormat.WITHOUT_TONE));
	this.pinyinInitial = StringUtils.lowerCase(PinyinHelper.getShortPinyin(name));
	this.unique = StringUtils.isBlank(this.unique) ? id : unique;
	this.distinguishedName = this.name + PersistenceProperties.distinguishNameSplit + this.unique
			+ PersistenceProperties.distinguishNameSplit + PersistenceProperties.Role.distinguishNameCharacter;
	/** 生成默认排序号 */
	if (null == this.orderNumber) {
		this.orderNumber = DateTools.timeOrderNumber();
	}
}
 
Example 7
/**
 * Adjust the id - trim it to null. Note: eid case insensitive option does NOT apply to id.
 *
 * @param id
 *        The id to clean up.
 * @return A cleaned up id.
 */
protected String cleanId(String id)
{
	// if we are not doing separate id and eid, use the eid rules
	if (!m_separateIdEid) {
	    id = cleanEid(id);
	}
	id = StringUtils.lowerCase(id);
	id = StringUtils.trimToNull(id);
	// max length for an id is 99 chars
       id = StringUtils.abbreviate(id, 99);
	return id;
}
 
Example 8
public void setLogin(String login) {
    this.login = StringUtils.lowerCase(login, Locale.ENGLISH);
}
 
Example 9
public Application(final String identifier, final String name) {
    this.identifier = StringUtils.lowerCase(identifier);
    this.name = name;
}
 
Example 10
private LRS_Verb getEventVerb(Event event) {
    LRS_Verb verb = null;
    if (event != null) {
        String e = StringUtils.lowerCase(event.getEvent());
        if ("user.login".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.initialized);
        } else if ("user.logout".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.exited);
        } else if ("annc.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("calendar.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("chat.new".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.responded);
        } else if ("chat.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("content.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.interacted);
        } else if ("content.new".equals(e) || "content.revise".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.shared);
        } else if ("gradebook.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("lessonbuilder.page.read".equals(e) || "lessonbuilder.item.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("news.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("podcast.read".equals(e) || "podcast.read.public".equals(e) || "podcast.read.site".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("syllabus.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("webcontent.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("wiki.new".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.initialized);
        } else if ("wiki.revise".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.shared);
        } else if ("wiki.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        }
    }
    return verb;
}
 
Example 11
private LRS_Verb getEventVerb(Event event) {
    LRS_Verb verb = null;
    if (event != null) {
        String e = StringUtils.lowerCase(event.getEvent());
        if ("user.login".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.initialized);
        } else if ("user.logout".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.exited);
        } else if ("annc.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("calendar.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("chat.new".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.responded);
        } else if ("chat.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("content.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.interacted);
        } else if ("content.new".equals(e) || "content.revise".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.shared);
        } else if ("gradebook.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("lessonbuilder.page.read".equals(e) || "lessonbuilder.item.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("news.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("podcast.read".equals(e) || "podcast.read.public".equals(e) || "podcast.read.site".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("syllabus.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("webcontent.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        } else if ("wiki.new".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.initialized);
        } else if ("wiki.revise".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.shared);
        } else if ("wiki.read".equals(e)) {
            verb = new LRS_Verb(SAKAI_VERB.experienced);
        }
    }
    return verb;
}
 
Example 12
public void setLogin(String login) {
    this.login = StringUtils.lowerCase(login, Locale.ENGLISH);
}
 
Example 13
private LRS_Object getEventObject(Event event) {
    LRS_Object object = null;
    if (event != null) {
        String e = StringUtils.lowerCase(event.getEvent());
        /*
         * NOTE: use the following terms "view", "add", "edit", "delete"
         */
        if ("user.login".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl(), "session-started");
        } else if ("user.logout".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl()+"/logout", "session-ended");
        } else if ("annc.read".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl() + event.getResource(), "view-announcement");
        } else if ("calendar.read".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl() + event.getResource(), "view-calendar");
        } else if ("chat.new".equals(e) || "chat.read".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl() + event.getResource(), "view-chats");
        } else if ("content.read".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getAccessUrl() + event.getResource(), "view-resource");
        } else if ("content.new".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getAccessUrl() + event.getResource(), "add-resource");
        } else if ("content.revise".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getAccessUrl() + event.getResource(), "edit-resource");
        } else if ("gradebook.read".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl() + event.getResource(), "view-grades");
        } else if ("lessonbuilder.page.read".equals(e) || "lessonbuilder.item.read".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl() + event.getResource(), "view-lesson");
        } else if ("news.read".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl() + event.getResource(), "view-news");
        } else if ("podcast.read".equals(e) || "podcast.read.public".equals(e) || "podcast.read.site".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl() + event.getResource(), "view-podcast");
        } else if ("syllabus.read".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl() + event.getResource(), "view-syllabus");
        } else if ("webcontent.read".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl() + event.getResource(), "view-web-content");
        } else if ("wiki.new".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl() + event.getResource(), "add-wiki-page");
        } else if ("wiki.revise".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl() + event.getResource(), "edit-wiki-page");
        } else if ("wiki.read".equals(e)) {
            object = new LRS_Object(serverConfigurationService.getPortalUrl() + event.getResource(), "view-wiki-page");
        }
    }
    return object;
}
 
Example 14
public void setLogin(String login) {
    this.login = StringUtils.lowerCase(login, Locale.ENGLISH);
}
 
Example 15
public void setLogin(String login) {
    this.login = StringUtils.lowerCase(login, Locale.ENGLISH);
}
 
Example 16
/**
 * 从单个建表语句中创建实体
 *
 * @param project
 * @param sqlStatement
 */
private void saveEntityFromSqlStatement(MetaProjectPO project, SQLCreateTableStatement sqlStatement) {
    SQLCreateTableStatement createTableStatement = sqlStatement;
    // 解析表名
    String tableName = this.parseTableName(createTableStatement);
    if (StringUtils.isBlank(tableName)) {
        return;
    }
    String comment = cleanQuote(SafeUtil.getString(createTableStatement.getComment()));
    MetaEntityPO entity = createEntity(project, tableName, comment);
    // 获取单独声明的主键
    String pkAlone = this.getPkAlone(createTableStatement);
    List<SQLTableElement> tableElementList = createTableStatement.getTableElementList();
    int orderNo = 0;
    // 缓存遍历到的字段
    Map<String, MetaFieldPO> fieldMap = new HashMap<>(32);
    for (SQLTableElement element : tableElementList) {
        // 创建字段
        if (element instanceof SQLColumnDefinition) {
            orderNo += 10;
            SQLColumnDefinition sqlColumnDefinition = (SQLColumnDefinition) element;
            String fieldName = cleanQuote(sqlColumnDefinition.getNameAsString());
            boolean pk = this.isPkField(sqlColumnDefinition, pkAlone);
            String fieldType = StringUtils.lowerCase(sqlColumnDefinition.getDataType().getName());
            int fieldLength = 0;
            int fieldScale = 0;
            List<SQLExpr> arguments = sqlColumnDefinition.getDataType().getArguments();
            if (CollectionUtils.isNotEmpty(arguments)) {
                fieldLength = SafeUtil.getInteger(arguments.get(0));
                if (arguments.size() >= 2) {
                    fieldScale = SafeUtil.getInteger(arguments.get(1));
                }
            }
            boolean autoIncrement = sqlColumnDefinition.isAutoIncrement();
            boolean notNull = sqlColumnDefinition.containsNotNullConstaint();
            if (pk) {
                notNull = true;
            }
            String defaultValue = sqlColumnDefinition.getDefaultExpr() == null ? "NULL" : sqlColumnDefinition.getDefaultExpr().toString();
            String desc = sqlColumnDefinition.getComment() == null ? "" : cleanQuote(sqlColumnDefinition.getComment().toString());

            MetaFieldPO field = this.createField(entity, fieldName, fieldType,
                fieldLength, fieldScale, pk,
                autoIncrement, notNull, orderNo,
                defaultValue, desc);
            fieldMap.put(fieldName, field);
            continue;
        }
        if (element instanceof MySqlPrimaryKey) {
            continue;
        }
        // 创建索引
        if (element instanceof MySqlKey) {
            boolean unique = (element instanceof MySqlUnique);
            MySqlKey sqlKey = (MySqlKey) element;
            String indexName = cleanQuote(sqlKey.getName().toString());
            List<MetaFieldPO> fields = new ArrayList<>();
            for (SQLSelectOrderByItem item : sqlKey.getColumns()) {
                String columnName = cleanQuote(item.getExpr().toString());
                fields.add(fieldMap.get(columnName));
            }
            this.createIndex(entity, indexName, unique, fields);
        }
    }
}
 
Example 17
public static void main(String... args) throws Exception {
	File base = new File(args[0]);
	File dir = new File(base, "configSample");
	List<Class<?>> classes = new ArrayList<Class<?>>();
	classes.add(AppStyle.class);
	classes.add(CenterServer.class);
	classes.add(Collect.class);
	classes.add(Dingding.class);
	classes.add(DumpRestoreData.class);
	classes.add(DumpRestoreStorage.class);
	classes.add(LogLevel.class);
	classes.add(Meeting.class);
	classes.add(Messages.class);
	classes.add(Node.class);
	classes.add(Person.class);
	classes.add(ProcessPlatform.class);
	classes.add(Qiyeweixin.class);
	classes.add(Query.class);
	classes.add(Token.class);
	classes.add(Vfs.class);
	classes.add(WorkTime.class);
	classes.add(ZhengwuDingding.class);
	//classes.add(ExternalDataSource.class);
	classes.add(Exmail.class);
	classes.add(Communicate.class);

	Collections.sort(classes, new Comparator<Class<?>>() {
		public int compare(Class<?> c1, Class<?> c2) {
			return c1.getCanonicalName().compareTo(c2.getCanonicalName());
		}
	});
	for (Class<?> cls : classes) {
		Object o = MethodUtils.invokeStaticMethod(cls, "defaultInstance", null);
		Map<String, Object> map = new LinkedHashMap<String, Object>();
		map = XGsonBuilder.convert(o, map.getClass());
		map = describe(cls, map);
		String name = StringUtils.lowerCase(cls.getSimpleName().substring(0, 1)) + cls.getSimpleName().substring(1)
				+ ".json";
		File file = new File(dir, name);
		logger.print("create file:{}.", file.getAbsoluteFile());
		FileUtils.write(file, XGsonBuilder.toJson(map), DefaultCharset.charset);
	}
	//convertExternalDataSource2ExternalDataSources(dir);
	renameNode(dir);
}
 
Example 18
Source Project: hygieia-core   File: HygieiaUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static boolean allowAutoDiscover(FeatureFlag featureFlag, CollectorType collectorType) {
	if(featureFlag == null) return false;
	String key = StringUtils.lowerCase(collectorType.toString());
	if(MapUtils.isEmpty(featureFlag.getFlags()) || Objects.isNull(featureFlag.getFlags().get(key))) return false;
	return BooleanUtils.toBoolean(featureFlag.getFlags().get(StringUtils.lowerCase(collectorType.toString())));
}
 
Example 19
Source Project: vscrawler   File: LowerCase.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected  String handleSingleStr(String input) {
    return StringUtils.lowerCase(input);
}
 
Example 20
Source Project: onos   File: BaseViewMessageHandler.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Returns a x-axis label for a monitoring value based on a map of submetrics.
 *
 * @param metric label metric
 * @param map a map of submetrics
 * @param index submetric index
 * @return a data label
 */
protected String getMappedLabel(MetricType metric, Map<Integer, String> map, int index) {
    String submetric = map.get(index);
    checkNotNull(submetric, MSG_UI_SUBMETRIC_NULL);
    return StringUtils.lowerCase(metric.name()) + "_" + submetric;
}