/** * Returns the qualified name of the given type. * * @param type The type * @return The qualified name of the given type. */ private String qualifiedName(Type type) { String result = null; if (type != null && !(type instanceof PrimitiveType)) { List<String> packagesName = new ArrayList<String>(); EObject eContainer = type.eContainer(); while (eContainer != null && eContainer instanceof Package && !(eContainer instanceof Model)) { Package umlPackage = (Package) eContainer; packagesName.add(umlPackage.getName()); eContainer = umlPackage.eContainer(); } Collections.reverse(packagesName); StringBuilder stringBuilder = new StringBuilder(); for (String packageName : packagesName) { stringBuilder.append(packageName); stringBuilder.append('.'); } stringBuilder.append(type.getName()); result = stringBuilder.toString(); if (JAVA_LANG_TYPES.contains(type.getName())) { result = null; } else if (JAVA_UTIL_TYPES.contains(type.getName())) { result = "java.util." + type.getName(); } } return result; }
/** * Returns the name of the type with its qualified name * * @param type a type * @return the name of the type with its qualified name */ public static String getTypeLabel(Type type, Namespace model) { String label = ""; // $NON-NLS-1$ List<Package> importedPackages = new ArrayList<Package>(model.getImportedPackages()); List<Package> visitedPackages = new ArrayList<Package>(); Package currentPackage = type.getNearestPackage(); boolean rootFound = false; while (currentPackage != null && !rootFound) { visitedPackages.add(currentPackage); if (importedPackages.contains(currentPackage) || currentPackage == model) { rootFound = true; } Element owner = currentPackage.getOwner(); while (owner != null && !(owner instanceof Package)) owner = owner.getOwner(); currentPackage = owner != null ? (Package) owner : null; } for (int i = visitedPackages.size() - 1; i >= 0; i--) { label += visitedPackages.get(i).getName() + "::"; // $NON-NLS-1$ } return label + type.getName(); }
/** * This returns the label text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ @Override public String getText(Object object) { StringBuffer text = appendType( appendKeywords(new StringBuffer(), object), "_UI_AssociationClass_type"); // $NON-NLS-1$ AssociationClass associationClass = (AssociationClass) object; if (associationClass.isDerived()) { appendString(text, "/"); // $NON-NLS-1$ } String label = associationClass.getLabel(shouldTranslate()); if (!UML2Util.isEmpty(label)) { appendString(text, label); } else { EList<Property> memberEnds = associationClass.getMemberEnds(); if (!memberEnds.isEmpty()) { appendString(text, "A"); // $NON-NLS-1$ for (Property memberEnd : memberEnds) { String memberEndName = memberEnd.getName(); text.append('_'); if (!UML2Util.isEmpty(memberEndName)) { text.append(memberEndName); } else { Type type = memberEnd.getType(); if (type != null) { String typeName = type.getName(); if (!UML2Util.isEmpty(typeName)) { memberEndName = Character.toLowerCase(typeName.charAt(0)) + typeName.substring(1); } } if (!UML2Util.isEmpty(memberEndName)) { text.append(memberEndName); } else { text.append('<'); text.append(getTypeText(memberEnd)); text.append('>'); } } } } } return text.toString(); }
// TODO add types from the loaded resources // traverse deep into the nested packages public IContentAssistProcessor getCompletionProcessor(IAdaptable subject) { CollaborationUse cu = doAdapt(subject); String name = cu.getName() == null ? "" : cu.getName(); // $NON-NLS-1$ List<Type> types = getTypeProposals(cu); LinkedList<String> names = new LinkedList<String>(); for (Type next : types) { names.add(COLLABORATION_USE_FORMAT.format(new Object[] {name, next.getName()})); } FixedSetCompletionProcessor cp = new FixedSetCompletionProcessor(names); cp.setContext(cu); return cp; }
public static String getSqlMapCondition(List<Property> properties, String ownerTableNameAs) { // List<Property> properties=getSearchTextFieldPropertiesFromSimple(clazz); StringBuilder sb = new StringBuilder(); for (Property property : properties) { String propertyUncapSafeName = NameHelper.uncapSafeName(property); String columnName = ColumnStereotypeHelper.getApplyColumn_name(property); String operator = getSearchOperator(property); Type propertyType = property.getType(); String propertyTypeName = propertyType.getName(); String compareColumnName = ownerTableNameAs + "." + columnName; String comparePropertyName = propertyUncapSafeName; if (ClassHelper.isSimple(property)) { sb.append( getSqlMapSearchStatement( compareColumnName, comparePropertyName, propertyTypeName, operator, property)); } else if (ClassHelper.isOneToOne(property) || ClassHelper.isManyToOne(property)) { Class relTargetClass = (Class) propertyType; // String relTargetClassCommentName=TypeHelper.getDocumentationOrName(relTargetClass); String relTargetClassTableName = TableStereotypeHelper.getApplyTable_name(relTargetClass); String relTargetClassTableNameAs = NameRuledSqlAsKind.tableAs.getRuleNamed(relTargetClassTableName); // for relClass id property Property propertyTypeIdProperty = EntityHelper.getIDProperty(relTargetClass); String propertyTypeIdPropertyUncapSafeName = NameHelper.uncapSafeName(propertyTypeIdProperty); String relJoinColumnName = JoinColumnStereotypeHelper.getApplyColumn_name(property); compareColumnName = ownerTableNameAs + "." + relJoinColumnName; comparePropertyName = propertyUncapSafeName + "." + propertyTypeIdPropertyUncapSafeName; sb.append( getSqlMapSearchStatement( compareColumnName, comparePropertyName, propertyTypeName, operator, property)); // for relClass lable property Property listLabelProperty = ViewListHelper.getProperty_listLabel(property); if (null != listLabelProperty) { String listLabelPropertyUncapSafeName = ViewListHelper.getViewListLabelRelPropertyName(property); // String // listLabelPropertyComment=ViewListHelper.getViewListLabelRelPropertyName(property); String listLabelColumnName = ColumnStereotypeHelper.getApplyColumn_name(property); compareColumnName = relTargetClassTableNameAs + "." + listLabelColumnName; comparePropertyName = propertyUncapSafeName + "." + listLabelPropertyUncapSafeName; sb.append( getSqlMapSearchStatement( compareColumnName, comparePropertyName, propertyTypeName, operator, property)); } } // String searchFieldName = getSearchFieldName(property); // String searchFieldCapName = NameHelper.getCapName(searchFieldName); } return sb.toString(); }
/** 获取索引字段类型. */ public String getIndexSolrFieldType() { Type type = property.getType(); if (type.getName().equalsIgnoreCase("Byte[]")) return "binary"; if (type.getName().equalsIgnoreCase("Currency")) return "double"; if (type.getName().equalsIgnoreCase("Percentage")) return "double"; if (type.getName().equalsIgnoreCase("Double")) return "double"; if (type.getName().equalsIgnoreCase("Float")) return "float"; if (type.getName().equalsIgnoreCase("Integer")) return "int"; if (type.getName().equalsIgnoreCase("Long")) return "long"; if (type.getName().equalsIgnoreCase("Boolean")) return "boolean"; if (type.getName().equalsIgnoreCase("String")) return "string"; if (type.getName().equalsIgnoreCase("Character")) return "string"; if (type.getName().equalsIgnoreCase("Decimal")) return "double"; if (type.getName().equalsIgnoreCase("Date")) return "date"; if (type.getName().equalsIgnoreCase("Image")) return "string"; if (type.getName().equalsIgnoreCase("Text")) return "string"; if (type.getName().equalsIgnoreCase("Link")) return "string"; return "string"; }
public static String getSpecialResultType(Property property) { Type propertyType = property.getType(); String propertyTypeName = propertyType.getName(); StringBuilder sb = new StringBuilder(); if ("Boolean".equalsIgnoreCase(propertyTypeName)) { sb.append("jdbcType=\"Boolean\" javaType=\"Boolean\""); } else if ("Date".equalsIgnoreCase(propertyTypeName)) { sb.append("jdbcType=\"Date\" javaType=\"Date\""); } else if ("Timestamp".equalsIgnoreCase(propertyTypeName)) { sb.append("jdbcType=\"Timestamp\" javaType=\"Timestamp\""); } else if ("Long".equalsIgnoreCase(propertyTypeName) || "Integer".equalsIgnoreCase(propertyTypeName) || "Double".equalsIgnoreCase(propertyTypeName) || "Decimal".equalsIgnoreCase(propertyTypeName)) { // sb.append("jdbcType=\"Timestamp\" javaType=\"Timestamp\""); } else if ("Clob".equalsIgnoreCase(propertyTypeName)) { // sb.append("jdbcType=\"Timestamp\" javaType=\"Timestamp\""); } else { return ""; } return sb.toString(); }
public ICommand getParseCommand(IAdaptable element, String newString, int flags) { CollaborationUse cu = doAdapt(element); if (cu == null) { return UnexecutableCommand.INSTANCE; } if (newString == null) { return UnexecutableCommand.INSTANCE; } Collaboration oldType = cu.getType(); String oldName = cu.getName() == null ? "" : cu.getName(); // $NON-NLS-1$ List<Type> types = getTypeProposals(cu); try { Object[] parsed = COLLABORATION_USE_FORMAT.parse(newString); String newName = (String) parsed[0]; CompositeCommand cc = new CompositeCommand( CustomMessages.CollaborationUseParser_collaboration_use_name_parser_command); if (!oldName.equals(newName)) { cc.add( new SetValueCommand( new SetRequest(cu, UMLPackage.eINSTANCE.getNamedElement_Name(), newName))); } if (parsed.length < 2) { return cc; } String newType = (String) parsed[1]; for (Type next : types) { if (newType.equals(next.getName()) && !newType.equals(oldType)) { cc.add( new SetValueCommand( new SetRequest(cu, UMLPackage.eINSTANCE.getCollaborationUse_Type(), next))); break; } } return cc; } catch (ParseException e) { } return UnexecutableCommand.INSTANCE; }
/** * Create an association from the specified Property. The association is created in the property's * nearest package. * * @param p The property to use to create an association. */ protected void createAssociationFromProperty(Property p) { Element owner = p.getOwner(); if (owner instanceof Type) { Type classOwner = (Type) owner; // Compute other end name String name = classOwner.getName(); String newname = name.substring(0, 1).toLowerCase() + name.substring(1); // Create TypeOperationsEnhanced.createAssociationFromProperty( p, true, AggregationKind.COMPOSITE_LITERAL, false, AggregationKind.NONE_LITERAL, newname, 0, 1); } }