當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。