本文整理汇总了Java中org.netbeans.jpa.modeler.spec.extend.CompositionAttribute类的典型用法代码示例。如果您正苦于以下问题:Java CompositionAttribute类的具体用法?Java CompositionAttribute怎么用?Java CompositionAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompositionAttribute类属于org.netbeans.jpa.modeler.spec.extend包,在下文中一共展示了CompositionAttribute类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processBase
import org.netbeans.jpa.modeler.spec.extend.CompositionAttribute; //导入依赖的package包/类
private void processBase(BaseAttribute parsedBaseAttribute) {
MetamodelVariableDefSnippet variableDef = getVariableDef(parsedBaseAttribute);
if (parsedBaseAttribute instanceof CompositionAttribute) {
if (parsedBaseAttribute instanceof ElementCollection) {
ElementCollection elementCollection = (ElementCollection) parsedBaseAttribute;
variableDef.setType(parsedBaseAttribute.getAttributeType());
variableDef.setAttributeType(MetamodelAttributeType.getInstance(elementCollection.getCollectionType()));
} else {
variableDef.setType(parsedBaseAttribute.getAttributeType());
variableDef.setAttributeType(MetamodelAttributeType.SINGULAR);
}
} else if (parsedBaseAttribute instanceof PersistenceBaseAttribute) {
variableDef.setType(parsedBaseAttribute.getAttributeType());
variableDef.setAttributeType(MetamodelAttributeType.SINGULAR);
}
}
示例2: createPropertySet
import org.netbeans.jpa.modeler.spec.extend.CompositionAttribute; //导入依赖的package包/类
@Override
public void createPropertySet(ElementPropertySet set) {
super.createPropertySet(set);
CompositionAttribute attribute = (CompositionAttribute) this.getBaseElementSpec();
if (attribute instanceof ConvertContainerHandler) {//means ElementCollectio<Embedded>, Embedded or represent value in map
set.put("JPA_PROP", getConvertProperties(this.getModelerScene(), (ConvertContainerHandler) attribute));
}
if (attribute instanceof MapKeyConvertContainerHandler) {//ElementCollectio<Embedded, Y>
set.put("JPA_PROP", getMapKeyConvertProperties(this, this.getModelerScene(), (MapKeyConvertContainerHandler) attribute));
}
if (attribute instanceof MapKeyConvertHandler) {//ElementCollectio<X, Y>
set.put("JPA_PROP", getMapKeyConvertProperty(this, this.getModelerScene(), (MapKeyConvertHandler) attribute));
}
set.put("JPA_PROP", PropertiesHandler.getAttributeOverridesProperty("AttributeOverrides", "Attribute Overrides", "", this.getModelerScene(), attribute.getAttributeOverride()));
if (attribute instanceof AssociationOverrideHandler) {
set.put("JPA_PROP", PropertiesHandler.getAssociationOverridesProperty("AssociationOverrides", "Association Overrides", "", this.getModelerScene(), ((AssociationOverrideHandler) attribute).getAssociationOverride()));
}
}
示例3: getSnippet
import org.netbeans.jpa.modeler.spec.extend.CompositionAttribute; //导入依赖的package包/类
@Override
public String getSnippet() throws InvalidDataException {
StringBuilder builder = new StringBuilder();
builder.append("if (obj == null) {return false;}\n");
builder.append(" ")
.append("if (!java.util.Objects.equals(getClass(), obj.getClass())) {return false;}\n");
builder.append(" ")
.append(String.format("final %s other = (%s) obj;\n", className, className));
if (StringUtils.isNotBlank(classMembers.getPreCode())) {
builder.append(classMembers.getPreCode()).append(NEW_LINE);
}
for (int i = 0; i < classMembers.getAttributes().size(); i++) {
Attribute attribute = classMembers.getAttributes().get(i);
String expression;
boolean optionalType = attribute.isOptionalReturnType();
if (attribute instanceof BaseAttribute && !(attribute instanceof CompositionAttribute)) {
expression = JavaHashcodeEqualsUtil.getEqualExpression(((BaseAttribute) attribute).getAttributeType(), attribute.getName(), optionalType);
} else {
expression = JavaHashcodeEqualsUtil.getEqualExpression(attribute.getName(), optionalType);
}
builder.append(" ")
.append(String.format("if (%s) {", expression));
builder.append(" ")
.append("return false;");
builder.append(" ")
.append(CLOSE_BRACES).append(NEW_LINE);
}
if (StringUtils.isNotBlank(classMembers.getPostCode())) {
builder.append(classMembers.getPostCode()).append(NEW_LINE);
}
builder.append(" ")
.append("return true;");
return builder.toString();
}
示例4: loadEmbeddedEdge
import org.netbeans.jpa.modeler.spec.extend.CompositionAttribute; //导入依赖的package包/类
private void loadEmbeddedEdge(JPAModelerScene scene, String contextToolId, PersistenceClassWidget sourcePersistenceClassWidget, EmbeddedAttributeWidget sourceAttributeWidget) {
CompositionAttribute sourceEmbeddedAttribute = (CompositionAttribute) sourceAttributeWidget.getBaseElementSpec();
EmbeddableWidget targetEntityWidget = (EmbeddableWidget) scene.getBaseElement(sourceEmbeddedAttribute.getConnectedClass().getId());
EdgeWidgetInfo edgeInfo = new EdgeWidgetInfo();
edgeInfo.setId(NBModelerUtil.getAutoGeneratedStringId());
edgeInfo.setSource(sourcePersistenceClassWidget.getNodeWidgetInfo().getId());
edgeInfo.setTarget(targetEntityWidget.getNodeWidgetInfo().getId());
edgeInfo.setType(NBModelerUtil.getEdgeType(sourcePersistenceClassWidget, targetEntityWidget, contextToolId));
IEdgeWidget edgeWidget = scene.createEdgeWidget(edgeInfo);
scene.setEdgeWidgetSource(edgeInfo, getEdgeSourcePinWidget(sourcePersistenceClassWidget, targetEntityWidget, edgeWidget, sourceAttributeWidget));
scene.setEdgeWidgetTarget(edgeInfo, getEdgeTargetPinWidget(sourcePersistenceClassWidget, targetEntityWidget, edgeWidget, null));
}
示例5: loadEmbeddedEdge
import org.netbeans.jpa.modeler.spec.extend.CompositionAttribute; //导入依赖的package包/类
private void loadEmbeddedEdge(IPModelerScene scene, String contextToolId, PersistenceClassWidget sourcePersistenceClassWidget, EmbeddedAttributeWidget sourceAttributeWidget) {
CompositionAttribute sourceEmbeddedAttribute = (CompositionAttribute) sourceAttributeWidget.getBaseElementSpec();
EmbeddableWidget targetEntityWidget = (EmbeddableWidget) scene.findBaseElement(sourceEmbeddedAttribute.getConnectedClassId());
EdgeWidgetInfo edgeInfo = new EdgeWidgetInfo();
edgeInfo.setId(NBModelerUtil.getAutoGeneratedStringId());
edgeInfo.setSource(sourcePersistenceClassWidget.getNodeWidgetInfo().getId());
edgeInfo.setTarget(targetEntityWidget.getNodeWidgetInfo().getId());
edgeInfo.setType(NBModelerUtil.getEdgeType(sourcePersistenceClassWidget, targetEntityWidget, contextToolId));
IEdgeWidget edgeWidget = scene.createEdgeWidget(edgeInfo);
scene.setEdgeWidgetSource(edgeInfo, getEdgeSourcePinWidget(sourcePersistenceClassWidget, targetEntityWidget, edgeWidget, sourceAttributeWidget));
scene.setEdgeWidgetTarget(edgeInfo, getEdgeTargetPinWidget(sourcePersistenceClassWidget, targetEntityWidget, edgeWidget, null));
}
示例6: getSnippet
import org.netbeans.jpa.modeler.spec.extend.CompositionAttribute; //导入依赖的package包/类
@Override
public String getSnippet() throws InvalidDataException {
StringBuilder builder = new StringBuilder();
int startNumber = generatePrimeNumber(2, 10);
int multiplyNumber = generatePrimeNumber(10, 100);
if(!classMembers.getAttributes().isEmpty()){
builder.append(String.format("int hash = %s;",startNumber)).append(NEW_LINE);
}
if (StringUtils.isNotBlank(classMembers.getPreCode())) {
builder.append(classMembers.getPreCode()).append(NEW_LINE);
}
for (int i = 0; i < classMembers.getAttributes().size(); i++) {
Attribute attribute = classMembers.getAttributes().get(i);
if(attribute instanceof DefaultAttribute) {
attribute = ((DefaultAttribute)attribute).getConnectedAttribute();
}
String expression;
boolean optionalType = attribute.isOptionalReturnType();
if(attribute instanceof BaseAttribute && !(attribute instanceof CompositionAttribute)){
expression = getHashcodeExpression(((BaseAttribute)attribute).getAttributeType(), attribute.getName(), optionalType);
} else {
expression = getHashcodeExpression(attribute.getName(), optionalType);
}
builder.append(" ")
.append(String.format("hash = %s * hash + %s;", multiplyNumber, expression)).append(NEW_LINE);
}
if (StringUtils.isNotBlank(classMembers.getPostCode())) {
builder.append(classMembers.getPostCode()).append(NEW_LINE);
}
if(!classMembers.getAttributes().isEmpty()){
builder.append(" ")
.append("return hash;");
}
return builder.toString();
}
示例7: copyRef
import org.netbeans.jpa.modeler.spec.extend.CompositionAttribute; //导入依赖的package包/类
private <P extends Object,T extends Object> void copyRef(P parentElement, T element, P parentClonedElement, T clonedElement, List<T> clonedElements) {
if (element instanceof BaseElement) {
((BaseElement) clonedElement).setRootElement(((BaseElement) element).getRootElement());
((BaseElement) clonedElement).setId(NBModelerUtil.getAutoGeneratedStringId());
}
if (element instanceof JavaClass) {
((JavaClass) clonedElement).setSuperclassRef(((JavaClass) element).getSuperclassRef());
if (element instanceof Entity) {
// skip LabelAttribute => child attribute is not required to set
}
List<Attribute> attributes = ((JavaClass) element).getAttributes().getAllAttribute();
List<Attribute> clonedAttributes = ((JavaClass) clonedElement).getAttributes().getAllAttribute();
for (int i = 0; i < attributes.size(); i++) {
copyRef(element, attributes.get(i), clonedElement, clonedAttributes.get(i), clonedAttributes);
}
if(((JavaClass) clonedElement).getAttributes() instanceof IPersistenceAttributes){
IPersistenceAttributes persistenceAttributes = (IPersistenceAttributes)((JavaClass) clonedElement).getAttributes();
persistenceAttributes.removeNonOwnerAttribute(new HashSet<>((List<JavaClass>)clonedElements));
}
} else if (element instanceof Attribute) {
if (element instanceof CompositionAttribute) {
if (((CompositionAttribute) clonedElement).getConnectedClass() == null) {
((CompositionAttribute) clonedElement).setConnectedClass(((CompositionAttribute) element).getConnectedClass());
}
if (element instanceof ElementCollection) {
if (((ElementCollection) clonedElement).getMapKeyEntity() == null) {
((ElementCollection) clonedElement).setMapKeyEntity(((ElementCollection) element).getMapKeyEntity());
}
if (((ElementCollection) clonedElement).getMapKeyEmbeddable() == null) {
((ElementCollection) clonedElement).setMapKeyEmbeddable(((ElementCollection) element).getMapKeyEmbeddable());
}//skip mapKeyAttribute
}
} else if (element instanceof RelationAttribute) {
if(((RelationAttribute) clonedElement).getConnectedEntity() == null){ //if not self
if(((RelationAttribute) clonedElement).getConnectedEntity() == null){
((RelationAttribute) clonedElement).setConnectedEntity(((RelationAttribute) element).getConnectedEntity());
}
}
// ConnectedAttribute => convert bi-directional to uni-directional
if (element instanceof MultiRelationAttribute) {
if (((MultiRelationAttribute) clonedElement).getMapKeyEntity() == null) {
((MultiRelationAttribute) clonedElement).setMapKeyEntity(((MultiRelationAttribute) element).getMapKeyEntity());
}
if (((MultiRelationAttribute) clonedElement).getMapKeyEntity() == null) {
((MultiRelationAttribute) clonedElement).setMapKeyEmbeddable(((MultiRelationAttribute) element).getMapKeyEmbeddable());
}
//skip mapKeyAttribute
}
}
}
}
示例8: setConnectedSibling
import org.netbeans.jpa.modeler.spec.extend.CompositionAttribute; //导入依赖的package包/类
public void setConnectedSibling(EmbeddableWidget embeddableWidget) {
CompositionAttribute compositionAttribute = (CompositionAttribute) this.getBaseElementSpec();
compositionAttribute.setConnectedClass(embeddableWidget.getBaseElementSpec());
setAttributeTooltip();
visualizeDataType();
}
示例9: setConnectedSibling
import org.netbeans.jpa.modeler.spec.extend.CompositionAttribute; //导入依赖的package包/类
public void setConnectedSibling(EmbeddableWidget embeddableWidget) {
CompositionAttribute compositionAttribute = (CompositionAttribute) this.getBaseElementSpec();
compositionAttribute.setConnectedClassId(embeddableWidget.getId());
}