Revision 0bb5c8a2
Added by Andreas Müller almost 2 years ago
cdmlib-cache/src/main/java/eu/etaxonomy/cdm/cache/CdmModelCacher.java | ||
---|---|---|
64 | 64 |
|
65 | 65 |
public Map<String, CdmModelFieldPropertyFromClass> loadModelClassMap() throws IOException, ClassNotFoundException { |
66 | 66 |
|
67 |
|
|
68 | 67 |
InputStream fin = this.getClass().getResourceAsStream(CDM_MAP_SER_FILE_PATH); |
69 | 68 |
ObjectInputStream ois = new ObjectInputStream(fin); |
70 | 69 |
@SuppressWarnings("unchecked") |
... | ... | |
94 | 93 |
handleEntityClass(modelClassMap, metadata, mappedClass); |
95 | 94 |
} |
96 | 95 |
} |
97 |
|
|
98 |
// Class<?> epc = entityBindings.iterator().next().getMappedClass(); |
|
99 |
|
|
100 |
//SessionFactory sessionFactory = metadata.buildSessionFactory(); |
|
101 |
// Metamodel metaModel = sessionFactory.getMetamodel(); |
|
102 |
// Set<EntityType<?>> entityTypes = metaModel.getEntities(); |
|
103 |
// for (EntityType<?> entityType : entityTypes) { |
|
104 |
// Class<?> mappedClass = entityType.getJavaType(); |
|
105 |
// handleEntityClass(modelClassMap, metadata, mappedClass); |
|
106 |
// } |
|
107 |
// sessionFactory.close(); |
|
108 |
|
|
109 |
// // *************** OLD ***********************/ |
|
110 |
// |
|
111 |
// Map<String, ClassMetadata> classMetaDataMap = sessionFactory.getAllClassMetadata(); |
|
112 |
//// Metadata metadata = new MetadataSources( registry ).getMetadataBuilder().applyImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE ).build(); |
|
113 |
// |
|
114 |
// for(ClassMetadata classMetaData : classMetaDataMap.values()) { |
|
115 |
// Class<?> mappedClass = classMetaData.getMappedClass(); |
|
116 |
// |
|
117 |
// String mappedClassName = mappedClass.getName(); |
|
118 |
// |
|
119 |
// PersistentClass persistentClass = metadata.getEntityBinding(mappedClassName); |
|
120 |
// CdmModelFieldPropertyFromClass cmgmfc = new CdmModelFieldPropertyFromClass(mappedClassName); |
|
121 |
// logger.warn("Adding class : " + mappedClassName + " to cache"); |
|
122 |
// addGetters(persistentClass, cmgmfc); |
|
123 |
// modelClassMap.put(mappedClassName, cmgmfc); |
|
124 |
// } |
|
125 | 96 |
} |
126 | 97 |
catch (Exception e) { |
127 |
// The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory |
|
128 |
// so destroy it manually. |
|
129 | 98 |
StandardServiceRegistryBuilder.destroy( registry ); |
130 | 99 |
e.printStackTrace(); |
131 | 100 |
} |
... | ... | |
168 | 137 |
|
169 | 138 |
public static void main(String argv[]) { |
170 | 139 |
|
171 |
// To re-create the serialised cdm map run,
|
|
172 |
// mvn exec:java -Dexec.mainClass="eu.etaxonomy.cdm.cache.CdmModelCacher"
|
|
173 |
// in the eu.etaxonomy.taxeditor.cdmlib project root dir
|
|
140 |
// To create the serialised cdm map run
|
|
141 |
// mvn exec:exec -Dexec.mainClass="eu.etaxonomy.cdm.cache.CdmModelCacher"
|
|
142 |
// in the cdmlib-cache project root directory
|
|
174 | 143 |
// See also https://dev.e-taxonomy.eu/redmine/projects/edit/wiki/TaxonomicEditorDevelopersGuide#Model-Change-Actions |
175 | 144 |
//Note AM: does not fully work for me, but running the main from the IDE works. |
176 | 145 |
|
... | ... | |
181 | 150 |
System.out.println("Model created."); |
182 | 151 |
if (!modelClassMap.isEmpty()){ |
183 | 152 |
String strPath = CdmModelCacher.class.getProtectionDomain().getCodeSource().getLocation().getFile(); |
184 |
// File outFile = new File("src/main/resources/" + CDM_MAP_SER_FILE_PATH); |
|
185 | 153 |
File outFile = new File(strPath + CDM_MAP_SER_FILE_PATH); |
186 | 154 |
|
187 | 155 |
System.out.println("writing to " + outFile.getAbsolutePath()); |
Also available in: Unified diff
ref #10067 cleanup CdmModelCacher