private static void undoTextElementToTextNode(XMLResource saturnResourceImpl_, Map<Entry, Entry> textNodes_) { DocumentRoot o = (DocumentRoot) saturnResourceImpl_.getContents().get(0); Saturn saturn = (Saturn) o.eContents().get(0); TreeIterator<EObject> ee = saturn.eAllContents(); while (ee.hasNext()) { EObject e = ee.next(); if (e == null) continue; EClass ec = e.eClass(); if (!ValuesPackage.eINSTANCE.getComplexValue().isSuperTypeOf(ec)) continue; ComplexValue cv = (ComplexValue) e; for (int i = 0; i < cv.getMixed().size(); i++) { FeatureMap.Entry entry = cv.getMixed().get(i); if (textNodes_.containsKey(entry)) { Entry textComplexValueEntry = textNodes_.get(entry); cv.getMixed().set(i, textComplexValueEntry); } } } }
private String findOwnerIdOfEObj(AnyType eObjAnyType) { String ownerId = null; if (eObjAnyType != null) { FeatureMap mixed = eObjAnyType.getMixed(); for (Entry entry : mixed) { String entryName = (entry.getEStructuralFeature()).getName(); if (entryName != null) { if (entryName.equals("model")) { if (entry.getValue() instanceof AnyType) { AnyType modelAnyType = (AnyType) entry.getValue(); ownerId = getEObjEOwnerIdFromModelAnyType(modelAnyType); break; } } } } } return ownerId; }
private String findStereoTypeOfEObj(AnyType eObjAnyType) { // find parameter and store it in List String stereoType = null; if (eObjAnyType != null) { FeatureMap mixed = eObjAnyType.getMixed(); for (Entry entry : mixed) { String entryName = (entry.getEStructuralFeature()).getName(); if (entryName != null) { if (entryName.equals("properties")) { if (entry.getValue() instanceof AnyType) { AnyType propertiesAnyType = (AnyType) entry .getValue(); stereoType = getEObjStereotypeFromPropertyAnyType(propertiesAnyType); break; } } } } } return stereoType; }
private ArrayList<Parameter> findEObjAllParameterList(AnyType eObjAnyType) { // find parameter in 'Tag' tag and store it in List ArrayList<Parameter> paramList = null; FeatureMap mixed = eObjAnyType.getMixed(); for (Entry entry : mixed) { String entryName = (entry.getEStructuralFeature()).getName(); if (entryName != null) { if (entryName.equals("tags")) { if (entry.getValue() instanceof AnyType) { AnyType tagAnyType = (AnyType) entry.getValue(); paramList = findTagsAttrAndAddToParamList(tagAnyType); } } } } return paramList; }
private String getEObjStereotypeFromPropertyAnyType( AnyType propertiesAnyType) { String stereoType = null; if (propertiesAnyType != null) { FeatureMap propertiesMap = propertiesAnyType.getAnyAttribute(); for (Entry entry : propertiesMap) { String entryName = (entry.getEStructuralFeature()).getName(); if (entryName != null) { if (entryName.equals("stereotype")) { stereoType = (String) entry.getValue(); break; } } } } return stereoType; }
@Override public boolean equals(Object that) { if (this == that) { return true; } else if (!(that instanceof FeatureMap.Entry)) { return false; } else { FeatureMap.Entry entry = (FeatureMap.Entry)that; return entry.getEStructuralFeature() == eStructuralFeature && (value == null ? entry.getValue() == null : value.equals(entry.getValue())); } }
public boolean addAllUnique(int index, Entry.Internal [] entries, int start, int end) { modCount = -1; BasicEList<Entry.Internal> collection = new BasicEList<Entry.Internal>(); if (start == 0) { collection.setData(end, entries); } else { collection.grow(end - start); for (int i = start; i < end; ++i) { collection.add(entries[i]); } } return featureMap.addAllUnique(index, collection); }
public boolean addAll(int index, EStructuralFeature feature, Collection<?> values) { if (isFeatureMap(feature)) { @SuppressWarnings("unchecked") Collection<? extends Entry> entryValues = (Collection<? extends Entry>)values; return addAll(index, entryValues); } else { Collection<Entry> entries = new ArrayList<Entry>(values.size()); for (Object value : values) { entries.add(createEntry(feature, value)); } return addAll(index, entries); } }
/** * 判断表单是否空 * * @param flowElement */ private static void verifyFormIsNull(FlowElement flowElement,StringBuffer sb) { if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; for (ExtensionAttributeValue extensionAttributeValue : userTask.getExtensionValues()) { FeatureMap extensionElements = extensionAttributeValue.getValue(); for (Entry entry : extensionElements) { if (entry.getValue() instanceof FormUri) { FormUri formUri = (FormUri) entry.getValue(); if (formUri.getExpression().getValue() != null || !(formUri.getExpression().getValue().equals(""))) { return; } } } } sb.append(userTask.getId() + "节点没有设置表单;" + ""); } }
/** * 验证所有人工节点含有处理命令 * * @param flowElement */ private static void allUserTaskNodeHaveTaskCommand(FlowElement flowElement,StringBuffer sb) { if (flowElement instanceof UserTask) { for (ExtensionAttributeValue extensionAttributeValue : ((UserTask) flowElement).getExtensionValues()) { FeatureMap extensionElements = extensionAttributeValue.getValue(); for (Entry entry : extensionElements) { if (entry.getValue() instanceof TaskCommand) { TaskCommand taskCommand = (TaskCommand) entry.getValue(); if (taskCommand != null) { return; } } } } sb.append(((UserTask) flowElement).getId() + "节点没有设置处理命令;" + ""); } }
/** * @generated NOT */ @Override public void doSave(OutputStream outputStream_, Map<?, ?> options_) throws IOException { final Map<Entry, Entry> textNodes_ = new HashMap<Entry, Entry>(); Collection<EObject> objects = EcoreUtil.copyAll(this.getContents()); SaturnResourceImpl s = new SaturnResourceImpl(this.uri); s.init(); s.getContents().addAll(objects); SaturnDocLoadSaveUtil.save(s, textNodes_); XMLSave xmlSave = createXMLSave(); if (options_ == null) { options_ = Collections.EMPTY_MAP; } ResourceHandler handler = (ResourceHandler) options_.get(OPTION_RESOURCE_HANDLER); if (handler != null) { handler.preSave(s, outputStream_, options_); } xmlSave.save(s, outputStream_, options_); if (handler != null) { handler.postSave(s, outputStream_, options_); } }
private static void textElementToTextNode(SaturnResourceImpl saturnResourceImpl_, Map<Entry, Entry> textNodes_) { DocumentRoot o = (DocumentRoot) saturnResourceImpl_.getContents().get(0); Saturn saturn = (Saturn) o.eContents().get(0); TreeIterator<EObject> ee = saturn.eAllContents(); while (ee.hasNext()) { EObject e = ee.next(); if (e == null) continue; EClass ec = e.eClass(); if (!ValuesPackage.eINSTANCE.getComplexValue().isSuperTypeOf(ec)) continue; ComplexValue cv = (ComplexValue) e; for (int i = 0; i < cv.getMixed().size(); i++) { FeatureMap.Entry entry = cv.getMixed().get(i); Object value = entry.getValue(); if (value instanceof TextComplexValue) { FeatureMap.Entry newEntry = FeatureMapUtil.createTextEntry(((TextComplexValue) value).getText()); cv.getMixed().set(i, newEntry); textNodes_.put(newEntry, entry); } } } }
private static void textNodeToTextElement(SaturnResourceImpl saturnResourceImpl_) { DocumentRoot o = (DocumentRoot) saturnResourceImpl_.getContents().get(0); Saturn saturn = (Saturn) o.eContents().get(0); TreeIterator<EObject> ee = saturn.eAllContents(); while (ee.hasNext()) { EObject e = ee.next(); if (e == null) continue; EClass ec = e.eClass(); if (!ValuesPackage.eINSTANCE.getComplexValue().isSuperTypeOf(ec)) continue; ComplexValue cv = (ComplexValue) e; for (int i = 0; i < cv.getMixed().size(); i++) { FeatureMap.Entry entry = cv.getMixed().get(i); Object value = entry.getValue(); if (value instanceof String) { TextComplexValue textComplexValue = ValuesPackage.eINSTANCE.getValuesFactory().createTextComplexValue(); textComplexValue.setText((String) value); FeatureMap.Entry newEntry = FeatureMapUtil.createEntry(ValuesPackage.eINSTANCE.getComplexValue_Text(), textComplexValue); cv.getMixed().set(i, newEntry); } } } }
private static void addXmlNsPrefixes(SaturnResourceImpl saturnResourceImpl_) { EList<EObject> contents = saturnResourceImpl_.getContents(); if (contents.size() <= 0) return; if (!(contents.get(0) instanceof DocumentRoot)) return; DocumentRoot documentRoot = (DocumentRoot) contents.get(0); List<BasicEMap.Entry<String, String>> xmlNsList = getXmlNsList(); for (BasicEMap.Entry<String, String> newEntry : xmlNsList) { documentRoot.getXMLNSPrefixMap().add(newEntry); } }
private String getEObjEOwnerIdFromModelAnyType(AnyType modelAnyType) { String ownerId = null; FeatureMap eObjAttrs = modelAnyType.getAnyAttribute(); for (Entry entry : eObjAttrs) { String entryName = (entry.getEStructuralFeature()).getName(); if (entryName.equals("owner")) { ownerId = (String) entry.getValue(); break; } } return ownerId; }
private String getEObjectIdRefFromExtensionImpl(AnyType eObjAnyType) { String idRef = null; FeatureMap eObjAttrs = eObjAnyType.getAnyAttribute(); for (Entry entry : eObjAttrs) { String entryName = (entry.getEStructuralFeature()).getName(); if (entryName.equals("idref")) { idRef = (String) entry.getValue(); } } return idRef; }
private ArrayList<Constraint> findEObjAllConstraintList(AnyType eObjAnyType) { ArrayList<Constraint> constraintList = null; FeatureMap mixed = eObjAnyType.getMixed(); for (Entry entry : mixed) { String entryName = (entry.getEStructuralFeature()).getName(); if (entryName != null) { if (entryName.equals("constraints")) { AnyType cosntraintsAnyType = (AnyType) entry.getValue(); constraintList = findConstraintAttrAndAddToConstraintList(cosntraintsAnyType); } } } return constraintList; }
public static FeatureMap.Entry.Internal createRawProcessingInstructionEntry(String target, String data) { ProcessingInstruction processingInstruction = XMLTypeFactory.eINSTANCE.createProcessingInstruction(); processingInstruction.setTarget(target); processingInstruction.setData(data); return XMLTypeFeatures.PROCESSING_INSTRUCTION_PROTOTYPE.createEntry(processingInstruction); }
@Override public String getText(Object object) { if (((FeatureMap.Entry)value).getValue() instanceof AnyType) { return ((FeatureMap.Entry) value).getEStructuralFeature().getName(); } else { return value.toString(); } }
@Override public Object getForeground(Object object) { Object result = null; if (object instanceof FeatureMapEntryWrapperItemProvider) { FeatureMap.Entry entry = (FeatureMap.Entry) ((FeatureMapEntryWrapperItemProvider)object).getValue(); EObject owner = (EObject) ((FeatureMapEntryWrapperItemProvider)object).getOwner(); result = ClickWatchReflectiveItemProviderAdapterFactory.this. getForeground(owner, entry.getEStructuralFeature(), entry.getValue()); } return result == null ? super.getForeground(object) : result; }
@Override public Object getBackground(Object object) { Object result = null; if (object instanceof FeatureMapEntryWrapperItemProvider) { FeatureMap.Entry entry = (FeatureMap.Entry) ((FeatureMapEntryWrapperItemProvider)object).getValue(); EObject owner = (EObject) ((FeatureMapEntryWrapperItemProvider)object).getOwner(); result = ClickWatchReflectiveItemProviderAdapterFactory.this. getBackground(owner, entry.getEStructuralFeature(), entry.getValue()); } return result == null ? super.getForeground(object) : result; }
@Override public Object getValue() { Object superValue = super.getValue(); if (superValue != null && (superValue instanceof FeatureMap.Entry)) { return new ExtendedFeatureMapEntry((FeatureMap.Entry)superValue, new XmlAttributeValue((EObject)getOwner(), getFeature(), (FeatureMap.Entry)superValue)); } else { return superValue; } }
@Override protected Object createWrapper(EObject object, EStructuralFeature feature, Object value, int index) { if (FeatureMapUtil.isFeatureMap(feature)) { return new ClickWatchFeatureMapEntryWrapperItemProvider( (FeatureMap.Entry) value, object, (EAttribute) feature, index, adapterFactory, getResourceLocator()); } else if (feature instanceof EAttribute) { return new AttributeWrapperItemProvider( value, object, (EAttribute) feature, index, adapterFactory); } else { return super.createWrapper(object, feature, value, index); } }
/** * 验证总方法 * * @return 通过返回异常信息,""表示通过 */ public static String verifyAll(Process process) { StringBuffer sb = new StringBuffer(); List<FlowElement> flowElements = process.getFlowElements(); // 先验证主流程信息 verificationProc(flowElements,sb); isSubmitNodeHasUserCommand(flowElements,sb); processDefaultTitleAndDefaultForm(process,sb); boolean yzForm = true; if (process.getExtensionValues().size() > 0) { for (ExtensionAttributeValue extensionAttributeValue : process.getExtensionValues()) { FeatureMap extensionElements = extensionAttributeValue.getValue(); for (Entry entry : extensionElements) { if (entry.getValue() instanceof FormUri) { FormUri formUri = (FormUri) entry.getValue(); if (formUri.getExpression().getValue() == null || formUri.getExpression().getValue().equals("")) { yzForm = true; } else { yzForm = false; } break; } } } } if (yzForm) { verifyFormIsNull(flowElements,sb); } // 循环主流程所有节点 for (FlowElement flowElement :process.getFlowElements()) { // 如果发现是子流程则进行递归 if (flowElement instanceof SubProcess) { getSubProcessElement((SubProcess) flowElement, yzForm,sb); } } if (sb.length() > 0 && !sb.toString().equals("子流程验证信息:")) { return sb.toString(); } return ""; }
private static void processDefaultTitleAndDefaultForm(Process process,StringBuffer sb) { boolean formUriYZ = false; boolean taskSubjectYZ = false; if (process.getExtensionValues().size() > 0) { for (ExtensionAttributeValue extensionAttributeValue : process.getExtensionValues()) { FeatureMap extensionElements = extensionAttributeValue.getValue(); for (Entry entry : extensionElements) { if (entry.getValue() instanceof FormUri) { FormUri formUri = (FormUri) entry.getValue(); if (formUri.getExpression().getValue() != null && !formUri.getExpression().getValue().equals("")) { formUriYZ = true; } } if (entry.getValue() instanceof TaskSubject) { TaskSubject taskSubject = (TaskSubject) entry.getValue(); if (taskSubject.getExpression().getValue() != null && !taskSubject.getExpression().getValue().equals("")) { taskSubjectYZ = true; } } } } } if (formUriYZ && taskSubjectYZ) { return; } else { if (!formUriYZ) { sb.append("流程定义上默认表单不能为空;" + ""); } if (!taskSubjectYZ) { sb.append("流程定义上默认任务主题不能为空;" + ""); } } return; }
/** * 判断所有人工任务节点都有任务分配 * * @param flowElements */ public static void allUserTaskNodeHaveTaskAssignment(List<FlowElement> flowElements,StringBuffer sb) { for (FlowElement flowElement : flowElements) { if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; if (userTask.getResources().size() < 1) { sb.append(userTask.getId() + "节点没有设置任务分配;" + ""); } LoopCharacteristics loopCharacteristics = userTask.getLoopCharacteristics(); if (loopCharacteristics instanceof MultiInstanceLoopCharacteristics) { for (ExtensionAttributeValue extensionAttributeValue : userTask.getExtensionValues()) { FeatureMap extensionElements = extensionAttributeValue.getValue(); for (Entry entry : extensionElements) { if (entry.getValue() instanceof TaskCommand) { TaskCommand taskCommand = (TaskCommand) entry.getValue(); if (taskCommand.getCommandType().equals("rollBack")) { sb.append(((UserTask) flowElement).getId() + " 含有多实例的节点不能做退回处理;" + ""); } } } } } } } }
private Hive createHive ( final String ref, final FeatureMap featureMap ) throws Exception { final Entry first = featureMap.get ( 0 ); final BundleContextHiveFactory factory = new BundleContextHiveFactory ( HivesPlugin.getDefault ().getBundle ().getBundleContext () ); return factory.createHive ( ref, (EObject)first.getValue () ); }
public static void save(SaturnResourceImpl saturnResourceImpl_, Map<Entry, Entry> textNodes_) { textElementToTextNode(saturnResourceImpl_, textNodes_); addXmlNsPrefixes(saturnResourceImpl_); }
public static void afterSave(XMLResource saturnResourceImpl_, Map<Entry, Entry> textNodes_) { undoTextElementToTextNode(saturnResourceImpl_, textNodes_); }
private final static List<BasicEMap.Entry<String, String>> getXmlNsList() { List<EPackage> packages = new ArrayList<EPackage>(); // resource packages packages.add(Db2ResourcePackage.eINSTANCE); packages.add(DirectoryResourcePackage.eINSTANCE); packages.add(FileResourcePackage.eINSTANCE); packages.add(InformixResourcePackage.eINSTANCE); packages.add(MqResourcePackage.eINSTANCE); packages.add(OracleResourcePackage.eINSTANCE); packages.add(QueryResourcePackage.eINSTANCE); packages.add(ReferenceResourcePackage.eINSTANCE); packages.add(ShadowDirectResourcePackage.eINSTANCE); packages.add(SoapIOResourcePackage.eINSTANCE); packages.add(SybaseResourcePackage.eINSTANCE); packages.add(TeradataResourcePackage.eINSTANCE); packages.add(UdbResourcePackage.eINSTANCE); packages.add(NullResourcePackage.eINSTANCE); packages.add(TransactionResourcePackage.eINSTANCE); packages.add(SemaphoreResourcePackage.eINSTANCE); packages.add(LdapResourcePackage.eINSTANCE); packages.add(LdapQueryResourcePackage.eINSTANCE); packages.add(SqliteResourcePackage.eINSTANCE); packages.add(MssqlResourcePackage.eINSTANCE); // global packages packages.add(ValuesPackage.eINSTANCE); packages.add(TypesPackage.eINSTANCE); packages.add(ListenersPackage.eINSTANCE); packages.add(RepetitionPackage.eINSTANCE); packages.add(SaturnWebPackage.eINSTANCE); packages.add(SaturnReportPackage.eINSTANCE); // module packages packages.add(CpsModulePackage.eINSTANCE); packages.add(DatacompareModulePackage.eINSTANCE); packages.add(DsConvertModulePackage.eINSTANCE); packages.add(DsValidatorModulePackage.eINSTANCE); packages.add(EnvValidatorModulePackage.eINSTANCE); packages.add(ExtractDDLModulePackage.eINSTANCE); packages.add(MailModulePackage.eINSTANCE); packages.add(MqModulePackage.eINSTANCE); packages.add(ProcedureCallModulePackage.eINSTANCE); packages.add(PsManagerModulePackage.eINSTANCE); packages.add(RuncmdsModulePackage.eINSTANCE); packages.add(SingularityModulePackage.eINSTANCE); packages.add(SoapIOModulePackage.eINSTANCE); packages.add(SqlModulePackage.eINSTANCE); packages.add(Xml2csvModulePackage.eINSTANCE); packages.add(XmlDiffModulePackage.eINSTANCE); packages.add(XmlGenModulePackage.eINSTANCE); packages.add(XmlManipModulePackage.eINSTANCE); packages.add(XmlValidatorModulePackage.eINSTANCE); packages.add(CometModulePackage.eINSTANCE); packages.add(XSplitModulePackage.eINSTANCE); packages.add(ReferenceModulePackage.eINSTANCE); packages.add(DocumentumModulePackage.eINSTANCE); List<BasicEMap.Entry<String, String>> xmlNsList = new ArrayList<BasicEMap.Entry<String, String>>(); for (EPackage ePackage : packages) { ((EcoreFactoryImpl) EcoreFactory.eINSTANCE).createEStringToStringMapEntry(); BasicEMap.Entry<String, String> newEntry = (BasicEMap.Entry<String, String>) EcoreUtil .create((EClass) SaturnPackage.eINSTANCE.getDocumentRoot_XMLNSPrefixMap().getEType()); // new EStringToStringMapEntryImpl(); // //((EcoreFactoryImpl)EcoreFactory.eINSTANCE).createEStringToStringMapEntry(); xmlNsList.add(newEntry); newEntry.setKey(ePackage.getNsPrefix()); newEntry.setValue(ePackage.getNsURI()); } return xmlNsList; }
public static boolean isText(FeatureMap.Entry entry) { return entry.getEStructuralFeature() == XMLTypeFeatures.TEXT; }
public static boolean isCDATA(FeatureMap.Entry entry) { return entry.getEStructuralFeature() == XMLTypeFeatures.CDATA; }
public static boolean isComment(FeatureMap.Entry entry) { return entry.getEStructuralFeature() == XMLTypeFeatures.COMMENT; }
public static boolean isProcessingInstruction(FeatureMap.Entry entry) { return entry.getEStructuralFeature() == XMLTypeFeatures.PROCESSING_INSTRUCTION; }
public static FeatureMap.Entry createTextEntry(String value) { return XMLTypeFeatures.TEXT_PROTOTYPE.createEntry(value); }
public static FeatureMap.Entry createCDATAEntry(String value) { return XMLTypeFeatures.CDATA_PROTOTYPE.createEntry(value); }