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

The following examples show how to use org.apache.commons.lang3.StringUtils#lowerCase() . 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 File: Attachment.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
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 2
Source File: FebsUtil.java    From FEBS-Cloud with 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 3
Source File: ActionListLike.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
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 4
Source File: CourseManagementAdministrationHibernateImpl.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
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
Source File: ActionListPinyinInitial.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
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 File: Role.java    From o2oa with 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
Source File: BaseUserDirectoryService.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * 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
Source File: LowerCase.java    From vscrawler with Apache License 2.0 4 votes vote down vote up
@Override
protected  String handleSingleStr(String input) {
    return StringUtils.lowerCase(input);
}
 
Example 9
Source File: HygieiaUtils.java    From hygieia-core with 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 10
Source File: CreateConfigSample.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
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 11
Source File: ReverseEngineeringService.java    From youran with Apache License 2.0 4 votes vote down vote up
/**
 * 从单个建表语句中创建实体
 *
 * @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 12
Source File: User.java    From java-microservices-examples with Apache License 2.0 4 votes vote down vote up
public void setLogin(String login) {
    this.login = StringUtils.lowerCase(login, Locale.ENGLISH);
}
 
Example 13
Source File: User.java    From java-microservices-examples with Apache License 2.0 4 votes vote down vote up
public void setLogin(String login) {
    this.login = StringUtils.lowerCase(login, Locale.ENGLISH);
}
 
Example 14
Source File: BaseLearningResourceStoreService.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
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 15
Source File: User.java    From Full-Stack-Development-with-JHipster with MIT License 4 votes vote down vote up
public void setLogin(String login) {
    this.login = StringUtils.lowerCase(login, Locale.ENGLISH);
}
 
Example 16
Source File: BaseLearningResourceStoreService.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
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 17
Source File: BaseLearningResourceStoreService.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
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 18
Source File: Application.java    From cyberduck with GNU General Public License v3.0 4 votes vote down vote up
public Application(final String identifier, final String name) {
    this.identifier = StringUtils.lowerCase(identifier);
    this.name = name;
}
 
Example 19
Source File: User.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 4 votes vote down vote up
public void setLogin(String login) {
    this.login = StringUtils.lowerCase(login, Locale.ENGLISH);
}
 
Example 20
Source File: BaseViewMessageHandler.java    From onos with 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;
}