/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.opentides.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.opentides.bean.UserDefinedField;
import org.opentides.persistence.UserDefinedFieldDAO;
import org.opentides.service.SystemCodesService;
import org.opentides.service.UserDefinedFieldService;
import org.opentides.util.StringUtil;
/**
* This is the service implementation for UserDefinedField.
* Auto generated by high tides.
* @author hightides
*
*/
public class UserDefinedFieldServiceImpl extends BaseCrudServiceImpl<UserDefinedField>
implements UserDefinedFieldService {
private SystemCodesService systemCodesService;
//-- Start custom codes. Do not delete this comment line.
/* (non-Javadoc)
* @see org.opentides.service.UserDefinedFieldService#findMetaByClas(java.lang.Class)
*/
@Override
public List<UserDefinedField> findMetaByClass(String clazz) {
UserDefinedFieldDAO dao = (UserDefinedFieldDAO) getDao();
return dao.findMetaByClass(clazz);
}
/* (non-Javadoc)
* @see org.opentides.service.UserDefinedFieldService#getDropDownReferenceData(java.lang.String)
*/
@Override
public Map<String, Object> getDropDownReferenceData(String clazz) {
Map<String, Object> model = new HashMap<String, Object>();
List<UserDefinedField> udfs = this.findMetaByClass(clazz);
if (udfs!=null) {
for (UserDefinedField udf:udfs) {
if (udf.getUserField().startsWith("dropdown") &&
!StringUtil.isEmpty(udf.getReference()) ) {
model.put(udf.getUserField(),
systemCodesService.findSystemCodesByCategory(udf.getReference()) );
}
}
}
return model;
}
public final void setSystemCodesService(SystemCodesService systemCodesService) {
this.systemCodesService = systemCodesService;
}
//-- End custom codes. Do not delete this comment line.
}