当前位置: 首页>>代码示例>>Java>>正文


Java Id类代码示例

本文整理汇总了Java中org.netbeans.jpa.modeler.spec.Id的典型用法代码示例。如果您正苦于以下问题:Java Id类的具体用法?Java Id怎么用?Java Id使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Id类属于org.netbeans.jpa.modeler.spec包,在下文中一共展示了Id类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInstance

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
public static IdSpecAccessor getInstance(Id id, boolean inherit) {
    IdSpecAccessor accessor = new IdSpecAccessor(id);
    accessor.inherit = inherit;
    accessor.setName(id.getName());
    accessor.setAttributeType(id.getAttributeType());
    if (id.getColumn() != null) {
        accessor.setColumn(id.getColumn().getAccessor());
    }
    if (id.getGeneratedValue() != null && id.getGeneratedValue().getStrategy()!=null) {
        accessor.setGeneratedValue(id.getGeneratedValue().getAccessor());
    }  
    if (id.getSequenceGenerator()!= null) {
        accessor.setSequenceGenerator(id.getSequenceGenerator().getAccessor());
    }  
    if (id.getTableGenerator() != null) {
        accessor.setTableGenerator(id.getTableGenerator().getAccessor());
    }  
    
    return accessor;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:21,代码来源:IdSpecAccessor.java

示例2: syncronizeCompositeKeyJoincolumn

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
/**
 * Exception Description: The @JoinColumns on the annotated element [method
 * get] from the entity class [class Employee] is incomplete.
 *
 * When the source entity class uses a composite primary key, a @JoinColumn
 * must be specified for each join column using the @JoinColumns. Both the
 * name and the referencedColumnName elements must be specified in each such
 * '@JoinColumn'.
 */
public static void syncronizeCompositeKeyJoincolumn(TableWidget<DBTable> sourceTableWidget, final TableWidget<DBTable> targetTableWidget) {
    if (sourceTableWidget.getPrimaryKeyWidgets().size() > 1) {
        for (IPrimaryKeyWidget<DBColumn<Id>> primaryKeyWidget : sourceTableWidget.getPrimaryKeyWidgets()) {
            Optional<ReferenceFlowWidget> optionalReferenceFlowWidget = primaryKeyWidget.getReferenceFlowWidget()
                    .stream()
                    .filter(r -> r.getForeignKeyWidget().getTableWidget() == targetTableWidget)
                    .findFirst();
            if (optionalReferenceFlowWidget.isPresent()) {
                ForeignKeyWidget foreignKeyWidget = optionalReferenceFlowWidget.get().getForeignKeyWidget();
                IJoinColumn joinColumn;
                if (foreignKeyWidget instanceof ParentAssociationColumnWidget) {
                    joinColumn = ((DBParentAssociationColumn) foreignKeyWidget.getBaseElementSpec()).getJoinColumnOverride();
                } else {
                    joinColumn = ((DBForeignKey) foreignKeyWidget.getBaseElementSpec()).getJoinColumn();
                }
                if (StringUtils.isEmpty(joinColumn.getReferencedColumnName())) {
                    joinColumn.setReferencedColumnName(primaryKeyWidget.getName());
                }
                if (StringUtils.isEmpty(joinColumn.getName())) {
                    joinColumn.setName(foreignKeyWidget.getName());
                }
            }
        }
    }
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:35,代码来源:ColumnUtil.java

示例3: evaluateName

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
public static String evaluateName(DBTable table, Id id) {
        Entity entity = table.getEntity();
        if (entity.getAttributes().getId().size() <= 1) {
            if (table instanceof DBRelationTable) {
                if (((DBRelationTable) table).getAttribute().getConnectedAttribute() != null) {
                    return ((DBRelationTable) table).getAttribute().getConnectedAttribute().getName() + "_" + id.getColumnName().toUpperCase();
                } else {
                    return entity.getClazz() + "_" + id.getColumnName().toUpperCase();
                }
            } else if (table instanceof DBCollectionTable) {
                return entity.getClazz() + "_" + id.getColumnName().toUpperCase();
            }
        } else {
            return id.getColumnName().toUpperCase();
//            if (table instanceof DBRelationTable) {
//                if (((DBRelationTable) table).getAttribute().getConnectedAttribute() != null) {
//                    return id.getColumnName().toUpperCase();
//                } else {
//                    return id.getColumnName().toUpperCase();
//                }
//            } else if (table instanceof DBCollectionTable) {
//                return id.getColumnName().toUpperCase();
//            }
        }
        return null;
    }
 
开发者ID:jeddict,项目名称:jeddict,代码行数:27,代码来源:JoinColumnWidget.java

示例4: evaluateName

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
@Override
protected String evaluateName() {
    DBTable table = (DBTable) this.getTableWidget().getBaseElementSpec();
    Entity entity = table.getEntity();
    List<Id> id = (List<Id>) entity.getAttributes().getId();
    return entity.getDefaultTableName().toUpperCase() + "_" + id.get(0).getName().toUpperCase();
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:8,代码来源:EmbeddedAssociationJoinColumnWidget.java

示例5: evaluateName

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
public static String evaluateName(RelationAttribute attribute, DBColumn referenceColumn) {
    Entity entity = attribute.getConnectedEntity();
    Id id = (Id) referenceColumn.getAttribute();
    if (entity.getAttributes().getId().size() <= 1) {
        return attribute.getName() + "_" + id.getColumnName().toUpperCase();
    } else {
        return id.getColumnName().toUpperCase();
    }
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:10,代码来源:InverseJoinColumnWidget.java

示例6: initTypeComboBox

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
private void initTypeComboBox() {
    TitledBorder titledBorder = (TitledBorder) jLayeredPane1.getBorder();
    List<String> type = new ArrayList<>();
    type.add(DEFAULT);
    if (mapKey) {
        type.add(ENUMERATED);
        type.add(TEMPORAL);
        type.add(ENTITY);
        type.add(EMBEDDABLE);
        titledBorder.setTitle("MapKey Attribute");
    } else if (attribute instanceof PersistenceBaseAttribute) {
        type.add(TEMPORAL);
        if (attribute instanceof Basic) {
            type.add(ENUMERATED);
            type.add(LOB);
            titledBorder.setTitle("Basic Attribute");
        } else if (attribute instanceof Id) {
            titledBorder.setTitle("Id Attribute");
        } else if (attribute instanceof Version) {
            titledBorder.setTitle("Version Attribute");
        }
    } else if (attribute instanceof ElementCollection) {
        type.add(ENUMERATED);
        type.add(LOB);
        type.add(TEMPORAL);
        titledBorder.setTitle("ElementCollection<Basic> Attribute");
    } else if (attribute instanceof Transient) {
        titledBorder.setTitle("Transient Attribute");
    }

    type_ComboBox.removeAllItems();
    type_ComboBox.setModel(new DefaultComboBoxModel(type.toArray(new String[0])));
    //ElementCollection[Basic Type Value] => Lob,Enumerated,Temporal
    //Id => Temporal
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:36,代码来源:FieldTypePanel.java

示例7: addDefaultJoinColumnForCompositePK

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
public static void addDefaultJoinColumnForCompositePK(IdentifiableClass identifiableClass,
        Attribute attribute, Set<String> allFields, List<JoinColumn> joinColumns) {
    if (attribute instanceof SingleRelationAttribute) {
        SingleRelationAttribute relationAttribute = (SingleRelationAttribute) attribute;
        if (!relationAttribute.isOwner()) {  //Only Owner will draw edge because in any case uni/bi owner is always exist
            return;
        }

        //check is it composite key
        Entity targetEntity = relationAttribute.getConnectedEntity();
        relationAttribute.getJoinColumn().clear();
        if (joinColumns == null || joinColumns.isEmpty()) {
            //unused snippet
            for (Attribute targetAttribute : targetEntity.getAttributes().getPrimaryKeyAttributes()) {
                JoinColumn joinColumn = new JoinColumn();
                String joinColumnName = (targetEntity.getClazz() + '_' + targetAttribute.getName()).toUpperCase();
                joinColumnName = getNext(joinColumnName, nextJoinColumnName -> allFields.contains(nextJoinColumnName));
                joinColumn.setName(joinColumnName);
                if (targetAttribute instanceof RelationAttribute) {
                    Entity connectedEntity = ((RelationAttribute) targetAttribute).getConnectedEntity();
                    if (connectedEntity.getCompositePrimaryKeyType() != null) {
                        //TODO  
                    } else {
                        Id id = connectedEntity.getAttributes().getId().get(0);
                        joinColumn.setReferencedColumnName(targetAttribute.getName() + "_" + id.getDefaultColumnName());
                    }
                } else {
                    joinColumn.setReferencedColumnName(targetAttribute.getName());
                }
                relationAttribute.getJoinColumn().add(joinColumn);
            }
        } else {
            //called from db exception handeler
            relationAttribute.getJoinColumn().addAll(joinColumns);
        }
    }
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:38,代码来源:JPAModelerUtil.java

示例8: initTypeComboBox

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
private void initTypeComboBox() {
        TitledBorder titledBorder = (TitledBorder) jLayeredPane1.getBorder();
        List<String> type = new ArrayList<String>();
        type.add("Default");
        if (baseAttribute instanceof Basic) {
            type.add("Enumerated");
            type.add("Lob");
            type.add("Temporal");
            titledBorder.setTitle("Basic Attribute");
        } else if (baseAttribute instanceof ElementCollection) {
            type.add("Enumerated");
            type.add("Lob");
            type.add("Temporal");
            titledBorder.setTitle("ElementCollection<Basic> Attribute");
        } else if (baseAttribute instanceof Id) {
            type.add("Temporal");
            titledBorder.setTitle("Id Attribute");
        } else if (baseAttribute instanceof Version) {
//            type.add("Temporal");
            titledBorder.setTitle("Version Attribute");
        } else if (baseAttribute instanceof Transient) {
            titledBorder.setTitle("Transient Attribute");
        }

        type_ComboBox.removeAllItems();
        type_ComboBox.setModel(new DefaultComboBoxModel(type.toArray(new String[0])));

        //ElementCollection[Basic Type Value] => Lob,Enumerated,Temporal
        //Id => Temporal
    }
 
开发者ID:foxerfly,项目名称:Netbeans-JPA-Modeler,代码行数:31,代码来源:FieldTypePanel.java

示例9: IdSpecAccessor

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
private IdSpecAccessor(Id id) {
    this.id = id;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:4,代码来源:IdSpecAccessor.java

示例10: generate

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
/**
 * Generates the repository for the given entity class.
 *
 * @return the generated files.
 */
private FileObject generate(final Entity entity, boolean overrideExisting) throws IOException {
    FileObject targetFolder = SourceGroupSupport.getFolderForPackage(appConfigData.getTargetSourceGroup(), 
            entity.getAbsolutePackage(appConfigData.getTargetPackage() + '.' + repositoryData.getPackage()), 
            true);
    String entityFQN = entity.getFQN();
    final String entitySimpleName = entity.getClazz();
    String abstractFileName = repositoryData.getPrefixName() + REPOSITORY_ABSTRACT + repositoryData.getSuffixName();
    String repositoryName = repositoryData.getPrefixName() + entitySimpleName + repositoryData.getSuffixName();
    // create the repository
    FileObject existingFO = targetFolder.getFileObject(repositoryName, JAVA_EXT);
    if (existingFO != null) {
        if (overrideExisting) {
            existingFO.delete();
        } else {
            throw new IOException("File already exists exception: " + existingFO.getPath());
        }
    }

    String entityClass = firstUpper(entitySimpleName);
    String entityInstance = firstLower(entitySimpleName);

    Map<String, Object> param = new HashMap<>();
    param.put("EntityClass", entityClass);
    param.put("EntityClassPlural", pluralize(entityClass));
    param.put("EntityClass_FQN", entityFQN);
    param.put("entityInstance", entityInstance);
    param.put("entityInstancePlural", pluralize(entityInstance));

    param.put("AbstractRepository", abstractFileName);
    if (!entity.getAbsolutePackage(repositoryData.getPackage()).equals(repositoryData.getPackage())) { //if both EntityRepository and AbstractRepository are not in same package
        param.put("AbstractRepository_FQN", '.' + repositoryData.getPackage() + "." + abstractFileName);
    } else {
        param.put("AbstractRepository_FQN", EMPTY);
    }
    param.put("EntityRepository", repositoryName);
    param.put("PU", entityMapping.getPersistenceUnitName());
    param.put("package", entity.getAbsolutePackage(appConfigData.getTargetPackage() + '.' + repositoryData.getPackage()));
    param.put("cdi", repositoryData.isCDI());
    param.put("named", repositoryData.isNamed());
    param.put("appPackage", appConfigData.getTargetPackage());

    Attribute idAttribute = entity.getAttributes().getIdField();
    if (idAttribute != null) {
        if (idAttribute instanceof Id) {
            String dataType_FQN = idAttribute.getDataTypeLabel();
            param.put("EntityPKClass_FQN", EMPTY);
            if (isPrimitive(dataType_FQN)) {
                param.put("EntityPKClass", getWrapperType(dataType_FQN));
            } else {
                String dataType = JavaIdentifiers.unqualify(dataType_FQN);
                param.put("EntityPKClass", dataType);
                if (dataType.length() != dataType_FQN.length()) {
                    param.put("EntityPKClass_FQN", dataType_FQN);
                }
            }
        } else if (idAttribute instanceof EmbeddedId || idAttribute instanceof DefaultAttribute) {
            param.put("EntityPKClass", idAttribute.getDataTypeLabel());
            param.put("EntityPKClass_FQN", entity.getRootPackage() + '.' + idAttribute.getDataTypeLabel());
        }
    }

    existingFO = org.netbeans.jcode.core.util.FileUtil.expandTemplate(TEMPLATE + "repository/EntityRepository.java.ftl", targetFolder, repositoryName + '.' + JAVA_EXT, param);

    return existingFO;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:71,代码来源:RepositoryGenerator.java

示例11: DBPrimaryKeyJoinColumn

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
public DBPrimaryKeyJoinColumn(String name, Entity entity, Id attribute) {
    super(name, attribute);
    joinColumns = JoinColumnFinder.findPrimaryKeyJoinColumns(entity);
    joinColumn = JoinColumnFinder.findPrimaryKeyJoinColumn(name, joinColumns);
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:6,代码来源:DBPrimaryKeyJoinColumn.java

示例12: evaluateName

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
@Override
protected String evaluateName() {
    DBTable table = (DBTable) this.getTableWidget().getBaseElementSpec();
    Id id = (Id) this.getBaseElementSpec().getReferenceColumn().getAttribute();
    return JoinColumnWidget.evaluateName(table, id);
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:7,代码来源:ParentAssociationJoinColumnWidget.java

示例13: evaluateName

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
@Override
protected String evaluateName() {
    Id attribute = this.getBaseElementSpec().getAttribute();
    return attribute.getDefaultColumnName();
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:6,代码来源:PrimaryKeyJoinColumnWidget.java

示例14: processId

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
protected void processId(List<Id> parsedIds) {

//        if (parsedAttributes == null) {
//            return;
//        }
//
//        List<ParsedId> parsedIds = parsedAttributes.getId();
        for (Id parsedId : parsedIds) {
            VariableDefSnippet variableDef = getVariableDef(parsedId);
            variableDef.setType(parsedId.getAttributeType());
            variableDef.setFunctionalType(parsedId.isOptionalReturnType());
            variableDef.setPrimaryKey(true);

            Column parsedColumn = parsedId.getColumn();

            if (parsedColumn != null) {
                ColumnDefSnippet columnDef = getColumnDef(parsedColumn);
                variableDef.setColumnDef(columnDef);
            }
            GeneratedValue parsedGeneratedValue = parsedId.getGeneratedValue();
            if (parsedGeneratedValue != null && parsedGeneratedValue.getStrategy() != null) {
                GeneratedValueSnippet generatedValue = new GeneratedValueSnippet();

                generatedValue.setGenerator(parsedGeneratedValue.getGenerator());
                generatedValue.setStrategy("GenerationType." + parsedGeneratedValue.getStrategy().value());

                variableDef.setGeneratedValue(generatedValue);

                SequenceGenerator parsedSequenceGenerator
                        = parsedId.getSequenceGenerator();

                if (parsedSequenceGenerator != null) {
                    SequenceGeneratorSnippet sequenceGenerator = processSequenceGenerator(parsedSequenceGenerator);
                    variableDef.setSequenceGenerator(sequenceGenerator);
                }

                TableGenerator parsedTableGenerator = parsedId.getTableGenerator();
                if (parsedTableGenerator != null) {
                    variableDef.setTableGenerator(processTableGenerator(parsedTableGenerator));
                }
            }

            TemporalType parsedTemporalType = parsedId.getTemporal();
            TemporalSnippet temporal = null;
            if (parsedTemporalType != null) {
                temporal = new TemporalSnippet();
                temporal.setValue(parsedTemporalType);
            }
            variableDef.setTemporal(temporal);
        }
    }
 
开发者ID:jeddict,项目名称:jeddict,代码行数:52,代码来源:ClassGenerator.java

示例15: getGeneratorProperty

import org.netbeans.jpa.modeler.spec.Id; //导入依赖的package包/类
public static EmbeddedPropertySupport getGeneratorProperty(IdAttributeWidget attributeWidget) {

        GenericEmbedded entity = new GenericEmbedded("generator", "Id Generator", "");
        entity.setEntityEditor(new IdGeneratorPanel());

        entity.setDataListener(new EmbeddedDataListener<Id>() {
            private Id idAttribute;

            @Override
            public void init() {
                idAttribute = attributeWidget.getBaseElementSpec();
            }

            @Override
            public Id getData() {
                if (idAttribute.getGeneratedValue() == null) {
                    idAttribute.setGeneratedValue(new GeneratedValue());
                }
                return idAttribute;
            }

            @Override
            public void setData(Id classSpec) {
                if (attributeWidget.getClassWidget() instanceof EntityWidget) {
                    ((EntityWidget) attributeWidget.getClassWidget()).scanKeyError();
                } else {
                    attributeWidget.getClassWidget().getAllSubclassWidgets().stream()
                            .filter(cw -> cw instanceof EntityWidget).findFirst().ifPresent(ew -> ((EntityWidget) ew).scanKeyError());
                }

//                attributeWidget.setBaseElementSpec(classSpec);
            }

            @Override
            public String getDisplay() {
                if (idAttribute.getGeneratedValue() != null && idAttribute.getGeneratedValue().getStrategy() != null) {
                    return firstLetterCaps(idAttribute.getGeneratedValue().getStrategy().toString());
                } else if (idAttribute.getGeneratedValue() == null || idAttribute.getGeneratedValue().getStrategy() == null) {
                    return NONE_TYPE;
                } else {
                    return "";
                }
            }

        });
        return new EmbeddedPropertySupport(attributeWidget.getModelerScene().getModelerFile(), entity);
    }
 
开发者ID:jeddict,项目名称:jeddict,代码行数:48,代码来源:PropertiesHandler.java


注:本文中的org.netbeans.jpa.modeler.spec.Id类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。