private void setDatasourceId(Data workingCopy, EStructuralFeature feature) { if (feature.equals(ProcessPackage.Literals.PAGE_FLOW__TRANSIENT_DATA) || feature.equals(ProcessPackage.Literals.RECAP_FLOW__RECAP_TRANSIENT_DATA) || feature.equals(ProcessPackage.Literals.VIEW_PAGE_FLOW__VIEW_TRANSIENT_DATA)) { workingCopy.setDatasourceId(DatasourceConstants.PAGEFLOW_DATASOURCE); } else if (workingCopy.isTransient()) { workingCopy.setDatasourceId(DatasourceConstants.IN_MEMORY_DATASOURCE); } else { workingCopy.setDatasourceId(DatasourceConstants.BOS_DATASOURCE); } }
protected DataWizardPage getWizardPage() { DataWizardPage page = null; if (!dataContainmentFeature.equals(ProcessPackage.Literals.DATA_AWARE__DATA)) { page = new DataWizardPage( dataWorkingCopy, container, false, false, false, showAutogenerateForm, featureToCheckForUniqueID, fixedReturnType); page.setIsPageFlowContext(isPageFlowContext); if (editMode) { page.setTitle(Messages.editVariableTitle); page.setDescription(Messages.editVariableDescription); } return page; } else { boolean isOnActivity = container instanceof Activity; page = new DataWizardPage( dataWorkingCopy, container, true, true, isOnActivity, showAutogenerateForm, featureToCheckForUniqueID, fixedReturnType); page.setIsPageFlowContext(isPageFlowContext); } if (editMode) { page.setTitle(Messages.editVariableTitle); page.setDescription(Messages.editVariableDescription); } return page; }
@Override protected Image doGetImage(Object element) { Parameter p = (Parameter) getOwner(element); EStructuralFeature feature = getEStructuralFeature(element); if (feature.equals(BizPackage.Literals.PARAMETER__FLAGS)) { switch (p.getParamType()) { case STD_FIELD: return PRAMETER_SINGLE_ICON; case NON_STD_FIELD: return PRAMETER_SINGLE_ICON2; case OBJECT: return PRAMETER_OBJ_ICON; case PARAM_GROUP: return PARAMETER_GROUP_ICON; case COMPONENT: return PARAMETER_COMPONENT_ICON; default: return PRAMETER_SINGLE_ICON; } } return super.doGetImage(element); }
/** * * <!-- begin-user-doc --> * This method is used to store daily values of some commodities in db. There are two types of * values written in this method. One which are rolled up in memory over the course of day and one * which are directly written to db as no roll up is required. * * @param dayChanged boolean to find whether the day has changed from the start * <!-- end-user-doc --> * @generated NOT */ @Override public EList<ReportingRecord> getDailyRecordList(boolean dayChanged) { EList<ReportingRecord> returnList = new BasicEList<ReportingRecord>(); long dailyTimeStamp = 0l; try { RepositoryRegistry rg = RepositoryRegistry.vmtMANAGER; Set<VMTRootObject> vObjList = rg.getInstances(getSEType()); if (dayChanged) { dailyTimeStamp = System.currentTimeMillis() - (1000 * 60 * 60); } for (VMTRootObject vObj : vObjList) { boolean constraintfailed = false; // Check constraints for (Constraint constraint : getMatchingCriteria()) { if (!constraint.match(vObj)) { constraintfailed = true; break; } } // and skip if any of the constraints do not match if (constraintfailed) continue; ServiceEntity se = (ServiceEntity) vObj; if (DeployManager.vmtMANAGER.inDeploy(se)) { continue; } for (NamedElementList neList : getNamedElementList()) { if (neList.getNamedElement().size() == 1) { if (dayChanged) { EStructuralFeature attribute = (EStructuralFeature) neList.getNamedElement().get(0); // Only create a record if the attribute has been set already if (vObj.eIsSet(attribute)) { Object attributeValue = vObj.eGet(attribute); ReportingRecord record = ReportingFactory.eINSTANCE.createReportingRecord(); // logger.info("comm att " + vObj.getName() + " " + attribute.getName() + " value = // " + attributeValue); record.setTimeStamp(dailyTimeStamp); record.setSeUuId(vObj.getUuid()); record.setPropertyType(attribute.getName()); record.setPropertySubType(attribute.getName()); record.setMinUtilization((Short) attributeValue); record.setMaxUtilization((Short) attributeValue); record.setAvgUtilization((Short) attributeValue); returnList.add(record); } } } else { // To be supported later : as needed // EReference reference = (EReference)neList.getNamedElement().get(0); ENamedElement commodity = neList.getNamedElement().get(1); EStructuralFeature attribute = (EStructuralFeature) neList.getNamedElement().get(neList.getNamedElement().size() - 1); List<ENamedElement> nesCommodity = new ArrayList<ENamedElement>(neList.getNamedElement()); nesCommodity.remove(neList.getNamedElement().size() - 1); List<Object> commodityList = vObj.getValues(nesCommodity); for (int i = 0; i < commodityList.size(); i++) { Commodity comm = (Commodity) commodityList.get(i); // get the attribute value from the commodity if it is set if (comm.eIsSet(attribute)) { Object attributeValue = comm.eGet(attribute); // logger.info("comm att " + comm.getName() + " " + attribute.getName() + " value = // " + attributeValue); CommodityReportingExt crExt = null; for (Extension ext : comm.getExtendedBy()) { if (ext instanceof CommodityReportingExt) { crExt = (CommodityReportingExt) ext; if (crExt.getAttribute() == attribute) { break; } else { crExt = null; } } } if (crExt == null) { crExt = ReportingExtensionsFactory.eINSTANCE.createCommodityReportingExt(); crExt.setAttribute(attribute); comm.getExtendedBy().add(crExt); } if (dayChanged) { // Record Object ReportingRecord record = this.createReportingRecord( crExt, vObj, attribute, commodity, comm, false, dailyTimeStamp); if (record != null) { returnList.add(record); } crExt.resetValues(); } // this condition for capacity, used and utilization values crExt.setMinUtilization(Double.parseDouble(attributeValue.toString())); if (attribute.equals(AnalysisPackage.eINSTANCE.getCommodity_Used()) && comm.eIsSet(AnalysisPackage.eINSTANCE.getCommodity_Peak())) { crExt.setMaxUtilization(comm.getPeak()); } else if (attribute.equals(AnalysisPackage.eINSTANCE.getCommodity_Utilization()) && comm.eIsSet(AnalysisPackage.eINSTANCE.getCommodity_PeakUtilization())) { crExt.setMaxUtilization(comm.getPeakUtilization()); } else { crExt.setMaxUtilization(Double.parseDouble(attributeValue.toString())); } crExt.setUtilSum(Double.parseDouble(attributeValue.toString())); crExt.setCapacity(comm.getCapacity()); // logger.info(vObj.getDisplayName() + " -> comm -> " + commodity.getName() + " min // = " + crExt.getMinUtilization() + " max = " + crExt.getMaxUtilization() + " sum = // " + crExt.getUtilSum() + " cap = " + crExt.getCapacity()); } } } } } } catch (Exception e) { logger.error("Exception in MetaRecordImpl.getDailyRecordList() ", e); } return returnList; }
/** * * <!-- begin-user-doc --> * This method goes over a provided SEType (config file) entities with matching criteria defined * in config file. It goes over the attributes required to report on and collects min,max and avg * into extension objects for commodity and service entity. * * <p>Every hour it creates a list of {@link ReportingRecord} objects with data and returns this * list. * <!-- end-user-doc --> * * @param hourChanged true if the hour changed from the previous gathering of values. * @generated NOT */ @Override public EList<ReportingRecord> getReportingRecordList(boolean hourChanged) { EList<ReportingRecord> returnList = new BasicEList<ReportingRecord>(); long hourlyTimeStamp = 0l; try { RepositoryRegistry rg = RepositoryRegistry.vmtMANAGER; Set<VMTRootObject> vObjList = rg.getInstances(getSEType()); if (hourChanged) { hourlyTimeStamp = (System.currentTimeMillis() - (1000 * 60 * 30)); // Give the record TS of the middle of the last hour } for (VMTRootObject vObj : vObjList) { boolean constraintfailed = false; // Check constraints for (Constraint constraint : getMatchingCriteria()) { if (!constraint.match(vObj)) { constraintfailed = true; break; } } // and skip if any of the constraints do not match if (constraintfailed) { continue; } ServiceEntity se = (ServiceEntity) vObj; if (DeployManager.vmtMANAGER.inDeploy(se)) { continue; } // Get the Extension for ServiceEntity ServiceEntityReportingExt seExt = (ServiceEntityReportingExt) se.findExtension( ReportingExtensionsPackage.eINSTANCE.getServiceEntityReportingExt()); if (seExt == null) { seExt = ReportingExtensionsFactory.eINSTANCE.createServiceEntityReportingExt(); se.getExtendedBy().add(seExt); } for (NamedElementList neList : getNamedElementList()) { if (neList.getNamedElement().size() == 1) { EStructuralFeature attribute = (EStructuralFeature) neList.getNamedElement().get(0); // Only create a record if the attribute has been set already if (vObj.eIsSet(attribute)) { Object attributeValue = vObj.eGet(attribute); if (attributeValue instanceof List<?>) { if (hourChanged) { // Record Object ReportingRecord record = this.createReportingRecord( seExt, vObj, attribute, null, null, true, hourlyTimeStamp); if (record != null) { returnList.add(record); } // reset only numProduces fields seExt.resetValues(attribute); } // this condition for numProduces value seExt.setMinNumProduces(((List<?>) attributeValue).size()); seExt.setMaxNumProduces(((List<?>) attributeValue).size()); seExt.setProducesSum(((List<?>) attributeValue).size()); // if(logger.isDebugEnabled())logger.debug("numProduces : min = " + // seExt.getMinNumProduces() + " max = " + seExt.getMaxNumProduces() + " sum = " + // seExt.getProducesSum()); } else { double val = Double.parseDouble(attributeValue.toString()); if (val > PRICE_THRESHOLD) { val = PRICE_THRESHOLD; } if (attribute == AnalysisPackage.eINSTANCE.getServiceEntity_PriceIndex()) { if (val < 0) { if (logger.isDebugEnabled()) { logger.error( "SE : " + vObj.toVMTString() + " has a negative value of " + val); for (StackTraceElement element : Thread.currentThread().getStackTrace()) { logger.debug(element.toString()); } } continue; } } List<EAttribute> atts = seExt.getExtAttributes(attribute); for (EAttribute att : atts) { seExt.eSet(att, val); } if (hourChanged) { // Record Object ReportingRecord record = this.createReportingRecord( seExt, vObj, attribute, null, null, false, hourlyTimeStamp); if (record != null) { returnList.add(record); } // reset only UtilIndex fields seExt.resetValues(attribute); } } } // Or get the list of attribute values and create a record for each } else { EReference reference = (EReference) neList.getNamedElement().get(0); ENamedElement commodity = neList.getNamedElement().get(1); EStructuralFeature attribute = (EStructuralFeature) neList.getNamedElement().get(neList.getNamedElement().size() - 1); List<ENamedElement> nesCommodity = new ArrayList<ENamedElement>(neList.getNamedElement()); nesCommodity.remove(neList.getNamedElement().size() - 1); List<Object> commodityList = vObj.getValues(nesCommodity); for (int i = 0; i < commodityList.size(); i++) { Commodity comm = (Commodity) commodityList.get(i); // get the attribute value from the commodity if it is set if (comm.eIsSet(attribute)) { Object attributeValue = comm.eGet(attribute); // logger.info("comm att " + comm.getName() + " " + attribute.getName() + " value = // " + attributeValue); CommodityReportingExt crExt = null; for (Extension ext : comm.getExtendedBy()) { if (ext instanceof CommodityReportingExt) { crExt = (CommodityReportingExt) ext; if (crExt.getAttribute() == attribute) { break; } else { crExt = null; } } } if (crExt == null) { crExt = ReportingExtensionsFactory.eINSTANCE.createCommodityReportingExt(); crExt.setAttribute(attribute); comm.getExtendedBy().add(crExt); } if (hourChanged) { // Record Object ReportingRecord record = this.createReportingRecord( crExt, vObj, attribute, commodity, comm, false, hourlyTimeStamp); if (record != null) { returnList.add(record); } crExt.resetValues(); } // this condition for capacity, used and utilization values crExt.setMinUtilization(Double.parseDouble(attributeValue.toString())); if (attribute.equals(AnalysisPackage.eINSTANCE.getCommodity_Used()) && comm.eIsSet(AnalysisPackage.eINSTANCE.getCommodity_Peak())) { crExt.setMaxUtilization(comm.getPeak()); } else if (attribute.equals(AnalysisPackage.eINSTANCE.getCommodity_Utilization()) && comm.eIsSet(AnalysisPackage.eINSTANCE.getCommodity_PeakUtilization())) { crExt.setMaxUtilization(comm.getPeakUtilization()); } else { crExt.setMaxUtilization(Double.parseDouble(attributeValue.toString())); } crExt.setUtilSum(Double.parseDouble(attributeValue.toString())); float capacity = comm.getCapacity(); if (capacity > CAPACITY_THRESHOLD) { if (logger.isDebugEnabled()) { logger.debug( "Capacity for " + se.getDisplayName() + "::" + comm.getDisplayName() + " is " + capacity + ". Capping it to " + CAPACITY_THRESHOLD); } capacity = CAPACITY_THRESHOLD; } crExt.setCapacity(capacity); crExt.setRelation( RelationType.valueOf(reference.getName().toUpperCase()).getValue()); crExt.setCommodityKey(comm.getKey()); // if(logger.isDebugEnabled())logger.debug("comm -> " + attribute.getName() + " min // = " + crExt.getMinUtilization() + " max = " + crExt.getMaxUtilization() + " sum = // " + crExt.getUtilSum() + " cap = " + crExt.getCapacity()); } } } } } } catch (Exception e) { logger.error("Exception in MetaRecordImpl.getReportingRecordList()", e); } return returnList; }
@Override public Color getBackground(Object element) { // DisplayItem 比如在接口中显示的对象的属性子节点,仅做展示用,任何属性都是只读的 if (element instanceof DisplayItem) { return COLOR_GRAY; } Parameter p = (Parameter) getOwner(element); EStructuralFeature feature = getEStructuralFeature(element); switch (p.getParamType()) { case STD_FIELD: if (BizPackage.Literals.PARAMETER__NAME.equals(feature) || BizPackage.Literals.PARAMETER__REAL_TYPE.equals(feature) || BizPackage.Literals.PARAMETER__TYPE.equals(feature) || BizPackage.Literals.PARAMETER__DESCRIPTION.equals(feature)) { return COLOR_GRAY; } break; case NON_STD_FIELD: if (feature.equals(BizPackage.Literals.PARAMETER__REAL_TYPE)) return COLOR_GRAY; break; case OBJECT: boolean hasStdObjectList = BizUtil.hasStdObjList(project); if (hasStdObjectList && (BizPackage.Literals.PARAMETER__TYPE.equals(feature) || MetadataPackage.Literals.NAMED_ELEMENT__DESCRIPTION.equals(feature) || MetadataPackage.Literals.NAMED_ELEMENT__CHINESE_NAME.equals(feature))) { return COLOR_GRAY; } if (BizPackage.Literals.PARAMETER__NAME.equals(feature) || BizPackage.Literals.PARAMETER__REAL_TYPE.equals(feature) || BizPackage.Literals.PARAMETER__DESCRIPTION.equals(feature) || BizPackage.Literals.PARAMETER__DEFAULT_VALUE.equals(feature)) { return COLOR_GRAY; } break; case COMPONENT: // 组件 if (BizPackage.Literals.PARAMETER__NAME.equals(feature) || BizPackage.Literals.PARAMETER__REAL_TYPE.equals(feature) || BizPackage.Literals.PARAMETER__DESCRIPTION.equals(feature) || BizPackage.Literals.PARAMETER__DEFAULT_VALUE.equals(feature)) { return COLOR_GRAY; } break; case PARAM_GROUP: // 参数组,只编辑类型来关联对象,其他都不可编辑 if (BizPackage.Literals.PARAMETER__NAME.equals(feature) || BizPackage.Literals.PARAMETER__ID.equals(feature) || BizPackage.Literals.PARAMETER__REAL_TYPE.equals(feature) || BizPackage.Literals.PARAMETER__DESCRIPTION.equals(feature) || BizPackage.Literals.PARAMETER__DEFAULT_VALUE.equals(feature)) { return COLOR_GRAY; } break; default: break; } if (resource != null && resource.isReadOnly()) { return COLOR_GRAY; } return super.getBackground(element); }
@Override public String getText(Object element) { Parameter p = (Parameter) getOwner(element); EStructuralFeature feature = getEStructuralFeature(element); if (feature.getEType().equals(EcorePackage.Literals.EBOOLEAN) || feature.getEType().equals(EcorePackage.Literals.EBOOLEAN_OBJECT)) { return StringUtils.EMPTY; } // 不同参数类型分开处理 switch (p.getParamType()) { case NON_STD_FIELD: // 非标准字段参数的真实类型也不可编辑,显示对应的业务数据类型的设置的语言的值(在项目属性中设置) if (feature.equals(BizPackage.Literals.PARAMETER__REAL_TYPE)) { String bizType = p.getType(); if (StringUtils.isEmpty(bizType)) break; ReferenceInfo ref = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.BizType, bizType, true); if (ref != null) { BusinessDataType bizDataType = (BusinessDataType) ref.getObject(); if (bizDataType == null) break; String stdType = bizDataType.getStdType(); if (StringUtils.isEmpty(stdType)) break; ReferenceInfo stdTypeRef = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.StdType, stdType, true); if (stdTypeRef == null) break; StandardDataType stdDataType = (StandardDataType) stdTypeRef.getObject(); return stdDataType.getData().get(dataType); } } else if (BizPackage.Literals.PARAMETER__DEFAULT_VALUE.equals(feature)) { return getNonStdParameterDefaultValue(p.getDefaultValue(), p); } break; case STD_FIELD: if (BizPackage.Literals.PARAMETER__NAME.equals(feature) || BizPackage.Literals.PARAMETER__REAL_TYPE.equals(feature) || BizPackage.Literals.PARAMETER__TYPE.equals(feature) || BizPackage.Literals.PARAMETER__DESCRIPTION.equals(feature) || BizPackage.Literals.PARAMETER__DEFAULT_VALUE.equals(feature)) { ReferenceInfo referenceInfo = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.StdField, p.getId(), true); if (referenceInfo != null) { StandardField field = (StandardField) referenceInfo.getObject(); if (field == null) { return StringUtils.EMPTY; } if (BizPackage.Literals.PARAMETER__NAME.equals(feature)) { return field.getChineseName(); } else if (BizPackage.Literals.PARAMETER__REAL_TYPE.equals( feature)) { // 一般不存在此情况,如果要取真实类型可以继承此类重新实现 try { StandardDataType sdt = MetadataServiceProvider.getStandardDataTypeOfStdFieldByName( project, field.getName()); if (sdt != null) { return sdt.getData().get(dataType); } } catch (Exception e) { // e.printStackTrace(); } } else if (BizPackage.Literals.PARAMETER__TYPE.equals(feature)) { return field.getDataType(); } else if (BizPackage.Literals.PARAMETER__DESCRIPTION.equals(feature)) { StringBuffer text = new StringBuffer(); String dictTypeStr = field.getDictionaryType(); if (StringUtils.isNotBlank(dictTypeStr)) { ReferenceInfo dictReferenceInfo = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.Dict, dictTypeStr, true); if (dictReferenceInfo != null) { DictionaryType objDictionaryType = (DictionaryType) dictReferenceInfo.getObject(); if (objDictionaryType != null) { for (DictionaryItem item : objDictionaryType.getItems()) { String value = StringUtils.defaultString(item.getValue()); String chineseName = StringUtils.defaultString(item.getChineseName()); text.append(value); text.append(":"); text.append(chineseName); text.append(" "); } } } } if (StringUtils.isNotBlank(text.toString()) && StringUtils.isNotBlank(field.getDescription())) { text.append("\r\n"); text.append(field.getDescription()); } return StringUtils.defaultString( StringUtils.defaultIfBlank(text.toString(), field.getDescription())); } else if (BizPackage.Literals.PARAMETER__DEFAULT_VALUE.equals(feature)) { return getParameterDefaultValue(p.getDefaultValue(), field); } } } break; case OBJECT: // 如果有对象标准字段列表资源 if (BizUtil.hasStdObjList(project)) { String refId = p.getId(); ReferenceInfo ref = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IBizRefType.Std_Obj, refId, true); if (ref == null) break; StandardObjField field = (StandardObjField) ref.getObject(); String objId = field.getType(); ARESObject obj = BizUtil.getObject(objId, project); if (feature.equals(BizPackage.Literals.PARAMETER__TYPE)) { if (StringUtils.contains(objId, '.')) return StringUtils.substringAfterLast(objId, "."); } else if (feature.equals(BizPackage.Literals.PARAMETER__NAME)) { return obj == null ? StringUtils.EMPTY : obj.getChineseName(); } else if (feature.equals(BizPackage.Literals.PARAMETER__DESCRIPTION)) { return obj == null ? StringUtils.EMPTY : obj.getDescription(); } } else { String objId = p.getType(); ReferenceInfo ref = null; // ReferenceManager.getInstance().getFirstReferenceInfo(project, // IBizRefType.Object, objId, true); List<String> refTypes = ObjectRefTypes.getRefTypes(); for (String refType : refTypes) { ref = ReferenceManager.getInstance().getFirstReferenceInfo(project, refType, objId, true); if (ref != null) { break; } } // 2012-10-18 sundl 对象类型参数显示的时候,只显示最后一个点后面的部分 if (feature.equals(BizPackage.Literals.PARAMETER__TYPE)) { String type = super.getText(element); if (StringUtils.indexOf(type, '.') != -1) return StringUtils.substringAfterLast(type, "."); } else if (feature.equals(BizPackage.Literals.PARAMETER__NAME)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getChineseName(); } } else if (feature.equals(BizPackage.Literals.PARAMETER__DESCRIPTION)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getDescription(); } } } break; case PARAM_GROUP: String objId = p.getType(); ReferenceInfo ref = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IBizRefType.Object, objId, true); // 2012-10-18 sundl 对象类型参数显示的时候,只显示最后一个点后面的部分 if (feature.equals(BizPackage.Literals.PARAMETER__TYPE)) { String type = super.getText(element); if (StringUtils.indexOf(type, '.') != -1) return StringUtils.substringAfterLast(type, "."); } else if (feature.equals(BizPackage.Literals.PARAMETER__NAME)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getChineseName(); } } else if (feature.equals(BizPackage.Literals.PARAMETER__DESCRIPTION)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getDescription(); } } else if (feature.equals(BizPackage.Literals.PARAMETER__ID)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getName(); } } default: break; } return super.getText(element); }